-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.iss
182 lines (168 loc) · 7.77 KB
/
setup.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
#define MyAppName "ZTMZ Next Generation Pacenote Tool"
#define MyAppVersion "2.99.99.2"
#define MyAppPublisher "ZTMZ Club"
#define MyAppURL "https://gitee.com/ztmz/ztmz_pacenote"
#define MyAppExeName "ZTMZ.PacenoteTool.WpfGUI.exe"
#define FolderName "ZTMZClub_nextgen"
[Code]
var
DownloadPage: TDownloadWizardPage;
NeedToDownload: Boolean;
{ Exec with output stored in result. }
{ ResultString will only be altered if True is returned. }
function ExecWithResult(const Filename, Params, WorkingDir: String; const ShowCmd: Integer;
const Wait: TExecWait; var ResultCode: Integer; var ResultString: AnsiString): Boolean;
var
TempFilename: String;
Command: String;
begin
TempFilename := ExpandConstant('{tmp}\~execwithresult.txt');
{ Exec via cmd and redirect output to file. Must use special string-behavior to work. }
Command :=
Format('"%s" /S /C ""%s" %s > "%s""', [
ExpandConstant('{cmd}'), Filename, Params, TempFilename]);
Result := Exec(ExpandConstant('{cmd}'), Command, WorkingDir, ShowCmd, Wait, ResultCode);
if not Result then
Exit;
LoadStringFromFile(TempFilename, ResultString); { Cannot fail }
DeleteFile(TempFilename);
{ Remove new-line at the end }
if (Length(ResultString) >= 2) and (ResultString[Length(ResultString) - 1] = #13) and
(ResultString[Length(ResultString)] = #10) then
Delete(ResultString, Length(ResultString) - 1, 2);
end;
function StartsText(const substr: String; str: String): Boolean;
var
index: Integer;
begin
index:= Pos(substr, str);
Result:= False;
if (index = 1) then
Result:= True;
end;
function CheckDotNetInstalled: Boolean;
var
i: Integer;
Success: Boolean;
ResultCode: Integer;
ExecStdout: AnsiString;
Lines: TStringList;
begin
Success :=
ExecWithResult('dotnet', '--list-runtimes', '', SW_HIDE, ewWaitUntilTerminated,
ResultCode, ExecStdout) or
(ResultCode <> 0);
if (Success) then
begin
Lines := TStringList.Create;
Lines.Text := ExecStdout;
{ find dotnet6 desktop }
for i:= 0 to Lines.Count-1 do
begin
{ Force version 6.0.10 }
if StartsText('Microsoft.WindowsDesktop.App 6.0.10', Lines[i]) then
begin
{ found }
Result:= True;
Exit;
end;
end;
Lines.Free;
end;
Result:= False;
end;
function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
begin
if Progress = ProgressMax then
begin
Log(Format('Successfully downloaded file to {tmp}: %s', [FileName]));
end;
Result := True;
end;
procedure InitializeWizard;
begin
NeedToDownload:= (not CheckDotNetInstalled);
DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
fullFileName: String;
ResultCode: Integer;
begin
if (CurPageID = wpReady) and NeedToDownload then begin
DownloadPage.Clear;
DownloadPage.Add('https://download.visualstudio.microsoft.com/download/pr/52d6ef78-d4ec-4713-9e01-eb8e77276381/e58f307cda1df61e930209b13ecb47a4/windowsdesktop-runtime-6.0.25-win-x64.exe', 'dotnet6.exe', '');
DownloadPage.Show;
try
try
DownloadPage.Download;
{ install it ! }
fullFileName:= ExpandConstant('{tmp}\dotnet6.exe');
Result := Exec(fullFileName, '/install /passive', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
except
SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
Result := False;
end;
finally
DownloadPage.Hide;
end;
end else
Result := True;
end;
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{9EF39FA9-58C6-40E7-B957-75EAC73369E7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\ztmzclub_pacenotetool_nextgen
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
PrivilegesRequired=lowest
Compression=lzma
SolidCompression=yes
WizardStyle=modern
VersionInfoVersion={#MyAppVersion}
;PrivilegesRequired=lowest
UninstallDisplayIcon={app}\{#MyAppExeName}
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"; LicenseFile:"license.txt"; InfoBeforeFile:"eula.txt";
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"; LicenseFile:"license-cn.txt"; InfoBeforeFile:"eula-cn.txt";
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}";
[InstallDelete]
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\default";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\engmale (by mesa)";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\wha1ing";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\南沢いずみ";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\图图(对讲机特效 by wha1ing)";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\圣沙蒙VK";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\拉稀车手老王";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\拉稀车手老王对讲机特效版";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\拉稀车手老王超快速语音包(兼容苏格兰)";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\权威Authority";
Type: filesandordirs; Name: "{userdocs}\My Games\{#FolderName}\codrivers\紫藤林沫(测试版)";
Type: files; Name: "{userdocs}\My Games\{#FolderName}\config.json";
; Delete previous default audio package
; Delete previous default configuration
[Files]
; No json file!
; Source: "ZTMZ.PacenoteTool.WpfGUI\bin\Release\net6.0-windows\*.json"; Excludes:"config.json,userconfig.json,*.deps.json,*.runtimeconfig.json"; DestDir: "{userdocs}\My Games\{#FolderName}"; Flags: ignoreversion
Source: "ZTMZ.PacenoteTool.WpfGUI\bin\Release\net6.0-windows\*.csv"; DestDir: "{userdocs}\My Games\{#FolderName}"; Flags: ignoreversion
Source: "ZTMZ.PacenoteTool.WpfGUI\bin\Release\net6.0-windows\codrivers\*"; DestDir: "{userdocs}\My Games\{#FolderName}\codrivers"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "ZTMZ.PacenoteTool.WpfGUI\bin\Release\net6.0-windows\profiles\*"; DestDir: "{userdocs}\My Games\{#FolderName}\profiles"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "ZTMZ.PacenoteTool.WpfGUI\bin\Release\net6.0-windows\lang\*"; DestDir: "{userdocs}\My Games\{#FolderName}\lang"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "ZTMZ.PacenoteTool.WpfGUI\bin\Release\net6.0-windows\games\*"; Excludes:"*.json"; DestDir: "{app}\games"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "ZTMZ.PacenoteTool.WpfGUI\bin\Release\net6.0-windows\games\*.json"; Excludes:"*.deps.json"; DestDir: "{userdocs}\My Games\{#FolderName}\games"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "ZTMZ.PacenoteTool.WpfGUI\bin\Release\net6.0-windows\runtimes\*"; DestDir: "{app}\runtimes"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent