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 1
/
FNVSGM_functions.ahk
226 lines (175 loc) · 4.35 KB
/
FNVSGM_functions.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
;functions for FNVSGM
;-------------------
doScanForSavegameNames( in_strSavegamefolder)
{
lstSavegames =
strName =
strNameOld =
Loop, %in_strSavegamefolder%\Saves\*.fos,0,1
{
strName = %A_LoopFileName%
if strName = autosave.fos
Continue
else if strName = quicksave.fos
Continue
else
{
;scan for name of character
;
nPos := InStr(strName, " ")
If nPos >0
{
strName := SubStr(strName, nPos) ;remove the savegame prefix "Speich. "
strName := SubStr(strName, 4) ;remove the "- "
nPos := InStr(strName, " ")
If nPos >0
{
strName := SubStr(strName, 1, nPos-1)
}
;Only store char name if not in list already
if ( strName != strNameOld)
{
lstSavegames = %lstSavegames%%strName%`n
}
strNameOld := strName
} ;if nPos >0
} ;else
} ;loop
Sort, lstSavegames, U
Return lstSavegames
} ;doScanForSavegameNames()
;------------------------
doScanForLIVEFolderNames( in_strSavegamefolder)
{
lstFolderName=
Loop, %in_strSavegamefolder%\Saves\*.*,2,0
{
strName = %A_LoopFileName%
lstFolderName = %lstFolderName%%strName%`n
} ;loop
Sort, lstFolderName, U
Return lstFolderName
} ;doScanForLIVEFolderNames
;----------------------------
doCreateSavegameFolders( in_strProfileFolder, in_lstSavegameNames, in_lstLIVEFoldernames, in_strSubfolder)
{
Loop, parse, in_lstSavegameNames, `n
{
if A_LoopField !=
{
strFoldername := A_LoopField
;create character folders
IfNotExist, %in_strProfileFolder%\%in_strSubfolder%\%strFoldername%
{
FileCreateDir, %in_strProfileFolder%\%in_strSubfolder%\%strFoldername%
;create LIVE subfolder
Loop, parse, in_lstLIVEFoldernames, `n
{
FileCreateDir, %in_strProfileFolder%\%in_strSubfolder%\%strFoldername%\%A_LoopField%
}
}
}
}
Return 0
;doCreateSavegameFolders
}
;--------------------
doCopySavegames( in_strSavegameFolder, in_lstSavegameNames, in_lstLIVEFoldernames, in_strSubfolder)
{
;scan normal savegame folder for savegames
Loop, parse, in_lstSavegameNames, `n
{
if A_LoopField !=
{
strFoldername := A_LoopField
;if profile folder exist
IfExist, %in_strSavegameFolder%\%in_strSubfolder%\%strFoldername%
{
;copy normal savegames to profile folder
FileCopy, %in_strSavegameFolder%\Saves\* %strFoldername%*.fos, %in_strSavegameFolder%\%in_strSubfolder%\%strFoldername%
;scan LIVE savegame folder for savegames
Loop, parse, in_lstLIVEFoldernames, `n
{
strLIVEFoldername := A_LoopField
IfExist, %in_strSavegameFolder%\%in_strSubfolder%\%strFoldername%\%strLIVEFoldername%
{
;copy LIVE files to savegame subfolder
FileCopy, %in_strSavegameFolder%\Saves\%strLIVEFoldername%\* %strFoldername%*.fos, %in_strSavegameFolder%\%in_strSubfolder%\%strFoldername%\%strLIVEFoldername%
}
}
}
}
}
Return 0
} ;doCopySavegames
;-----------------
doUpdateProfileDDL( in_strSavegamefolder, in_strSubfolder, in_strPreSelect)
{
;check if profile for preselection exists
if (in_strPreSelect != STANDARD)
{
IfNotExist, %in_strSavegamefolder%\%in_strSubfolder%\%in_strPreSelect%
{
in_strPreSelect = STANDARD
}
}
;clear the dropdownlist
GuiControl, , ddlCharacter, |
;add Standard to combobox
if in_strPreSelect = STANDARD
{
;pre-select
GuiControl, , ddlCharacter, STANDARD||
}
else
{
GuiControl, , ddlCharacter, STANDARD|
}
;scan all folders and add to combobox
Loop, %in_strSavegamefolder%\%in_strSubfolder%\*.,2,0
{
lstProfilenames = %lstProfilenames%%A_LoopFileName%`n
if A_LoopFileName = %in_strPreSelect%
{
;pre-select
GuiControl, , ddlCharacter, %A_LoopFileName%||
}
else
{
GuiControl, , ddlCharacter, %A_LoopFileName%|
}
}
iSavegamecount := doCountSavegames(in_strSavegamefolder,in_strSubfolder,in_strPreSelect)
GuiControl, ,guiSavegameCount, Savegames: %iSavegamecount%
Gosub, guiDropdownProfile
;update GUI
Gui, Show
Return lstProfilenames
} ;doUpdateProfileDDL
;-----------------
doCountSavegames( in_strProfilefolder, in_strProfilesub, in_strActiveProfile)
{
iCount = 0
strPath=
if in_strActiveProfile=
{
iCount = 0
}
else
{
if in_strActiveProfile=STANDARD
{
strPath = %in_strProfilefolder%\Saves
}
else
{
strPath = %in_strProfilefolder%\%in_strProfilesub%\%in_strActiveProfile%
}
Loop, %strPath%\*.fos,0,1
{
iCount := A_Index
}
}
;doCountSavegames
Return iCount
}