-
Notifications
You must be signed in to change notification settings - Fork 4
/
WHDLoadTool07a_MACOS.pb
3174 lines (2635 loc) · 114 KB
/
WHDLoadTool07a_MACOS.pb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;- ############### WHDLoad Download Tool Info
;
; Version 0.7a
;
; © 2021 / 2022 Paul Vince (MrV2k)
;
; https://easyemu.mameworld.info
;
; [ PB V5.7x/V6.x / 64Bit / Linux Ubuntu 20+]
;
; A downloader for Retroplay's WHDLoad archive and more!
;
;- ############### Credits
;
; RSBasic for the PBEx_FTP library
; Conrad Fenech & Brian Lloyd for bug testing the connection issues
;
;- ############### Version Info
;
;============================================
; VERSION INFO v0.1a (Initial Release)
;============================================
;
;============================================
; VERSION INFO v0.2a
;============================================
;
; Updated Turran FTP info in docs.
; Updated donate link on about window.
; Fixed save path gadgets actions when loading prefs.
;
;============================================
; VERSION INFO v0.3a
;============================================
;
; Load / Save prefs now only shows prefs files
; Changed FTP connections to PBEx_FTP DLL which has fixed the connection errors.
; Fixed a typo in the demo download paths
; Fixed bug in list creator/editor that ignored selected files when updating main list.
; Changed download to console window and added escape key
; Blocked close console button
;
;============================================
; VERSION INFO v0.4a
;============================================
;
; Added support for WHDLoad based disk magazines.
; Added a check to FTP download to catch if a file is created but no data is downloaded. The error is logged in the ftp.log file and the empty file is deleted.
; Fixed a crash if the required DLL files are missing by preventing the program loading.
; Added minimize to main window.
; Switched dat file download to a console and added ftp log support.
; The edit window now work with the filters. You can now filter and add/remove files to the same list.
; Added Chip and Fast memory files to the filter.
; Preference files have been updated for new filters.
; Re-worked the filter panel to make room by moving game, demo and magazine filters next to path boxes.
; All FTP settings and FTP paths are now stored in the preferences files and can be edited.
; Updated the help window to reflect all the new changes.
;
;============================================
; VERSION INFO v0.5a
;============================================
;
; Added magazines to the 'Clean Files' procedure.
; Added 0kb file check to 'Clean Files' procedure.
; Added temporary fix to FTP download for 0kb files via DOS FTP command.
; Added a few more donation notifications to the download procedure.
;
;============================================
; VERSION INFO v0.6a
;============================================
;
; Fixed escaping FTP download crashing the download window.
; Added separate download folder for Beta games.
; Added preview window to show download file list.
; Fixed Port gadget overlap on main window.
; Fixed disabled gadgets when loading a prefs file.
; Added switch to change between default PB or alternate FTP procedures.
; Updated help to reflect changes.
; Adapted filter to show beta files separate to games
;
;============================================
; VERSION INFO v0.7a
;============================================
;
; Clean files now only lists lha & lzx files
; Added support for Linux Ubuntu
;
;============================================
; To Do List
;============================================
;
; FTP Connection is a bit unreliable.
;
;============================================
;
EnableExplicit
Enumeration
#FTP
#REGEX
#MAIN_WINDOW
#MAIN_STATUS
#MAIN_LIST
#MAIN_FONT
#MAIN_MENU
#MAIN_FILTER_CONTAINER
#MAIN_PATH_CONTAINER
#MAIN_FTP_CONTAINER
#MAIN_BUTTON_CONTAINER
#DELETE_WINDOW
#DELETE_LIST
#DELETE_CANCEL_BUTTON
#DELETE_DEL_BUTTON
#DELETE_BACKUP_BUTTON
#DELETE_OWN_BUTTON
#HELP_WINDOW
#HELP_EDITOR
#HELP_FONT
#ABOUT_WINDOW
#ABOUT_STRING
#ABOUT_LINK
#UPDATE_WINDOW
#UPDATE_LIST
#UPDATE_UPDATE_BUTTON
#UPDATE_CANCEL_BUTTON
#EDIT_WINDOW
#EDIT_UPDATE_BUTTON
#EDIT_CANCEL_BUTTON
#EDIT_CLEAR_BUTTON
#EDIT_LIST
#EDIT_FILTER
#DOWNLOAD_WINDOW
#DOWNLOAD_LIST
#DOWNLOAD_YES
#DOWNLOAD_NO
#SCAN_BUTTON
#DOWNLOAD_BUTTON
#CLEAR_LIST_BUTTON
#RESET_BUTTON
#SAVE_PREFS_BUTTON
#LOAD_PREFS_BUTTON
#CLEANUP_BUTTON
#HELP_BUTTON
#ABOUT_BUTTON
#CLEAR_LANG_BUTTON
#ALT_FTP_CHECK
#LIST_APPEND_BUTTON
#LIST_LOAD_BUTTON
#LIST_SAVE_BUTTON
#LIST_EDIT_BUTTON
#CLEAR_EDITS_BUTTON
#FTP_PASS_STRING
#FTP_USER_STRING
#FTP_SERVER_STRING
#FTP_FOLDER_STRING
#FTP_PORT_STRING
#WHD_MAIN_STRING
#WHD_OPEN_PATH_BUTTON
#WHD_SET_PATH_BUTTON
#WHD_GAME_STRING
#WHD_OPEN_GAME_BUTTON
#WHD_DEMO_STRING
#WHD_OPEN_DEMO_BUTTON
#WHD_MAGS_STRING
#WHD_OPEN_MAGS_BUTTON
#WHD_BETA_STRING
#WHD_OPEN_BETA_BUTTON
#WHD_SUBFOLDER_CHECK
#WHD_0TOZ_CHECK
#GAME_OPTION
#DEMO_OPTION
#BETA_OPTION
#MAGS_OPTION
#AGA_OPTION
#ECS_OPTION
#CD32_OPTION
#CDTV_OPTION
#CDROM_OPTION
#ARCADIA_OPTION
#NTSC_OPTION
#PAL_OPTION
#AMIGA_OPTION
#CZECH_OPTION
#DANISH_OPTION
#DUTCH_OPTION
#IMAGE_OPTION
#FILES_OPTION
#ENGLISH_OPTION
#FINNISH_OPTION
#FRENCH_OPTION
#GERMAN_OPTION
#GREEK_OPTION
#ITALIAN_OPTION
#MULTI_OPTION
#POLISH_OPTION
#SPANISH_OPTION
#SWEDISH_OPTION
#CLEAR_BUTTON
#CHIP_OPTION
#FAST_OPTION
EndEnumeration
;- ############### Structures
Structure Game_Data
File_Name.s
File_Path.s
File_SubFolder.s
File_Type.s
File_BETA.b
File_Language.s
File_Chip.b
File_Fast.b
File_AGA.b
File_CD32.b
File_CDTV.b
File_CDROM.b
File_Amiga.b
File_Arcadia.b
File_NTSC.b
File_Available.b
File_Filtered.b
File_Size.i
File_Files.b
File_Image.b
File_Version.s
File_Ignore.b
File_Extra.b
EndStructure
Structure Filter_Data
F_Games.b
F_Demos.b
F_Beta.b
F_Mags.b
F_AGA.b
F_ECS.b
F_NTSC.b
F_PAL.b
F_Amiga.b
F_Arcadia.b
F_Files.b
F_Image.b
F_Chip.b
F_Fast.b
F_CDTV.b
F_CD32.b
F_CDROM.b
F_Czech.b
F_Danish.b
F_Dutch.b
F_English.b
F_Finnish.b
F_French.b
F_German.b
F_Greek.b
F_Italian.b
F_Multi.b
F_Polish.b
F_Spanish.b
F_Swedish.b
EndStructure
Structure Down_Data
Down_Subfolder.s
Down_Name.s
Down_0toZ.s
Down_FTP_Folder.s
EndStructure
Structure Own_Data
own_file.s
own_folder.s
EndStructure
Structure Edit_Data
Edit_File.s
Edit_Index.i
Edit_Existing.b
Edit_Filter.b
Edit_Type.s
EndStructure
Structure File_Data
R_File_Size.l
R_File_Name.s
EndStructure
;- ############### Lists
Global NewList File_List.s()
Global NewList Game_List.Game_Data()
Global NewList Down_List.Down_Data()
Global NewList File_List_Size.File_Data()
Global NewList Delete_List.s()
Global NewList Filtered_List.i()
Global NewList Edit_Filtered_List.i()
Global NewList Directory_List.s()
Global NewList List_Games.s()
Global NewList Editor_List.Edit_Data()
;- ############### Global Variables
Global Version.s="0.7a"
Global Path.s, Count.i, Folder.s
Global Home_Path.s=GetCurrentDirectory()
Global Temp_Folder.s=GetTemporaryDirectory()+"whd_temp/"
Global Dat_Folder.s=Home_Path+"Dats/"
Global List_Path.s=Home_Path+"Lists/"
Global First_Run.b=#False
Global Prefs_Name.s="default.prefs"
Global Lang_Bool.b=#True
Global Avail_Games.i=0
Global Old_Pos.i
Global Use_Subfolder.b=#False
Global Use_0toZ_Folder.b=#False
Global Alternate_FTP.b=#False
Global FTP_Folder.s
Global FTP_Server.s
Global FTP_User.s
Global FTP_Pass.s
Global FTP_Passive.b
Global FTP_Port.i
Global WHD_Folder.s
Global FTP_Game_Folder.s
Global WHD_Game_Folder.s
Global FTP_Demo_Folder.s
Global WHD_Demo_Folder.s
Global WHD_Beta_Folder.s
Global FTP_Beta_Folder.s
Global WHD_Mags_Folder.s
Global FTP_Mags_Folder.s
Global FCount.f
Global Event.l, Gadget.l, Type.l
Global Dim Filter.Filter_Data(0)
;- ############### Declares
Declare Draw_List()
;- ############### Macros
Macro Pause_Console()
PrintN("Press A Key To Continue...")
Repeat : Until Inkey()<>""
EndMacro
Macro DpiX(value) ; <--------------------------------------------------> DPI X Scaling
DesktopScaledX(value)
EndMacro
Macro DpiY(value) ; <--------------------------------------------------> DPI Y Scaling
DesktopScaledY(value)
EndMacro
Macro Language(exp,lang)
CreateRegularExpression(#REGEX,"_("+exp+")(\.|_)")
If MatchRegularExpression(#REGEX, Game_List()\File_Name) : Game_List()\File_Language=lang : EndIf
FreeRegularExpression(#REGEX)
EndMacro
Macro Version()
CreateRegularExpression(#REGEX,"(?i)_v[0-9].[0-9][0-9](\.|_)")
ExamineRegularExpression(#REGEX,Game_List()\File_Name)
While NextRegularExpressionMatch(#REGEX)
Path=RemoveString(RegularExpressionMatchString(#REGEX),"_")
Game_List()\File_Version=path
Wend
FreeRegularExpression(#REGEX)
CreateRegularExpression(#REGEX,"(?i)_v[0-9].[0-9](\.|_)")
ExamineRegularExpression(#REGEX,LCase(Game_List()\File_Name))
While NextRegularExpressionMatch(#REGEX)
Path=RemoveString(RegularExpressionMatchString(#REGEX),"_")
Game_List()\File_Version=path
Wend
FreeRegularExpression(#REGEX)
CreateRegularExpression(#REGEX,"(?i)_v[0-9].[0-9][a-z](\.|_)")
ExamineRegularExpression(#REGEX,Game_List()\File_Name)
While NextRegularExpressionMatch(#REGEX)
Path=RemoveString(RegularExpressionMatchString(#REGEX),"_")
Game_List()\File_Version=path
Wend
FreeRegularExpression(#REGEX)
CreateRegularExpression(#REGEX,"(?i)_v[0-9].[0-9][a-z][0-9](\.|_)")
ExamineRegularExpression(#REGEX,Game_List()\File_Name)
While NextRegularExpressionMatch(#REGEX)
Path=RemoveString(RegularExpressionMatchString(#REGEX),"_")
Game_List()\File_Version=path
Wend
FreeRegularExpression(#REGEX)
CreateRegularExpression(#REGEX,"(?i)_v[0-9].[0-9]-[a-z](\.|_)")
ExamineRegularExpression(#REGEX,Game_List()\File_Name)
While NextRegularExpressionMatch(#REGEX)
Path=RemoveString(RegularExpressionMatchString(#REGEX),"_")
Game_List()\File_Version=path
Wend
FreeRegularExpression(#REGEX)
CreateRegularExpression(#REGEX,"(?i)_v[0-9].[0-9][0-9][a-z](\.|_)")
ExamineRegularExpression(#REGEX,Game_List()\File_Name)
While NextRegularExpressionMatch(#REGEX)
Path=RemoveString(RegularExpressionMatchString(#REGEX),"_")
Game_List()\File_Version=path
Wend
FreeRegularExpression(#REGEX)
If Right(Game_List()\File_Version,1)="." : Game_List()\File_Version=RTrim(Game_List()\File_Version,".") : EndIf
EndMacro
Macro Update_File_List()
ClearList(File_List())
List_Files_Recursive(WHD_Folder,File_List(),"")
EndMacro
Macro Update_Title()
FCount=0
ForEach Filtered_List()
SelectElement(Game_List(),Filtered_List())
FCount+Game_List()\File_Size
Next
FCount/1048576 ; Convert to MBs
Path="WHDLoad Download Tool v"+Version+" "
If Prefs_Name<>"default.prefs" : Path+" ["+GetFilePart(Prefs_Name)+"] - " : EndIf
Path+"(Showing "+Str(ListSize(Filtered_List()))+" of "+Str(ListSize(Game_List()))+")"
Path+" - ("+StrF(FCount,2)+" MB)"
SetWindowTitle(#MAIN_WINDOW,Path)
EndMacro
Macro PrintNCol(PText,PFCol,PBCol)
ConsoleColor(PFCol,PBCol)
PrintN(PText)
ConsoleColor(7,0)
EndMacro
Macro Default_Settings()
Prefs_Name="default.prefs"
FTP_Folder="Retroplay WHDLoad Packs"
FTP_Server="grandis.nu"
FTP_User="ftp"
FTP_Pass="amiga"
FTP_Passive=#True
FTP_Port=21
WHD_Folder=Home_Path+"Download/"
FTP_Game_Folder="Commodore_Amiga_-_WHDLoad_-_Games"
WHD_Game_Folder="Games"
FTP_Demo_Folder="Commodore_Amiga_-_WHDLoad_-_Demos"
WHD_Demo_Folder="Demos"
FTP_Beta_Folder="Commodore_Amiga_-_WHDLoad_-_Games_-_Beta_&_Unreleased"
WHD_Beta_Folder="Beta"
FTP_Mags_Folder="Commodore_Amiga_-_WHDLoad_-_Magazines"
WHD_Mags_Folder="Magazines"
Filter(0)\F_Games=#True
Filter(0)\F_Demos=#True
Filter(0)\F_Beta=#True
Filter(0)\F_Mags=#True
Filter(0)\F_AGA=#True
Filter(0)\F_ECS=#True
Filter(0)\F_NTSC=#True
Filter(0)\F_PAL=#True
Filter(0)\F_Amiga=#True
Filter(0)\F_Arcadia=#True
Filter(0)\F_CD32=#True
Filter(0)\F_CDTV=#True
Filter(0)\F_CDROM=#True
Filter(0)\F_Files=#True
Filter(0)\F_Image=#True
Filter(0)\F_Chip=#True
Filter(0)\F_Fast=#True
Filter(0)\F_Czech=#True
Filter(0)\F_Danish=#True
Filter(0)\F_Dutch=#True
Filter(0)\F_English=#True
Filter(0)\F_Finnish=#True
Filter(0)\F_French=#True
Filter(0)\F_German=#True
Filter(0)\F_Greek=#True
Filter(0)\F_Italian=#True
Filter(0)\F_Multi=#True
Filter(0)\F_Polish=#True
Filter(0)\F_Spanish=#True
Filter(0)\F_Swedish=#True
EndMacro
;- ############### Misc Procedures
Procedure.i Game_Number(archive.s)
Protected NewMap Games.i()
Protected proc_return.i
proc_return=-1
ForEach Game_List()
Games(Game_List()\File_Name)=ListIndex(Game_List())
Next
If FindMapElement(Games(),archive)
proc_return=Games()
EndIf
ProcedureReturn proc_return
FreeMap(Games())
EndProcedure
Procedure.s GetDefaultFontName()
CompilerIf #PB_Compiler_OS=#PB_OS_Windows
Protected fnt.l=GetStockObject_(#DEFAULT_GUI_FONT)
If fnt
Protected finfo.LOGFONT
GetObject_(fnt,SizeOf(LOGFONT),@finfo)
Protected systemfontname.s=PeekS(@finfo\lfFaceName[0])
ProcedureReturn PeekS(@finfo\lfFaceName[0])
EndIf
ProcedureReturn "System"
CompilerEndIf
EndProcedure
Procedure TreeExpandAllItems(TreeId)
Protected CurItem.i, CurState.i, ItemCnt.i = CountGadgetItems(TreeId)
If ItemCnt <= 0: ProcedureReturn: EndIf
For CurItem = 0 To ItemCnt-1
CurState = GetGadgetItemState(TreeId, CurItem)
CurState = CurState ! #PB_Tree_Collapsed
If CurState & #PB_Tree_Checked
CurState = #PB_Tree_Checked | #PB_Tree_Expanded
ElseIf CurState & #PB_Tree_Inbetween
CurState = #PB_Tree_Inbetween | #PB_Tree_Expanded
Else
CurState = #PB_Tree_Expanded
EndIf
SetGadgetItemState(TreeId, CurItem, CurState)
Next
EndProcedure
;- ############### Update Gadgets
Procedure Set_List_Gadgets(bool)
DisableGadget(#LIST_APPEND_BUTTON,bool)
EndProcedure
Procedure Disable_Gadgets(bool.b)
DisableGadget(#GAME_OPTION,bool)
DisableGadget(#DEMO_OPTION,bool)
DisableGadget(#BETA_OPTION,bool)
DisableGadget(#MAGS_OPTION,bool)
DisableGadget(#AMIGA_OPTION,bool)
DisableGadget(#CD32_OPTION,bool)
DisableGadget(#CDTV_OPTION,bool)
DisableGadget(#CDROM_OPTION,bool)
DisableGadget(#ARCADIA_OPTION,bool)
DisableGadget(#AGA_OPTION,bool)
DisableGadget(#ECS_OPTION,bool)
DisableGadget(#NTSC_OPTION,bool)
DisableGadget(#PAL_OPTION,bool)
DisableGadget(#FILES_OPTION,bool)
DisableGadget(#IMAGE_OPTION,bool)
DisableGadget(#CHIP_OPTION,bool)
DisableGadget(#FAST_OPTION,bool)
DisableGadget(#CZECH_OPTION,bool)
DisableGadget(#DANISH_OPTION,bool)
DisableGadget(#DUTCH_OPTION,bool)
DisableGadget(#ENGLISH_OPTION,bool)
DisableGadget(#FINNISH_OPTION,bool)
DisableGadget(#FRENCH_OPTION,bool)
DisableGadget(#GERMAN_OPTION,bool)
DisableGadget(#GREEK_OPTION,bool)
DisableGadget(#ITALIAN_OPTION,bool)
DisableGadget(#MULTI_OPTION,bool)
DisableGadget(#POLISH_OPTION,bool)
DisableGadget(#SPANISH_OPTION,bool)
DisableGadget(#SWEDISH_OPTION,bool)
DisableGadget(#CLEAR_LANG_BUTTON,bool)
DisableGadget(#CLEANUP_BUTTON,bool)
DisableGadget(#CLEAR_BUTTON,bool)
DisableGadget(#CLEAR_LIST_BUTTON,bool)
DisableGadget(#RESET_BUTTON,bool)
DisableGadget(#DOWNLOAD_BUTTON,bool)
DisableGadget(#LIST_EDIT_BUTTON,bool)
DisableGadget(#LIST_LOAD_BUTTON,bool)
DisableGadget(#LIST_SAVE_BUTTON,bool)
EndProcedure
Procedure Update_Statusbar()
If CountGadgetItems(#MAIN_LIST)>0
If Game_List()\File_Amiga : StatusBarText(#MAIN_STATUS,0,"System: Amiga",#PB_StatusBar_Center) : EndIf
If Game_List()\File_CD32 : StatusBarText(#MAIN_STATUS,0,"System: CD32",#PB_StatusBar_Center) : EndIf
If Game_List()\File_CDTV : StatusBarText(#MAIN_STATUS,0,"System: CDTV",#PB_StatusBar_Center) : EndIf
If Game_List()\File_CDROM : StatusBarText(#MAIN_STATUS,0,"System: CDROM",#PB_StatusBar_Center) : EndIf
If Game_List()\File_Arcadia : StatusBarText(#MAIN_STATUS,0,"System: Arcadia",#PB_StatusBar_Center) : EndIf
If Game_List()\File_AGA : StatusBarText(#MAIN_STATUS,1,"Chipset: AGA",#PB_StatusBar_Center) : Else : StatusBarText(#MAIN_STATUS,1,"Chipset: ECS/OCS",#PB_StatusBar_Center) : EndIf
If Game_List()\File_NTSC : StatusBarText(#MAIN_STATUS,2,"TV System: NTSC",#PB_StatusBar_Center) : Else : StatusBarText(#MAIN_STATUS,2,"TV System: PAL",#PB_StatusBar_Center) : EndIf
StatusBarText(#MAIN_STATUS,3,"Language: "+Game_List()\File_Language,#PB_StatusBar_Center)
If Game_List()\File_BETA=#True
Path="Beta"
Else
path=Game_List()\File_Type
EndIf
StatusBarText(#MAIN_STATUS,4,"Type: "+Path,#PB_StatusBar_Center)
If Game_List()\File_Available
StatusBarText(#MAIN_STATUS,5,"Status: Available",#PB_StatusBar_Center)
Else
StatusBarText(#MAIN_STATUS,5,"Status: Missing",#PB_StatusBar_Center)
EndIf
StatusBarText(#MAIN_STATUS,6,"Size: "+Str(Game_List()\File_Size/1024)+" KB",#PB_StatusBar_Center)
StatusBarText(#MAIN_STATUS,7,"Version: "+Game_List()\File_Version,#PB_StatusBar_Center)
Else
StatusBarText(#MAIN_STATUS,0,"System: ?",#PB_StatusBar_Center)
StatusBarText(#MAIN_STATUS,1,"Chipset: ?",#PB_StatusBar_Center)
StatusBarText(#MAIN_STATUS,2,"TV System: ?",#PB_StatusBar_Center)
StatusBarText(#MAIN_STATUS,3,"Language: ?",#PB_StatusBar_Center)
StatusBarText(#MAIN_STATUS,4,"Type: ?",#PB_StatusBar_Center)
StatusBarText(#MAIN_STATUS,5,"Status: ?",#PB_StatusBar_Center)
StatusBarText(#MAIN_STATUS,6,"Size: ?",#PB_StatusBar_Center)
StatusBarText(#MAIN_STATUS,7,"Version: ?",#PB_StatusBar_Center)
EndIf
EndProcedure
;- ############### File I/O
Procedure List_Files_Recursive(Dir.s, List Files.s(), Extension.s) ; <------> Adds All Files In A Folder Into The Supplied List
Protected NewList Directories.s()
Protected Folder_LIST
;ClearList(Directory_List())
If Right(Dir, 1) <> "/"
Dir + "/"
EndIf
If ExamineDirectory(Folder_LIST, Dir, Extension)
While NextDirectoryEntry(Folder_LIST)
Select DirectoryEntryType(Folder_LIST)
Case #PB_DirectoryEntry_File
AddElement(Files())
Files() = Dir + DirectoryEntryName(Folder_LIST)
Case #PB_DirectoryEntry_Directory
Select DirectoryEntryName(Folder_LIST)
Case ".", ".."
Continue
Default
AddElement(Directories())
Directories() = Dir + DirectoryEntryName(Folder_LIST)
EndSelect
EndSelect
Wend
FinishDirectory(Folder_LIST)
ForEach Directories()
AddElement(Directory_List())
Directory_List()=Directories()
List_Files_Recursive(Directories(), Files(), Extension)
Next
EndIf
FreeList(Directories())
EndProcedure
Procedure List_Files_Recursive_Size(Dir.s, List Files.File_Data(), Extension.s) ; <------> Adds All Files In A Folder Into The Supplied List with size information
Protected NewList Directories.s()
Protected Folder_LIST
;ClearList(Directory_List())
If Right(Dir, 1) <> "/"
Dir + "/"
EndIf
If ExamineDirectory(Folder_LIST, Dir, Extension)
While NextDirectoryEntry(Folder_LIST)
Select DirectoryEntryType(Folder_LIST)
Case #PB_DirectoryEntry_File
AddElement(Files())
Files()\R_File_Name = Dir + DirectoryEntryName(Folder_LIST)
Files()\R_File_Size = DirectoryEntrySize(Folder_LIST)
Case #PB_DirectoryEntry_Directory
Select DirectoryEntryName(Folder_LIST)
Case ".", ".."
Continue
Default
AddElement(Directories())
Directories() = Dir + DirectoryEntryName(Folder_LIST)
EndSelect
EndSelect
Wend
FinishDirectory(Folder_LIST)
ForEach Directories()
AddElement(Directory_List())
Directory_List()=Directories()
List_Files_Recursive_Size(Directories(), Files(), Extension)
Next
EndIf
FreeList(Directories())
EndProcedure
Procedure DeleteDirectorySafely(Path.s)
Protected PathID
Protected Result
Protected EntryName.s
Protected PathNotEmpty
Protected i
If Not FileSize(Path.s)=-2
ProcedureReturn #False
EndIf
PathID=ExamineDirectory(#PB_Any,Path.s,"")
If PathID
For i=1 To 3
Result=NextDirectoryEntry(PathID)
EntryName.s=DirectoryEntryName(PathID)
If Result And EntryName.s<>"." And EntryName.s<>".."
PathNotEmpty=#True
EndIf
Next i
If Not PathNotEmpty
FinishDirectory(PathID)
Result=DeleteDirectory(Path.s,"")
ProcedureReturn Result
EndIf
FinishDirectory(PathID)
EndIf
ProcedureReturn #False
EndProcedure
;- ############### Filter
Procedure.b Check_Filter()
Protected f_return.b
If Filter(0)\F_Games=#False : f_return=#True : EndIf
If Filter(0)\F_Demos=#False : f_return=#True : EndIf
If Filter(0)\F_Beta=#False : f_return=#True : EndIf
If Filter(0)\F_Mags=#False : f_return=#True : EndIf
If Filter(0)\F_AGA=#False : f_return=#True : EndIf
If Filter(0)\F_ECS=#False : f_return=#True : EndIf
If Filter(0)\F_NTSC=#False : f_return=#True : EndIf
If Filter(0)\F_PAL=#False : f_return=#True : EndIf
If Filter(0)\F_Amiga=#False : f_return=#True : EndIf
If Filter(0)\F_Arcadia=#False : f_return=#True : EndIf
If Filter(0)\F_CD32=#False : f_return=#True : EndIf
If Filter(0)\F_CDTV=#False : f_return=#True : EndIf
If Filter(0)\F_CDROM=#False : f_return=#True : EndIf
If Filter(0)\F_Files=#False : f_return=#True : EndIf
If Filter(0)\F_Image=#False : f_return=#True : EndIf
If Filter(0)\F_Czech=#False : f_return=#True : EndIf
If Filter(0)\F_Danish=#False : f_return=#True : EndIf
If Filter(0)\F_Dutch=#False : f_return=#True : EndIf
If Filter(0)\F_English=#False : f_return=#True : EndIf
If Filter(0)\F_Finnish=#False : f_return=#True : EndIf
If Filter(0)\F_French=#False : f_return=#True : EndIf
If Filter(0)\F_German=#False : f_return=#True : EndIf
If Filter(0)\F_Greek=#False : f_return=#True : EndIf
If Filter(0)\F_Italian=#False : f_return=#True : EndIf
If Filter(0)\F_Multi=#False : f_return=#True : EndIf
If Filter(0)\F_Polish=#False : f_return=#True : EndIf
If Filter(0)\F_Spanish=#False : f_return=#True : EndIf
If Filter(0)\F_Swedish=#False : f_return=#True : EndIf
ProcedureReturn f_return
EndProcedure
Procedure Set_Filter_Gadgets()
SetGadgetState(#GAME_OPTION,Filter(0)\F_Games)
SetGadgetState(#DEMO_OPTION,Filter(0)\F_Demos)
SetGadgetState(#BETA_OPTION,Filter(0)\F_Beta)
SetGadgetState(#MAGS_OPTION,Filter(0)\F_Mags)
SetGadgetState(#AGA_OPTION,Filter(0)\F_AGA)
SetGadgetState(#ECS_OPTION,Filter(0)\F_ECS)
SetGadgetState(#NTSC_OPTION,Filter(0)\F_NTSC)
SetGadgetState(#PAL_OPTION,Filter(0)\F_PAL)
SetGadgetState(#AMIGA_OPTION,Filter(0)\F_Amiga)
SetGadgetState(#ARCADIA_OPTION,Filter(0)\F_Arcadia)
SetGadgetState(#CD32_OPTION,Filter(0)\F_CD32)
SetGadgetState(#CDTV_OPTION,Filter(0)\F_CDTV)
SetGadgetState(#CDROM_OPTION,Filter(0)\F_CDROM)
SetGadgetState(#FILES_OPTION,Filter(0)\F_Files)
SetGadgetState(#IMAGE_OPTION,Filter(0)\F_Image)
SetGadgetState(#CHIP_OPTION,Filter(0)\F_Chip)
SetGadgetState(#FAST_OPTION,Filter(0)\F_Fast)
SetGadgetState(#CZECH_OPTION,Filter(0)\F_Czech)
SetGadgetState(#DANISH_OPTION,Filter(0)\F_Danish)
SetGadgetState(#DUTCH_OPTION,Filter(0)\F_Dutch)
SetGadgetState(#ENGLISH_OPTION,Filter(0)\F_English)
SetGadgetState(#FINNISH_OPTION,Filter(0)\F_Finnish)
SetGadgetState(#FRENCH_OPTION,Filter(0)\F_French)
SetGadgetState(#GERMAN_OPTION,Filter(0)\F_German)
SetGadgetState(#GREEK_OPTION,Filter(0)\F_Greek)
SetGadgetState(#ITALIAN_OPTION,Filter(0)\F_Italian)
SetGadgetState(#MULTI_OPTION,Filter(0)\F_Multi)
SetGadgetState(#POLISH_OPTION,Filter(0)\F_Polish)
SetGadgetState(#SPANISH_OPTION,Filter(0)\F_Spanish)
SetGadgetState(#SWEDISH_OPTION,Filter(0)\F_Swedish)
EndProcedure
Procedure Set_Filter(bool)
Filter(0)\F_Games=bool
Filter(0)\F_Demos=bool
Filter(0)\F_Beta=bool
Filter(0)\F_Mags=bool
Filter(0)\F_AGA=bool
Filter(0)\F_ECS=bool
Filter(0)\F_NTSC=bool
Filter(0)\F_PAL=bool
Filter(0)\F_Amiga=bool
Filter(0)\F_Arcadia=bool
Filter(0)\F_CD32=bool
Filter(0)\F_CDTV=bool
Filter(0)\F_CDROM=bool
Filter(0)\F_Files=bool
Filter(0)\F_Image=bool
Filter(0)\F_Chip=bool
Filter(0)\F_Fast=bool
Filter(0)\F_Czech=bool
Filter(0)\F_Danish=bool
Filter(0)\F_Dutch=bool
Filter(0)\F_English=bool
Filter(0)\F_Finnish=bool
Filter(0)\F_French=bool
Filter(0)\F_German=bool
Filter(0)\F_Greek=bool
Filter(0)\F_Italian=bool
Filter(0)\F_Multi=bool
Filter(0)\F_Polish=bool
Filter(0)\F_Spanish=bool
Filter(0)\F_Swedish=bool
Set_Filter_Gadgets()
EndProcedure
Procedure Set_Language_Gadgets(bool)
Filter(0)\F_Czech=bool
Filter(0)\F_Danish=bool
Filter(0)\F_Dutch=bool
Filter(0)\F_English=bool
Filter(0)\F_Finnish=bool
Filter(0)\F_French=bool
Filter(0)\F_German=bool
Filter(0)\F_Greek=bool
Filter(0)\F_Italian=bool
Filter(0)\F_Multi=bool
Filter(0)\F_Polish=bool
Filter(0)\F_Spanish=bool
Filter(0)\F_Swedish=bool
If bool : SetGadgetText(#CLEAR_LANG_BUTTON,"Clear") : Else : SetGadgetText(#CLEAR_LANG_BUTTON,"All") : EndIf
Set_Filter_Gadgets()
EndProcedure
Procedure Filter_List()
Protected NewMap File_Map.i();, filetype.s
ForEach Game_List()
If Use_Subfolder=#False
File_Map(WHD_Folder+Game_List()\File_Name)=ListIndex(Game_List())
EndIf
If Use_Subfolder=#True
If Use_0toZ_Folder=#True
If Game_List()\File_Type="Game" And Game_List()\File_BETA=#False : File_Map(WHD_Folder+WHD_Game_Folder+"/"+Game_List()\File_SubFolder+"/"+Game_List()\File_Name)=ListIndex(Game_List()) :EndIf
If Game_List()\File_Type="Demo" : File_Map(WHD_Folder+WHD_Demo_Folder+"/"+Game_List()\File_SubFolder+"/"+Game_List()\File_Name)=ListIndex(Game_List()) :EndIf
If Game_List()\File_Type="Game" And Game_List()\File_BETA=#True : File_Map(WHD_Folder+WHD_Beta_Folder+"/"+Game_List()\File_SubFolder+"/"+Game_List()\File_Name)=ListIndex(Game_List()) :EndIf
If Game_List()\File_Type="Magazine" : File_Map(WHD_Folder+WHD_Mags_Folder+"/"+Game_List()\File_SubFolder+"/"+Game_List()\File_Name)=ListIndex(Game_List()) :EndIf
Else
If Game_List()\File_Type="Game" : File_Map(WHD_Folder+WHD_Game_Folder+"/"+Game_List()\File_Name)=ListIndex(Game_List()) :EndIf
If Game_List()\File_Type="Demo" : File_Map(WHD_Folder+WHD_Demo_Folder+"/"+Game_List()\File_Name)=ListIndex(Game_List()) :EndIf
If Game_List()\File_Type="Game" And Game_List()\File_BETA=#True : File_Map(WHD_Folder+WHD_Beta_Folder+"/"+Game_List()\File_Name)=ListIndex(Game_List()) :EndIf
If Game_List()\File_Type="Magazine" : File_Map(WHD_Folder+WHD_Mags_Folder+"/"+Game_List()\File_Name)=ListIndex(Game_List()) :EndIf
EndIf
EndIf
Next
ForEach Game_List()
Game_List()\File_Available=#False
Game_List()\File_Filtered=#False
If Game_List()\File_Ignore=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Games=#False And Game_List()\File_Type="Game" And Game_List()\File_BETA<>#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Demos=#False And Game_List()\File_Type="Demo" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Mags=#False And Game_List()\File_Type="Magazine" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Beta=#False And Game_List()\File_Type="Game" And Game_List()\File_BETA=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_AGA=#False And Game_List()\File_AGA=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_ECS=#False And Game_List()\File_AGA=#False : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_NTSC=#False And Game_List()\File_NTSC=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_PAL=#False And Game_List()\File_NTSC=#False : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_CDTV=#False And Game_List()\File_CDTV=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_CD32=#False And Game_List()\File_CD32=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_CDROM=#False And Game_List()\File_CDROM=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Arcadia=#False And Game_List()\File_Arcadia=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Amiga=#False And Game_List()\File_Amiga=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Files=#False And Game_List()\File_Files=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Image=#False And Game_List()\File_Image=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Chip=#False And Game_List()\File_Chip=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Fast=#False And Game_List()\File_Fast=#True : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Czech=#False And Game_List()\File_Language="Czech" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Danish=#False And Game_List()\File_Language="Danish" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Dutch=#False And Game_List()\File_Language="Dutch" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_English=#False And Game_List()\File_Language="English" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Finnish=#False And Game_List()\File_Language="Finnish" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_French=#False And Game_List()\File_Language="French" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_German=#False And Game_List()\File_Language="German" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Greek=#False And Game_List()\File_Language="Greek" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Italian=#False And Game_List()\File_Language="Italian" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Multi=#False And Game_List()\File_Language="Multi" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Polish=#False And Game_List()\File_Language="Polish" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Spanish=#False And Game_List()\File_Language="Spanish" : Game_List()\File_Filtered=#True : EndIf
If Filter(0)\F_Swedish=#False And Game_List()\File_Language="Swedish" : Game_List()\File_Filtered=#True : EndIf
Next
Avail_Games=0
ForEach File_List()
Count=CountString(File_List(),"/")
If FindMapElement(File_Map(),File_List())
SelectElement(Game_List(),File_Map())
Game_List()\File_Available=#True
Avail_Games+1
Game_List()\File_Path=GetPathPart(File_List())