2016-08-25 22:17:15 +01:00
!define APPNAME " OpenRCT2 "
2017-02-02 10:53:56 +00:00
!define APPVERSION " ${APPV_MAIN}${APPV_EXTRA} "
!define APPVERSIONINTERNAL " ${APPV_MAIN}.0 "
!define APPNAMEANDVERSION " ${APPNAME} ${APPVERSION} "
!define APPURLLINK " https://github.com/OpenRCT2/OpenRCT2 "
2015-02-06 19:54:44 +00:00
2016-08-25 22:17:15 +01:00
!if " ${PLATFORM} " == " Win32 "
2017-02-02 10:53:56 +00:00
!define OPENRCT2_EXE " openrct2.exe "
!define APPBITS 32
!define APPARCH " win32 "
2016-08-25 22:17:15 +01:00
InstallDir " $PROGRAMFILES32 \OpenRCT2\ "
!else
2017-02-02 10:53:56 +00:00
!define OPENRCT2_EXE " openrct2.exe "
!define APPBITS 64
!define APPARCH " win64 "
2016-08-25 22:17:15 +01:00
InstallDir " $PROGRAMFILES64 \OpenRCT2\ "
!endif
2017-02-02 10:53:56 +00:00
!define SUPPORTED_OS " Windows Vista, 7, 8.1 and 10 "
2016-08-25 22:17:15 +01:00
2015-02-06 19:54:44 +00:00
; Define root variable relative to installer
!define PATH_ROOT " ..\..\ "
2016-08-25 22:17:15 +01:00
!define BINARY_DIR " ${PATH_ROOT}bin "
2015-02-06 19:54:44 +00:00
2015-02-22 17:42:40 +00:00
!define MUI_ICON " ${PATH_ROOT}resources\logo\icon.ico "
!define MUI_UNICON " ${PATH_ROOT}resources\logo\icon.ico "
2015-02-06 19:54:44 +00:00
!define MUI_WELCOMEFINISHPAGE_BITMAP " welcome.bmp "
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP " top.bmp "
BrandingText " OpenRCT2 Installer "
SetCompressor LZMA
; Version Info
VIProductVersion " ${APPVERSIONINTERNAL} "
2016-08-25 22:17:15 +01:00
VIAddVersionKey " ProductName " " OpenRCT2 ${APPBITS}-bit Installer for ${SUPPORTED_OS} "
2015-02-06 19:54:44 +00:00
VIAddVersionKey " Comments " " Installs ${APPNAMEANDVERSION} "
VIAddVersionKey " CompanyName " " OpenRCT2 Developers "
VIAddVersionKey " FileDescription " " Installs ${APPNAMEANDVERSION} "
VIAddVersionKey " ProductVersion " " ${APPVERSION} "
VIAddVersionKey " InternalName " " InstOpenRCT2-${APPARCH} "
VIAddVersionKey " FileVersion " " ${APPVERSION}-${APPARCH} "
VIAddVersionKey " LegalCopyright " " "
; Main Install settings
2016-08-25 22:17:15 +01:00
Name " ${APPNAMEANDVERSION} ${APPBITS}-bit for ${SUPPORTED_OS} "
2015-02-06 19:54:44 +00:00
; NOTE: Keep trailing backslash!
InstallDirRegKey HKLM " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " Install Folder "
2015-02-22 23:26:07 +01:00
!ifndef OUTFILE
2016-08-25 21:29:38 +01:00
!define OUTFILE " openrct2-install.exe "
2015-02-22 23:26:07 +01:00
!endif
OutFile " ${OUTFILE} "
2015-02-06 19:54:44 +00:00
CRCCheck force
ShowInstDetails show
ShowUninstDetails show
RequestExecutionLevel admin
Var SHORTCUTS
; Modern interface settings
!include " MUI2.nsh "
!include " InstallOptions.nsh "
!include " WinVer.nsh "
!include " x64.nsh "
!define MUI_ABORTWARNING
!define MUI_WELCOMEPAGE_TITLE_3LINES
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE " ..\..\licence.txt "
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
ManifestDPIAware true
;Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_DEFAULTFOLDER $SHORTCUTS
!define MUI_STARTMENUPAGE_REGISTRY_ROOT " HKEY_LOCAL_MACHINE "
!define MUI_STARTMENUPAGE_REGISTRY_KEY " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 "
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME " Shortcut Folder "
!insertmacro MUI_PAGE_STARTMENU " OpenRCT2 " $SHORTCUTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_TITLE_3LINES
!define MUI_FINISHPAGE_RUN_TEXT " Run ${APPNAMEANDVERSION} now! "
2016-08-25 22:17:15 +01:00
!define MUI_FINISHPAGE_RUN " $INSTDIR \${OPENRCT2_EXE} "
2015-02-06 19:54:44 +00:00
!define MUI_FINISHPAGE_LINK " Visit the OpenRCT2 site for more information "
!define MUI_FINISHPAGE_LINK_LOCATION " ${APPURLLINK} "
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_SHOWREADME " $INSTDIR \readme.txt "
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT DisableBack
!insertmacro MUI_PAGE_FINISH
!define MUI_PAGE_HEADER_TEXT " Uninstall ${APPNAMEANDVERSION} "
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
; Set languages (first is default language)
!insertmacro MUI_LANGUAGE " English "
!insertmacro MUI_RESERVEFILE_LANGDLL
;--------------------------------------------------------------
; (Core) OpenRCT2 install section. Copies all internal game data
Section " !OpenRCT2 " Section1
; Make sure to be upgraded OpenRCT2 is not running
Call CheckOpenRCT2Running
; Overwrite files by default, but don't complain on failure
SetOverwrite try
SetShellVarContext all
; Copy data files
SetOutPath " $INSTDIR \data\ "
2015-12-27 14:25:55 +01:00
File /r ${PATH_ROOT} bin\ data\ *
2015-02-06 19:54:44 +00:00
; Copy the rest of the stuff
SetOutPath " $INSTDIR \ "
2015-10-20 20:16:30 +02:00
2015-02-06 19:54:44 +00:00
; Copy text files
File ..\ changelog.txt
Push " $INSTDIR \changelog.txt "
Call unix2dos
File ..\ ..\ licence.txt
Push " $INSTDIR \licence.txt "
Call unix2dos
File ..\ readme.txt
Push " $INSTDIR \readme.txt "
Call unix2dos
File ..\ ..\ contributors.md
Push " $INSTDIR \contributors.md "
Call unix2dos
; Copy executable
2016-08-25 22:17:15 +01:00
File /oname = ${OPENRCT2_EXE} ${BINARY_DIR} \ ${OPENRCT2_EXE}
2017-01-09 20:25:30 +00:00
File /oname = openrct2.com ${BINARY_DIR} \ openrct2.com
File /oname = openrct2.dll ${BINARY_DIR} \ openrct2.dll
2015-02-06 19:54:44 +00:00
; Create the Registry Entries
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " Comments " " Visit ${APPURLLINK} "
2016-08-25 22:17:15 +01:00
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " DisplayIcon " " $INSTDIR \${OPENRCT2_EXE},0 "
2015-02-06 19:54:44 +00:00
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " DisplayName " " OpenRCT2 ${APPVERSION} "
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " DisplayVersion " " ${APPVERSION} "
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " HelpLink " " ${APPURLLINK} "
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " Install Folder " " $INSTDIR "
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " Publisher " " OpenRCT2 "
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " Shortcut Folder " " $SHORTCUTS "
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " UninstallString " " $INSTDIR \uninstall.exe "
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " URLInfoAbout " " ${APPURLLINK} "
; This key sets the Version DWORD that new installers will check against
2015-02-23 01:30:16 +01:00
WriteRegStr HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " Version " " ${APPVERSIONINTERNAL} "
2015-02-06 19:54:44 +00:00
!insertmacro MUI_STARTMENU_WRITE_BEGIN " OpenRCT2 "
2016-08-25 22:17:15 +01:00
CreateShortCut " $DESKTOP \OpenRCT2.lnk " " $INSTDIR \${OPENRCT2_EXE} "
2015-02-06 19:54:44 +00:00
CreateDirectory " $SMPROGRAMS \$SHORTCUTS "
2016-08-25 22:17:15 +01:00
CreateShortCut " $SMPROGRAMS \$SHORTCUTS\OpenRCT2.lnk " " $INSTDIR \${OPENRCT2_EXE} "
2015-02-06 19:54:44 +00:00
CreateShortCut " $SMPROGRAMS \$SHORTCUTS\Uninstall.lnk " " $INSTDIR \uninstall.exe "
CreateShortCut " $SMPROGRAMS \$SHORTCUTS\Readme.lnk " " $INSTDIR \Readme.txt "
CreateShortCut " $SMPROGRAMS \$SHORTCUTS\Changelog.lnk " " $INSTDIR \Changelog.txt "
CreateShortCut " $SMPROGRAMS \$SHORTCUTS\Contributors.lnk " " $INSTDIR \contributors.md "
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
;-------------------------------------------
; Install the uninstaller (option is hidden)
Section - FinishSection
WriteUninstaller " $INSTDIR \uninstall.exe "
SectionEnd
; Modern install component descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} " Minimal OpenRCT2 installation in English. You must have RollerCoaster Tycoon 2 installed. "
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;-----------------------------------------------
; Uninstall section, deletes all installed files
Section " Uninstall "
SetShellVarContext all
; Remove from registry...
!insertmacro MUI_STARTMENU_GETFOLDER " OpenRCT2 " $SHORTCUTS
ReadRegStr $SHORTCUTS HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " Shortcut Folder "
DeleteRegKey HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 "
; Delete self
Delete " $INSTDIR \uninstall.exe "
; Delete Shortcuts
Delete " $DESKTOP \OpenRCT2.lnk "
Delete " $SMPROGRAMS \$SHORTCUTS\OpenRCT2.lnk "
Delete " $SMPROGRAMS \$SHORTCUTS\Uninstall.lnk "
Delete " $SMPROGRAMS \$SHORTCUTS\Readme.lnk "
Delete " $SMPROGRAMS \$SHORTCUTS\Changelog.lnk "
Delete " $SMPROGRAMS \$SHORTCUTS\Contributors.lnk "
; Clean up OpenRCT2 dir
Delete " $INSTDIR \changelog.txt "
2016-08-25 22:17:15 +01:00
Delete " $INSTDIR \licence.txt "
2015-02-06 19:54:44 +00:00
Delete " $INSTDIR \readme.txt "
Delete " $INSTDIR \contributors.md "
2016-08-25 22:17:15 +01:00
Delete " $INSTDIR \${OPENRCT2_EXE} "
2017-01-09 20:25:30 +00:00
Delete " $INSTDIR \openrct2.com "
Delete " $INSTDIR \openrct2.dll "
2015-02-06 19:54:44 +00:00
Delete " $INSTDIR \INSTALL.LOG "
; Data files
2016-08-25 22:17:15 +01:00
RMDir /r " $INSTDIR \data "
2015-02-06 19:54:44 +00:00
; Remove remaining directories
RMDir " $SMPROGRAMS \$SHORTCUTS "
RMDir " $INSTDIR "
SectionEnd
;-------------------------------------------------------------------------------
; Determine windows version, returns "win9x" if Win9x/Me/2000/XP SP2- or "winnt" for the rest on the stack
Function GetWindowsVersion
ClearErrors
StrCpy $R0 " win9x "
${If} ${RunningX64}
goto WinNT
${EndIf}
${If} ${IsNT}
${If} ${IsWinXP}
${AndIf} ${AtLeastServicePack} 3
${OrIf} ${AtLeastWin2003}
GoTo WinNT
${EndIf}
${EndIf}
GoTo Done
WinNT :
StrCpy $R0 " winnt "
Done :
Push $R0
FunctionEnd
;-------------------------------------------------------------------------------
; Check whether we're not running an installer for 64 bits on 32 bits and vice versa
Function CheckProcessorArchitecture
ClearErrors
${If} ${RunningX64}
IntCmp ${APPBITS} 64 Done 0
MessageBox MB_YESNO | MB_ICONINFORMATION " You are trying to install the 32-bit OpenRCT2 on a 64-bit operating system. This is not advised, but will work with reduced capabilities. We suggest that you download the correct version. Do you really want to continue? " IDYES Done IDNO Abort
${Else}
IntCmp ${APPBITS} 64 0 Done
MessageBox MB_YESNO | MB_ICONSTOP " You are trying to install the 64-bit OpenRCT2 on a 32-bit operating system. This is not going to work. Please download the correct version. Do you really want to continue? " IDYES Done IDNO Abort
${EndIf}
GoTo Done
Abort :
Quit
Done :
FunctionEnd
;-------------------------------------------------------------------------------
; Check whether we're not running an installer for NT on 9x and vice versa
Function CheckWindowsVersion
Call GetWindowsVersion
Pop $R0
StrCmp $R0 " win9x " 0 WinNT
ClearErrors
StrCmp ${APPARCH} " win9x " Done 0
MessageBox MB_YESNO | MB_ICONSTOP " You are trying to install the Windows XP SP3, Vista, 7 and 8.1 version on Windows 95, 98, ME, 2000 and XP without SP3. This is will not work. Please download the correct version. Do you really want to continue? " IDYES Done IDNO Abort
GoTo Done
WinNT :
ClearErrors
StrCmp ${APPARCH} " win9x " 0 Done
MessageBox MB_YESNO | MB_ICONEXCLAMATION " You are trying to install the Windows 95, 98, 2000 and XP without SP3 version on Windows XP SP3, Vista, 7 and 8.1. This is not advised, but will work with reduced capabilities. We suggest that you download the correct version. Do you really want to continue? " IDYES Done IDNO Abort
Abort :
Quit
Done :
FunctionEnd
;-------------------------------------------------------------------------------
; Check whether OpenRCT2 is running
Function CheckOpenRCT2Running
2016-08-25 22:17:15 +01:00
IfFileExists " $INSTDIR \${OPENRCT2_EXE} " 0 Done
2015-02-06 19:54:44 +00:00
Retry :
2016-08-25 22:17:15 +01:00
FindProcDLL :: FindProc " ${OPENRCT2_EXE} "
2015-02-06 19:54:44 +00:00
Pop $R0
IntCmp $R0 1 0 Done
ClearErrors
2016-08-25 22:17:15 +01:00
Delete " $INSTDIR \${OPENRCT2_EXE} "
2015-02-06 19:54:44 +00:00
IfErrors 0 Done
ClearErrors
MessageBox MB_RETRYCANCEL | MB_ICONEXCLAMATION " OpenRCT2 is running. Please close it and retry. " IDRETRY Retry
Abort
Done :
FunctionEnd
;-------------------------------------------------------------------------------
; strips all CRs
; and then converts all LFs into CRLFs
; (this is roughly equivalent to "cat file | dos2unix | unix2dos")
;
; usage:
; Push "infile"
; Call unix2dos
;
; beware that this function destroys $0 $1 $2
Function unix2dos
ClearErrors
Pop $2
Rename $2 $2 .U2D
FileOpen $1 $2 w
FileOpen $0 $2 .U2D r
Push $2 ; save name for deleting
IfErrors unix2dos_done
; $0 = file input (opened for reading)
; $1 = file output (opened for writing)
unix2dos_loop :
; read a byte (stored in $2)
FileReadByte $0 $2
IfErrors unix2dos_done ; EOL
; skip CR
StrCmp $2 13 unix2dos_loop
; if LF write an extra CR
StrCmp $2 10 unix2dos_cr unix2dos_write
unix2dos_cr :
FileWriteByte $1 13
unix2dos_write :
; write byte
FileWriteByte $1 $2
; read next byte
Goto unix2dos_loop
unix2dos_done :
; close files
FileClose $0
FileClose $1
; delete original
Pop $0
Delete $0 .U2D
FunctionEnd
2015-02-23 01:30:16 +01:00
;-----------------------------------------------------------------------------------
; Properly compare 2 versions
; syntax:
; ${VersionCompare} "[Version1]" "[Version2]" $var
; output:
; $var=0 Versions are equal
; $var=1 Version1 is newer
; $var=2 Version2 is newer
Function VersionCompare
2016-08-25 21:29:38 +01:00
!define VersionCompare ` !insertmacro VersionCompareCall `
!macro VersionCompareCall _VER1 _VER2 _RESULT
Push ` ${_VER1} `
Push ` ${_VER2} `
Call VersionCompare
Pop ${_RESULT}
!macroend
Exch $1
Exch
Exch $0
Exch
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7
begin :
StrCpy $2 - 1
IntOp $2 $2 + 1
StrCpy $3 $0 1 $2
StrCmp $3 '' + 2
StrCmp $3 '.' 0 - 3
StrCpy $4 $0 $2
IntOp $2 $2 + 1
StrCpy $0 $0 '' $2
StrCpy $2 - 1
IntOp $2 $2 + 1
StrCpy $3 $1 1 $2
StrCmp $3 '' + 2
StrCmp $3 '.' 0 - 3
StrCpy $5 $1 $2
IntOp $2 $2 + 1
StrCpy $1 $1 '' $2
StrCmp $4 $5 '' equal
StrCpy $6 - 1
IntOp $6 $6 + 1
StrCpy $3 $4 1 $6
StrCmp $3 '0' - 2
StrCmp $3 '' 0 + 2
StrCpy $4 0
StrCpy $7 - 1
IntOp $7 $7 + 1
StrCpy $3 $5 1 $7
StrCmp $3 '0' - 2
StrCmp $3 '' 0 + 2
StrCpy $5 0
StrCmp $4 0 0 + 2
StrCmp $5 0 begin newer2
StrCmp $5 0 newer1
IntCmp $6 $7 0 newer1 newer2
StrCpy $4 '1$4'
StrCpy $5 '1$5'
IntCmp $4 $5 begin newer2 newer1
equal :
StrCpy $0 0
goto end
newer1 :
StrCpy $0 1
goto end
newer2 :
StrCpy $0 2
end :
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
2015-02-23 01:30:16 +01:00
FunctionEnd
2015-02-06 19:54:44 +00:00
Var OLDVERSION
Var UninstallString
;-----------------------------------------------------------------------------------
; NSIS Initialize function, determine if we are going to install/upgrade or uninstall
Function .onInit
StrCpy $SHORTCUTS " OpenRCT2 "
SectionSetFlags 0 17
ShowWelcomeMessage :
ReadRegStr $R8 HKLM " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " Version "
IfErrors FinishCallback
WelcomeToSetup :
; An older version was found. Let's let the user know there's an upgrade that will take place.
ReadRegStr $OLDVERSION HKEY_LOCAL_MACHINE " SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2 " " DisplayVersion "
; Gets the older version then displays it in a message box
MessageBox MB_OK | MB_ICONINFORMATION \
" Welcome to ${APPNAMEANDVERSION} Setup.$\nThis will allow you to upgrade from version $OLDVERSION. "
Goto FinishCallback
FinishCallback :
ClearErrors
; Call CheckProcessorArchitecture
; Call CheckWindowsVersion
FunctionEnd
; eof