-
Notifications
You must be signed in to change notification settings - Fork 71
/
guiAddonInfo.ahk
174 lines (144 loc) · 6.37 KB
/
guiAddonInfo.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
/*
Func: guiAddonInfo
Form to edit or create addoninfo.txt files used by source engine addons to display addon information ingame
Parameters:
SourceFile - (optional) path to existing addoninfo.txt file
Returns:
ErrorLevel if
SourceFile is specified and is not a text file
Form was closed without saving
Examples:
> guiAddonInfo()
= returns addoninfo file var when form is saved
> guiAddonInfo("e:\downloads\addoninfo.txt")
= loads file into form and deletes&rewrites file when form is saved
Required libs:
StringBetween.ahk
*/
guiAddonInfo(SourceFile="") {
global
OutPut := ""
gui addonInfo: Default
gui addonInfo: Margin, 5, 5
gui addonInfo: +AlwaysOnTop +Hwnd_guiAddonInfo +LabelguiAddonInfo_
gui addonInfo: Add, Text, section, SteamAppID
gui addonInfo: Add, Edit, vaddonSteamAppID w120 r1, %addonSteamAppID%
gui addonInfo: Add, Text, , Title
gui addonInfo: Add, Edit, vaddonTitle w120 r1, %addonTitle%
gui addonInfo: Add, Text, , Version
gui addonInfo: Add, Edit, vaddonVersion w120 r1, %addonVersion%
gui addonInfo: Add, Text, , Tagline
gui addonInfo: Add, Edit, vaddonTagline w120 r1, %addonTagline%
gui addonInfo: Add, Text, , Author
gui addonInfo: Add, Edit, vaddonAuthor w120 r1, %addonAuthor%
gui addonInfo: Add, Text, , AuthorSteamID
gui addonInfo: Add, Edit, vaddonAuthorSteamID w120 r1, %addonAuthorSteamID%
gui addonInfo: Add, Text, , SteamGroupName
gui addonInfo: Add, Edit, vaddonSteamGroupName w120 r1, %addonSteamGroupName%
gui addonInfo: Add, Text, , URL
gui addonInfo: Add, Edit, vaddonURL0 w120 r1, %addonURL0%
gui addonInfo: Add, Text, , Description
gui addonInfo: Add, Edit, vaddonDescription w240 r3, %addonDescription%
gui addonInfo: Add, Button, w240 r1 gguiAddonInfo_btnSave, Save
gui addonInfo: Add, Text, xs+130 ys, Game Modes
gui addonInfo: Add, Checkbox, checked%addonContent_Campaign% Checked0 vaddonContent_Campaign, Campaign
gui addonInfo: Add, Checkbox, checked%addonContent_Survival% Checked0 vaddonContent_Survival, Survival
gui addonInfo: Add, Checkbox, checked%addonContent_Scavenge% Checked0 vaddonContent_Scavenge, Scavenge
gui addonInfo: Add, Checkbox, checked%addonContent_Versus% Checked0 vaddonContent_Versus, Versus
gui addonInfo: Add, Checkbox, checked%addonContent_Map% Checked0 vaddonContent_Map, Map
gui addonInfo: Add, Text, , Skin
gui addonInfo: Add, Checkbox, checked%addonContent_Survivor% Checked0 vaddonContent_Survivor, Survivor
gui addonInfo: Add, Checkbox, checked%addonContent_Skin% Checked0 vaddonContent_Skin, Skin
gui addonInfo: Add, Text, , Misc
gui addonInfo: Add, Checkbox, checked%addonContent_BossInfected% Checked0 vaddonContent_BossInfected, BossInfected
gui addonInfo: Add, Checkbox, checked%addonContent_CommonInfected% Checked0 vaddonContent_CommonInfected, CommonInfected
gui addonInfo: Add, Checkbox, checked%addonContent_Music% Checked0 vaddonContent_Music, Music
gui addonInfo: Add, Checkbox, checked%addonContent_Sound% Checked0 vaddonContent_Sound, Sound
gui addonInfo: Add, Checkbox, checked%addonContent_Prop% Checked0 vaddonContent_Prop, Prop
gui addonInfo: Add, Checkbox, checked%addonContent_Prefab% Checked0 vaddonContent_Prefab, Prefab
gui addonInfo: Add, Checkbox, checked%addonContent_Spray% Checked0 vaddonContent_Spray, Spray
gui addonInfo: Add, Checkbox, checked%addonContent_Script% Checked0 vaddonContent_Script, Script
gui addonInfo: Add, Checkbox, checked%addonContent_BackgroundMovie% Checked0 vaddonContent_BackgroundMovie, BackgroundMovie
gui addonInfo: Add, Link, y+10, <a href="https://developer.valvesoftware.com/wiki/Deadline_AddonInfo_File">Help</a>
Gosub guiAddonInfo_readSourceFile
gui addonInfo: Show, x0 y0
WinWaitClose, % "ahk_id " _guiAddonInfo
gui addonInfo: Destroy
If (OutPut = "")
return ErrorLevel := 1
else
return OutPut
guiAddonInfo_close:
gui addonInfo: destroy
return
guiAddonInfo_readSourceFile:
If !(SourceFile = "") ; read addonfile if specified
{
SplitPath, SourceFile, , , SourceFileExt
If !(SourceFileExt = "txt")
return ErrorLevel := 1
FileRead, addonInfo, % SourceFile
loop, parse, addonInfo, `n
{
StringReplace, LoopField, A_LoopField, ", ", UseErrorLevel
LoopFieldQuoteCount := ErrorLevel
If (LoopFieldQuoteCount = 2) ; assumed layout: addonSteamAppID "550"
{
key := SubStr(A_LoopField, 1, InStr(A_LoopField, """") - 1)
key := Trim(key)
value := StringBetween(A_LoopField, """", """")
}
If (LoopFieldQuoteCount = 4) ; assumed layout: "addonSteamAppID" "550"
{
key := StringBetween(A_LoopField, """", """") ; key is first value between quotes
StringReplace, value, A_LoopField, % """" key """" ; remove key from line to build value var
StringReplace, value, value, ", , All ; " ; remove quotes
StringReplace, value, value, `r, , All ; remove enters
value := Trim(value) ; remove empty space
}
GuiControl addonInfo: , % key, % value
}
}
return
guiAddonInfo_btnSave:
gui addonInfo: Submit, NoHide
StringReplace, addonDescription, addonDescription, `n, , All ; remove enters from description
OutPut =
(
"AddonInfo"
{
"addonSteamAppID" "%addonSteamAppID%"
"addonTitle" "%addonTitle%"
"addonVersion" "%addonVersion%"
"addonTagline" "%addonTagline%"
"addonAuthor" "%addonAuthor%"
"addonAuthorSteamID" "%addonAuthorSteamID%"
"addonSteamGroupName" "%addonSteamGroupName%"
"addonURL0" "%addonURL0%"
"addonContent_Campaign" "%addonContent_Campaign%"
"addonContent_Survival" "%addonContent_Survival%"
"addonContent_Scavenge" "%addonContent_Scavenge%"
"addonContent_Versus" "%addonContent_Versus%"
"addonContent_Map" "%addonContent_Map%"
"addonContent_Survivor" "%addonContent_Survivor%"
"addonContent_Skin" "%addonContent_Skin%"
"addonContent_BossInfected" "%addonContent_BossInfected%"
"addonContent_CommonInfected" "%addonContent_CommonInfected%"
"addonContent_Music" "%addonContent_Music%"
"addonContent_Sound" "%addonContent_Sound%"
"addonContent_Prop" "%addonContent_Prop%"
"addonContent_Prefab" "%addonContent_Prefab%"
"addonContent_Spray" "%addonContent_Spray%"
"addonContent_Script" "%addonContent_Script%"
"addonContent_BackgroundMovie" "%addonContent_BackgroundMovie%"
"addonDescription" "%addonDescription%"
}
)
If !(SourceFile = "")
{
FileDelete, % SourceFile
FileAppend, % OutPut, % SourceFile
}
gui addonInfo: Destroy
return
}