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