-
Notifications
You must be signed in to change notification settings - Fork 4
/
WHDLoadToolv1.5.pb
6467 lines (5584 loc) · 240 KB
/
WHDLoadToolv1.5.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
;
;
Global Version.s="1.4.2"
;
; © 2024 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
;
;
;============================================
; 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.
;
;============================================
; VERSION INFO v1.3
;============================================
;
; Added CRC32 checking to the update procedure.
; Added support for the new Beta Demo folder on the FTP. All beta files are still saved to the selected beta folder.
; Users are now prompted to download the dat files when a prefs file is loaded and no data has been downloaded.
; All download files are size checked against the dat files and removed it they are wrong.
; HTTP download errors are logged in a file called error_log.txt.
; You can now toggle the file tree in the download preview.
; Downloads are a tiny bit slower as the files are size and crc checked once received.
; You can now save the download list as a text file.
; Fixed status bar spacing.
; Changing prefs files will prompt for clearing the database and will rescan the WHDLoad folders.
; Save Prefs button is now active all the time.
; The file list now shows any errors in your files by highlighting them with red for missing and blue for bad CRC32.
; Moved all donate links to a new window.
;
;============================================
; VERSION INFO v1.3.1
;============================================
;
; Fixed list filter not updating for games and beta files
; Fixed Make Folder not finding any games.
; Clear data now resets all settings and filters including sort and download paths.
;
;============================================
; VERSION INFO v1.3.2
;============================================
;
; Re-enabled automatic file cleaning after download
;
;============================================
; VERSION INFO v1.4
;============================================
;
; Fixed Magazine button logic in filter.
; Split Beta category into Games and Demos and added separate paths to the folder List.
; Moved folder options into a scrolling gadget to keep window size the same.
; 'Update Files' window now only shows if a file is actually downloaded from the 'Download' window.
; CD32 games now are categorised as AGA.
; Fixed download preview list.
; Added AGA/ECS data to Magazines. Files will be split if category sort is selected on download.
; Fixed FTP download not creating all Category (0-Z) sub folders.
; Fixed a few errors in the help file.
; Improved CD32 & CDTV detection in game list filename scrape.
;
;============================================
; VERSION INFO v1.4.1
;============================================
;
; Added Croation language to the filter.
; Move language toggle button and renamed to 'Lang.'
; Renamed 'Clear Filter' button to 'Clear'
; Renamed 'Reset Filter' button to 'Reset'
;
;============================================
; VERSION INFO v1.4.2
;============================================
;
; Fixed Croatian button not setting when a prefs file is loaded.
; Optimized button setting process.
;
;============================================
; VERSION INFO v1.5
;============================================
;
; Fixed crash when appending lists.
;
;============================================
; To Do List
;============================================
;
;
;============================================
;
EnableExplicit
;- ############### Imports
CompilerIf #PB_Compiler_64Bit
Import ""
GetConsoleWindow(Void)
EndImport
CompilerEndIf
;- ############### Enumerations
Enumeration
#FTP
#REGEX
#LIST_FILE
#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
#DONATE_WINDOW
#DONATE_BUTTON_A
#DONATE_BUTTON_B
#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
#DOWNLOAD_SAVE
#DOWNLOAD_EXPAND
#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_GAME_STRING
#WHD_BETA_DEMO_STRING
#WHD_OPEN_BETA_GAME_BUTTON
#WHD_OPEN_BETA_DEMO_BUTTON
#WHD_SORT_COMBO
#WHD_CATEGORY_CHECK
#WHD_LANGUAGE_COMBO
#PARENT_TXT
#GAME_OPTION
#DEMO_OPTION
#BETA_GAME_OPTION
#BETA_DEMO_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
#CROATIAN_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_CRC.s
File_Archive_CRC.s
File_InvalidCRC.b
File_SubFolder.s
File_Genre.s
File_Type.s
File_Beta_Type.s
File_Beta_Game.b
File_Beta_Demo.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_Game.b
F_Beta_Demo.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_Croatian.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_Index.i
Down_CRC.s
Down_FTP_CRC.s
Down_Genre.s
Down_Folder.s
Down_Size.i
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
own_crc32.s
own_size.i
EndStructure
Structure Del_Structure
del_name.s
del_type.i
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
R_File_File.s
R_File_CRC32.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, Path2.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_Folder1.s
Global WHD_Beta_Folder2.s
Global FTP_Beta_Folder1.s
Global FTP_Beta_Folder2.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_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_Folder1="Commodore_Amiga_-_WHDLoad_-_Games_-_Beta_&_Unreleased"
FTP_Beta_Folder2="Commodore_Amiga_-_WHDLoad_-_Demos_-_Beta_&_Unreleased"
WHD_Beta_Folder1="Beta-Game"
WHD_Beta_Folder2="Beta-Demo"
FTP_Mags_Folder="Commodore_Amiga_-_WHDLoad_-_Magazines"
WHD_Mags_Folder="Magazines"
HTTP_Server="http://ftp2.grandis.nu/turran/FTP/Retroplay%20WHDLoad%20Packs"
Lang_Bool=#True
Avail_Games=0
Sort_Type=0
Split_Languages=0
A500Mini=#False
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)
SetGadgetState(#GAME_OPTION,Filter(0)\F_Games)
SetGadgetState(#DEMO_OPTION,Filter(0)\F_Demos)
SetGadgetState(#BETA_GAME_OPTION,Filter(0)\F_Beta_Game)
SetGadgetState(#BETA_DEMO_OPTION,Filter(0)\F_Beta_Demo)
SetGadgetState(#MAGS_OPTION,Filter(0)\F_Mags)
SetGadgetText(#WHD_DEMO_STRING,WHD_Demo_Folder)
SetGadgetText(#WHD_BETA_GAME_STRING,WHD_Beta_Folder1)
SetGadgetText(#WHD_BETA_DEMO_STRING,WHD_Beta_Folder2)
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
Macro Delete_File_List_Entry(entry)
ForEach File_List_Size()
If entry=File_List_Size()\R_File_File
DeleteElement(File_List_Size())
Break
EndIf
Next
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
Procedure TreeCollapseAllItems(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_Expanded
If CurState & #PB_Tree_Checked
CurState = #PB_Tree_Checked | #PB_Tree_Collapsed
ElseIf CurState & #PB_Tree_Inbetween
CurState = #PB_Tree_Inbetween | #PB_Tree_Collapsed
Else
CurState = #PB_Tree_Collapsed
EndIf
SetGadgetItemState(TreeId, CurItem, CurState)
Next
EndProcedure
;- ############### Update Gadgets
Procedure Set_List_Gadgets(bool)
DisableGadget(#LIST_APPEND_BUTTON,bool)