2009-12-14 18:20:42 +00:00
# Version numbers to update
2009-12-23 23:09:47 +00:00
!define APPV_MAJOR 1
2010-02-17 15:31:46 +00:00
!define APPV_MINOR 1
2009-12-14 18:20:42 +00:00
!define APPV_MAINT 0
2010-02-17 15:31:46 +00:00
!define APPV_BUILD 0
!define APPV_EXTRA "-alpha"
2009-12-14 18:20:42 +00:00
2007-02-27 16:51:49 +00:00
!define APPNAME "OpenTTD" ; Define application name
2009-12-14 18:20:42 +00:00
!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}
2008-08-15 12:47:20 +00:00
!include ${VERSION_INCLUDE}
2007-02-27 16:51:49 +00:00
!define APPURLLINK "http://www.openttd.org"
2008-06-19 11:45:44 +00:00
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}"
2007-02-27 16:51:49 +00:00
2009-08-15 20:32:57 +00:00
!define OPENGFX_BASE_VERSION "0.7.0"
!define OPENSFX_BASE_VERSION "0.8.0"
2010-02-23 17:39:07 +00:00
!define OPENMSX_BASE_VERSION "1.0.0"
2009-08-15 20:32:57 +00:00
2007-02-27 17:04:22 +00:00
!define MUI_ICON "..\..\..\media\openttd.ico"
!define MUI_UNICON "..\..\..\media\openttd.ico"
2005-01-29 16:47:19 +00:00
!define MUI_WELCOMEFINISHPAGE_BITMAP "welcome.bmp"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "top.bmp"
2004-08-09 17:04:08 +00:00
BrandingText "OpenTTD Installer"
2005-01-29 16:47:19 +00:00
SetCompressor LZMA
2004-08-09 17:04:08 +00:00
; Version Info
Var AddWinPrePopulate
2007-02-27 16:51:49 +00:00
VIProductVersion "${APPVERSIONINTERNAL}"
2009-12-29 19:47:57 +00:00
VIAddVersionKey "ProductName" "OpenTTD ${APPBITS}-bit Installer for Windows ${EXTRA_VERSION}"
2004-08-09 17:04:08 +00:00
VIAddVersionKey "Comments" "Installs ${APPNAMEANDVERSION}"
VIAddVersionKey "CompanyName" "OpenTTD Developers"
VIAddVersionKey "FileDescription" "Installs ${APPNAMEANDVERSION}"
VIAddVersionKey "ProductVersion" "${APPVERSION}"
2008-08-15 12:47:20 +00:00
VIAddVersionKey "InternalName" "InstOpenTTD-${APPARCH}"
VIAddVersionKey "FileVersion" "${APPVERSION}-${APPARCH}"
2004-08-09 17:04:08 +00:00
VIAddVersionKey "LegalCopyright" " "
; Main Install settings
2009-12-29 19:47:57 +00:00
Name "${APPNAMEANDVERSION} ${APPBITS}-bit for Windows ${EXTRA_VERSION}"
2004-08-09 17:04:08 +00:00
; NOTE: Keep trailing backslash!
InstallDirRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Install Folder"
2008-08-15 12:47:20 +00:00
OutFile "openttd-${APPVERSION}-${APPARCH}.exe"
2005-01-29 16:47:19 +00:00
CRCCheck force
2004-08-09 17:04:08 +00:00
ShowInstDetails show
ShowUninstDetails show
Var SHORTCUTS
Var CDDRIVE
; Modern interface settings
2009-12-14 18:20:42 +00:00
!include "MUI2.nsh"
!include "InstallOptions.nsh"
2004-08-09 17:04:08 +00:00
!define MUI_ABORTWARNING
2008-08-15 12:47:20 +00:00
!define MUI_WELCOMEPAGE_TITLE_3LINES
2004-08-09 17:04:08 +00:00
!insertmacro MUI_PAGE_WELCOME
2005-01-29 16:47:19 +00:00
!insertmacro MUI_PAGE_LICENSE "..\..\..\COPYING"
2004-08-09 17:04:08 +00:00
2009-12-14 18:20:42 +00:00
!define MUI_COMPONENTSPAGE_SMALLDESC
2004-08-09 17:04:08 +00:00
!insertmacro MUI_PAGE_COMPONENTS
2007-02-27 16:51:49 +00:00
;---------------------------------
; Custom page for finding TTDLX CD
Page custom SelectCDEnter SelectCDExit ": TTD folder"
2004-08-09 17:04:08 +00:00
!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
2008-08-15 12:47:20 +00:00
!define MUI_FINISHPAGE_TITLE_3LINES
!define MUI_FINISHPAGE_RUN_TEXT "Run ${APPNAMEANDVERSION} now!"
2007-02-27 16:51:49 +00:00
!define MUI_FINISHPAGE_RUN "$INSTDIR\openttd.exe"
2009-12-29 19:47:57 +00:00
!define MUI_FINISHPAGE_LINK "Visit the OpenTTD site for the latest news, FAQs and downloads"
2007-02-27 16:51:49 +00:00
!define MUI_FINISHPAGE_LINK_LOCATION "${APPURLLINK}"
2004-08-09 17:04:08 +00:00
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\readme.txt"
2005-05-15 21:50:26 +00:00
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
2007-05-29 19:01:38 +00:00
!define MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT DisableBack
2004-08-09 17:04:08 +00:00
!insertmacro MUI_PAGE_FINISH
2008-08-15 12:47:20 +00:00
!define MUI_PAGE_HEADER_TEXT "Uninstall ${APPNAMEANDVERSION}"
2004-08-09 17:04:08 +00:00
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
; Set languages (first is default language)
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL
2007-02-27 16:51:49 +00:00
;--------------------------------------------------------------
; (Core) OpenTTD install section. Copies all internal game data
2004-08-09 17:04:08 +00:00
Section "!OpenTTD" Section1
2007-02-27 16:51:49 +00:00
; Overwrite files by default, but don't complain on failure
2004-08-09 17:04:08 +00:00
SetOverwrite try
2007-02-27 16:51:49 +00:00
; Define root variable relative to installer
2004-08-09 17:04:08 +00:00
!define PATH_ROOT "..\..\..\"
; Copy language files
2007-02-27 16:51:49 +00:00
SetOutPath "$INSTDIR\lang\"
2009-12-14 18:20:42 +00:00
File ${PATH_ROOT}bin\lang\english.lng
2004-08-09 17:04:08 +00:00
2009-08-22 16:07:39 +00:00
; Copy AI files
SetOutPath "$INSTDIR\ai\"
File ${PATH_ROOT}bin\ai\compat_*.nut
2004-08-09 17:04:08 +00:00
; Copy data files
SetOutPath "$INSTDIR\data\"
2007-02-27 17:04:22 +00:00
File ${PATH_ROOT}bin\data\*.grf
2008-08-31 19:46:04 +00:00
File ${PATH_ROOT}bin\data\*.obg
2009-08-09 19:50:44 +00:00
File ${PATH_ROOT}bin\data\*.obs
2007-02-27 17:04:22 +00:00
File ${PATH_ROOT}bin\data\opntitle.dat
2007-02-27 22:11:12 +00:00
2009-12-22 21:40:29 +00:00
; Copy the music base metadata files
SetOutPath "$INSTDIR\gm\"
File ${PATH_ROOT}bin\gm\*.obm
2008-11-16 13:05:39 +00:00
; Copy the scripts
SetOutPath "$INSTDIR\scripts\"
File ${PATH_ROOT}bin\scripts\*.*
2010-01-03 22:10:17 +00:00
; Copy some documention files
SetOutPath "$INSTDIR\docs\"
File ${PATH_ROOT}docs\multiplayer.txt
File ${PATH_ROOT}docs\32bpp.txt
2004-08-09 17:04:08 +00:00
; Copy the rest of the stuff
SetOutPath "$INSTDIR\"
2007-02-27 16:51:49 +00:00
; Copy text files
File ${PATH_ROOT}changelog.txt
File ${PATH_ROOT}COPYING
File ${PATH_ROOT}readme.txt
File ${PATH_ROOT}known-bugs.txt
2004-08-09 17:04:08 +00:00
; Copy executable
2008-08-15 12:47:20 +00:00
File /oname=openttd.exe ${BINARY_DIR}\openttd.exe
2004-08-09 17:04:08 +00:00
2007-02-27 16:51:49 +00:00
; Delete old files from the main dir. they are now placed in data/ and lang/
2004-08-09 17:04:08 +00:00
Delete "$INSTDIR\*.lng"
Delete "$INSTDIR\*.grf"
Delete "$INSTDIR\sample.cat"
Delete "$INSTDIR\ttd.exe"
2007-02-27 16:51:49 +00:00
; Create the Registry Entries
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Comments" "Visit ${APPURLLINK}"
2005-01-29 16:47:19 +00:00
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "DisplayIcon" "$INSTDIR\openttd.exe,0"
2004-08-09 17:04:08 +00:00
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}"
2007-02-27 16:51:49 +00:00
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "HelpLink" "${APPURLLINK}"
2004-08-09 17:04:08 +00:00
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"
2007-02-27 16:51:49 +00:00
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "URLInfoAbout" "${APPURLLINK}"
; This key sets the Version DWORD that new installers will check against
2004-08-09 17:04:08 +00:00
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"
2004-12-24 00:00:10 +00:00
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Known-bugs.lnk" "$INSTDIR\known-bugs.txt"
2004-08-09 17:04:08 +00:00
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
2009-12-14 18:20:42 +00:00
;--------------------------------------------------------------
; OpenTTD translation install section. Copies only translations
Section "OpenTTD translations" Section6
; Overwrite files by default, but don't complain on failure
SetOverwrite try
; Copy language files
SetOutPath "$INSTDIR\lang\"
File ${PATH_ROOT}bin\lang\*.lng
SectionEnd
2009-08-15 20:32:57 +00:00
;----------------------------------------------------------------------------------
; OpenGFX files install section. Downloads OpenGFX and installs it
2009-12-14 18:20:42 +00:00
Section "Download OpenGFX (free graphics set)" Section3
2009-08-15 20:32:57 +00:00
SetOverwrite try
2009-12-15 14:29:47 +00:00
NSISdl::download "http://binaries.openttd.org/installer/opengfx-${OPENGFX_BASE_VERSION}.7z" "$INSTDIR\data\opengfx.7z"
2009-08-15 20:32:57 +00:00
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Downloading of OpenGFX failed"
Goto Done
; Let's extract the files
SetOutPath "$INSTDIR\data\"
2009-12-15 14:29:47 +00:00
NSIS7z::Extract "$INSTDIR\data\opengfx.7z"
2009-08-15 20:32:57 +00:00
2009-12-15 14:29:47 +00:00
Delete "$INSTDIR\data\opengfx.7z"
2009-08-15 20:32:57 +00:00
SetOutPath "$INSTDIR\"
Done:
SectionEnd
;----------------------------------------------------------------------------------
; OpenSFX files install section. Downloads OpenSFX and installs it
2009-12-14 18:20:42 +00:00
Section "Download OpenSFX (free sound set)" Section4
2009-08-15 20:32:57 +00:00
SetOverwrite try
2009-12-15 14:29:47 +00:00
NSISdl::download "http://binaries.openttd.org/installer/opensfx-${OPENSFX_BASE_VERSION}.7z" "$INSTDIR\data\opensfx.7z"
2009-08-15 20:32:57 +00:00
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Downloading of OpenSFX failed"
Goto Done
; Let's extract the files
SetOutPath "$INSTDIR\data\"
2009-12-15 14:29:47 +00:00
NSIS7z::Extract "$INSTDIR\data\opensfx.7z"
2009-08-15 20:32:57 +00:00
2009-12-15 14:29:47 +00:00
Delete "$INSTDIR\data\opensfx.7z"
2009-08-15 20:32:57 +00:00
SetOutPath "$INSTDIR\"
Done:
SectionEnd
2009-12-14 18:20:42 +00:00
;----------------------------------------------------------------------------------
2010-02-23 17:39:07 +00:00
; OpenMSX files install section. Downloads OpenMSX and installs it
Section "Download OpenMSX (free music set)" Section5
2009-12-14 18:20:42 +00:00
SetOverwrite try
2010-02-23 17:39:07 +00:00
NSISdl::download "http://binaries.openttd.org/installer/openmsx-${OPENMSX_BASE_VERSION}.7z" "$INSTDIR\gm\openmsx.7z"
2009-12-14 18:20:42 +00:00
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
2010-02-23 17:39:07 +00:00
MessageBox MB_OK "Downloading of OpenMSX failed"
2009-12-14 18:20:42 +00:00
Goto Done
; Let's extract the files
2010-02-23 17:39:07 +00:00
SetOutPath "$INSTDIR\gm\"
NSIS7z::Extract "$INSTDIR\gm\openmsx.7z"
2009-12-14 18:20:42 +00:00
2010-02-23 17:39:07 +00:00
Delete "$INSTDIR\gm\openmsx.7z"
2009-12-14 18:20:42 +00:00
SetOutPath "$INSTDIR\"
Done:
SectionEnd
2007-02-27 16:51:49 +00:00
;----------------------------------------------------------------------------------
; TTDLX files install section. Copies all needed TTDLX files from CD or install dir
2009-12-14 18:20:42 +00:00
Section /o "Copy data from Transport Tycoon Deluxe CD-ROM" Section2
2009-08-15 20:32:57 +00:00
SetOverwrite try
2007-02-27 16:51:49 +00:00
; Let's copy the files with size approximation
2004-08-09 17:04:08 +00:00
SetOutPath "$INSTDIR\gm"
2007-02-27 16:51:49 +00:00
CopyFiles "$CDDRIVE\gm\*.gm" "$INSTDIR\gm\" 1028
2004-08-09 17:04:08 +00:00
SetOutPath "$INSTDIR\data\"
CopyFiles "$CDDRIVE\sample.cat" "$INSTDIR\data\sample.cat" 1566
2007-02-27 16:51:49 +00:00
; Copy Windows files
2004-08-09 17:04:08 +00:00
CopyFiles "$CDDRIVE\trg1r.grf" "$INSTDIR\data\trg1r.grf" 2365
CopyFiles "$CDDRIVE\trgcr.grf" "$INSTDIR\data\trgcr.grf" 260
CopyFiles "$CDDRIVE\trghr.grf" "$INSTDIR\data\trghr.grf" 400
CopyFiles "$CDDRIVE\trgir.grf" "$INSTDIR\data\trgir.grf" 334
CopyFiles "$CDDRIVE\trgtr.grf" "$INSTDIR\data\trgtr.grf" 546
2005-01-29 16:47:19 +00:00
; Copy DOS files
CopyFiles "$CDDRIVE\trg1.grf" "$INSTDIR\data\trg1.grf" 2365
CopyFiles "$CDDRIVE\trgc.grf" "$INSTDIR\data\trgc.grf" 260
CopyFiles "$CDDRIVE\trgh.grf" "$INSTDIR\data\trgh.grf" 400
CopyFiles "$CDDRIVE\trgi.grf" "$INSTDIR\data\trgi.grf" 334
CopyFiles "$CDDRIVE\trgt.grf" "$INSTDIR\data\trgt.grf" 546
2004-08-09 17:04:08 +00:00
SetOutPath "$INSTDIR\"
SectionEnd
2007-02-27 16:51:49 +00:00
;-------------------------------------------
; Install the uninstaller (option is hidden)
2004-08-09 17:04:08 +00:00
Section -FinishSection
WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd
; Modern install component descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
2009-12-14 18:20:42 +00:00
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} "Minimal OpenTTD installation in English. You need at least one of the game graphics and sound sets installed."
!insertmacro MUI_DESCRIPTION_TEXT ${Section6} "Translations of OpenTTD."
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} "Download the free OpenGFX game graphics set. This download is about 3 MiB."
2009-12-23 23:00:23 +00:00
!insertmacro MUI_DESCRIPTION_TEXT ${Section4} "Download the free OpenSFX game sound set. This download is about 10 MiB."
2010-02-23 17:39:07 +00:00
!insertmacro MUI_DESCRIPTION_TEXT ${Section5} "Download the free OpenMSX game music set. This download is about 200 KiB."
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} "Copies the game graphics, sounds and music from the Transport Tycoon Deluxe CD."
2004-08-09 17:04:08 +00:00
!insertmacro MUI_FUNCTION_DESCRIPTION_END
2007-02-27 16:51:49 +00:00
;-----------------------------------------------
; Uninstall section, deletes all installed files
Section "Uninstall"
MessageBox MB_YESNO|MB_ICONQUESTION \
"Remove the save game folders located at $\"$INSTDIR\save?$\"$\n \
If you choose Yes, your saved games will be deleted." \
IDYES RemoveSavedGames IDNO NoRemoveSavedGames
2004-08-09 17:04:08 +00:00
RemoveSavedGames:
2007-02-27 16:51:49 +00:00
Delete "$INSTDIR\save\autosave\*"
RMDir "$INSTDIR\save\autosave"
Delete "$INSTDIR\save\*"
RMDir "$INSTDIR\save"
2004-08-09 17:04:08 +00:00
NoRemoveSavedGames:
2007-02-27 16:51:49 +00:00
MessageBox MB_YESNO|MB_ICONQUESTION \
"Remove the scenario folders located at $\"$INSTDIR\scenario?$\"$\n \
If you choose Yes, your scenarios will be deleted." \
IDYES RemoveScen IDNO NoRemoveScen
2004-08-12 21:46:56 +00:00
RemoveScen:
2007-02-27 22:11:12 +00:00
Delete "$INSTDIR\scenario\heightmap*"
RMDir "$INSTDIR\scenario\heightmap"
2007-02-27 16:51:49 +00:00
Delete "$INSTDIR\scenario\*"
RMDir "$INSTDIR\scenario"
2004-08-12 21:46:56 +00:00
NoRemoveScen:
2007-02-27 16:51:49 +00:00
; Remove from registry...
2004-08-09 17:04:08 +00:00
!insertmacro MUI_STARTMENU_GETFOLDER "OpenTTD" $SHORTCUTS
ReadRegStr $SHORTCUTS HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Shortcut Folder"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD"
; Delete self
Delete "$INSTDIR\uninstall.exe"
; Delete Shortcuts
Delete "$DESKTOP\OpenTTD.lnk"
Delete "$SMPROGRAMS\$SHORTCUTS\OpenTTD.lnk"
Delete "$SMPROGRAMS\$SHORTCUTS\Uninstall.lnk"
Delete "$SMPROGRAMS\$SHORTCUTS\Readme.lnk"
Delete "$SMPROGRAMS\$SHORTCUTS\Changelog.lnk"
2004-12-24 00:00:10 +00:00
Delete "$SMPROGRAMS\$SHORTCUTS\Known-bugs.lnk"
2004-08-09 17:04:08 +00:00
; Clean up OpenTTD dir
Delete "$INSTDIR\changelog.txt"
Delete "$INSTDIR\readme.txt"
2004-12-24 00:00:10 +00:00
Delete "$INSTDIR\known-bugs.txt"
2004-08-09 17:04:08 +00:00
Delete "$INSTDIR\openttd.exe"
2004-09-14 18:19:29 +00:00
Delete "$INSTDIR\COPYING"
2004-08-09 17:04:08 +00:00
Delete "$INSTDIR\INSTALL.LOG"
Delete "$INSTDIR\crash.log"
2008-08-15 12:47:20 +00:00
Delete "$INSTDIR\crash.dmp"
2004-08-09 17:04:08 +00:00
Delete "$INSTDIR\openttd.cfg"
2005-01-25 15:43:27 +00:00
Delete "$INSTDIR\hs.dat"
2005-05-17 20:59:29 +00:00
Delete "$INSTDIR\cached_sprites.*"
2004-12-24 00:00:10 +00:00
Delete "$INSTDIR\save\autosave\network*.tmp" ; temporary network file
2004-08-09 17:04:08 +00:00
2009-08-22 16:07:39 +00:00
; AI files
Delete "$INSTDIR\ai\compat_*.nut"
2004-08-09 17:04:08 +00:00
; Data files
Delete "$INSTDIR\data\opntitle.dat"
2007-02-27 16:51:49 +00:00
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"
2006-01-31 22:26:00 +00:00
Delete "$INSTDIR\data\nsignalsw.grf"
2004-08-09 17:04:08 +00:00
Delete "$INSTDIR\data\openttd.grf"
2007-02-27 17:04:22 +00:00
Delete "$INSTDIR\data\roadstops.grf"
2004-09-14 18:19:29 +00:00
Delete "$INSTDIR\data\trkfoundw.grf"
2008-08-15 12:47:20 +00:00
Delete "$INSTDIR\data\openttdd.grf"
Delete "$INSTDIR\data\openttdw.grf"
2008-08-31 19:46:04 +00:00
Delete "$INSTDIR\data\orig_win.obg"
Delete "$INSTDIR\data\orig_dos.obg"
Delete "$INSTDIR\data\orig_dos_de.obg"
2009-08-09 19:50:44 +00:00
Delete "$INSTDIR\data\orig_win.obs"
Delete "$INSTDIR\data\orig_dos.obs"
2010-02-23 17:39:07 +00:00
Delete "$INSTDIR\data\no_sound.obs"
2007-02-27 16:51:49 +00:00
2005-01-29 16:47:19 +00:00
Delete "$INSTDIR\data\sample.cat"
2007-02-27 16:51:49 +00:00
; Windows Data files
2004-08-09 17:04:08 +00:00
Delete "$INSTDIR\data\trg1r.grf"
Delete "$INSTDIR\data\trghr.grf"
Delete "$INSTDIR\data\trgtr.grf"
Delete "$INSTDIR\data\trgcr.grf"
Delete "$INSTDIR\data\trgir.grf"
2005-01-29 16:47:19 +00:00
; Dos Data files
Delete "$INSTDIR\data\trg1.grf"
Delete "$INSTDIR\data\trgh.grf"
Delete "$INSTDIR\data\trgt.grf"
Delete "$INSTDIR\data\trgc.grf"
Delete "$INSTDIR\data\trgi.grf"
2004-08-09 17:04:08 +00:00
2007-02-27 16:51:49 +00:00
; Music
2004-08-09 17:04:08 +00:00
Delete "$INSTDIR\gm\*.gm"
2010-02-23 17:39:07 +00:00
; Downloaded OpenGFX/OpenSFX/OpenMSX
2009-12-15 14:29:47 +00:00
Delete "$INSTDIR\data\opengfx\*"
RMDir "$INSTDIR\data\opengfx"
Delete "$INSTDIR\data\opensfx\*"
RMDir "$INSTDIR\data\opensfx"
2010-02-23 17:39:07 +00:00
Delete "$INSTDIR\gm\openmsx\*"
RMDir "$INSTDIR\gm\openmsx"
2009-08-15 20:32:57 +00:00
2007-02-27 16:51:49 +00:00
; Language files
2004-08-09 17:04:08 +00:00
Delete "$INSTDIR\lang\*.lng"
2008-11-16 13:05:39 +00:00
; Scripts
2008-11-16 20:15:37 +00:00
Delete "$INSTDIR\scripts\*.*"
2008-11-16 13:05:39 +00:00
2010-01-03 22:10:17 +00:00
; Documentation
Delete "$INSTDIR\docs\*.*"
2009-12-22 21:40:29 +00:00
; Base sets for music
2009-12-23 23:00:23 +00:00
Delete "$INSTDIR\gm\orig_win.obm"
Delete "$INSTDIR\gm\no_music.obm"
2009-12-22 21:40:29 +00:00
2004-08-09 17:04:08 +00:00
; Remove remaining directories
RMDir "$SMPROGRAMS\$SHORTCUTS\Extras\"
RMDir "$SMPROGRAMS\$SHORTCUTS"
2009-12-15 14:29:47 +00:00
RMDir "$INSTDIR\ai"
RMDir "$INSTDIR\data"
2004-08-09 17:04:08 +00:00
RMDir "$INSTDIR\gm"
RMDir "$INSTDIR\lang"
2009-12-15 14:29:47 +00:00
RMDir "$INSTDIR\scripts"
2010-01-03 22:10:17 +00:00
RMDir "$INSTDIR\docs"
2004-08-09 17:04:08 +00:00
RMDir "$INSTDIR"
2007-02-27 16:51:49 +00:00
2004-08-09 17:04:08 +00:00
SectionEnd
2007-02-27 16:51:49 +00:00
;------------------------------------------------------------
; Custom page function to find the TTDLX CD/install location
Function SelectCDEnter
2004-08-09 17:04:08 +00:00
SectionGetFlags ${Section2} $0
2004-12-24 00:00:10 +00:00
IntOp $1 $0 & 0x80 ; bit 7 set by upgrade, no need to copy files
2007-02-27 16:51:49 +00:00
IntCmp $1 1 DoneCD ; Upgrade doesn't need copy files
2005-01-29 16:47:19 +00:00
2004-08-09 17:04:08 +00:00
IntOp $0 $0 & 1
IntCmp $0 1 NoAbort
2007-02-27 16:51:49 +00:00
Abort
2004-08-09 17:04:08 +00:00
NoAbort:
GetTempFileName $R0
!insertmacro MUI_HEADER_TEXT "Locate TTD" "Setup needs the location of Transport Tycoon Deluxe in order to continue."
2009-12-14 18:20:42 +00:00
!insertmacro INSTALLOPTIONS_EXTRACT_AS "CDFinder.ini" "CDFinder"
2007-02-27 16:51:49 +00:00
2004-08-09 17:04:08 +00:00
ClearErrors
2007-02-27 16:51:49 +00:00
; Now, let's populate $CDDRIVE
ReadRegStr $R0 HKLM "SOFTWARE\Fish Technology Group\Transport Tycoon Deluxe" "HDPath"
2004-08-09 17:04:08 +00:00
IfErrors NoTTD
2007-02-27 16:51:49 +00:00
StrCmp $CDDRIVE "" 0 Populated
StrCpy $CDDRIVE $R0
Populated:
StrCpy $AddWinPrePopulate "Setup has detected your TTD folder. Don't change the folder. Simply press Next."
2004-08-09 17:04:08 +00:00
Goto TruFinish
NoTTD:
2007-02-27 16:51:49 +00:00
StrCpy $AddWinPrePopulate "Setup couldn't find TTD. Please enter the path where the graphics files from TTD are stored and press Next to continue."
2004-08-09 17:04:08 +00:00
TruFinish:
ClearErrors
2009-12-14 18:20:42 +00:00
!insertmacro INSTALLOPTIONS_WRITE "CDFinder" "Field 2" "State" $CDDRIVE ; TTDLX path
!insertmacro INSTALLOPTIONS_WRITE "CDFinder" "Field 3" "Text" $AddWinPrePopulate ; Caption
2004-12-24 00:00:10 +00:00
DoneCD:
2007-02-27 16:51:49 +00:00
; Initialize the dialog *AFTER* we've changed the text otherwise we won't see the changes
2009-12-14 18:20:42 +00:00
!insertmacro INSTALLOPTIONS_INITDIALOG "CDFinder"
!insertmacro INSTALLOPTIONS_SHOW
2004-08-09 17:04:08 +00:00
FunctionEnd
2007-02-27 16:51:49 +00:00
;----------------------------------------------------------------
; Custom page function when 'next' is selected for the TTDLX path
Function SelectCDExit
2009-12-14 18:20:42 +00:00
!insertmacro INSTALLOPTIONS_READ $CDDRIVE "CDFinder" "Field 2" "State"
2007-02-27 16:51:49 +00:00
; If trg1r.grf does not exist at the path, retry with DOS version
IfFileExists $CDDRIVE\trg1r.grf "" DosCD
IfFileExists $CDDRIVE\trgir.grf "" NoCD
IfFileExists $CDDRIVE\sample.cat hasCD NoCD
DosCD:
IfFileExists $CDDRIVE\TRG1.GRF "" NoCD
IfFileExists $CDDRIVE\TRGI.GRF "" NoCD
IfFileExists $CDDRIVE\SAMPLE.CAT hasCD NoCD
2004-08-09 17:04:08 +00:00
NoCD:
2009-12-29 19:47:57 +00:00
MessageBox MB_OK "Setup cannot continue without the Transport Tycoon Deluxe location!"
2007-02-27 16:51:49 +00:00
Abort
2004-08-09 17:04:08 +00:00
hasCD:
FunctionEnd
2007-02-27 16:51:49 +00:00
;-------------------------------------------------------------------------------
; Determine windows version, returns "win9x" if Win9x/Me or "winnt" on the stack
Function GetWindowsVersion
ClearErrors
StrCpy $R0 "winnt"
2008-08-15 23:00:56 +00:00
GetVersion::WindowsPlatformId
Pop $R0
IntCmp $R0 2 WinNT 0
2007-02-27 16:51:49 +00:00
StrCpy $R0 "win9x"
WinNT:
ClearErrors
Push $R0
FunctionEnd
2004-08-09 17:04:08 +00:00
2008-08-15 12:47:20 +00:00
;-------------------------------------------------------------------------------
; Check whether we're not running an installer for 64 bits on 32 bits and vice versa
Function CheckProcessorArchitecture
2008-08-15 23:00:56 +00:00
GetVersion::WindowsPlatformArchitecture
Pop $R0
IntCmp $R0 64 Win64 0
2008-08-15 12:47:20 +00:00
ClearErrors
IntCmp ${APPBITS} 64 0 Done
2009-12-29 19:47:57 +00:00
MessageBox MB_OKCANCEL|MB_ICONSTOP "You are trying to install the 64-bit OpenTTD on a 32-bit operating system. This is not going to work. Please download the correct version. Do you really want to continue?" IDOK Done IDCANCEL Abort
2008-08-15 12:47:20 +00:00
GoTo Done
Win64:
ClearErrors
IntCmp ${APPBITS} 64 Done 0
2009-12-29 19:47:57 +00:00
MessageBox MB_OKCANCEL|MB_ICONINFORMATION "You are trying to install the 32-bit OpenTTD 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?" IDOK Done IDCANCEL Abort
2008-08-15 12:47:20 +00:00
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
2009-12-29 19:47:57 +00:00
MessageBox MB_OKCANCEL|MB_ICONSTOP "You are trying to install the Windows 2000, XP and Vista version on Windows 95, 98 or ME. This is will not work. Please download the correct version. Do you really want to continue?" IDOK Done IDCANCEL Abort
2008-08-15 12:47:20 +00:00
GoTo Done
WinNT:
ClearErrors
StrCmp ${APPARCH} "win9x" 0 Done
2009-12-29 19:47:57 +00:00
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "You are trying to install the Windows 95, 98 and ME version on Windows 2000, XP or Vista. This is not advised, but will work with reduced capabilities. We suggest that you download the correct version. Do you really want to continue?" IDOK Done IDCANCEL Abort
2008-08-15 12:47:20 +00:00
Abort:
Quit
Done:
FunctionEnd
2004-08-09 17:04:08 +00:00
Var OLDVERSION
Var UninstallString
2007-02-27 16:51:49 +00:00
;-----------------------------------------------------------------------------------
2009-08-15 20:32:57 +00:00
; NSIS Initialize function, determine if we are going to install/upgrade or uninstall
2004-08-09 17:04:08 +00:00
Function .onInit
StrCpy $SHORTCUTS "OpenTTD"
2009-08-15 20:32:57 +00:00
SectionSetSize ${Section3} 6144
2009-12-14 18:20:42 +00:00
SectionSetSize ${Section4} 13312
2010-02-23 17:39:07 +00:00
SectionSetSize ${Section5} 1024
2009-08-15 20:32:57 +00:00
2004-08-09 17:04:08 +00:00
SectionSetFlags 0 17
2007-02-27 16:51:49 +00:00
; Starts Setup - let's look for an older version of OpenTTD
2004-08-09 17:04:08 +00:00
ReadRegDWORD $R8 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Version"
IfErrors ShowWelcomeMessage ShowUpgradeMessage
ShowWelcomeMessage:
ReadRegStr $R8 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "Version"
2007-02-27 16:51:49 +00:00
; In the event someone still has OpenTTD 0.1, this will detect that (that installer used a string instead of dword entry)
2004-08-09 17:04:08 +00:00
IfErrors FinishCallback
ShowUpgradeMessage:
IntCmp ${INSTALLERVERSION} $R8 VersionsAreEqual InstallerIsOlder WelcomeToSetup
WelcomeToSetup:
2007-02-27 16:51:49 +00:00
; An older version was found. Let's let the user know there's an upgrade that will take place.
2004-08-09 17:04:08 +00:00
ReadRegStr $OLDVERSION HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "DisplayVersion"
2007-02-27 16:51:49 +00:00
; Gets the older version then displays it in a message box
MessageBox MB_OK|MB_ICONINFORMATION \
"Welcome to ${APPNAMEANDVERSION} Setup.$\n \
This will allow you to upgrade from version $OLDVERSION."
2004-12-24 00:00:10 +00:00
SectionSetFlags ${Section2} 0x80 ; set bit 7
2009-08-15 20:32:57 +00:00
SectionSetFlags ${Section3} 0x80 ; set bit 7
SectionSetFlags ${Section4} 0x80 ; set bit 7
2009-12-14 18:20:42 +00:00
SectionSetFlags ${Section5} 0x80 ; set bit 7
2004-08-09 17:04:08 +00:00
Goto FinishCallback
VersionsAreEqual:
ReadRegStr $UninstallString HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenTTD" "UninstallString"
IfFileExists "$UninstallString" "" FinishCallback
2007-02-27 16:51:49 +00:00
MessageBox MB_YESNO|MB_ICONQUESTION \
2009-12-29 19:47:57 +00:00
"Setup detected ${APPNAMEANDVERSION} on your system. This is the same version that this program will install.$\n \
2007-02-27 16:51:49 +00:00
Are you trying to uninstall it?" \
IDYES DoUninstall IDNO FinishCallback
DoUninstall: ; You have the same version as this installer. This allows you to uninstall.
2004-08-09 17:04:08 +00:00
Exec "$UninstallString"
Quit
InstallerIsOlder:
2007-02-27 16:51:49 +00:00
MessageBox MB_OK|MB_ICONSTOP \
"You have a newer version of ${APPNAME}.$\n \
Setup will now exit."
2004-08-09 17:04:08 +00:00
Quit
FinishCallback:
ClearErrors
2008-08-15 12:47:20 +00:00
Call CheckProcessorArchitecture
Call CheckWindowsVersion
2004-08-09 17:04:08 +00:00
FunctionEnd
; eof