-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcode.iss
/
code.iss
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
[Files]
//Bringing the file reference for the DLL here to keep code stuff together.
Source:"Utility\DLL\CMIHelper.dll"; DestDir: "{tmp}"; Permissions: everyone-full; Flags: dontcopy deleteafterinstall nocompression noencryption
[/Files]
[Code]
//GlobalVariables
var
PresetFile: String;
DownloadPage: TDownloadWizardPage;
EngDisable: Boolean;
EmptyFolder: Boolean;
path: WideString;
OGEvent: TNotifyEvent;
ProgressOGEvent: TNotifyEvent;
DownloadProgressLabel: TNewStaticText;
x86bit: Boolean;
x64bit: Boolean;
bitString: String;
MinimumVersion: Integer;
IsCR: Boolean;
[/Code]
//#include "MyDownloadPage.iss"
//The following script contains a bunch of helper functions and methods. They were moved out so better track could be kept.
#include "helper.iss"
#if LMMT == true
//Functions exclusive to LMMT. Only really loaded if needed.
#include "LMMT/LMMTExclusive.iss"
#elif LMMT == false
//Functions exclusive to LMMT. Only really loaded if needed.
#include "CMI/CMIExclusive.iss"
#endif
//This zip is basically a library for unzipping zip files quickly.
#include "unzip.iss"
//The following script contains a bunch of helper functions and methods. They were moved out so better track could be kept.
#include "OldInstallHandler.iss"
//KeyValueLists Expandable
#include "AssetDownloadHandler.iss"
//This version and path verification are such a lengthy and careful process, I've overhauled it and moved it to a seperate "class".
#include "VersionVerification.iss"
//Collection of code blocks that are delegated an event and deal with it.
#include "DelegateCode.iss"
[Code]
procedure InitializeWizard();
var
Value: String;
ErrorCode: Integer;
FreeSpace, TotalSpace: Cardinal;
ManifestVersion: String;
VersionResult: Integer;
begin
OGEvent := WizardForm.TypesCombo.OnChange;
WizardForm.TypesCombo.OnChange := @TypesComboChange;
PresetFile := 'Custom.{#ShortName}Type';
if (GetSpaceOnDisk(ExpandConstant('{tmp}'),True, FreeSpace, TotalSpace)) AND (FreeSpace < 5000) then
begin
MsgBox(FmtMessage(CustomMessage('StorageSpaceLow'), IntToStr(FreeSpace)), mbCriticalError, MB_OK)
abort
end;
try
DownloadTemporaryFile('{#ManifestLink}','manifest.txt','',nil);
if (StringFetch(ExpandConstant('{tmp}\manifest.txt'), ManifestVersion, 'CMI:')) then
begin
Log('Version fetch suceeded: ' + ManifestVersion)
if VersionCompare('{#MyAppVersion}', ManifestVersion, VersionResult) then
begin
Log('Version compare returned: ' + IntToStr(VersionResult))
if (VersionResult < 1) then
begin
MsgBox(CustomMessage('OutdatedInstaller') , mbCriticalError, MB_OK);
end
end
end;
except
Log('Failed to vet the installer...')
end;
MsgBox(CustomMessage('ScamWarning') , mbInformation, MB_OK);
if MsgBox(CustomMessage('ReadmeRead'), mbConfirmation, MB_YESNO) = IDNO then
begin
MsgBox(CustomMessage('ReadmeExit'), mbCriticalError, MB_OK)
ExtractTemporaryFile('{#ShortName}_Readme.pdf');
ShellExecAsOriginalUser('open',
AddQuotes(ExpandConstant('{tmp}\{#ShortName}_Readme.pdf')), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
abort
end;
DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
DownloadPage.ProgressBar.Top := DownloadPage.Msg2Label.Top + (DownloadPage.Msg2Label.Height * 3)
DownloadPage.AbortButton.Top := DownloadPage.ProgressBar.Top + DownloadPage.AbortButton.Height
DownloadProgressLabel := TNewStaticText.Create(WizardForm);
DownloadProgressLabel.Parent := DownloadPage.Msg1Label.Parent;
DownloadProgressLabel.Width := DownloadProgressLabel.Parent.Width - DownloadPage.Msg2Label.Height;
DownloadProgressLabel.Left := DownloadPage.Msg2Label.Left;
DownloadProgressLabel.Height := DownloadPage.Msg2Label.Height;
DownloadProgressLabel.Top := DownloadPage.ProgressBar.Top - DownloadProgressLabel.Height;
DownloadProgressLabel.Font.Assign(DownloadPage.Msg1Label.Font);
DownloadProgressLabel.Caption := '';
//Tries to find the path of the game via the registry and if it suceeds, pushes it to the value var.
if RegQueryStringValue(HKEY_CURRENT_USER, '{#JapRegistry}','InstallPath', Value) then
//Sets the wizard dir field to default to what is found in the registry
begin
WizardForm.DirEdit.Text := (Value);
end
#if LMMT == false
else if RegQueryStringValue(HKEY_CURRENT_USER, '{#EnglishRegistry}','InstallPath', Value) then
//Sets the wizard dir field to default to what is found in the registry if the JP path isn't found but the ENG path is.
begin
WizardForm.DirEdit.Text := (Value);
end
#endif
//If no registry key is found, it will blank the field to force users to select their path.
else
begin
WizardForm.DirEdit.Text := '';
end;
end;
procedure CurPageChanged(const CurPageID: Integer);
begin
//Only run the code if wizard is on the components page
if CurPageID=wpSelectComponents then
begin
//Saves path to global var.
path := ExpandConstant('{app}');
#if LMMT == false
FixEngComponents()
#else
FixBitComponents();
#endif
end;
end;
function BackButtonClick(const CurPageID: Integer): Boolean;
begin
if CurPageID = wpSelectComponents then
begin
if (EngDisable = true) OR x86bit = false OR x64bit = false then
begin
if MsgBox(CustomMessage('GameTypeChangedExit'), mbConfirmation, MB_YESNO) = IDYES then
begin
Abort;
end;
end else begin
result := true;
end;
end else
begin
result := true;
end;
end;
procedure CurStepChanged(const CurStep: TSetupStep);
begin
case CurStep of ssInstall:
begin
DownloadAssets()
//Saves any custom selections to components on install.
if (CompareText(WizardSetupType(false),'custom') = 0) then
begin
while SaveCustomPreset(path) = false do
begin
case SuppressibleMsgBox('We encountered an error while trying to save the custom preset...', mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of
IDIGNORE: break;
IDABORT: abort;
end;
end
end;
//Starts by removing the Read-Only flag if applicable.
if WizardIsTaskSelected('readonly') then
begin
while RemoveReadOnlyRecursive(path) = false do
begin
case SuppressibleMsgBox('We encountered an error while trying to remove readonly from your application directory...', mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of
IDIGNORE: break;
IDABORT: abort;
end;
end
end;
//Will now begin the move old install to backup folder if task was selected.
if WizardIsTaskSelected('clean/moveold') then
begin
//MsgBox('File moving was selected', mbInformation, MB_OK);
while (DirExists(path + '\OldInstall')) AND (AppendCreationTimeToName(path + '\OldInstall') = false) do
begin
case SuppressibleMsgBox('Encountered an issue while attempting to rename OldInstall folder.', mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of
IDIGNORE: break;
IDABORT: abort;
end;
end;
while MoveOld(path, ['', ExpandConstant('\Sybaris')]) = false do
begin
case SuppressibleMsgBox(CustomMessage('MoveOldExcep'), mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of
IDIGNORE: break;
IDABORT: abort;
end;
end;
end;
if WizardIsTaskSelected('clean/moveold/mods') then
begin
//MsgBox('mod moving was chosen', mbInformation, MB_OK);
//Checks if mod moving was selected and if so will execute that.
while MoveOldMod(path, ['{#ModDir}']) = false do
begin
case SuppressibleMsgBox(CustomMessage('MoveOldModExcep'), mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of
IDIGNORE: break;
IDABORT: abort;
end;
end;
end;//Mod Move
end;
end;//Case
case CurStep of ssPostInstall:
begin
#if LMMT == false
HandleSer(path)
#endif
if WizardIsTaskSelected('clean/moveold/config') then
begin
while MoveOldConfigBack(path) = false do
begin
case SuppressibleMsgBox('Encountered an issue while attempting to copy your old configs back...', mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of
IDIGNORE: break;
IDABORT: abort;
end;
end
end;
while (DirExists(path + '\OldInstall')) AND (AppendCreationTimeToName(path + '\OldInstall') = false) do
begin
case SuppressibleMsgBox(CustomMessage('CannotRenameOld'), mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of
IDIGNORE: break;
IDABORT: abort;
end;
end;
if WizardIsTaskSelected('readonly') then
begin
while RemoveReadOnlyRecursive(path) = false do
begin
// Display a message box
case SuppressibleMsgBox('We encountered an error while trying to remove readonly from your application directory...', mbError, MB_ABORTRETRYIGNORE, IDIGNORE) of
IDIGNORE: break;
IDABORT: abort;
end;
end
end;
SaveStringToFile(path + '\{#ShortName}.ver','{#MyAppVersion}', False);
end;
end;
end;//First begin
//This whole fucking function is to correctly remove the created temp file and the CMIHelper.dll after install because Inno doesn't like .Net Assemblies.
procedure DeinitializeSetup();
var
FilePath: string;
BatchPath: string;
S: TArrayOfString;
ResultCode: Integer;
begin
FilePath := ExpandConstant('{tmp}\{#HelperDLL}');
if not FileExists(FilePath) then
begin
Log(Format('File %s does not exist', [FilePath]));
end
else
begin
BatchPath :=
ExpandConstant('{%TEMP}\') +
'delete_' + ExtractFileName(ExpandConstant('{tmp}')) + '.bat';
SetArrayLength(S, 7);
S[0] := ':loop';
S[1] := 'del "' + FilePath + '"';
S[2] := 'if not exist "' + FilePath + '" goto end';
S[3] := 'goto loop';
S[4] := ':end';
S[5] := 'rd "' + ExpandConstant('{tmp}') + '"';
S[6] := 'del "' + BatchPath + '"';
if not SaveStringsToFile(BatchPath, S, False) then
begin
Log(Format('Error creating batch file %s to delete %s', [BatchPath, FilePath]));
end
else
if not Exec(BatchPath, '', '', SW_HIDE, ewNoWait, ResultCode) then
begin
Log(Format('Error executing batch file %s to delete %s', [BatchPath, FilePath]));
end
else
begin
Log(Format('Executed batch file %s to delete %s', [BatchPath, FilePath]));
end;
end;
end;
//end.//Code end. Fuck Pascal.
[/Code]