|
| 1 | +;Open Rails installer |
| 2 | +;12-Jul-2021 |
| 3 | +;Chris Jakeman |
| 4 | + |
| 5 | +; Assuming that Build.cmd is run from its directory then, in the same directory, this installer for "stable" requires file: |
| 6 | +; ".NET Framework 4.7.2 web installer\ndp472-kb4054531-web.exe" |
| 7 | +; which can be downloaded from: |
| 8 | +; http://go.microsoft.com/fwlink/?LinkId=863262 |
| 9 | +; and creates: |
| 10 | +; Open Rails/Program/* |
| 11 | +; Source/Installer/Output/OpenRailsSetup.exe |
| 12 | +; Build.cmd for "stable" will move OpenRailSetup.exe back into .\OpenRails-<mode>-Setup.exe. |
| 13 | + |
| 14 | +#define MyAppName "Open Rails" |
| 15 | +#include "Version.iss" ; provides the version number |
| 16 | +#define MyAppPublisher "Open Rails Project" |
| 17 | +#define MyAppManualName "Open Rails manual" |
| 18 | +#define MyAppSourceName "Download Open Rails source code" |
| 19 | +#define MyAppBugName "Report a bug in Open Rails" |
| 20 | + |
| 21 | +#define DotNETName "Microsoft .NET Framework 4.7.2" |
| 22 | + |
| 23 | +#define MyAppURL "http://openrails.org" ; Not yet HTTPS |
| 24 | +#define MyAppSourceURL "http://openrails.org/download/source/" |
| 25 | +#define MyAppSupportURL "https://launchpad.net/or" |
| 26 | + |
| 27 | +#define MyAppExeName "OpenRails.exe" |
| 28 | +#define MyAppManual "Documentation\Manual.pdf" |
| 29 | + |
| 30 | +#define MyAppProgPath "..\..\Program" |
| 31 | +#define MyAppDocPath "..\..\Program\Documentation" |
| 32 | + |
| 33 | +#define NetRedistPath "..\..\.NET Framework 4.7.2 web installer" |
| 34 | +#define NetRedist "NDP472-KB4054531-Web.exe" |
| 35 | + |
| 36 | +[Setup] |
| 37 | +; NOTE: The value of AppId uniquely identifies this application. |
| 38 | +; Do not use the same AppId value in installers for other applications. |
| 39 | +; (To generate a new GUID, use Tools > Generate GUID.) |
| 40 | +AppId={{94E15E08-869D-4B69-B8D7-8C82075CB51C} ; Generated for OpenRails pre-v1.0 |
| 41 | + |
| 42 | +AppName ={#MyAppName} |
| 43 | +AppVersion ={#MyAppVersion} |
| 44 | +AppVerName ={#MyAppName} {#MyAppVersion} |
| 45 | +AppPublisher ={#MyAppPublisher} |
| 46 | +AppPublisherURL ={#MyAppURL} |
| 47 | +AppSupportURL ={#MyAppSupportURL} |
| 48 | +AppUpdatesURL ={#MyAppURL} |
| 49 | +DefaultDirName ={commonpf}\{#MyAppName} |
| 50 | +DefaultGroupName={#MyAppName} |
| 51 | +AllowNoIcons =yes |
| 52 | +LicenseFile ={#MyAppProgPath}\Copying.txt |
| 53 | +InfoBeforeFile ={#MyAppProgPath}\Prerequisites.txt |
| 54 | +InfoAfterFile ={#MyAppProgPath}\Readme.txt |
| 55 | + |
| 56 | +; Remove the following line to run in administrative install mode (install for all users.) |
| 57 | +; PrivilegesRequired=lowest ; Cannot create the directory C:\Program Files\Open Rails |
| 58 | + |
| 59 | +Compression =lzma |
| 60 | +SolidCompression=yes |
| 61 | +WizardStyle=modern |
| 62 | +Uninstallable =yes |
| 63 | +UninstallDisplayIcon={app}\{#MyAppExeName} |
| 64 | +OutputBaseFilename=OpenRailsSetup |
| 65 | + |
| 66 | +; Windows 7 SP1 |
| 67 | +MinVersion =6.1sp1 |
| 68 | + |
| 69 | +[Languages] |
| 70 | +Name: "english"; MessagesFile: "compiler:Default.isl" |
| 71 | +Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.isl" |
| 72 | +Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" |
| 73 | +Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl" |
| 74 | +Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl" |
| 75 | +Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl" |
| 76 | +Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl" |
| 77 | +Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl" |
| 78 | +Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl" |
| 79 | +Name: "french"; MessagesFile: "compiler:Languages\French.isl" |
| 80 | +Name: "german"; MessagesFile: "compiler:Languages\German.isl" |
| 81 | +Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl" |
| 82 | +Name: "icelandic"; MessagesFile: "compiler:Languages\Icelandic.isl" |
| 83 | +Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl" |
| 84 | +Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" |
| 85 | +Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl" |
| 86 | +Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl" |
| 87 | +Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl" |
| 88 | +Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl" |
| 89 | +Name: "slovak"; MessagesFile: "compiler:Languages\Slovak.isl" |
| 90 | +Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl" |
| 91 | +Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" |
| 92 | +Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl" |
| 93 | +Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl" |
| 94 | + |
| 95 | +[Tasks] |
| 96 | +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked |
| 97 | +Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 |
| 98 | + |
| 99 | +[Files] |
| 100 | +; Don't install these prerequisites until after the licence file has been accepted. |
| 101 | +; .NET Framework redistributable |
| 102 | +Source: {#NetRedistPath}\{#NetRedist}; DestDir: {tmp}; Flags: deleteafterinstall; AfterInstall: InstallFrameworkNet472; Check: IsNotInstalledFrameworkNet472 |
| 103 | + |
| 104 | +; The game itself |
| 105 | +; Readme.txt is copied from Source\RunActivity\Readme.txt |
| 106 | +Source: {#MyAppProgPath}\*; Excludes: Readme*.txt; DestDir: {app}; Flags: ignoreversion recursesubdirs |
| 107 | +Source: ..\..\Program\Readme.txt; DestDir: {app}; Flags: ignoreversion |
| 108 | +Source: {#MyAppDocPath}\*; DestDir: {app}\Documentation; Flags: ignoreversion recursesubdirs |
| 109 | + |
| 110 | +[Icons] |
| 111 | +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" |
| 112 | +Name: "{group}\{#MyAppManualName}"; Filename: "{app}\{#MyAppManual}" |
| 113 | +Name: "{group}\{#MyAppSourceName}"; Filename: "{#MyAppSourceURL}" |
| 114 | +Name: "{group}\{#MyAppBugName}"; Filename: "{#MyAppSupportURL}" |
| 115 | +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon |
| 116 | +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon |
| 117 | + |
| 118 | +[Run] |
| 119 | +Filename: "{app}\{#MyAppExeName}"; StatusMsg: "Installing Open Rails ..."; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent |
| 120 | + |
| 121 | + |
| 122 | +[Code] |
| 123 | +function IsNotInstalledFrameworkNet472: Boolean; |
| 124 | +var |
| 125 | + data: Cardinal; |
| 126 | + StatusText: string; |
| 127 | +begin |
| 128 | + // Gets left on screen while file is unpacked. |
| 129 | + StatusText := WizardForm.StatusLabel.Caption; |
| 130 | + WizardForm.StatusLabel.Caption := 'Checking for prerequisite {#DotNETName}...'; |
| 131 | + Result := true; // Result is a pre-declared return value |
| 132 | + if (RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', data)) then begin |
| 133 | + // "or" operator doesn't work |
| 134 | + if (IntToStr(data) = '461808') then Result := false; // v4.7.2 |
| 135 | + if (IntToStr(data) = '461814') then Result := false; // v4.7.2 |
| 136 | + if (IntToStr(data) = '528040') then Result := false; // v4.8 |
| 137 | + if (IntToStr(data) = '528372') then Result := false; // v4.8 |
| 138 | + if (IntToStr(data) = '528049') then Result := false; // v4.8 |
| 139 | + end; |
| 140 | + if (Result = true) then |
| 141 | + WizardForm.StatusLabel.Caption := 'Installing Open Rails ...'; |
| 142 | +end; |
| 143 | +
|
| 144 | +procedure InstallFrameworkNet472; |
| 145 | +var |
| 146 | + StatusText: string; |
| 147 | + ResultCode: Integer; |
| 148 | +begin |
| 149 | + StatusText := WizardForm.StatusLabel.Caption; |
| 150 | + WizardForm.StatusLabel.Caption := 'Installing {#DotNETName} (takes about 8 mins and downloads 82MB)...'; |
| 151 | + WizardForm.ProgressGauge.Style := npbstMarquee; |
| 152 | + try |
| 153 | + begin |
| 154 | + // Install the package |
| 155 | + if not Exec(ExpandConstant('{tmp}\{#NetRedist}'), ' /q /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then |
| 156 | + begin |
| 157 | + // Tell the user why the installation failed |
| 158 | + MsgBox('Installing {#DotNETName} failed with code: ' + IntToStr(ResultCode) + '.', mbError, MB_OK); |
| 159 | + end; |
| 160 | + end; |
| 161 | + finally |
| 162 | + WizardForm.StatusLabel.Caption := StatusText; |
| 163 | + WizardForm.ProgressGauge.Style := npbstNormal; |
| 164 | + end; |
| 165 | +end; |
0 commit comments