| 1 |
#define AppId "{{B67333BB-1CF9-4EFD-A40B-E25B5CB4C8A7}}" |
| 2 |
#define AppVersion "0.99" |
| 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 |
|
| 50 |
[Icons] |
| 51 |
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 |
| 52 |
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 |
| 53 |
|
| 54 |
|
| 55 |
[Code] |
| 56 |
var |
| 57 |
javaPath: String; |
| 58 |
|
| 59 |
procedure DecodeVersion (verstr: String; var verint: array of Integer); |
| 60 |
var |
| 61 |
i,p: Integer; s: string; |
| 62 |
begin |
| 63 |
// initialize array |
| 64 |
verint := [0,0,0,0]; |
| 65 |
i := 0; |
| 66 |
while ((Length(verstr) > 0) and (i < 4)) do |
| 67 |
begin |
| 68 |
p := pos ('.', verstr); |
| 69 |
if p > 0 then |
| 70 |
begin |
| 71 |
if p = 1 then s:= '0' else s:= Copy (verstr, 1, p - 1); |
| 72 |
verint[i] := StrToInt(s); |
| 73 |
i := i + 1; |
| 74 |
verstr := Copy (verstr, p+1, Length(verstr)); |
| 75 |
end |
| 76 |
else |
| 77 |
begin |
| 78 |
verint[i] := StrToInt (verstr); |
| 79 |
verstr := ''; |
| 80 |
end; |
| 81 |
end; |
| 82 |
|
| 83 |
end; |
| 84 |
|
| 85 |
function CompareVersion (ver1, ver2: String) : Integer; |
| 86 |
var |
| 87 |
verint1, verint2: array of Integer; |
| 88 |
i: integer; |
| 89 |
begin |
| 90 |
SetArrayLength (verint1, 4); |
| 91 |
DecodeVersion (ver1, verint1); |
| 92 |
|
| 93 |
SetArrayLength (verint2, 4); |
| 94 |
DecodeVersion (ver2, verint2); |
| 95 |
|
| 96 |
Result := 0; i := 0; |
| 97 |
while ((Result = 0) and ( i < 4 )) do |
| 98 |
begin |
| 99 |
if verint1[i] > verint2[i] then |
| 100 |
Result := 1 |
| 101 |
else |
| 102 |
if verint1[i] < verint2[i] then |
| 103 |
Result := -1; |
| 104 |
i := i + 1; |
| 105 |
end; |
| 106 |
|
| 107 |
end; |
| 108 |
|
| 109 |
procedure CheckJavaRuntime(); |
| 110 |
var |
| 111 |
W6432: Boolean; |
| 112 |
Res: Boolean; |
| 113 |
JavaVer: String; |
| 114 |
begin |
| 115 |
W6432 := False; |
| 116 |
Res := RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion', JavaVer); |
| 117 |
if (Res = False) and IsWin64() then |
| 118 |
begin |
| 119 |
Res := RegQueryStringValue(HKLM32, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion', JavaVer); |
| 120 |
W6432 := Res; |
| 121 |
end; |
| 122 |
if Res = True then |
| 123 |
begin |
| 124 |
if Length( JavaVer ) > 0 then |
| 125 |
begin |
| 126 |
if CompareVersion(JavaVer, '{#MinJavaVersion}') >= 0 then |
| 127 |
begin |
| 128 |
if W6432 then |
| 129 |
Res := RegQueryStringValue(HKLM32, 'SOFTWARE\JavaSoft\Java Runtime Environment\'+JavaVer, 'JavaHome', javaPath) |
| 130 |
else |
| 131 |
Res := RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment\'+JavaVer, 'JavaHome', javaPath); |
| 132 |
end; |
| 133 |
end; |
| 134 |
end; |
| 135 |
end; |
| 136 |
|
| 137 |
function IsJavaInstalled(): Boolean; |
| 138 |
begin |
| 139 |
Result := Length(javaPath) > 0; |
| 140 |
end; |
| 141 |
|
| 142 |
function GetJavaPath(Param: String): String; |
| 143 |
begin |
| 144 |
Result := javaPath; |
| 145 |
end; |
| 146 |
|
| 147 |
function InitializeSetup(): Boolean; |
| 148 |
var |
| 149 |
ErrorCode: Integer; |
| 150 |
begin |
| 151 |
CheckJavaRuntime(); |
| 152 |
Result := IsJavaInstalled(); |
| 153 |
if not Result then |
| 154 |
begin |
| 155 |
if MsgBox(FmtMessage(CustomMessage('JavaNotFound'), ['{#MinJavaVersion}']), mbConfirmation, MB_YESNO) = idYes then |
| 156 |
begin |
| 157 |
ShellExecAsOriginalUser('open', '{#JavaDownloadPage}', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode); |
| 158 |
end; |
| 159 |
end; |
| 160 |
end; |
| 161 |
|
| 162 |
function DirOk(Path: String): boolean; |
| 163 |
begin |
| 164 |
Result := DirExists(Path+'\GameDataFolder') and FileExists(Path+'\Oni.exe'); |
| 165 |
end; |
| 166 |
|
| 167 |
function NextButtonClick(CurPageID: Integer): boolean; |
| 168 |
begin |
| 169 |
Result := True; |
| 170 |
|
| 171 |
if CurPageID = wpSelectDir then |
| 172 |
begin |
| 173 |
if (not DirOk(WizardDirValue)) then |
| 174 |
begin |
| 175 |
MsgBox(CustomMessage('wrongDir'), mbError, MB_OK); |
| 176 |
Result := False; |
| 177 |
end; |
| 178 |
end; |
| 179 |
end; |
| 180 |
|
| 181 |
|
| 182 |
function ShouldSkipPage(PageID: Integer): Boolean; |
| 183 |
begin |
| 184 |
Result := PageID = wpSelectComponents; |
| 185 |
end; |
| 186 |
|
| 187 |
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String; |
| 188 |
begin |
| 189 |
Result := MemoUserInfoInfo + NewLine; |
| 190 |
Result := Result + MemoDirInfo + NewLine; |
| 191 |
Result := Result + MemoGroupInfo + NewLine; |
| 192 |
Result := Result + MemoTasksInfo + NewLine; |
| 193 |
end; |
| 194 |
|