This repository has been archived by the owner on Mar 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
guihandler.ahk
296 lines (222 loc) · 5.72 KB
/
guihandler.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
;subroutines for gui
;-------------------
submenuSGHandler:
If A_ThisMenuItem = Create New Profile...
{
InputBox, strNewProfileName, Create New Profile, Enter the name of your new profile`nNew Profilename:
;user click OK
If (ErrorLevel = 0 AND StrLen( strNewProfileName) > 0)
{
;abort if profile exist already
IfExist %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%strNewProfileName%
{
MsgBox, 0, ERROR, The Profile exists already!
}
Else
{
FileCreateDir %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%strNewProfileName%
MsgBox, 4, Create New Profile Folder,Explore the new profile folder?
ACTIVE=%strNewProfileName%
doUpdateProfileDDL(SAVEGAMESFOLDER,PROFILESSUBFOLDER,ACTIVE)
IfMsgBox, Yes
{
Run, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%strNewProfileName%
}
}
}
}
Else If A_ThisMenuItem = Backup Active Profile...
{
;profile = STANDARD
If ACTIVE = STANDARD
{
FileSelectFolder, strBackupFolder,,, Backup -%ACTIVE%- to ...
;folderselect OK
if strBackupFolder!=
{
FileCopyDir, %SAVEGAMESFOLDER%\Saves, %strBackupFolder%\STANDARD, 1
}
Return
}
;profile folder not found
IfNotExist, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ACTIVE%
{
MsgBox, 0, Error, Profile folder not found!`n(%SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ACTIVE%)
return
}
;if profile folder exists
IfExist, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ACTIVE%
{
FileSelectFolder, strBackupFolder,,, Backup -%ACTIVE%- to ...`n
;folderselect OK
if strBackupFolder!=
{
FileCopyDir, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ACTIVE%, %strBackupFolder%\%ACTIVE%, 1
}
}
}
Else If A_ThisMenuItem = Backup All Profiles...
{
FileSelectFolder, strBackupFolder,,, Backup -%ACTIVE%- to ...`n
;folderselect OK
if strBackupFolder!=
{
FileCopyDir, %SAVEGAMESFOLDER%\Saves, %strBackupFolder%\STANDARD, 1
FileCopyDir, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%, %strBackupFolder%, 1
}
}
Else If A_ThisMenuItem = Scan For New Profiles
{
MsgBox, Note that your actual AUTO- and QUICKSAVE will stay in the STANDARD profile.`n`nTo move it to your character's profile:`n`n*Activate STANDARD profile`n*Run %LONGNAME% and load your AUTO/QUICKSAVE`n*Save as New Savegame`n*Run Scan again
gosub subScanForNewProfiles
;Activate STANDARD profile
IniWrite, STANDARD, %INIFILENAME%, general, active
ACTIVE = STANDARD
Gosub, subActivateProfile
doUpdateProfileDDL(SAVEGAMESFOLDER,PROFILESSUBFOLDER,ACTIVE)
}
else if A_ThisMenuItem = Open %LONGNAME% Savegame Folder
{
If SAVEGAMESFOLDER != ""
{
Run, "%SAVEGAMESFOLDER%\Saves"
}
}
else if A_ThisMenuItem = Open Active Profile Folder
{
If SAVEGAMESFOLDER != ""
{
IfExist, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ACTIVE%
{
Run, "%SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ACTIVE%"
}
Else
{
Run, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\
}
}
}
;submenuSGHandler
Return
;-------------------
submenuADVHandler:
if A_ThisMenuItem = Change Play-button link...
{
FileSelectFile, strRunfile,1,, Select the file you want to run...
If ErrorLevel = 0
{
IniWrite, %strRunfile%, %INIFILENAME%, advanced, playbuttonlink
}
}
;submenuADVHandler
Return
;----------------------
submenuHELPHandler:
; if A_ThisMenuItem = Help
; {
; Run, helpfile.html
; }
; else
if A_ThisMenuItem = About
{
MsgBox, 0, About %LONGNAME% Savegame Manager, %LONGNAME% Savegame Manager`nVersion %myVERSION%`n`nAuthor: RedawgTS`nSpecial thanks to: -digitalfun-`n`n%APPNAME% is published exclusively on: `n%NEXUSLINK%,
}
;submenuHELPHandler
Return
;------------------
submenuTrayHandler:
If A_ThisMenuItem = Run %LONGNAME%
{
gosub subRunGame
}
Else If A_ThisMenuItem = Open %APPNAME% window
{
Gui, Show
}
Else if A_ThisMenuItem = Exit
{
goto FinishApp
}
;submenuTrayHandler
Return
;-------------------------
guiDropdownProfile:
Gui, Submit, NoHide
;after submit -> ddlCharacter = savegame profile folder (or STANDARD)
strPicFilename=
;activate selected profile
ACTIVE := ddlCharacter
gosub subActivateProfile
iSavegamecount := doCountSavegames(SAVEGAMESFOLDER,PROFILESSUBFOLDER,ACTIVE)
GuiControl, ,guiSavegameCount, Savegames: %iSavegamecount%
;show profile picture
;
;if standard, use standard pic
If ddlCharacter = STANDARD
{
strPicFilename = standard.jpg
}
else
{
;scan profile folder for jpg
Loop, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ddlCharacter%\*.jpg, 0, 1
{
If A_LoopFileName !=
{
strPicFilename=%SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ddlCharacter%\%A_LoopFileName%
Break
}
}
If strPicFilename =
{
;scan profile folder for jpg
Loop, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ddlCharacter%\*.bmp, 0, 1
{
If A_LoopFileName !=
{
strPicFilename=%SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ddlCharacter%\%A_LoopFileName%
Break
}
}
}
}
if strPicFilename =
{
strPicFilename = standard.jpg
}
;set picture control
GuiControl, ,pic, %strPicFilename%
;guiDropdownProfile:
Return
;-----------------
GuiDropFiles:
; Extract filename (only the first if multiple files were dropped)
Loop, parse, A_GuiEvent, `n
{
strFilename = %A_LoopField%
Break
}
;if strFilename is a JPG or BMP
SplitPath, strFilename,,, strExt
if (strExt = "JPG" OR strExt = "BMP")
{
if ACTIVE=
{
}
else if ACTIVE=STANDARD
{
MsgBox, You cannot change the STANDARD profile picture!
}
else
{
;remove previous pic
FileDelete, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ACTIVE%\*.jpg
FileDelete, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ACTIVE%\*.bmp
;copy the picture to the profilefolder
FileCopy, %strFilename%, %SAVEGAMESFOLDER%\%PROFILESSUBFOLDER%\%ACTIVE%
;show the new pic
gosub guiDropdownProfile
}
}
;GuiDropFiles
Return