# Version numbers to update
!define APPV_MAJOR 1
!define APPV_MINOR 2
!define APPV_MAINT 0
!define APPV_BUILD 0
!define APPV_EXTRA "-alpha"
!define APPNAME "OpenTTD" ; Define application name
!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version
!define APPVERSIONINTERNAL "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}.${APPV_BUILD}" ; Define application version in X.X.X.X
!define INSTALLERVERSION ${APPV_MAJOR}${APPV_MINOR}${APPV_MAINT}${APPV_BUILD}
!include ${VERSION_INCLUDE}
!define APPURLLINK "http://www.openttd.org"
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}"
!define OPENGFX_BASE_VERSION "0.7.0"
!define OPENSFX_BASE_VERSION "0.8.0"
!define OPENMSX_BASE_VERSION "1.0.0"
!define MUI_ICON "..\..\..\media\openttd.ico"
!define MUI_UNICON "..\..\..\media\openttd.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP "welcome.bmp"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "top.bmp"
BrandingText "OpenTTD Installer"
SetCompressor LZMA
; Version Info
Var AddWinPrePopulate
VIProductVersion "${APPVERSIONINTERNAL}"
VIAddVersionKey "ProductName" "OpenTTD ${APPBITS}-bit Installer for Windows ${EXTRA_VERSION}"
VIAddVersionKey "Comments" "Installs ${APPNAMEANDVERSION}"
VIAddVersionKey "CompanyName" "OpenTTD Developers"
VIAddVersionKey "FileDescription" "Installs ${APPNAMEANDVERSION}"
VIAddVersionKey "ProductVersion" "${APPVERSION}"
VIAddVersionKey "InternalName" "InstOpenTTD-${APPARCH}"
VIAddVersionKey "FileVersion" "${APPVERSION}-${APPARCH}"
VIAddVersionKey "LegalCopyright" " "
; Main Install settings
Name "${APPNAMEANDVERSION} ${APPBITS}-bit for Windows ${EXTRA_VERSION}"
; NOTE: Keep trailing backslash!
InstallDirRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Install Folder"
OutFile "openttd-${APPVERSION}-${APPARCH}.exe"
CRCCheck force
ShowInstDetails show
ShowUninstDetails show
RequestExecutionLevel admin
Var SHORTCUTS
Var CDDRIVE
; Modern interface settings
!include "MUI2.nsh"
!include "InstallOptions.nsh"
!include "WinVer.nsh"
!define MUI_ABORTWARNING
!define MUI_WELCOMEPAGE_TITLE_3LINES
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "..\..\..\COPYING"
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_COMPONENTS
;---------------------------------
; Custom page for finding TTDLX CD
Page custom SelectCDEnter SelectCDExit ": TTD folder"
!insertmacro MUI_PAGE_DIRECTORY
;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\OpenTTD"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Shortcut Folder"
!insertmacro MUI_PAGE_STARTMENU "OpenTTD" $SHORTCUTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_TITLE_3LINES
!define MUI_FINISHPAGE_RUN_TEXT "Run ${APPNAMEANDVERSION} now!"
!define MUI_FINISHPAGE_RUN "$INSTDIR\openttd.exe"
!define MUI_FINISHPAGE_LINK "Visit the OpenTTD site for the latest news, FAQs and downloads"
!define MUI_FINISHPAGE_LINK "Visit the OpenTTD 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) OpenTTD install section. Copies all internal game data
Section "!OpenTTD" Section1
; Make sure to be upgraded OpenTTD is not running
Call CheckOpenTTDRunning
; Overwrite files by default, but don't complain on failure
SetOverwrite try
SetShellVarContext all
; Define root variable relative to installer
!define PATH_ROOT "..\..\..\"
; Copy language files
SetOutPath "$INSTDIR\lang\"
File ${PATH_ROOT}bin\lang\english.lng
; Copy AI files
SetOutPath "$INSTDIR\ai\"
File ${PATH_ROOT}bin\ai\compat_*.nut
; Copy data files
SetOutPath "$INSTDIR\baseset\"
File ${PATH_ROOT}bin\baseset\*.grf
File ${PATH_ROOT}bin\baseset\*.obg
File ${PATH_ROOT}bin\baseset\*.obm
File ${PATH_ROOT}bin\baseset\*.obs
File ${PATH_ROOT}bin\baseset\opntitle.dat
; Copy the scripts
SetOutPath "$INSTDIR\scripts\"
File ${PATH_ROOT}bin\scripts\*.*
Push "$INSTDIR\scripts\readme.txt"
Call unix2dos
; Copy some documention files
SetOutPath "$INSTDIR\docs\"
File ${PATH_ROOT}docs\multiplayer.txt
Push "$INSTDIR\docs\multiplayer.txt"
File ${PATH_ROOT}docs\32bpp.txt
Push "$INSTDIR\docs\32bpp.txt"
; Copy the rest of the stuff
SetOutPath "$INSTDIR\"
; Copy text files
File ${PATH_ROOT}changelog.txt
Push "$INSTDIR\changelog.txt"
File ${PATH_ROOT}COPYING
Push "$INSTDIR\COPYING"
File ${PATH_ROOT}readme.txt
Push "$INSTDIR\readme.txt"
File ${PATH_ROOT}known-bugs.txt
Push "$INSTDIR\known-bugs.txt"
; Copy executable
File /oname=openttd.exe ${BINARY_DIR}\openttd.exe
; Delete old files from the main dir. they are now placed in baseset/ and lang/
Delete "$INSTDIR\*.lng"
Delete "$INSTDIR\*.grf"
Delete "$INSTDIR\sample.cat"
Delete "$INSTDIR\ttd.exe"
Delete "$INSTDIR\data\opntitle.dat"
Delete "$INSTDIR\data\2ccmap.grf"
Delete "$INSTDIR\data\airports.grf"
Delete "$INSTDIR\data\autorail.grf"
Delete "$INSTDIR\data\canalsw.grf"
Delete "$INSTDIR\data\dosdummy.grf"
Delete "$INSTDIR\data\elrailsw.grf"
Delete "$INSTDIR\data\nsignalsw.grf"
Delete "$INSTDIR\data\openttd.grf"
Delete "$INSTDIR\data\roadstops.grf"
Delete "$INSTDIR\data\trkfoundw.grf"
Delete "$INSTDIR\data\openttdd.grf"
Delete "$INSTDIR\data\openttdw.grf"
Delete "$INSTDIR\data\orig_win.obg"
Delete "$INSTDIR\data\orig_dos.obg"
Delete "$INSTDIR\data\orig_dos_de.obg"
Delete "$INSTDIR\data\orig_win.obs"
Delete "$INSTDIR\data\orig_dos.obs"
Delete "$INSTDIR\data\no_sound.obs"
; Create the Registry Entries
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Comments" "Visit ${APPURLLINK}"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "DisplayIcon" "$INSTDIR\openttd.exe,0"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "DisplayName" "OpenTTD ${APPVERSION}"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "DisplayVersion" "${APPVERSION}"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "HelpLink" "${APPURLLINK}"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Install Folder" "$INSTDIR"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Publisher" "OpenTTD"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Shortcut Folder" "$SHORTCUTS"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "URLInfoAbout" "${APPURLLINK}"
; This key sets the Version DWORD that new installers will check against
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Version" ${INSTALLERVERSION}
!insertmacro MUI_STARTMENU_WRITE_BEGIN "OpenTTD"
CreateShortCut "$DESKTOP\OpenTTD.lnk" "$INSTDIR\openttd.exe"
CreateDirectory "$SMPROGRAMS\$SHORTCUTS"
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\OpenTTD.lnk" "$INSTDIR\openttd.exe"
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\Known-bugs.lnk" "$INSTDIR\known-bugs.txt"
CreateDirectory "$SMPROGRAMS\$SHORTCUTS\Docs"
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Docs\Multiplayer.lnk" "$INSTDIR\docs\multiplayer.txt"
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Docs\32bpp.lnk" "$INSTDIR\docs\32bpp.txt"
CreateDirectory "$SMPROGRAMS\$SHORTCUTS\Scripts"
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Scripts\Readme.lnk" "$INSTDIR\scripts\readme.txt"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
; OpenTTD translation install section. Copies only translations
Section "OpenTTD translations" Section6
File ${PATH_ROOT}bin\lang\*.lng
;----------------------------------------------------------------------------------
; OpenGFX files install section. Downloads OpenGFX and installs it
Section "Download OpenGFX (free graphics set)" Section3
NSISdl::download "http://binaries.openttd.org/installer/opengfx-${OPENGFX_BASE_VERSION}.7z" "$INSTDIR\baseset\opengfx.7z"
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Downloading of OpenGFX failed"
Goto Done
; Let's extract the files
NSIS7z::Extract "$INSTDIR\baseset\opengfx.7z"
Delete "$INSTDIR\baseset\opengfx.7z"
Done:
; OpenSFX files install section. Downloads OpenSFX and installs it
Section "Download OpenSFX (free sound set)" Section4
NSISdl::download "http://binaries.openttd.org/installer/opensfx-${OPENSFX_BASE_VERSION}.7z" "$INSTDIR\baseset\opensfx.7z"
MessageBox MB_OK "Downloading of OpenSFX failed"
NSIS7z::Extract "$INSTDIR\baseset\opensfx.7z"
Delete "$INSTDIR\baseset\opensfx.7z"
; OpenMSX files install section. Downloads OpenMSX and installs it
Section "Download OpenMSX (free music set)" Section5
Status change: