-
Notifications
You must be signed in to change notification settings - Fork 4
/
WHDLoadToolv1.21.pb
5863 lines (5029 loc) · 217 KB
/
WHDLoadToolv1.21.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 1.2
;
; © 2023 Paul Vince (MrV2k)
;
; https://easyemu.mameworld.info
;
; [ PB V5.7x/V6.x / 32Bit / 64Bit / Windows / DPI ]
;
; A downloader for Retroplay's WHDLoad Archive & More!
;
;- ############### Credits
;
; Conrad Fenech & Brian Lloyd for bug testing the connection issues
;
;- ############### Version Info
;
Global Version.s="1.21"
;
;============================================
; 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
;============================================
;
; Moved FTP procedures To Windows API functions.
; Fixed FTP fallback related console And UI crashes.
; Fixed non unicode characters in download name saving as empty files.
; Fixed open beta folder button.
; Removed requirement For PB_FTPEx libraries
; Clean files now only lists lha & lzx files.
; Added experimental support For Linux Ubuntu 20+ & MacOS (source available).
; Added check For lists folder. Creates If Not found.
; Added donate button To main window.
; Added version information To executables
;
;============================================
; VERSION INFO v0.8a
;============================================
;
; Fixed old dat files not being deleted in Scan FTP procedure.
; Cleaned up unneeded variables and lists from the FTP download procedures.
; Fixed console actions on Download FTP procedure.
; Tweaked FTP procedures to use real FTP variables rather than 1 & 0.
; Minor speed up when processing strings.
; Added button that makes a new folder of archives based on your filter selections.
; Make Folder opens the output folder window when complete.
;
;============================================
; VERSION INFO v0.9a
;============================================
;
; Fixed a bug in subfolder creation.
; Added ability to download to folder structures either by category or alphabetically.
; Changed 'Save Prefs' and 'Load Prefs' to be disabled until the database is loaded.
; Updated the default ftp login to ftp2.grandis.nu.
; Centered console on main window.
; Added HTTP based downloads.
; HTTP & FTP downloading now selectable fron the main window. HTTP is now the default, but the setting is saved in the prefs files if the user wants to change it.
; Added HTTP path to main window and prefs.
; Removed 'Use Subfolders' gadget and replaced with selectable combo gadgets for sorting downloads.
; Improved the download preview window procedure.
; Added a selectable 255 file limit to the download folders for the A500 mini home computer.
; All FTP and download gadgets are enabled by default.
; The FTP procedure has been updated to support the 0-Z and category downloads.
; Removed 'Make Folder' until I can make a better implementation of it.
; Fixed a small bug in scrape data procedure.
; Updated help file to reflect this versions changes.
; Improved the filter speed.
; Clear data now keeps the server and filter settings.
; Fixed a couple of bugs in the save/load prefs procedure. All gadgets now update properly.
; The clean files process is a bit dumber in the sense that it just looks for the right filename and deletes any lha or lzx file that doesn't match. It does still look for zero kilobyte files.
; Added a 'refresh list' keyboard shortcut (F5) to update the available files if the user deletes any files manually.
;
;============================================
; VERSION INFO v1.0
;============================================
;
; Added a check for duplicate dat files and delete the older one.
; 'Load Prefs' now enabled by default as it loads server settings.
;
;============================================
; VERSION INFO v1.1
;============================================
;
; Added 28 new filters.
; Fixed bug in scrape procedure that forgot to add beta games to Amiga system.
; Added fix for x86 compilation.
; Fixed download number in download screen.
;
;============================================
; VERSION INFO v1.11
;============================================
;
; Fixed bug in beta path.
; Fixed compilation version info.
; Added paypal.me link To the about window If you think I deserve a coffee.
;
;============================================
; VERSION INFO v1.12
;============================================
;
; Fixed bug where default.prefs was loaded at startup but the gadgets didn't update.
;
;============================================
; VERSION INFO v1.2
;============================================
;
; Added alphabetical sorting to category download.
; Fixed the sort gadgets not updating when the default.prefs was loaded at startup.
; Added an improved 'Make Folder' procedure back. It doesn't support A500 mini 255 file limit though.
; Fixed sort gadget logic.
; Updated the help window to reflect the new changes.
; Increased the window height to fit new button in and space out the filter a bit better.
;
;============================================
; VERSION INFO v1.21
;============================================
;
; Fixed a bug when the FTP and sort settings weren't applied to the relevant gadgets when loading the default prefs
;
;============================================
; To Do List
;============================================
;
;============================================
;
EnableExplicit
;- ############### Imports
CompilerIf #PB_Compiler_64Bit
Import ""
GetConsoleWindow(Void)
EndImport
CompilerEndIf
;- ############### Enumerations
Enumeration
#FTP
#REGEX
#LIST_FILE
#MAIN_WINDOW
#MAIN_STATUS
#MAIN_LIST
#MAIN_FONT
#MAIN_MENU
#MAIN_FILTER_CONTAINER
#MAIN_PATH_CONTAINER
#MAIN_FTP_CONTAINER
#MAIN_BUTTON_CONTAINER
#FILTER_PANEL
#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
#DOWNLOAD_A500MINI
#SCAN_BUTTON
#DOWNLOAD_BUTTON
#DOWNLOAD_TYPE_COMBO
#CLEAR_DATA_BUTTON
#RESET_BUTTON
#SAVE_PREFS_BUTTON
#LOAD_PREFS_BUTTON
#CLEANUP_BUTTON
#HELP_BUTTON
#ABOUT_BUTTON
#CLEAR_LANG_BUTTON
#LIST_APPEND_BUTTON
#LIST_LOAD_BUTTON
#LIST_SAVE_BUTTON
#LIST_EDIT_BUTTON
#CLEAR_EDITS_BUTTON
#MAKE_FOLDER_BUTTON
#DONATE_BUTTON
#COFFEE_BUTTON
#FTP_PASS_STRING
#FTP_USER_STRING
#FTP_SERVER_STRING
#FTP_FOLDER_STRING
#FTP_PORT_STRING
#HTTP_SERVER_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_SORT_COMBO
#WHD_CATEGORY_CHECK
#WHD_LANGUAGE_COMBO
#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
#ENGLISH_OPTION
#FINNISH_OPTION
#FRENCH_OPTION
#GERMAN_OPTION
#GREEK_OPTION
#ITALIAN_OPTION
#MULTI_OPTION
#POLISH_OPTION
#SPANISH_OPTION
#SWEDISH_OPTION
#CLEAR_BUTTON
#MT32_OPTION
#NOVOICE_OPTION
#NOSPEECH_OPTION
#NOMUSIC_OPTION
#MEM_1MB_OPTION
#MEM_1MB_CHIP_OPTION
#MEM_8MB_OPTION
#MEM_12MB_OPTION
#MEM_15MB_OPTION
#MEM_2MB_OPTION
#MEM_512K_OPTION
#MEM_512KB_OPTION
#CHIP_OPTION
#FAST_OPTION
#LOWMEM_OPTION
#SLOWMEM_OPTION
#IMAGE_OPTION
#FILES_OPTION
#DISK1_OPTION
#DISK2_OPTION
#DISK3_OPTION
#DISK4_OPTION
#NOINTRO_OPTION
#HIRES_OPTION
#LORES_OPTION
#PRERELEASE_OPTION
#PREVIEW_OPTION
#GAMEDEMO_OPTION
#ENHANCED_OPTION
#CENSORED_OPTION
#UNCENSORED_OPTION
#NOMOVIE_OPTION
EndEnumeration
;- ############### Structures
Structure Game_Data
File_Name.s
File_Path.s
File_SubFolder.s
File_Genre.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
File_512K.b
File_512KB.b
File_1MB.b
File_1_5MB.b
File_1MBCHIP.b
File_2MB.b
File_8MB.b
File_12MB.b
File_LowMem.b
File_SlowMem.b
File_NoIntro.b
File_MT32.b
File_NoVoice.b
File_NoSpeech.b
File_NoMusic.b
File_NoMovie.b
File_1Disk.b
File_2Disk.b
File_3Disk.b
File_4Disk.b
File_HiRes.b
File_LoRes.b
File_GameDemo.b
File_Preview.b
File_PreRelease.b
File_Enhanced.b
File_Censored.b
File_UnCensored.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
F_512K.b
F_512KB.b
F_1MB.b
F_1_5MB.b
F_1MBCHIP.b
F_2MB.b
F_8MB.b
F_12MB.b
F_LowMem.b
F_SlowMem.b
F_NoIntro.b
F_MT32.b
F_NoVoice.b
F_NoSpeech.b
F_NoMusic.b
F_NoMovie.b
F_1Disk.b
F_2Disk.b
F_3Disk.b
F_4Disk.b
F_HiRes.b
F_LoRes.b
F_GameDemo.b
F_Preview.b
F_PreRelease.b
F_Enhanced.b
F_Censored.b
F_UnCensored.b
EndStructure
Structure Down_Data
Down_Name.s
Down_Type.s
Down_Genre.s
Down_Folder.s
Down_FTP_Folder.s
Down_HTTP_Folder.s
Down_SubFolder_1.s
Down_SubFolder_2.s
Down_SubFolder_3.s
Down_Path.s
Down_0toZ.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
Structure Sort_Struct
Sort_Name.s
Sort_Index.i
EndStructure
Structure Temp_Struct
List nums.s()
List a.s()
List b.s()
List c.s()
List d.s()
List e.s()
List f.s()
List g.s()
List h.s()
List i.s()
List j.s()
List k.s()
List l.s()
List m.s()
List n.s()
List o.s()
List p.s()
List q.s()
List r.s()
List s.s()
List t.s()
List u.s()
List v.s()
List w.s()
List x.s()
List y.s()
List z.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 Path.s, Count.i, Folder.s, FCount.f
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 Sort_Type.i=0
Global Split_Languages.i=0
Global A500Mini.b=#False
Global Slash$ ; For cross platform path compatibility
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 HTTP_Server.s
Global Download_Type.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 Event.l, Gadget.l, Type.l
Global hWnd
Global Dim Filter.Filter_Data(0)
;- ############### Declares
Declare Draw_List()
;- ############### Macros
Macro Center_Console()
CompilerIf #PB_Compiler_64Bit
hWnd = GetConsoleWindow(0)
MoveWindow_(hWnd, DpiX(WindowX(#MAIN_WINDOW))+(WindowWidth(#MAIN_WINDOW)/8), DpiY(WindowY(#MAIN_WINDOW))+(WindowHeight(#MAIN_WINDOW)/8), DpiX(WindowWidth(#MAIN_WINDOW)/1.25), DpiY(WindowHeight(#MAIN_WINDOW)/1.25), 1)
CompilerEndIf
EndMacro
Macro Remove_Console_Close()
CompilerIf #PB_Compiler_64Bit
hWnd = GetConsoleWindow(0)
DeleteMenu_(GetSystemMenu_(hWnd, #False), 6, #MF_BYPOSITION)
SendMessage_(hWnd, #WM_NCPAINT, 1, 0)
CompilerEndIf
EndMacro
Macro Pause_Window(window)
SendMessage_(WindowID(window),#WM_SETREDRAW,#False,0)
EndMacro
Macro Resume_Window(window)
SendMessage_(WindowID(window),#WM_SETREDRAW,#True,0)
RedrawWindow_(WindowID(window),#Null,#Null,#RDW_INVALIDATE)
EndMacro
Macro Pause_Gadget(gadget)
SendMessage_(GadgetID(gadget),#WM_SETREDRAW,#False,0)
EndMacro
Macro Resume_Gadget(gadget)
SendMessage_(GadgetID(gadget),#WM_SETREDRAW,#True,0)
InvalidateRect_(GadgetID(gadget), 0, 0)
UpdateWindow_(GadgetID(gadget))
EndMacro
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) - (Press F5 to refresh list)"
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"
Download_Type=1 ; 0=FTP 1=HTTP
FTP_Folder="Retroplay WHDLoad Packs"
FTP_Server="ftp2.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"
HTTP_Server="http://ftp2.grandis.nu/turran/FTP/Retroplay%20WHDLoad%20Packs"
EndMacro
Macro Update_Gadgets()
SetGadgetText(#FTP_FOLDER_STRING,FTP_Folder)
SetGadgetText(#FTP_USER_STRING,FTP_User)
SetGadgetText(#FTP_PASS_STRING,FTP_Pass)
SetGadgetText(#FTP_PORT_STRING,Str(FTP_Port))
SetGadgetText(#FTP_SERVER_STRING,FTP_Server)
SetGadgetText(#HTTP_SERVER_STRING,HTTP_Server)
SetGadgetText(#WHD_MAIN_STRING,WHD_Folder)
SetGadgetText(#WHD_GAME_STRING,WHD_Game_Folder)
SetGadgetText(#WHD_DEMO_STRING,WHD_Demo_Folder)
SetGadgetText(#WHD_BETA_STRING,WHD_Beta_Folder)
SetGadgetText(#WHD_MAGS_STRING,WHD_Mags_Folder)
SetGadgetState(#DOWNLOAD_TYPE_COMBO,Download_Type)
SetGadgetState(#WHD_SORT_COMBO,Sort_Type)
SetGadgetState(#WHD_LANGUAGE_COMBO,Split_Languages)
EndMacro
Macro OpenFolder(folder_path)
RunProgram(folder_path)
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()
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"
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)
Pause_Window(#MAIN_WINDOW)
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(#MEM_512K_OPTION,bool)
DisableGadget(#MEM_512KB_OPTION,bool)
DisableGadget(#MEM_1MB_OPTION,bool)
DisableGadget(#MEM_15MB_OPTION,bool)
DisableGadget(#MEM_1MB_CHIP_OPTION,bool)
DisableGadget(#MEM_2MB_OPTION,bool)
DisableGadget(#MEM_8MB_OPTION,bool)
DisableGadget(#MEM_12MB_OPTION,bool)
DisableGadget(#LOWMEM_OPTION,bool)
DisableGadget(#SLOWMEM_OPTION,bool)
DisableGadget(#NOINTRO_OPTION,bool)
DisableGadget(#MT32_OPTION,bool)
DisableGadget(#NOVOICE_OPTION,bool)
DisableGadget(#NOSPEECH_OPTION,bool)
DisableGadget(#NOMUSIC_OPTION,bool)
DisableGadget(#NOMOVIE_OPTION,bool)
DisableGadget(#DISK1_OPTION,bool)
DisableGadget(#DISK2_OPTION,bool)
DisableGadget(#DISK3_OPTION,bool)
DisableGadget(#DISK4_OPTION,bool)
DisableGadget(#HIRES_OPTION,bool)
DisableGadget(#LORES_OPTION,bool)
DisableGadget(#GAMEDEMO_OPTION,bool)
DisableGadget(#PREVIEW_OPTION,bool)
DisableGadget(#PRERELEASE_OPTION,bool)
DisableGadget(#ENHANCED_OPTION,bool)
DisableGadget(#CENSORED_OPTION,bool)
DisableGadget(#UNCENSORED_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_DATA_BUTTON,bool)
DisableGadget(#MAKE_FOLDER_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)
DisableGadget(#SAVE_PREFS_BUTTON,bool)
DisableGadget(#WHD_MAIN_STRING,bool)
DisableGadget(#WHD_GAME_STRING,bool)
DisableGadget(#WHD_OPEN_GAME_BUTTON,bool)
DisableGadget(#WHD_BETA_STRING,bool)
DisableGadget(#WHD_OPEN_BETA_BUTTON,bool)
DisableGadget(#WHD_DEMO_STRING,bool)
DisableGadget(#WHD_OPEN_DEMO_BUTTON,bool)
DisableGadget(#WHD_MAGS_STRING,bool)
DisableGadget(#WHD_OPEN_MAGS_BUTTON,bool)
DisableGadget(#WHD_OPEN_PATH_BUTTON,bool)
DisableGadget(#WHD_SET_PATH_BUTTON,bool)
DisableGadget(#WHD_SORT_COMBO,bool)
If Sort_Type=2
DisableGadget(#WHD_LANGUAGE_COMBO,bool)
EndIf
DisableGadget(#GAME_OPTION,bool)
DisableGadget(#DEMO_OPTION,bool)
DisableGadget(#BETA_OPTION,bool)
DisableGadget(#MAGS_OPTION,bool)
Resume_Window(#MAIN_WINDOW)
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
Procedure Update_Genre()