1 | #define AppId "{{B67333BB-1CF9-4EFD-A40B-E25B5CB4C8A7}}"
|
---|
2 | #define AppVersion "0.77"
|
---|
3 | #define AppLongName "Anniversary Edition of Oni"
|
---|
4 | #define AppShortName "AEInstaller"
|
---|
5 |
|
---|
6 | #define MinJavaVersion "1.6"
|
---|
7 |
|
---|
8 | [Setup]
|
---|
9 | AppId={#AppId}
|
---|
10 | AppVersion={#AppVersion}
|
---|
11 | AppName={#AppLongName}
|
---|
12 | DefaultDirName={pf32}\Oni
|
---|
13 | OutputBaseFilename={#AppShortName}-v{#AppVersion}-Setup
|
---|
14 | DefaultGroupName=Oni AE
|
---|
15 |
|
---|
16 | DirExistsWarning=no
|
---|
17 | AppendDefaultDirName=no
|
---|
18 |
|
---|
19 | ShowComponentSizes=no
|
---|
20 | AppPublisher=
|
---|
21 | AppPublisherURL=
|
---|
22 | AppSupportURL=
|
---|
23 | AppUpdatesURL=
|
---|
24 | AllowNoIcons=yes
|
---|
25 | OutputDir=.
|
---|
26 | Compression=lzma2/max
|
---|
27 | SolidCompression=yes
|
---|
28 |
|
---|
29 | [Languages]
|
---|
30 | Name: "en"; MessagesFile: "compiler:Default.isl"
|
---|
31 |
|
---|
32 | [Messages]
|
---|
33 | en.SelectDirBrowseLabel=Please select the installation directory of Oni.
|
---|
34 |
|
---|
35 | [CustomMessages]
|
---|
36 | en.wrongDir=This doesn't seem to be your Oni installation; I don't see a file here named "Oni.exe".
|
---|
37 |
|
---|
38 | [Tasks]
|
---|
39 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
---|
40 |
|
---|
41 | [Components]
|
---|
42 | Name: "JRE"; Description: "JRE"
|
---|
43 | Name: "AEI"; Description: "AEI"
|
---|
44 |
|
---|
45 | [Dirs]
|
---|
46 | Name: "{app}\Edition"; Permissions: users-modify
|
---|
47 |
|
---|
48 | [Files]
|
---|
49 | Source: "AEInstaller2.jar"; DestDir: "{app}\Edition\AEInstaller"; Components: AEI
|
---|
50 | Source: "JRE\*"; DestDir: "{app}\Edition\AEInstaller\JRE"; Flags: createallsubdirs recursesubdirs onlyifdoesntexist; Components: JRE
|
---|
51 | Source: "AElogo.ico"; DestDir: "{app}\Edition\AEInstaller"; Components: AEI
|
---|
52 |
|
---|
53 | [Icons]
|
---|
54 | Name: "{group}\AEInstaller 2"; Filename: "{app}\Edition\AEInstaller\JRE\bin\javaw.exe"; WorkingDir: "{app}\Edition\AEInstaller"; IconFilename: "{app}\Edition\AEInstaller\AElogo.ico"; Parameters: "-Dsun.java2d.d3d=false -jar AEInstaller2.jar"; Check: not IsJavaInstalled
|
---|
55 | Name: "{commondesktop}\AEInstaller 2"; Filename: "{app}\Edition\AEInstaller\JRE\bin\javaw.exe"; WorkingDir: "{app}\Edition\AEInstaller"; IconFilename: "{app}\Edition\AEInstaller\AElogo.ico"; Parameters: "-Dsun.java2d.d3d=false -jar AEInstaller2.jar"; Tasks: desktopicon; Check: not IsJavaInstalled
|
---|
56 | Name: "{group}\AEInstaller 2"; Filename: "{code:GetJavaPath}\bin\javaw.exe"; WorkingDir: "{app}\Edition\AEInstaller"; IconFilename: "{app}\Edition\AEInstaller\AElogo.ico"; Parameters: "-Dsun.java2d.d3d=false -jar AEInstaller2.jar"; Check: IsJavaInstalled
|
---|
57 | Name: "{commondesktop}\AEInstaller 2"; Filename: "{code:GetJavaPath}\bin\javaw.exe"; WorkingDir: "{app}\Edition\AEInstaller"; IconFilename: "{app}\Edition\AEInstaller\AElogo.ico"; Parameters: "-Dsun.java2d.d3d=false -jar AEInstaller2.jar"; Tasks: desktopicon; Check: IsJavaInstalled
|
---|
58 |
|
---|
59 |
|
---|
60 | [Code]
|
---|
61 | var
|
---|
62 | javaPath: String;
|
---|
63 |
|
---|
64 | procedure DecodeVersion (verstr: String; var verint: array of Integer);
|
---|
65 | var
|
---|
66 | i,p: Integer; s: string;
|
---|
67 | begin
|
---|
68 | // initialize array
|
---|
69 | verint := [0,0,0,0];
|
---|
70 | i := 0;
|
---|
71 | while ((Length(verstr) > 0) and (i < 4)) do
|
---|
72 | begin
|
---|
73 | p := pos ('.', verstr);
|
---|
74 | if p > 0 then
|
---|
75 | begin
|
---|
76 | if p = 1 then s:= '0' else s:= Copy (verstr, 1, p - 1);
|
---|
77 | verint[i] := StrToInt(s);
|
---|
78 | i := i + 1;
|
---|
79 | verstr := Copy (verstr, p+1, Length(verstr));
|
---|
80 | end
|
---|
81 | else
|
---|
82 | begin
|
---|
83 | verint[i] := StrToInt (verstr);
|
---|
84 | verstr := '';
|
---|
85 | end;
|
---|
86 | end;
|
---|
87 |
|
---|
88 | end;
|
---|
89 |
|
---|
90 | function CompareVersion (ver1, ver2: String) : Integer;
|
---|
91 | var
|
---|
92 | verint1, verint2: array of Integer;
|
---|
93 | i: integer;
|
---|
94 | begin
|
---|
95 | SetArrayLength (verint1, 4);
|
---|
96 | DecodeVersion (ver1, verint1);
|
---|
97 |
|
---|
98 | SetArrayLength (verint2, 4);
|
---|
99 | DecodeVersion (ver2, verint2);
|
---|
100 |
|
---|
101 | Result := 0; i := 0;
|
---|
102 | while ((Result = 0) and ( i < 4 )) do
|
---|
103 | begin
|
---|
104 | if verint1[i] > verint2[i] then
|
---|
105 | Result := 1
|
---|
106 | else
|
---|
107 | if verint1[i] < verint2[i] then
|
---|
108 | Result := -1;
|
---|
109 | i := i + 1;
|
---|
110 | end;
|
---|
111 |
|
---|
112 | end;
|
---|
113 |
|
---|
114 | procedure CheckJavaRuntime();
|
---|
115 | var
|
---|
116 | Res: Boolean;
|
---|
117 | JavaVer: String;
|
---|
118 | begin
|
---|
119 | Res := RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion', JavaVer);
|
---|
120 | if Res = True then
|
---|
121 | begin
|
---|
122 | if Length( JavaVer ) > 0 then
|
---|
123 | begin
|
---|
124 | if CompareVersion(JavaVer, '{#MinJavaVersion}') >= 0 then
|
---|
125 | begin
|
---|
126 | Res := RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment\'+JavaVer, 'JavaHome', javaPath);
|
---|
127 | end;
|
---|
128 | end;
|
---|
129 | end;
|
---|
130 | end;
|
---|
131 |
|
---|
132 | function IsJavaInstalled(): Boolean;
|
---|
133 | begin
|
---|
134 | Result := Length(javaPath) > 0;
|
---|
135 | end;
|
---|
136 |
|
---|
137 | function GetJavaPath(Param: String): String;
|
---|
138 | begin
|
---|
139 | Result := javaPath;
|
---|
140 | end;
|
---|
141 |
|
---|
142 | function InitializeSetup(): Boolean;
|
---|
143 | begin
|
---|
144 | CheckJavaRuntime();
|
---|
145 | Result := True;
|
---|
146 | end;
|
---|
147 |
|
---|
148 | procedure InitializeWizard();
|
---|
149 | var
|
---|
150 | Components : TNewCheckListbox;
|
---|
151 | i : integer;
|
---|
152 | begin
|
---|
153 | Components := WizardForm.ComponentsList;
|
---|
154 | i := Components.Items.IndexOf('JRE');
|
---|
155 | if i <> -1 then
|
---|
156 | begin
|
---|
157 | Components.ItemEnabled[i] := false;
|
---|
158 | Components.Checked[i] := not IsJavaInstalled();
|
---|
159 | end;
|
---|
160 | i := Components.Items.IndexOf('AEI');
|
---|
161 | if i <> -1 then
|
---|
162 | begin
|
---|
163 | Components.ItemEnabled[i] := false;
|
---|
164 | Components.Checked[i] := true;
|
---|
165 | end;
|
---|
166 | end;
|
---|
167 |
|
---|
168 | function DirOk(Path: String): boolean;
|
---|
169 | begin
|
---|
170 | Result := DirExists(Path+'\GameDataFolder') and FileExists(Path+'\Oni.exe');
|
---|
171 | end;
|
---|
172 |
|
---|
173 | function NextButtonClick(CurPageID: Integer): boolean;
|
---|
174 | begin
|
---|
175 | Result := True;
|
---|
176 |
|
---|
177 | if CurPageID = wpSelectDir then
|
---|
178 | begin
|
---|
179 | if (not DirOk(WizardDirValue)) then
|
---|
180 | begin
|
---|
181 | MsgBox(CustomMessage('wrongDir'), mbError, MB_OK);
|
---|
182 | Result := False;
|
---|
183 | end;
|
---|
184 | end;
|
---|
185 | end;
|
---|
186 |
|
---|
187 |
|
---|
188 | function ShouldSkipPage(PageID: Integer): Boolean;
|
---|
189 | begin
|
---|
190 | Result := PageID = wpSelectComponents;
|
---|
191 | end;
|
---|
192 |
|
---|
193 | function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
|
---|
194 | begin
|
---|
195 | Result := MemoUserInfoInfo + NewLine;
|
---|
196 | Result := Result + MemoDirInfo + NewLine;
|
---|
197 | Result := Result + MemoGroupInfo + NewLine;
|
---|
198 | Result := Result + MemoTasksInfo + NewLine;
|
---|
199 | end;
|
---|
200 |
|
---|