-
Notifications
You must be signed in to change notification settings - Fork 0
/
v7_launcher.hta
775 lines (721 loc) · 24.4 KB
/
v7_launcher.hta
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
<html>
<head>
<title>v7 ArmA Launcher 3.3</title>
<!-- !!! ID is used in code !!! -->
<HTA:APPLICATION
ID="v7_ArmA_LauncherID"
applicationName="ArmA Launcher"
scroll="no"
border="thin"
maximizeButton="yes"
minimizeButton="yes"
singleInstance="yes"
icon="v7.ico"
>
</head>
<SCRIPT Language="VBScript">
Option Explicit
' ãëîáàëüíûå ïåðåìåííûå
Dim DBFILE ' ôàéë ñ îïèñàíèÿìè ìîäîâ
Dim optionsFile ' ôàéë ñ íàñòðîéêàìè
Dim Mods, EMods, Deps, Opts, Desc, Visible, Checked ' ÁÄ ìîäîâ
Dim WshShell, fso, f ' äåñêðèïòîð ôàéëà
Dim strEXE, strMods ' ñòðîêè çàïóñêà ãàìû
Dim regEx ' ðåãóëÿðêà, êîòîðîé áóäåì ïðîâåðÿòü ÷å-íèáóäü
Dim isStarting ' ïîêà èäåò ñòàðò èãðû, = true
Dim oldModSum ' ÷èñëî â ñòðîêå ââîäà
Dim idTimer ' id ñîçäàâàåìûõ òàéìåðîâ, ÷òîáû áûëî ÷òî îáíóëèòü
Dim subFolderMode ' ðåæèì ðàáîòû â ïîäïàïêå
Dim modPrefix ' ïðåôèêñ ìîäîâ äëÿ ðåæèìà ðàáîòû â ïîäïàïêå
Dim Options ' îïöèè â íèæíåé ÷àñòè îêíà
Dim isServer ' = true åñëè ñåðâåð
Dim HTTP_code, HTTP_last ' îáúåêò îòêðûòèÿ ñòðàíèö â èíåòå, äëÿ çàïðîñà/îòïðàâêè êîäà è ïðîâåðêè íàäî ëè îáíîâëÿòüñÿ
Const URL_code_get = ""
Const URL_code_set = ""
Const URL_last_get = ""
Const AdminComputerName = "ADMIN"
Dim extArgs ' àðãóìåíòû, ïåðåäàííûå ëàí÷åðó, ïåðåäàäèì â èãðó
Dim is64 ' true åñëè âèíäà 64-áèòíàÿ
Sub Window_onLoad
' start from TotalCmd with right mouse double click causes error on "window.resizeTo" if timeout ~< 60
idTimer = window.setTimeout("Main", 60, "VBScript")
End Sub
Sub Main
window.clearTimeout(idTimer)
Dim width, height
Dim s, a, i ' âðåìåííûå ïåðåìåííûå
Dim args ' àðãóìåíòû ñêðèïòà
width = 800
height = 600
window.resizeTo width, height
window.moveTo (screen.width - width) / 2, (screen.height - height) / 2
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set regEx = New RegExp
Set HTTP_code = CreateObject("MSXML2.XMLHTTP.3.0")
Set HTTP_last = CreateObject("MSXML2.XMLHTTP.3.0")
isStarting = False
oldModSum = ""
is64 = "AMD64" = WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITEW6432%")
DBFILE = "descript.ion"
GoToScriptDirectory
If "v7" <> fso.GetFileName(WshShell.CurrentDirectory) Then
subFolderMode = False
modPrefix = ""
Else
subFolderMode = True
modPrefix = "v7\"
DBFILE = modPrefix & DBFILE
WshShell.CurrentDirectory = WshShell.CurrentDirectory & "\.."
End If
password_desc.style.visibility = "hidden"
password.style.visibility = "hidden"
If fso.FileExists("arma3.exe") Then
isServer = False
headless_label.InnerHTML = ""
password_desc.InnerHTML = ""
password.size = 1
ElseIf fso.FileExists("arma3server.exe") Then
isServer = True
Else
isServer = ""
End If
optionsFile = WshShell.ExpandEnvironmentStrings("%APPDATA%") & "\v7ArmALauncher.ini"
' êëþ÷îì äëÿ âñåõ ýòèõ ÁÄ ÿâëÿåòñÿ èìÿ ìîäà
Set Mods = CreateObject("Scripting.Dictionary") ' èìÿ ìîäà (êàòàëîã, åñëè â êîðíå èãðû, è ïîëíûé/îòíîñèòåëüíûé ïóòü, â èíîì ñëó÷àå)
Set EMods = CreateObject("Scripting.Dictionary") ' òîæå, íî ñ îïöèåé if_exist
Set Deps = CreateObject("Scripting.Dictionary") ' ñïèñîê òðåáóåìûõ ìîäîâ
Set Opts = CreateObject("Scripting.Dictionary")' ñïèñîê îïöèé
Set Desc = CreateObject("Scripting.Dictionary") ' îïèñàíèå
Set Visible = CreateObject("Scripting.Dictionary") ' âèäèìûå â ãëàâíîì îêíå. Íåâèäèìûõ â ýòîé áàçå íåò
' Çíà÷åíèå: 2^n, ãäå n - ïîðÿäêîâûé íîìåð ýòîãî âèäèìîãî ìîäà ñ 0
Set Checked = CreateObject("Scripting.Dictionary") ' îòìå÷åííûå ãàëêîé âûáîðà
If Not fso.FileExists(DBFILE) Then
msgbox DBFILE & " not found"
Else
' èìÿ(ïóòü) (åñëè ñîäåðæèò ïðîáåëû - â êàâû÷êàõ), òðåáóåìûå ìîäû, îïöèè ìîäà, îïèñàíèå
regEx.Pattern = "(""[^""]+""|[^ ]+) (?:\{([^\}]*)\})? *(?:\[([^\]]*)\])? *(.*)?"
Set f = fso.OpenTextFile(DBFILE)
Do Until f.AtEndOfStream
s = LTrim(f.ReadLine)
If s <> "" And "#" <> Left(s, 1) Then
Set a = regEx.Execute(s)
If 0 < a.Count Then
' äîáàâëÿåì áåç êàâû÷åê
i = Replace(a(0).SubMatches(0), """", "")
Deps.Add i, a(0).SubMatches(1)
Opts.Add i, a(0).SubMatches(2)
Desc.Add i, a(0).SubMatches(3)
If ModHasOption(i, "if_exist") Then
EMods.Add i, modPrefix & i
Else
Mods.Add i, modPrefix & i
End If
Else
msgbox """" & s & """ no regex"
End If
End If
Loop
f.Close
' äîáàâëÿåì EMods â êîíåö Mods
For Each i In EMods.Keys
Mods.Add i, EMods(i)
Next
End If
If subFolderMode And fso.FileExists(modPrefix & "found_addons.txt") Then
Set f = fso.OpenTextFile(modPrefix & "found_addons.txt")
Do Until f.AtEndOfStream
s = f.ReadLine
a = f.ReadLine
For Each i In Array("", "!Workshop\")
If fso.FolderExists(i & a) Then
If Mods.Exists(s) Then
Mods(s) = i & a
Else
Mods.Add s, i & a
Opts.Add s, "dont_show"
End If
Exit For
End If
Next
Loop
f.Close
End If
' óäàëÿåì íåñóùåñòâóþùèå EMods èç Mods
For Each i In EMods.Keys
If Not ModExists(i) Then Mods.Remove i
Next
Dim Colors(2), currentColor ' öâåòà ÷åðåäóþùèõñÿ ñòðîê òàáëèöû
' infobackground silver lightskyblue bisque cornsilk lightcyan
Colors(0) = "lightcyan"
Colors(1) = "cornsilk"
currentColor = 0
Dim HTMLTable ' èñõ. òåêñò òàáëèöû ìîäîâ
HTMLTable = "<table align='center' border=0 cellspacing=5 cellpadding=0 style='padding-left:5;padding-right:5'>"
a = 1 ' çíà÷åíèå "Num" êàæäîãî âèäèìîãî ìîäà
For Each i In Mods.Keys
If Not ModHasOption(i, "with:") And Not ModHasOption(i, "dont_show") Then
Visible.Add i, a
a = a * 2
If EMods.Exists(i) Then
s = "* " ' ïîìåòèì çâåçäîé ìîäû ñ îïöèåé if_exist
Else
s = ""
End If
' â òàáëèöå ÷åêáîêñû èìåþò id = èìåíè ìîäà, íàïðèìåð:
'<label for='_new'><tr bgcolor='cyan'><td><input id='_new' type='checkbox' onclick='ModOnClick'>new</td><td>Descr</td></tr></label>
HTMLTable = HTMLTable & _
"<label for='" & i & "'><tr bgcolor='"& Colors(currentColor) & "'>" & _
"<td><input id='" & i & "' type='checkbox' onclick='ModOnClick'>" & s & i & "</td>" & _
"<td>" & Desc(i) & "</td>" & _
"<td>" & Visible(i) & "</td>" & _
"</tr></label>"
currentColor = 1 - currentColor
End If
Next
HTMLTable = HTMLTable & "</table>"
ModsTable.InnerHTML = HTMLTable
' ïðîéäåìñÿ ïî ìîäàì â òàáëèöå â ïîèñêàõ äåôîëòíî-îòìå÷àåìûõ
For Each i In Visible.Keys
If Not ModHasOption(i, "not_default") And Not ModHasOption(i, "if_exist") Then
ModCheck(i)
End If
Next
If AdminComputerName = WshShell.ExpandEnvironmentStrings("%ComputerName%") Then
filePatching_label.style.visibility = "visible"
End If
Set Options = CreateObject("Scripting.Dictionary")
' çíà÷åíèå: ðåãóëÿðêà, äåôîëòíîå çíà÷åíèå, ÿâëÿåòñÿ ëè àðãóìåíòîì äëÿ arma
Options.Add "startBefore", Array(".*", "", false)
'Options.Add "cpuCount", Array("[0-8]", "0", true)
'Options.Add "exThreads", Array("0|1|3|5|7", "0", true)
'Options.Add "maxMem", Array("0|768|1024|2047|4096|8192|16384|32768", "0", true)
Options.Add "Priority", Array("0|-?[12]", "0", false)
Options.Add "showScriptErrors", Array("[01]", "0", true)
Options.Add "nologs", Array("[01]", "1", true)
If is64 Then
s = "1"
Else
s = "0"
End If
Options.Add "x64", Array("[01]", s, false)
Options.Add "filePatching", Array("[01]", "0", true)
For Each s In Options.Keys
Call SetHTMLValue(s, Options(s)(1))
Next
LoadOptions
If "String" <> TypeName(isServer) And "" <> URL_code_get Then
If Not isServer Then
HTTP_code.open "GET", URL_code_get & fso.GetTempName
HTTP_code.onreadystatechange = GetRef("onreadyHTTP_code")
code_status.InnerHTML = "--"
code_status.title = "Code checking..."
HTTP_code.send
End If
End If
extArgs = Mid(v7_ArmA_LauncherID.commandLine, 1 + InStr(2, v7_ArmA_LauncherID.commandLine, """", vbBinaryCompare))
regEx.Pattern = "^\s+start"
If regEx.Test(extArgs) Then
extArgs = regEx.Replace(extArgs, "")
Launch
End If
If "" <> URL_last_get Then
HTTP_last.open "GET", URL_last_get & fso.GetTempName
HTTP_last.onreadystatechange = GetRef("onreadyHTTP_last")
idUpdate.value = "Checking..."
HTTP_last.send
End If
End Sub
Sub onreadyHTTP_last
' âûçûâàåòñÿ, êîãäà ãîòîâ ðåçóëüòàò http-çàïðîñà øòàìïà
If 4 <> HTTP_last.readyState Then Exit Sub
If 200 <> HTTP_last.status Then
idUpdate.value = "ERROR :("
idUpdate.title = "HTTP_last.status=" & HTTP_last.status
Exit Sub
End If
If fso.FileExists(modPrefix & "last") Then
If HTTP_last.responseText = fso.OpenTextFile(modPrefix & "last").ReadAll Then
idUpdate.value = "No updates :)"
idUpdate.title = "HTTP_last.responseText=" & Left(HTTP_last.responseText, 30)
Exit Sub
End If
End If
UpdateBlink ' èç-çà êîñÿêà (ñì. íèæå) çäåñü ïðÿìîé âûçîâ âìåñòî setTimeout
End Sub
Sub UpdateBlink
' ìîðãàåò êíîïêîé Update
' çäåñü êàêîé-òî êîñÿê, â îòëè÷èå îò äîêóìåíòàöèè ñîáûòèå ïî setTimeout íå ïîâòîðÿåòñÿ áåñêîíå÷íî
Const str = "--> Update <--"
Dim time
If str <> idUpdate.value Then
idUpdate.value = str
time = 600
Else
idUpdate.value = " "
time = 300
End If
window.setTimeout "UpdateBlink", time, "VBScript"
End Sub
Function ModExists(m)
' ïðîâåðÿåò ñóùåñòâîâàíèå ìîäà ñ îïöèåé if_exist èëè åãî çàâèñèìîñòè (ðåêóðñèâíî)
Dim ret, dep
If Not Mods.Exists(m) Then
ret = fso.FolderExists(modPrefix & m)
Else
If Not ModHasOption(m, "only_required") Then
ret = fso.FolderExists(Mods(m))
Else
ret = True
For Each dep In Split(Deps(m), ";")
If Not ModExists(dep) Then
ret = False
Exit For
End If
Next
End If
End If
ModExists = ret
End Function
Function ModHasOption(m, opt)
' âîçâðàùàåò, åñòü ëè ó äàííîãî ìîäà äàííàÿ îïöèÿ
Dim ret
' dont_show only_required not_default with:aaa,ddd,fff if_exist
If InStr(1, Opts(m), opt, vbTextCompare) Then
ret = True
Else
ret = False
End If
ModHasOption = ret
End Function
Function IsModInList(list, strMod)
' âîçâðàùàåò, íàõîäèòñÿ ëè â äàííîì ñïèñêå ìîäîâ äàííûé ìîä
Dim ret, s
ret = False
For Each s In Split(list, ";")
If s = strMod Then
ret = True
Exit For
End If
Next
IsModInList = ret
End Function
Sub ModOnClick
' çàïóñêàåòñÿ ïðè íàæàòèè íà ãàëêó ëþáîãî ìîäà
If window.event.srcelement.checked Then
ModCheck(window.event.srcelement.id)
Else
ModUnCheck(window.event.srcelement.id)
End If
End Sub
Sub ModCheck(m)
' îòìå÷àåò òåêóùèé ìîä, êàê âûáðàííûé, à òàêæå âñå åìó òðåáóåìûå
Dim i
If Not Checked.Exists(m) Then Checked.Add m, Null
document.getElementById(m).checked = True
' ìåíÿòü çíà÷åíèå ñóììû áóäåì òîëüêî, åñëè òåêóùèé ìîä â íåå íå âêëþ÷åí
'èñïîëüçóåì ïîáèòîâîå È
If (CLng(Visible(m)) And CLng(ModSum.value)) = 0 Then ModSum.value = CLng(ModSum.value) + CLng(Visible(m))
' âêëþ÷èì âñå òðåáóåìûå ìîäû
For Each i In Visible.Keys
If IsModInList(Deps(m), i) And Not Checked.Exists(i) Then ModCheck(i)
Next
End Sub
Sub ModUnCheck(m)
' ñíèìàåò ñ òåêóùåãî ìîäà îòìåòêó âûáðàííîñòè. È çàîäíî ñî âñåõ ìîäîâ, êîòîðûå òðåáóþò åãî
Dim i
If Checked.Exists(m) Then Checked.Remove m
document.getElementById(m).checked = False
' ìåíÿòü çíà÷åíèå ñóììû áóäåì òîëüêî, åñëè òåêóùèé ìîä â íåå âêëþ÷åí
'èñïîëüçóåì ïîáèòîâîå È
If (CLng(Visible(m)) And CLng(ModSum.value)) > 0 Then ModSum.value = CLng(ModSum.value) - CLng(Visible(m))
' âûêëþ÷èì âñå çàâèñèìûå ìîäû
For Each i In Visible.Keys
If IsModInList(Deps(i), m) And Checked.Exists(i) Then ModUnCheck(i)
Next
End Sub
Sub ModSum_KeyDown
' çàïóñêàåòñÿ ïðè íàæàòèè ëþáîé êëàâèøè â ïîëå ââîäà ñóììû-êîäà ìîäîâ
If 13 = window.event.Keycode Then Exit Sub
If "" = oldModSum Then
' çàïîìíèì ñòàðîå çíà÷åíèå
oldModSum = ModSum.value
idStartButton.Disabled = True
Else
window.clearTimeout(idTimer)
End If
idTimer = window.setTimeout("ModSum_Change", 1000, "VBScript")
End Sub
Sub ModSum_Change
' çàïóñêàåòñÿ èç ôóíêöèè ModSum_KeyDown ñ çàäåðæêîé, ÷òîáû KeyDown èçìåíèëî ïîëå ModSum
Dim i
window.clearTimeout(idTimer)
ModSum.ReadOnly = True
regEx.Pattern = "^[\d]+$"
' åñëè íîâîå çíà÷åíèå íå öèôðû, ïðîñòî âåðíåì ñòàðîå
If Not regEx.Test(ModSum.value) Then
ModSum.value = oldModSum
ElseIf CLng(oldModSum) <> CLng(ModSum.value) Then
'ïðîõîäèìñÿ ïî ìîäàì â òàáëèöå, åñëè íàäî îòìåòèòü - îòì., íàäî ñíÿòü - ñíÿòü
For Each i In Visible.Keys
'èñïîëüçóåì ïîáèòîâîå È
If (CLng(Visible(i)) And CLng(ModSum.value)) > 0 Then
If Not Checked.Exists(i) Then ModCheck(i)
Else
If Checked.Exists(i) Then ModUnCheck(i)
End If
Next
End If
oldModSum = ""
ModSum.ReadOnly = False
idStartButton.Disabled = False
End Sub
Sub AddModToString(path)
' ïðîâåðÿåò, ñóùåñòâóåò ëè êàòàëîã ìîäà, è äîáàâëÿåò åãî ê ñòðîêå ìîäîâ
If IsModInList(strMods, path) Then Exit Sub
If Not fso.FolderExists(path) Then msgbox path & " added, but folder not found"
strMods = strMods & ";" & path
End Sub
Sub AddModAndDepsToString(m)
' äîáàâëÿåò â ñòðîêó strMods äàííûé ìîä è, åñëè åñòü, åãî çàâèñèìîñòè (ðåêóðñèâíî)
Dim dep
If Not Mods.Exists(m) Then
' åñëè ìîäà â áàçå íåò, ïðîñòî äîáàâèì åãî
AddModToString(modPrefix & m)
Exit Sub
End If
' åñëè ìîä â áàçå, âûçîâåì ðåêóðñèþ äëÿ âñåõ çàâèñèìîñòåé è äîáàâèì åãî ñàìîãî
For Each dep In Split(Deps(m), ";")
AddModAndDepsToString(dep)
Next
If Not ModHasOption(m, "only_required") Then AddModToString(Mods(m))
End Sub
Sub AddModsWith_with
' äîáàâëÿåò, åñëè íàäî, â ñòðîêó ìîäîâ ìîäû ñ îïöèåé with
Dim m, modAdded, withList, withMod
modAdded = True ' ïåðåìåííàÿ ïîêàçûâàåò, ïðîèçîøëî ëè äîáàâëåíèå òåêóùåãî ìîäà ê ñïèñêó
Do While modAdded ' è ïîêà ìîäû áóäóò äîáàâëÿòüñÿ, ìû áóäåì ïðîõîäèòü ïî âñåì ìîäàì ñ with çàíîâî
modAdded = False
For Each m In Mods.Keys
If ModHasOption(m, "with:") And Not IsModInList(strMods, Mods(m)) Then
' óáåðåì âïåðåäè ñòîÿùóþ "with:"
withList = Split(Opts(m), ":")(1)
modAdded = True
For Each withMod In Split(withList, ",")
' åñëè ìîä â áàçå, ïðîâåðÿåì ðåàëüíîå èìÿ, èíà÷å òåêóùåå
If Mods.Exists(withMod) Then
If Not IsModInList(strMods, Mods(withMod)) Then
modAdded = False
Exit For
End If
Else
If Not IsModInList(strMods, modPrefix & withMod) Then
modAdded = False
Exit For
End If
End If
Next
If modAdded Then AddModAndDepsToString(m)
End If
Next
Loop
End Sub
Sub myQuit
window.close() : WScript.Quit
End Sub
Sub Launch
' çàïóñêàåòñÿ ïðè íàæàòèè íà êíîïêó çàïóñêà èãðû
If isStarting Then
msgbox "Already starting"
Exit Sub
End If
isStarting = True
idStartButton.Disabled = True
ModSum.ReadOnly = True
Dim s, i, StartPriorities
' ïàðàìåòðû äëÿ êîìàíäû start
StartPriorities = Array("low", "belownormal", "normal", "abovenormal", "high")
If "String" = TypeName(isServer) Then
msgbox "exe not found"
myQuit
End If
' check if arma path is correct
If Not isServer Then
s = ""
On Error Resume Next
s = WshShell.RegRead("HKLM\SOFTWARE\bohemia interactive\arma 3\main")
On Error Goto 0
If s = "" Then
msgbox "reg key not found"
Else
If LCase(s) <> LCase(WshShell.CurrentDirectory) Then
msgbox "Wrong path!" & _
vbNewLine & "Registry path: " & s & _
vbNewLine & "Current path: " & WshShell.CurrentDirectory & _
vbNewLine & vbNewLine & vbNewLine & "Press Ctrl+C to copy this message"
End If
End If
End If
If 0 = GetHTMLValue("x64") Then
strEXE = ""
Else
strEXE = "_x64"
End If
If Not isServer Then
strEXE = "arma3" & strEXE & ".exe"
Else
If headless.checked Then
strEXE = "arma3server" & strEXE & ".exe ""-profiles=hcprofiles"" -client -connect=127.0.0.1 -password=" & password.value
Else
strEXE = "arma3server" & strEXE & ".exe ""-profiles=profiles"" -config=server.cfg -loadMissionToMemory"
If fso.FolderExists("servermod\addons") Then
strEXE = strEXE & " -servermod=servermod"
End If
If "" <> URL_code_set Then
HTTP_code.open "GET", URL_code_set & ModSum.value & "&rand=" & fso.GetTempName
HTTP_code.onreadystatechange = GetRef("onreadyHTTP_code")
code_status.InnerHTML = "--"
code_status.title = "Code " & ModSum.value & " uploading..."
HTTP_code.send
End If
End If
End If
strEXE = strEXE & " -nosplash -world=empty -skipIntro -noPause"
strEXE = "cmd /c start """" /" & StartPriorities(2+CInt(GetHTMLValue("Priority"))) & " " & strEXE
strMods = ""
' ñíà÷àëà ïðîéäåìñÿ ïî âñåì îòìå÷åííûì ìîäàì
For Each i In Mods.Keys
If Checked.Exists(i) Then AddModAndDepsToString(i)
If (i = "@pooter_enhanced_asr_ai" Or i = "@Vcom_AI") And Checked.Exists(i) Then strEXE = strEXE & " -filePatching"
Next
' ïîòîì ïî ìîäàì ñ îïöèåé with:
AddModsWith_with
If fso.FolderExists("R:\@_RAM") Then strMods = strMods & ";" & "R:\@_RAM"
strEXE = strEXE & GetOptionsString
' ìîäû â êàâû÷êè íà ñëó÷àé ïðîáåëîâ
If ";" = Left(strMods, 1) Then strMods = " ""-mod=" & Mid(strMods, 2) & """"
s = GetHTMLValue("startBefore")
If s <> "" Then
If LCase("msg ") = LCase(Left(s,4)) Then
MsgBox Mid(s,5)
Else
WshShell.Run s, , True
End If
End IF
'msgbox strEXE & strMods & extArgs
WshShell.Run strEXE & strMods & extArgs, , True
idTimer = window.setTimeout("Launch_finished", 10000, "VBScript")
'Launch_finished
'myQuit
End Sub
Sub Launch_finished
' çàïóñêàåòñÿ èç ôóíêöèè Launch
window.clearTimeout(idTimer)
ModSum.ReadOnly = False
idStartButton.Disabled = False
isStarting = False
End Sub
Sub onreadyHTTP_code
' âûçûâàåòñÿ, êîãäà ãîòîâ ðåçóëüòàò http-çàïðîñà øòàìïà
If 4 <> HTTP_code.readyState Then Exit Sub
If 200 <> HTTP_code.status Then
code_status.InnerHTML = "ER"
code_status.title = "HTTP_code.status=" & HTTP_code.status
Exit Sub
End If
If isServer Then
If HTTP_code.responseText <> ModSum.value Then
code_status.InnerHTML = "ER"
code_status.title = "HTTP_code.responseText=" & Left(HTTP_code.responseText, 30)
Exit Sub
End If
code_status.title = "Code " & ModSum.value & " uploaded"
Else
If "" = oldModSum Then
oldModSum = ModSum.value
idStartButton.Disabled = True
End If
ModSum.value = Left(HTTP_code.responseText, 9)
code_status.title = "server code = " & ModSum.value
ModSum_Change
End If
code_status.InnerHTML = "OK"
End Sub
Sub OnKeyDown
' çàïóñêàåòñÿ ïðè íàæàòèè ëþáîé êëàâèøè â îêíå
If window.event.Keycode = 27 Then myQuit
If window.event.Keycode = 13 And Not idStartButton.Disabled And "idStartButton" <> window.event.srcElement.id Then Launch
End Sub
Function GetHTMLValue(id)
' âîçâðàùàåò çíà÷åíèå äàííîãî ýëåìåíòà (â ò.÷. checkbox)
Dim ret
If "checkbox" <> document.getElementById(id).type Then
ret = document.getElementById(id).value
Else
If document.getElementById(id).checked Then
ret = "1"
Else
ret = "0"
End If
End If
GetHTMLValue = ret
End Function
Sub SetHTMLValue(id, val)
' óñòàíàâëèâàåò äëÿ äàííîãî ýëåìåíòà äàííîå çíà÷åíèå (â ò.÷. checkbox)
If "checkbox" <> document.getElementById(id).type Then
document.getElementById(id).value = val
Else
If "1" = val Then
document.getElementById(id).checked = True
Else
document.getElementById(id).checked = False
End If
End If
End Sub
Function GetOptionsString
' âîçâðàùàåò ñòðîêó ñ ïàðàìåòðàìè, ñîîòâåòñòâóþùèìè òåêóùèì îïöèÿì çàïóñêà
Dim ret, opt
ret = ""
For Each opt In Options.Keys
If Options(opt)(2) Then
If "checkbox" = document.getElementById(opt).type Then
If "1" = GetHTMLValue(opt) Then ret = ret & " -" & opt
Else
If 0 <> GetHTMLValue(opt) Then ret = ret & " -" & opt & "=" & GetHTMLValue(opt)
End If
End If
Next
GetOptionsString = ret
End Function
Sub SaveOnClick
' ïðè íàæàòèè êíîïêè "Ñîõðàíèòü"
Dim opt
Set f = fso.CreateTextFile(optionsFile, True)
f.WriteLine("[User]")
For Each opt In Options.Keys
f.WriteLine(opt & "=" & GetHTMLValue(opt))
Next
f.Close
End Sub
Sub LoadOptions
' çàãðóæàåò îïöèè èç ôàéëà
Dim s, a
If Not fso.FileExists(optionsFile) Then Exit Sub
Set f = fso.OpenTextFile(optionsFile)
Do Until f.AtEndOfStream
s = f.ReadLine
a = Split(s, "=")
If 1 = UBound(a) Then
If Options.Exists(a(0)) Then
regEx.Pattern = Options(a(0))(0)
If regEx.Test(a(1)) Then
Call SetHTMLValue(a(0), a(1))
Else
Call SetHTMLValue(a(0), Options(a(0))(1))
End If
End If
End If
Loop
f.Close
End Sub
Sub LoadOnClick
' ïðè íàæàòèè êíîïêè "Çàãðóçèòü"
If Not fso.FileExists(optionsFile) Then
msgbox "save not found"
Exit Sub
End If
LoadOptions
End Sub
Sub HeadlessOnClick
' ïðè èçìåíåíèè ãàëêè Headless
If headless.checked Then
password_desc.style.visibility = "visible"
password.style.visibility = "visible"
password.focus
Else
password_desc.style.visibility = "hidden"
password.style.visibility = "hidden"
End If
End Sub
Sub UpdateOnClick
' ïðè íàæàòèè êíîïêè "Update"
GoToScriptDirectory
WshShell.CurrentDirectory = WshShell.CurrentDirectory & "\cwRsync\"
WshShell.Run """Download_from_inet.cmd"" launcher", , True
End Sub
Sub GoToScriptDirectory
' ìåíÿåò òåêóùèé êàòàëîã íà êàòàëîã, ãäå ëåæèò ñêðèïò
Dim path
path = document.location.href
path = fso.GetParentFolderName(UnEscape(Replace(Right(path, Len(path) - 8), "/", "\")))
WshShell.CurrentDirectory = path
End Sub
</SCRIPT>
<body bgcolor="buttonface" onKeyDown="OnKeyDown">
<span id="ModsTable" style="overflow: auto; width: 770px; height: 400;"></span>
<br><br>
<div align="center">
<span id="code_status"></span>
<input type="text" value="0" maxlength="8" size="15" id="ModSum" onKeyDown="ModSum_KeyDown">
<input type="button" value="Start game" title="Start game" id="idStartButton" onClick="Launch">
<label for="headless" id="headless_label"><input id="headless" type="checkbox" onClick="HeadlessOnClick">Headless Client</label>
<span id="password_desc" title="Server password">pass:</span><input type="text" value="777" maxlength="200" size="10" id="password" title="Server password">
<input type="button" value="Update" title="Update" id="idUpdate" onClick="UpdateOnClick">
</div>
<fieldset>
<legend>Personal settings</legend>
<div align="center">
Start before
<input type="text" value="" maxlength="2000" size="100" id="startBefore">
<input type="button" value=" X " onClick="startBefore.value=''">
<br />
<label for="x64"><input id="x64" type="checkbox">x64</label>
<!--cpuCount
<select id="cpuCount">
<option value=0>not set
<option value=1>1
<option value=2>2
<option value=3>3
<option value=4>4
<option value=5>5
<option value=6>6
<option value=7>7
<option value=8>8
<option value=9>9
<option value=10>10
<option value=11>11
<option value=12>12
<option value=13>13
<option value=14>14
<option value=15>15
<option value=16>16
</select>
--><!--maxMem
<select id="maxMem">
<option value=0>not set
<option value=768>768
<option value=1024>1024
<option value=2047>2047
<option value=4096>4096
<option value=8192>8192
<option value=16384>16384
<option value=32768>32768
</select>
-->Priority
<select id="Priority">
<option value="-2">low
<option value="-1">below normal
<option value="0">normal
<option value="1" selected="">above normal
<option value="2">high
</select>
<label for="showScriptErrors"><input id="showScriptErrors" type="checkbox">Show script errors</label>
<label for="nologs"><input id="nologs" type="checkbox">No logs</label>
<label for="filePatching" id="filePatching_label" style="visibility: hidden"><input id="filePatching" type="checkbox">FP</label>
<br /><br />
<input type="button" value="Save" onClick="SaveOnClick">
<input type="button" value="Load" onClick="LoadOnClick">
</div>
</fieldset>
</body>
</html>