forked from Marshallx/Launch-Base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmModCat.frm
1328 lines (1301 loc) · 57.4 KB
/
frmModCat.frm
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
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmModCat
BorderStyle = 1 'Fixed Single
Caption = "Launch Base: Check For Updates"
ClientHeight = 5160
ClientLeft = 45
ClientTop = 330
ClientWidth = 10920
Icon = "frmModCat.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5160
ScaleWidth = 10920
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdCancel
Caption = "Back to Launch Menu"
Height = 375
Left = 7320
TabIndex = 37
Top = 4680
Width = 3495
End
Begin VB.CommandButton cmdDownload
Caption = "Download and Install Selected Mod"
Enabled = 0 'False
Height = 375
Left = 3720
TabIndex = 40
Top = 4680
Width = 3495
End
Begin VB.CommandButton cmdChangeLog
Caption = "View Change Log for Selected Mod"
Enabled = 0 'False
Height = 375
Left = 120
TabIndex = 39
Top = 4680
Width = 3495
End
Begin VB.Frame frameFilter
Caption = "Filter"
Height = 3495
Left = 120
TabIndex = 24
Top = 1080
Width = 1575
Begin VB.CheckBox cboxFilterUpdates
Caption = "Installed Mods"
Height = 255
Index = 2
Left = 120
TabIndex = 38
ToolTipText = "Shows mods that you have already installed and already have the latest version."
Top = 3120
Width = 1425
End
Begin VB.CheckBox cboxFilterGame
Caption = "Yuri's Revenge"
Height = 255
Index = 1
Left = 120
TabIndex = 35
ToolTipText = "Select which games you are interested in."
Top = 2040
Width = 1425
End
Begin VB.CheckBox cboxFilterGame
Caption = "Red Alert 2"
Height = 255
Index = 0
Left = 120
TabIndex = 34
ToolTipText = "Select which games you are interested in."
Top = 1800
Width = 1425
End
Begin VB.CheckBox cboxFilterUpdates
Caption = "Updates"
Height = 255
Index = 0
Left = 120
TabIndex = 32
ToolTipText = "Shows mods that you have already installed for which there is a newer version."
Top = 2640
Width = 1425
End
Begin VB.CheckBox cboxFilterUpdates
Caption = "New Mods"
Height = 255
Index = 1
Left = 120
TabIndex = 31
ToolTipText = "Shows mods that you haven't installed."
Top = 2880
Width = 1425
End
Begin VB.CheckBox cboxFilterModType
Caption = "Tools"
Height = 255
Index = 3
Left = 120
TabIndex = 28
ToolTipText = "Select which mod types you are interested in acquiring/updating."
Top = 1200
Width = 1395
End
Begin VB.CheckBox cboxFilterModType
Caption = "FA2 Mods"
Height = 255
Index = 2
Left = 120
TabIndex = 27
ToolTipText = "Select which mod types you are interested in acquiring/updating."
Top = 960
Width = 1395
End
Begin VB.CheckBox cboxFilterModType
Caption = "Plugins"
Height = 255
Index = 1
Left = 120
TabIndex = 26
ToolTipText = "Select which mod types you are interested in acquiring/updating."
Top = 720
Width = 1395
End
Begin VB.CheckBox cboxFilterModType
Caption = "Mods"
Height = 255
Index = 0
Left = 120
TabIndex = 25
ToolTipText = "Select which mod types you are interested in acquiring/updating."
Top = 480
Width = 1395
End
Begin VB.Label lblFilterUpdates
Caption = "Updates:"
Height = 255
Left = 120
TabIndex = 33
Top = 2400
Width = 1335
End
Begin VB.Label lblFilterGame
Caption = "Games:"
Height = 255
Left = 120
TabIndex = 30
Top = 1560
Width = 1335
End
Begin VB.Label lblFilterModType
Caption = "Mod Types:"
Height = 255
Left = 120
TabIndex = 29
Top = 240
Width = 1335
End
End
Begin VB.Frame frameAvailableMods
Caption = "Available Mods/Updates"
Height = 3495
Left = 1800
TabIndex = 16
Top = 1080
Width = 4695
Begin MSComctlLib.ListView listModCat
Height = 3135
Left = 120
TabIndex = 17
Top = 240
Width = 4440
_ExtentX = 7832
_ExtentY = 5530
View = 3
LabelEdit = 1
LabelWrap = 0 'False
HideSelection = 0 'False
FullRowSelect = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 0
End
End
Begin VB.Frame Frame2
Caption = "Update Check Progress"
Height = 975
Left = 120
TabIndex = 14
Top = 0
Width = 10695
Begin MSComctlLib.ProgressBar pbarModCat
Height = 375
Left = 120
TabIndex = 36
Top = 480
Width = 10455
_ExtentX = 18441
_ExtentY = 661
_Version = 393216
Appearance = 1
End
Begin VB.Label lblModCatFails
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "see which update checks failed"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 195
Left = 7320
MouseIcon = "frmModCat.frx":0E42
MousePointer = 99 'Custom
TabIndex = 41
Top = 240
Visible = 0 'False
Width = 3210
End
Begin VB.Label lblCheckProgress
Height = 255
Left = 120
TabIndex = 15
Top = 240
Width = 10455
End
End
Begin VB.Frame frameModDetails
Caption = "Selected Mod Details"
Height = 3495
Left = 6600
TabIndex = 0
Top = 1080
Width = 4215
Begin VB.Label lblModGame
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Red Alert 2"
Height = 195
Left = 1440
TabIndex = 23
Top = 360
Width = 795
End
Begin VB.Label lblGame
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Game:"
Height = 195
Left = 120
TabIndex = 22
Top = 360
Width = 465
End
Begin VB.Label lblModYourVersion
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "1.001"
Height = 195
Left = 1440
TabIndex = 21
Top = 840
Width = 405
End
Begin VB.Label lblYourVersion
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Installed Version:"
Height = 195
Left = 120
TabIndex = 20
Top = 840
Width = 1200
End
Begin VB.Label lblSize
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Download:"
Height = 195
Left = 120
TabIndex = 19
Top = 1800
Width = 765
End
Begin VB.Label lblModSize
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "KB"
Height = 195
Left = 1440
TabIndex = 18
Top = 1800
Width = 210
End
Begin VB.Label lblModTX
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Not Required"
ForeColor = &H00004000&
Height = 195
Left = 1440
TabIndex = 13
Top = 2280
Width = 945
End
Begin VB.Label lblTX
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "TX Plugin:"
Height = 195
Left = 120
TabIndex = 12
Top = 2280
Width = 735
End
Begin VB.Label lblModDate
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "2006-11-12"
Height = 195
Left = 1440
TabIndex = 11
Top = 1080
Width = 810
End
Begin VB.Label lblDate
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Date:"
Height = 195
Left = 120
TabIndex = 10
Top = 1080
Width = 390
End
Begin VB.Label lblModDescription
BackStyle = 0 'Transparent
Caption = $"frmModCat.frx":114C
Height = 855
Left = 120
TabIndex = 9
Top = 2640
Width = 3975
End
Begin VB.Label lblVersion
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Latest Version:"
Height = 195
Left = 120
TabIndex = 8
Top = 600
Width = 1050
End
Begin VB.Label lblCampaigns
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Campaigns:"
Height = 195
Left = 120
TabIndex = 7
Top = 2040
Width = 825
End
Begin VB.Label lblAuthor
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Author:"
Height = 195
Left = 120
TabIndex = 6
Top = 1320
Width = 510
End
Begin VB.Label lblWebsite
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Website:"
Height = 195
Left = 120
TabIndex = 5
Top = 1560
Width = 630
End
Begin VB.Label lblModVersion
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "1.001"
Height = 195
Left = 1440
TabIndex = 4
Top = 600
Width = 405
End
Begin VB.Label lblModAuthor
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Westwood Studios"
Height = 195
Left = 1440
TabIndex = 3
Top = 1320
Width = 1335
End
Begin VB.Label lblModCampaigns
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Original Campaigns"
Height = 195
Left = 1440
TabIndex = 2
Top = 2040
Width = 1350
End
Begin VB.Label lblModWebsite
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "http://www.westwood.com"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 1440
MouseIcon = "frmModCat.frx":11DD
MousePointer = 99 'Custom
TabIndex = 1
Top = 1560
Width = 1935
End
End
Begin VB.Menu menu_rc2
Caption = ""
Visible = 0 'False
Begin VB.Menu menu_url
Caption = "Copy URL to Clipboard"
End
End
End
Attribute VB_Name = "frmModCat"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const ColorGood = &H4000&
Private Const ColorBad = &H80&
Private Const ColorURL = &HC00000
Private Const ColorURLActive = &HFF&
Public Busy As Boolean
Public Function DownloadProgress(ByVal iBytesReceived As Long, ByVal iBytesExpected As Long)
'called by internet module. needed to allow user to abort
DoEvents
End Function
Private Sub RedimAndInit(iNewSize)
Dim iCounter As Integer
If iNewSize = 0 Then
iCounter = 0
Else
iCounter = UBound(UpdateRecords()) + 1
End If
ReDim Preserve UpdateRecords(iNewSize)
Do While iCounter <= iNewSize
Call InitialiseRecord(iCounter)
iCounter = iCounter + 1
Loop
End Sub
Public Sub LoadUpdateCat()
Dim hModCat As Integer
Dim iRecord As Integer
Dim iMod As Integer
Dim bUpdateMod As Boolean
Call CallStackPush(Me.Name & ".LoadUpdateCat()")
If Not CL_noexcept Then On Error GoTo LocalErr
GoTo LocalMain
LocalErr:
Call GlobalErr
LocalMain:
Call frmMain.WriteLogEntry("Loading mod update records...", LogLevel1)
Call RedimAndInit(0)
Call RedimAndInit(ModCount + 20)
UpdateRecords(0).CheckURL = ModCatUPD
UpdateRecordCount = 0
For iMod = 0 To ModCount
If Len(Mods(iMod).ModName) <> 0 Then 'mod has been deleted if name is blank
'Check for legacy versions of the same mod
iRecord = 1
Do While iRecord <> (UpdateRecordCount + 1)
If UpdateRecords(iRecord).CheckURL = Mods(iMod).ModUpdateCheckURL Then
If CompareVersions(Mods(iMod).ModVersion, ">", UpdateRecords(iRecord).ModUserVersion) Then
UpdateRecords(iRecord).CheckModNum = iMod
Call InitialiseRecord(UpdateRecordCount, True)
Exit Do
End If
End If
iRecord = iRecord + 1
Loop
If iRecord = (UpdateRecordCount + 1) Then
'we didn't find the mod so create new record
UpdateRecordCount = UpdateRecordCount + 1
UpdateRecords(UpdateRecordCount).CheckModNum = iMod
Call InitialiseRecord(UpdateRecordCount, True)
End If
End If
Next iMod
'All plugins are in the online catalogue
Call CallStackPop
End Sub
Public Sub UpdateUpdateCat()
Dim iRecord As Long
Dim iFails As Long
Call CallStackPush(Me.Name & ".UpdateUpdateCat()")
If Not CL_noexcept Then On Error GoTo LocalErr
GoTo LocalMain
LocalErr:
Call GlobalErr
LocalMain:
Call EnableControls(False)
Call frmMain.WriteLogEntry("Checking for updates...", LogLevel1)
lblCheckProgress.Caption = "Checking for updates..."
cmdCancel.Caption = "Abort Update Check"
frmModCat.pbarModCat.Value = 0
Call Me.Refresh
Busy = True
frmModCat.pbarModCat.Max = UpdateRecordCount + 1
iFails = 0
iRecord = 0
If Not theInternet.Connected Then
Me.Enabled = False
Call theInternet.Connect(Me.hWnd)
Me.Enabled = True
Me.SetFocus
End If
If theInternet.Connected Then
Do While iRecord <= UpdateRecordCount
iFails = iFails + UpdateUpdateRecord(iRecord)
If theInternet.DownloadCancelled Then Exit Do
iRecord = iRecord + 1
frmModCat.pbarModCat.Value = frmModCat.pbarModCat.Value + 1
Loop
End If
Busy = False
If theInternet.Connected Then
If iFails = 0 Then
If Not theInternet.DownloadCancelled Then
Call frmMain.WriteLogEntry("Update check complete.", LogLevel1)
lblCheckProgress.Caption = "Update check complete."
Else
Call frmMain.WriteLogEntry("Update check cancelled by user.", LogLevel1)
lblCheckProgress.Caption = "Update check cancelled by user."
End If
Else
lblModCatFails.Visible = True
If Not theInternet.DownloadCancelled Then
Call frmMain.WriteLogEntry("Update check complete. " & CStr(iFails) & " mods' update checks failed.", LogLevel1)
lblCheckProgress.Caption = "Update check complete. " & CStr(iFails) & " mods' update checks failed."
Else
Call frmMain.WriteLogEntry("Update check cancelled by user. " & CStr(iFails) & " mods' update checks failed.", LogLevel1)
lblCheckProgress.Caption = "Update check cancelled by user. " & CStr(iFails) & " mods' update checks failed."
End If
End If
Else
Call frmMain.WriteLogEntry("Update check skipped - no connection to Internet.", LogLevel1)
lblCheckProgress.Caption = "Update check skipped - no connection to Internet."
End If
cmdCancel.Caption = "Back to Launch Menu"
Call EnableControls(True)
Call FilterModCat
Call CallStackPop
End Sub
Public Function UpdateUpdateRecord(ByVal iRecord As Integer) As Integer
Dim iCounter As Integer
Dim iLine As Integer
Dim iPos As Integer
Dim sBuffer As String
Dim sArray() As String
Dim sValue As String
Dim sFlag As String
Dim iUpdate As Integer
Dim iMirror As Integer
Dim bPluginAuthed As Boolean
Dim bCentralOk As Boolean
Dim iFails As Integer
Call CallStackPush(Me.Name & ".UpdateUpdateRecord(" & CStr(iRecord))
If Not CL_noexcept Then On Error GoTo LocalErr
GoTo LocalMain
LocalErr:
Call GlobalErr
LocalMain:
iFails = 0
If iRecord = 0 Then
'Need to update all central records from the current Central catalogue
lblCheckProgress.Caption = "Downloading central catalogue data..."
Call lblCheckProgress.Refresh
If theInternet.CopyURLToString(ModCatUPD, sBuffer, Me) Then
sBuffer = ConvertEOL(sBuffer, vbCrLf)
If Not theInternet.DownloadCancelled Then
'Process all the URLs from the central catalogue
sArray = Split(sBuffer, vbCrLf)
iLine = 0
Do While iLine <= UBound(sArray())
iPos = InStr(1, sArray(iLine), "=")
If iPos > 1 Then
sValue = Mid$(sArray(iLine), iPos + 1) 'URL
sFlag = Left$(sArray(iLine), iPos - 1) 'index
'Check if we have already got a record for this one
iCounter = 1
Do While iCounter <= UpdateRecordCount
If Len(StripNumbers(sFlag)) = 0 Then
'numeric index so not plugin
If UpdateRecords(iCounter).CheckURL = sValue Then
Exit Do
End If
Else
'Non-numeric index so must be a plugin
If UpdateRecords(iCounter).ModPluginID = sFlag Then
UpdateRecords(iCounter).CheckURL = sValue
Exit Do
End If
End If
iCounter = iCounter + 1
Loop
'If we haven't got a record for this one, create a record. We'll download the UPD later though.
If iCounter = UpdateRecordCount + 1 Then
UpdateRecordCount = UpdateRecordCount + 1
pbarModCat.Max = pbarModCat.Max + 1 'we've already set this so need to update it
If UBound(UpdateRecords()) < UpdateRecordCount Then Call RedimAndInit(UpdateRecordCount + 20)
Call InitialiseRecord(UpdateRecordCount)
UpdateRecords(UpdateRecordCount).CheckURL = sValue
If Len(StripNumbers(sFlag)) <> 0 Then
'Non-numeric index so must be a plugin
UpdateRecords(UpdateRecordCount).ModPluginID = sFlag 'although this will get updated from the UPD when we download it later anyway
End If
End If
End If
iLine = iLine + 1
Loop
End If
Else
Call frmMain.WriteLogEntry("Failed to download central mod catalogue " & Quote(ModCatUPD))
End If
Else
'download the UPD and update the record
UpdateRecords(iRecord).FailReason = ""
If Len(UpdateRecords(iRecord).CheckURL) <> 0 Then
If Len(UpdateRecords(iRecord).ModName) <> 0 Then
lblCheckProgress.Caption = "Checking for updates... " & UpdateRecords(iRecord).ModName
Else
lblCheckProgress.Caption = "Checking for updates... " & UpdateRecords(iRecord).CheckURL
End If
Call lblCheckProgress.Refresh
If theInternet.CopyURLToString(UpdateRecords(iRecord).CheckURL, sBuffer, Me) Then
sBuffer = ConvertEOL(sBuffer, vbCrLf)
UpdateRecords(iRecord).ModName = ReadINIStrMemory(sBuffer, "General", "Name")
UpdateRecords(iRecord).ModLatestVersion = ReadINIStrMemory(sBuffer, "General", "LatestVersion")
UpdateRecords(iRecord).ModDate = ReadINIStrMemory(sBuffer, "General", "Date")
UpdateRecords(iRecord).ModAuthor = ReadINIStrMemory(sBuffer, "General", "Author")
UpdateRecords(iRecord).ModWebsite = ReadINIStrMemory(sBuffer, "General", "Website")
UpdateRecords(iRecord).ModDescription = ReadINIStrMemory(sBuffer, "General", "Description")
UpdateRecords(iRecord).ModCampaigns = ReadINIStrMemory(sBuffer, "General", "Campaigns")
UpdateRecords(iRecord).ModTXVersion = ReadINIStrMemory(sBuffer, "General", "TXVersion")
UpdateRecords(iRecord).ModFA2Version = ReadINIStrMemory(sBuffer, "General", "FA2Version")
UpdateRecords(iRecord).ModGameIsRA2 = BooleanStringToBoolean(ReadINIStrMemory(sBuffer, "General", "IsForRA2", , , "no"))
Select Case UCase$(ReadINIStrMemory(sBuffer, "General", "ModType"))
Case "MOD": UpdateRecords(iRecord).ModType = TypeMod
Case "PLUGIN": UpdateRecords(iRecord).ModType = TypePlugin
Case "FA2MOD": UpdateRecords(iRecord).ModType = TypeFA2Mod
Case "USERTOOL", "DEVTOOL", "MODTOOL", "TOOL", "program": UpdateRecords(iRecord).ModType = TypeProgram
End Select
sValue = ReadINIStrMemory(sBuffer, "General", "PluginID")
If Len(sValue) <> 0 Then
UpdateRecords(iRecord).ModPluginID = sValue
UpdateRecords(iRecord).ModType = TypePlugin
End If
If UpdateRecords(iRecord).ModType = TypePlugin Then
'there is only ever one update record for a given plugin because we don't allow plugins to specify their own UPD
'just need to find what version the user has
iCounter = frmMain.GetLatestPlugin(UpdateRecords(iRecord).ModPluginID)
If iCounter <> -1 Then
UpdateRecords(iRecord).ModUserVersion = Plugins(iCounter).PluginVersion
UpdateRecords(iRecord).CheckModNum = iCounter
Else
UpdateRecords(iRecord).ModUserVersion = ""
End If
Else
If UpdateRecords(iRecord).CheckModNum = -1 Then
'we might already have the mod but didn't know the update check file
'however, now we have enough information to search by name and type
iCounter = 0
Do While iCounter <= ModCount
If UpdateRecords(iRecord).ModName = Mods(iCounter).ModName Then
If UpdateRecords(iRecord).ModType = Mods(iCounter).ModType Then Exit Do
End If
iCounter = iCounter + 1
Loop
If iCounter <= ModCount Then
'we found a match!
UpdateRecords(iRecord).CheckModNum = iCounter
UpdateRecords(iRecord).ModUserVersion = Mods(iCounter).ModVersion
'but we could have a problem here. what if the mod specified a UPD and the central UPD was different?
'this would mean that we have a second redundant mod entry in the catalogue
iCounter = 1
Do While iCounter <= UpdateRecordCount
If iRecord <> iCounter Then
If UpdateRecords(iCounter).CheckModNum = UpdateRecords(iRecord).CheckModNum Then
If CompareVersions(UpdateRecords(iCounter).ModLatestVersion, ">", UpdateRecords(iRecord).ModLatestVersion) Then
'this other entry offers a more recent version so we'll use that
Call InitialiseRecord(iRecord)
iRecord = -1
Exit Do
Else
'this other entry isn't so great
Call InitialiseRecord(iCounter)
Exit Do
End If
End If
End If
iCounter = iCounter + 1
Loop
End If
End If
End If
If iRecord <> -1 Then
UpdateRecords(iRecord).CheckChangeLog = ReadINIStrMemory(sBuffer, "General", "ChangeLogURL")
UpdateRecords(iRecord).CheckUpdateOnly = False
UpdateRecords(iRecord).CheckDownloadURL = ""
UpdateRecords(iRecord).CheckDownloadSize = 0
If CompareVersions(UpdateRecords(iRecord).ModLatestVersion, ">", UpdateRecords(iRecord).ModUserVersion) Then
If Not OptFullDownloads Then
If Len(UpdateRecords(iRecord).ModUserVersion) <> 0 Then
iUpdate = 0
sValue = ReadINIStrMemory(sBuffer, "General", "Update" & CStr(iUpdate))
Do While Len(sValue) <> 0
If CompareVersions(sValue, "=", UpdateRecords(iRecord).ModUserVersion) Then
UpdateRecords(iRecord).CheckUpdateOnly = True
Exit Do
End If
iUpdate = iUpdate + 1
sValue = ReadINIStrMemory(sBuffer, "General", "Update" & CStr(iUpdate))
Loop
End If
End If
iCounter = -1
If UpdateRecords(iRecord).CheckUpdateOnly Then
iMirror = 0
sValue = ReadINIStrMemory(sBuffer, "Downloads", "Update" & CStr(iUpdate) & "Mirror" & CStr(iMirror))
Do While Len(sValue) <> 0
iCounter = iCounter + 1
ReDim sArray(iCounter)
sArray(iCounter) = sValue
iMirror = iMirror + 1
sValue = ReadINIStrMemory(sBuffer, "Downloads", "Update" & CStr(iUpdate) & "Mirror" & CStr(iMirror))
Loop
Do While iCounter <> -1
iMirror = Random(0, iCounter)
UpdateRecords(iRecord).CheckDownloadSize = theInternet.GetRemoteFileSize(sArray(iMirror))
If UpdateRecords(iRecord).CheckDownloadSize <> 0 Then
'found a download!
UpdateRecords(iRecord).CheckDownloadURL = sArray(iMirror)
Exit Do
Else
'failed to get remote file size so won't be able to get the file either
Do While iMirror < iCounter
sArray(iMirror) = sArray(iMirror + 1)
iMirror = iMirror + 1
Loop
iCounter = iCounter - 1
End If
Loop
End If
If iCounter = -1 Then
'for whatever reason, an update-only installer will not be downloaded
UpdateRecords(iRecord).CheckUpdateOnly = False
iMirror = 0
sValue = ReadINIStrMemory(sBuffer, "Downloads", "FullMirror" & CStr(iMirror))
Do While Len(sValue) <> 0
iCounter = iCounter + 1
ReDim sArray(iCounter)
sArray(iCounter) = sValue
iMirror = iMirror + 1
sValue = ReadINIStrMemory(sBuffer, "Downloads", "FullMirror" & CStr(iMirror))
Loop
Do While iCounter <> -1
iMirror = Random(0, iCounter)
UpdateRecords(iRecord).CheckDownloadSize = theInternet.GetRemoteFileSize(sArray(iMirror))
If UpdateRecords(iRecord).CheckDownloadSize <> 0 Then
'found a download!
UpdateRecords(iRecord).CheckDownloadURL = sArray(iMirror)
Exit Do
Else
'failed to get remote file size so won't be able to get the file either
Do While iMirror < iCounter
sArray(iMirror) = sArray(iMirror + 1)
iMirror = iMirror + 1
Loop
iCounter = iCounter - 1
End If
Loop
End If
'If Counter = -1 then for some reason or another, a download is not available
'Else no point checking for downloads
End If
Else
Call frmMain.WriteLogEntry("Installed mod's update check file offers a more recent version.", LogLevel1)
End If
Else
If Not theInternet.DownloadCancelled Then
Call frmMain.WriteLogEntry("Failed to download update check file " & Quote(UpdateRecords(iRecord).CheckURL), LogLevel1)
UpdateRecords(iRecord).FailReason = "Failed to download update check file."
iFails = iFails + 1
End If
End If
Else
UpdateRecords(iRecord).FailReason = "No update check URL specified."
iFails = iFails + 1
End If
End If
Call CallStackPop
UpdateUpdateRecord = iFails
End Function
Public Sub InitialiseRecord(ByVal iRecord As Integer, Optional ByVal bGetFromMod As Boolean = False)
Dim iMod As Integer
UpdateRecords(iRecord).ModLatestVersion = ""
UpdateRecords(iRecord).ModDate = ""
UpdateRecords(iRecord).ModAuthor = ""
UpdateRecords(iRecord).ModDescription = ""
UpdateRecords(iRecord).ModCampaigns = ""
UpdateRecords(iRecord).ModTXVersion = ""
UpdateRecords(iRecord).ModFA2Version = ""
UpdateRecords(iRecord).ModPluginID = ""
UpdateRecords(iRecord).CheckChangeLog = ""
UpdateRecords(iRecord).CheckUpdateOnly = False
UpdateRecords(iRecord).CheckDownloadURL = ""
UpdateRecords(iRecord).CheckDownloadSize = -1
UpdateRecords(iRecord).FailReason = ""
If bGetFromMod And Len(UpdateRecords(iRecord).ModPluginID) = 0 Then
iMod = UpdateRecords(iRecord).CheckModNum
UpdateRecords(iRecord).ModName = Mods(iMod).ModName
UpdateRecords(iRecord).ModType = Mods(iMod).ModType
UpdateRecords(iRecord).ModGameIsRA2 = Mods(iMod).ModIsForRA2
UpdateRecords(iRecord).ModWebsite = Mods(iMod).ModWebsite
UpdateRecords(iRecord).ModUserVersion = Mods(iMod).ModVersion
UpdateRecords(iRecord).CheckURL = Mods(iMod).ModUpdateCheckURL
Else
UpdateRecords(iRecord).ModName = ""
UpdateRecords(iRecord).ModType = -1
UpdateRecords(iRecord).ModGameIsRA2 = False
UpdateRecords(iRecord).ModWebsite = ""
UpdateRecords(iRecord).CheckModNum = -1
UpdateRecords(iRecord).ModUserVersion = ""
UpdateRecords(iRecord).CheckURL = ""
End If
End Sub
Private Sub EnableControls(ByVal Enable As Boolean)
frameAvailableMods.Enabled = Enable
listModCat.Enabled = Enable
If Enable Then
listModCat.BackColor = &H80000005
Else
listModCat.BackColor = &H8000000F
End If
frameFilter.Enabled = Enable
lblFilterModType.Enabled = Enable
cboxFilterModType(0).Enabled = Enable
cboxFilterModType(1).Enabled = Enable
cboxFilterModType(2).Enabled = Enable
cboxFilterModType(3).Enabled = Enable
lblFilterGame.Enabled = Enable
cboxFilterGame(0).Enabled = Enable
cboxFilterGame(1).Enabled = Enable
lblFilterUpdates.Enabled = Enable
cboxFilterUpdates(0).Enabled = Enable
cboxFilterUpdates(1).Enabled = Enable
cboxFilterUpdates(2).Enabled = Enable
frameModDetails.Enabled = Enable
lblGame.Enabled = Enable
lblModGame.Enabled = Enable
lblVersion.Enabled = Enable
lblModVersion.Enabled = Enable
lblYourVersion.Enabled = Enable
lblModYourVersion.Enabled = Enable
lblDate.Enabled = Enable
lblModDate.Enabled = Enable
lblAuthor.Enabled = Enable
lblModAuthor.Enabled = Enable
lblWebsite.Enabled = Enable
lblModWebsite.Enabled = Enable
lblSize.Enabled = Enable
lblModSize.Enabled = Enable
lblCampaigns.Enabled = Enable
lblModCampaigns.Enabled = Enable
lblTX.Enabled = Enable
lblModTX.Enabled = Enable
lblModDescription.Enabled = Enable
cmdDownload.Enabled = Enable
cmdChangeLog.Enabled = Enable
End Sub
Private Sub FilterModCat()
Dim iRecord As Integer
Dim iIncluded As Integer
listModCat.Sorted = False
iIncluded = 0
Call listModCat.ListItems.Clear
listModCat.Sorted = False
iRecord = 1
Do While iRecord <= UpdateRecordCount
Do
'Name
If Len(UpdateRecords(iRecord).ModName) = 0 Then Exit Do
'Version
If Len(UpdateRecords(iRecord).ModLatestVersion) = 0 Then Exit Do
'Updates
If UpdateRecords(iRecord).CheckModNum = -1 Then
If cboxFilterUpdates(1).Value <> 1 Then Exit Do
Else
If CompareVersions(UpdateRecords(iRecord).ModLatestVersion, "<=", UpdateRecords(iRecord).ModUserVersion) Then
If cboxFilterUpdates(2).Value <> 1 Then Exit Do
Else
If cboxFilterUpdates(0).Value <> 1 Then Exit Do
End If
End If
'Mod Type
If UpdateRecords(iRecord).ModType = -1 Then Exit Do
If cboxFilterModType(UpdateRecords(iRecord).ModType).Value <> 1 Then Exit Do
'Game
Select Case UpdateRecords(iRecord).ModType
Case TypeMod, TypePlugin
If UpdateRecords(iRecord).ModGameIsRA2 Then
If cboxFilterGame(0).Value <> 1 Then Exit Do
Else
If cboxFilterGame(1).Value <> 1 Then Exit Do
End If
End Select
'If we're still here then can include this one
If UpdateRecords(iRecord).CheckURL = Mods(LBModNum).ModUpdateCheckURL Then
'Launch Base - needs emphasising
Call listModCat.ListItems.Add(, , " " & UpdateRecords(iRecord).ModName)
listModCat.ListItems(listModCat.ListItems.Count).Bold = True
Else
Call listModCat.ListItems.Add(, , UpdateRecords(iRecord).ModName)
End If
Select Case UpdateRecords(iRecord).ModType
Case TypeMod: listModCat.ListItems(listModCat.ListItems.Count).SubItems(1) = "Mod"
Case TypeFA2Mod: listModCat.ListItems(listModCat.ListItems.Count).SubItems(1) = "FA2 Mod"
Case TypeProgram: listModCat.ListItems(listModCat.ListItems.Count).SubItems(1) = "Tool"
Case TypePlugin: listModCat.ListItems(listModCat.ListItems.Count).SubItems(1) = "Plugin"
End Select
listModCat.ListItems(listModCat.ListItems.Count).Tag = CStr(iRecord)
iIncluded = iIncluded + 1
Exit Do
Loop
iRecord = iRecord + 1
Loop
listModCat.Sorted = True
If iIncluded <> 0 Then
listModCat.SelectedItem = listModCat.ListItems.Item(1)
Call listModCat_ItemClick(listModCat.SelectedItem)
Else
Call listModCat_ItemClick(Nothing)
End If
End Sub
Private Sub cboxFilterGame_Click(Index As Integer)
Call FilterModCat
End Sub
Private Sub cboxFilterModType_Click(Index As Integer)
Call FilterModCat
End Sub
Private Sub cboxFilterUpdates_Click(Index As Integer)
Call FilterModCat
End Sub