-
Notifications
You must be signed in to change notification settings - Fork 0
/
Launcher.ahk
465 lines (425 loc) · 13.4 KB
/
Launcher.ahk
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
#SingleInstance
INI_FILENAME = launcher.ini
IWAD_FILES = doom1.wad|doom.wad|doomu.wad|bfgdoom.wad|doombfg.wad|doom2.wad|bfgdoom2.wad|doom2bfg.wad|freedoom.wad|freedoom1.wad|freedoom2.wad|freedoomu.wad|freedm.wad|delaweare.wad|tnt.wad|plutonia.wad|heretic1.wad|heretic.wad|hexen.wad|strife.wad|strife0.wad|strife1.wad|sve.wad|chex.wad|chex3.wad|action2.wad|harm1.wad|hacx.wad|hacx2.wad|rotwb.wad|blasphem.wad|blasphemer.wad|square1.pk3|square.pk3|doom_complete.pk3
Title = Quickly Launchering Doom v1.8
Cmd := ""
Files := []
Levels := ""
Pos := ""
Profiles := ""
Ports := ""
Loop, 32 {
level := "MAP"
if( StrLen(A_Index) == 1 )
level = %level%0%A_Index%
else
level = %level%%A_Index%
levels = %level%|%levels%
}
Loop, 4 {
episode := A_Index
Loop, 9
levels = E%episode%M%A_Index%|%levels%
}
Gui, Add, Text, Section, Port Location
Gui, Add, Text, , IWAD Directory
Gui, Add, Text, , IWAD
Gui, Add, ComboBox, w200 Section YS vPort
Gui, Add, Edit, w200 XS vIwadDir
Gui, Add, DropDownList, XS vIwad W100
Gui, Add, Button, YS Center Section gSetPort, ...
Gui, Add, Button, XS Center gSetDir, ...
Gui, Add, Text, XM Section, Additional Files
Gui, Add, ListBox, R10 W330 Multi AltSubmit vFileDisplay HScroll
Gui, Add, Button, W75 Center Section gAdd, &Add File
Gui, Add, Button, W75 YS Center gRemove, &Remove File
Gui, Add, Button, W35 YS Center gUp, &Up
Gui, Add, Button, W35 YS Center gDown, &Down
Gui, Add, Button, W75 YS Center gClear, &Clear List
Gui, Add, Text, X15 Y+30 Section, Mode
Gui, Add, Text, , Skill
Gui, Add, Text, , Level
Gui, Add, DropDownList, YS Section Right vMode W100 gChangeMode, Client|Server|Single||
Gui, Add, DropDownList, W100 AltSubmit vSkill, Easy|Medium|Hard|UltraViolence|Nightmare| ||
Gui, Add, ComboBox, W100 vLevel, %Levels%
Gui, Add, Text, YS Section, Host IP
Gui, Add, Text, , Players
Gui, Add, CheckBox, Y+15 Checked vCheats, Cheats?
Gui, Add, Edit, YS Section W100 vIP
Gui, Add, Edit, W20 vPlayers Number,
Gui, Add, CheckBox, vItemRespawn, Item Respawn?
Gui, Add, Text, X15 Section, Params
Gui, Add, Edit, YS W230 vOptions R1
Gui, Add, Button, YS gHelp, ?
Gui, Add, Text, XM Y+10 Section, Profile
Gui, Add, ComboBox, W150 YS vCurrentProfile
Gui, Add, Button, YS Center gLoad, &Load
Gui, Add, Button, YS Center gSave, &Save
Gui, Add, Button, YS Center gDelete, &Delete
Gui, Add, Button, XM Y+5 W150 Section Center gLaunch default, &Launch
Gui, Add, Button, YS Center gShowCmd, &Preview
Gui, Add, GroupBox, X10 Y290 W330 H130, Options
Gui, Add, CheckBox, X270 Y345 vDeathmatch, DM
Menu, Tray, NoStandard
Menu, Tray, Add, Show, Show
Menu, Tray, Add, Exit, GuiClose
Menu, Tray, Default, Show
LoadSettings()
if( Pos = "" ) {
Pos := "Center"
}
Gui, Show, AutoSize %Pos%, %Title%
return
Show:
WinRestore, %Title%
WinActivate, %Title%
return
SetDir:
FileSelectFolder, folder, *%A_ScriptDir%, 0, Select IWAD Directory
GuiControl, Text, IwadDir, %folder%
GoSub, GetIwads
return
SetPort:
FileSelectFile, file, 3, %A_WorkingDir%\gzdoom.exe, Select Port, Executables (*.exe)
if( file = "" )
return
if( !InStr(Ports, file) ) {
Ports := Ports . "|" . file
}
GuiControl, , Port, %Ports%
GuiControl, ChooseString, Port, %file%
return
Add:
FileSelectFile, selectedfiles, M3, ,Select File, Doom Files (*.wad; *.pk3; *.pk7; *.deh; *.cfg; *.dsg; *.zds; *.lmp; *.ini)
if selectedfiles =
return
path := ""
Loop, Parse, selectedfiles, `n
if A_Index = 1
path := A_LoopField
else
Files.Push(path . "\" . A_LoopField)
GuiControl, , FileDisplay, % FileList()
return
GuiDropFiles:
Loop, parse, A_GuiEvent, `n
if( RegExMatch( A_LoopField, "i)(wad|pk3|pk7|deh|cfg|dsg|zds|lmp|ini)$") > 0)
Files.Push(A_LoopField)
GuiControl, , FileDisplay, % FileList()
return
Clear:
Files := []
GuiControl, , FileDisplay, % FileList()
return
Remove:
Gui, Submit, NoHide
remove := StrSplit(FileDisplay, "|")
removed := 0
for i, r in remove {
Files.RemoveAt(r - removed)
removed++
}
GuiControl, ,FileDisplay, % FileList()
return
Up:
Gui, Submit, NoHide
split := StrSplit(FileDisplay, "|")
if( split.Length() != 1 ) {
Msgbox, Please select one file.
return
}
pos := Shift(Files, split[1], -1)
GuiControl, , FileDisplay, % FileList()
GuiControl, Choose, FileDisplay, % pos
return
Down:
Gui, Submit, NoHide
split := StrSplit(FileDisplay, "|")
if( split.Length() != 1 ) {
Msgbox, Please select one file.
return
}
pos := Shift(Files, split[1], 1)
GuiControl, , FileDisplay, % FileList()
GuiControl, Choose, FileDisplay, % pos
return
MakeCmd:
Gui, Submit, NoHide
cmd = "%Port%" -iwad
cmd = %cmd% "%IwadDir%\%Iwad%"
cmd = %cmd% %Options%
wads := []
for i, file in Files {
if( RegexMatch(file, "i)deh$") ) {
cmd = %cmd% -deh "%file%"
} else if( RegexMatch(file, "i)cfg$") ) {
if( Chocolate() )
cmd = %cmd% -config "%file%"
else
cmd = %cmd% +exec "%file%"
} else if( RegexMatch(file, "i)ini$") && !Chocolate() ) {
cmd = %cmd% -config "%file%"
} else if( RegexMatch(file, "i)dsg$") && Chocolate() ) {
cmd = %cmd% -loadgame "%file%"
} else if( RegexMatch(file, "i)zds$") && !Chocolate() ) {
cmd = %cmd% -loadgame "%file%"
} else if( RegexMatch(file, "i)lmp$") ) {
cmd = %cmd% -playdemo "%file%"
} else if( file != "" ) {
wads.Push(file)
}
}
if( Mode = "Client" ) {
If( Chocolate() )
cmd = %cmd% -connect %IP%
else if ( Skulltag() && IP != "" )
cmd = %cmd% +connect %IP%
else
cmd = %cmd% -join %IP% -netmode 1
} else {
if( Level != "" ) {
if( Chocolate() ) {
chocolevel := RegExReplace(Level,"i)[A-Z]"," ")
cmd = %cmd% -warp %chocolevel%
} else
cmd = %cmd% +map %Level%
}
if( Mode = "Server" ) {
if( Chocolate() )
cmd = %cmd% -server
else if( Skulltag() )
cmd = %cmd% -host +sv_maxplayers %Players% +sv_maxclients %Players%
else
cmd = %cmd% -host %Players% -netmode 1
if( DeathMatch )
cmd = %cmd% -deathmatch
}
if( ItemRespawn = 1 )
cmd = %cmd% +sv_itemrespawn 1
if( Cheats = "1" )
cmd = %cmd% +sv_cheats 1
if( Skill != "6" )
cmd = %cmd% -skill %Skill%
}
if( wads.Length() != 0 ) {
cmd = %cmd% -file
for i, wad in wads {
if( wad != "" ) {
cmd = %cmd% "%wad%"
}
}
}
return
FileList() {
global Files
list := "|"
for idx, file in Files {
list .= file "|"
}
return list
}
Shift(array, idx, offset) {
new := idx + offset
if( new < array.MinIndex() || new > array.MaxIndex() ) {
return idx
}
old := array[new]
array[new] := array[idx]
array[idx] := old
return new
}
Chocolate() {
global Port
return RegExMatch( Port, "i)(chocolate-doom|boom-plus|crispy)" ) > 0
}
SkullTag() {
global Port
return RegExMatch( Port, "i)skulltag|zandronum" ) > 0
}
PrBoom() {
global Port
return RegExMatch( Port, "i)boom-plus" ) > 0
}
ZDoom() {
global Port
return RegExMatch( Port, "i)zdoom" ) > 0
}
Validate() {
Gui, Submit, NoHide
global Port, IwadDir, Iwad
if( StrLen(Port) == 0 ) {
MsgBox, You need to specify a port!
return 0
}
if( StrLen(IwadDir) == 0 || StrLen(Iwad) == 0 ) {
MsgBox, You need to specify an Iwad dir and an Iwad!
return 0
}
return 1
}
Launch:
if( Validate() == 0 )
return
GoSub, MakeCmd
SaveSettings()
SplitPath, Port, , dir
Run, %cmd%, %dir%
return
ShowCmd:
if( Validate() == 0 )
return
GoSub, MakeCmd
MsgBox, %cmd%
return
Save:
Gui, Submit, NoHide
SaveSettings("Default")
if( CurrentProfile != "" )
SaveSettings(CurrentProfile)
return
Load:
Gui, Submit, NoHide
if( !(CurrentProfile = "") && InStr(Profiles, CurrentProfile) )
LoadSettings(CurrentProfile)
return
Delete:
Gui, Submit, NoHide
MsgBox, 1, Delete Profile?, Really delete profile %CurrentProfile%?
IfMsgBox, Cancel
return
IniDelete, %INI_FILENAME%, %CurrentProfile%
StringReplace, Profiles, Profiles, |%CurrentProfile%
GuiControl, , CurrentProfile, %Profiles%
if( Profiles = "" )
GuiControl, Text, CurrentProfile,
Save("profiles",Profiles,"Default")
return
Help:
Gui, Submit, NoHide
if( Chocolate() && !PrBoom() )
Run, http://www.chocolate-doom.org/wiki/index.php/Command_line_arguments
else if( Skulltag() )
Run, http://wiki.zandronum.com/Command_Line_Parameters
else if( Zdoom() )
Run, http://zdoom.org/wiki/Command_line_parameters
else
Run, http://doomwiki.org/wiki/Source_port_parameters
return
ChangeMode:
Gui, Submit, NoHide
if( Mode = "Single" ) {
GuiControl, Disable, IP
GuiControl, Disable, Players
GuiControl, Disable, Deathmatch
} else if( Mode = "Server" ) {
GuiControl, Disable, IP
GuiControl, Enable, Players
GuiControl, Enable, Deathmatch
} else if( Mode = "Client" ) {
GuiControl, Enable, IP
GuiControl, Disable, Players
GuiControl, Disable, Deathmatch
}
return
SaveSettings(profile="Default") {
global Iwad, Files, Level, Cheats, ItemRespawn, Skill, Options, IP, Mode, Players,
global IwadDir, Port, Profiles, CurrentProfile, Ports, Deathmatch
if( profile != "Default" ) {
if( !InStr(Profiles,profile) ) {
Profiles := Profiles . "|" . profile
}
}
Save("iwad",Iwad,profile)
Save("files",FileList(),profile)
Save("level",Level,profile)
Save("cheats",Cheats,profile)
Save("respawn",ItemRespawn,profile)
Save("skill",Skill,profile)
Save("options",Options,profile)
Save("ip",IP,profile)
Save("mode",Mode,profile)
Save("players",Players,profile)
Save("iwaddir",IwadDir,profile)
Save("port",Port,profile)
Save("deathmatch",Deathmatch,profile)
WinGetPos, X, Y, W, H, ahk_class AutoHotkeyGUI
Save("pos","X" . X . " " . "Y" . Y,"Default")
Save("profiles",Profiles,"Default")
Save("profile",CurrentProfile,"Default")
Save("ports",Ports,"Default")
}
LoadSettings(profile="Default") {
global INI_FILENAME, Pos, Profiles, Files, Ports
ifExist %INI_FILENAME%
{
grossfiles := StrSplit(Load("files",profile), "|")
;remove empty items resulting from storing the | list
Files := []
for i, file in grossfiles {
if( file != "" ) {
Files.Push(file)
}
}
GuiControl, Text, FileDisplay, % FileList()
GuiControl, Text, Level, % Load("level",profile)
GuiControl, , Cheats, % Load("cheats",profile)
GuiControl, , ItemRespawn, % Load("respawn",profile)
GuiControl, , Deathmatch, % Load("deathmatch",profile)
GuiControl, Choose, Skill, % Load("skill",profile)
GuiControl, , Options, % Load("options",profile)
GuiControl, , IP, % Load("ip",profile)
GuiControl, ChooseString, Mode, % Load("mode",profile)
GuiControl, , Players, % Load("players",profile)
GuiControl, , IwadDir, % Load("iwaddir",profile)
GoSub, GetIwads
GuiControl, ChooseString, Iwad, % Load("iwad",profile)
Ports := Load("ports","Default")
GuiControl, , Port, %Ports%
GuiControl, ChooseString, Port, % Load("port",profile)
Pos := Load("pos","Default")
Profiles := Load("profiles","Default")
GuiControl, , CurrentProfile, %Profiles%
if(profile != "Default") {
p := profile
} else {
p := Load("profile","Default")
}
GuiControl, ChooseString, CurrentProfile, %p%
}
GoSub, ChangeMode
}
GetIwads:
Gui, Submit, NoHide
if( IwadDir != "" ) {
Iwads := ""
Between := "||"
if( FileExist(IwadDir) ) {
Loop, %IwadDir%\*.wad {
if( InStr(IWAD_FILES, A_LoopFileName) ) {
Iwads = %Iwads%%A_LoopFileName%%Between%
Between := "|"
}
}
Loop, %IwadDir%\*.pk3 {
if( InStr(IWAD_FILES, A_LoopFileName) ) {
Iwads = %Iwads%%A_LoopFileName%%Between%
Between := "|"
}
}
}
ifExist %IwadDir%
GuiControl, Text, Iwad, |%Iwads%
}
return
Save(key, value, section="save") {
global INI_FILENAME
IniWrite, %value%, %INI_FILENAME%, %section%, %key%
}
Load(key, section="save") {
global INI_FILENAME
IniRead, value, %INI_FILENAME%, %section%, %key%
return value
}
GuiClose:
GuiEscape:
ExitApp