use Modern UI for multilanguage installer

This commit is contained in:
Chris Danford
2005-10-31 20:50:42 +00:00
parent 8bb2254628
commit 25caea972d
2 changed files with 464 additions and 360 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

+193 -89
View File
@@ -1,11 +1,13 @@
; NSIS Install Script ; NSIS Install Script
; created by ; created by
; BBF ; BBF, GlennMaynard, ChrisDanford
; I use the following command to create the installer: ; I use the following command to create the installer:
; D:\Program Files\NSIS>makensis.exe /v3 /cd "m:\Dev Projects\CVS\stepmania\stepmania.nsi"
;
; NOTE: this .NSI script is designed for NSIS v2.0+ ; NOTE: this .NSI script is designed for NSIS v2.0+
;--------------------------------
;Includes
!include "MUI.nsh" ; Modern UI
; Product info is in a separate file so that people will change ; Product info is in a separate file so that people will change
; the version info for the installer and the program at the same time. ; the version info for the installer and the program at the same time.
@@ -13,13 +15,15 @@
; title screen version text. ; title screen version text.
!include "src\ProductInfo.inc" !include "src\ProductInfo.inc"
;--------------------------------
;General
!system "echo This may take a moment ..." ignore !system "echo This may take a moment ..." ignore
!system "utils\upx Program\*.exe Program\*.dll" ignore !system "utils\upx Program\*.exe Program\*.dll" ignore
Name "${PRODUCT_NAME_VER}" Name "${PRODUCT_NAME_VER}"
OutFile "${PRODUCT_NAME_VER}.exe" OutFile "${PRODUCT_NAME_VER}.exe"
; Don't say "StepMania 3.9 Setup"; just say "StepMania 3.9".
Caption "${PRODUCT_NAME_VER}" Caption "${PRODUCT_NAME_VER}"
UninstallCaption "${PRODUCT_NAME_VER}" UninstallCaption "${PRODUCT_NAME_VER}"
@@ -37,84 +41,100 @@ DirText "${PRODUCT_NAME_VER}"
InstallColors /windows InstallColors /windows
InstProgressFlags smooth InstProgressFlags smooth
PageEx directory ;--------------------------------
Caption " " ;Interface Settings
PageExEnd
Page instfiles
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "installer-header.bmp"
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\win-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico"
; ;--------------------------------
; .oninit is called before window is shown ;Language Selection Dialog Settings
;
Function .onInit
;Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\${PRODUCT_NAME}\${PRODUCT_ID}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
; force uninstall of previous version using NSIS ;--------------------------------
; We need to wait until the uninstaller finishes before continuing, since it's possible ;Pages
; to click the next button again before the uninstaller's window appears and takes focus.
; This is tricky: we can't just ExecWait the uninstaller, since it copies off the uninstaller
; EXE and exec's that (otherwise it couldn't delete itself), so it appears to exit immediately.
; We need to copy it off ourself, run it with the hidden parameter to tell it it's a copy,
; and then delete the copy ourself. There's one more trick: the hidden parameter changed
; between NSIS 1 and 2: in 1.x it was _=C:\Foo, in 2.x it's _?=C:\Foo. Rename the installer
; for newer versions, so we can tell the difference: "uninst.exe" is the old 1.x uninstaller,
; "uninstall.exe" is 2.x.
StrCpy $R1 "$INSTDIR\uninst.exe"
StrCpy $R2 "_="
IfFileExists "$R1" prompt_uninstall_nsis
StrCpy $R1 "$INSTDIR\uninstall.exe"
StrCpy $R2 "_?="
IfFileExists "$R1" prompt_uninstall_nsis old_nsis_not_installed
prompt_uninstall_nsis: ;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
MessageBox MB_YESNO|MB_ICONINFORMATION "The previous version of ${PRODUCT_ID} must be uninstalled before continuing.$\nDo you wish to continue?" IDYES do_uninstall_nsis ;!insertmacro MUI_PAGE_COMPONENTS
Abort !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
do_uninstall_nsis: !insertmacro MUI_UNPAGE_CONFIRM
GetTempFileName $R3 !insertmacro MUI_UNPAGE_INSTFILES
CopyFiles /SILENT $R1 $R3
ExecWait '$R3 $R2$INSTDIR' $R4
; Delete the copy of the installer.
Delete $R3
; $R4 is the exit value of the uninstaller. 0 means success, anything else is ;--------------------------------
; failure (eg. aborted). ;Languages
IntCmp $R4 0 old_nsis_not_installed ; jump if 0
MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONINFORMATION "Uninstallation failed. Install anyway?" IDYES old_nsis_not_installed !insertmacro MUI_LANGUAGE "English" # first language is the default language
Abort !insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Spanish"
;!insertmacro MUI_LANGUAGE "SimpChinese"
;!insertmacro MUI_LANGUAGE "TradChinese"
;!insertmacro MUI_LANGUAGE "Japanese"
;!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Italian"
;!insertmacro MUI_LANGUAGE "Dutch"
;!insertmacro MUI_LANGUAGE "Danish"
;!insertmacro MUI_LANGUAGE "Swedish"
;!insertmacro MUI_LANGUAGE "Norwegian"
;!insertmacro MUI_LANGUAGE "Finnish"
;!insertmacro MUI_LANGUAGE "Greek"
;!insertmacro MUI_LANGUAGE "Russian"
;!insertmacro MUI_LANGUAGE "Portuguese"
;!insertmacro MUI_LANGUAGE "PortugueseBR"
;!insertmacro MUI_LANGUAGE "Polish"
;!insertmacro MUI_LANGUAGE "Ukrainian"
;!insertmacro MUI_LANGUAGE "Czech"
;!insertmacro MUI_LANGUAGE "Slovak"
;!insertmacro MUI_LANGUAGE "Croatian"
;!insertmacro MUI_LANGUAGE "Bulgarian"
;!insertmacro MUI_LANGUAGE "Hungarian"
;!insertmacro MUI_LANGUAGE "Thai"
;!insertmacro MUI_LANGUAGE "Romanian"
;!insertmacro MUI_LANGUAGE "Latvian"
;!insertmacro MUI_LANGUAGE "Macedonian"
;!insertmacro MUI_LANGUAGE "Estonian"
;!insertmacro MUI_LANGUAGE "Turkish"
;!insertmacro MUI_LANGUAGE "Lithuanian"
;!insertmacro MUI_LANGUAGE "Catalan"
;!insertmacro MUI_LANGUAGE "Slovenian"
;!insertmacro MUI_LANGUAGE "Serbian"
;!insertmacro MUI_LANGUAGE "SerbianLatin"
;!insertmacro MUI_LANGUAGE "Arabic"
;!insertmacro MUI_LANGUAGE "Farsi"
;!insertmacro MUI_LANGUAGE "Hebrew"
;!insertmacro MUI_LANGUAGE "Indonesian"
;!insertmacro MUI_LANGUAGE "Mongolian"
;!insertmacro MUI_LANGUAGE "Luxembourgish"
;!insertmacro MUI_LANGUAGE "Albanian"
;!insertmacro MUI_LANGUAGE "Breton"
;!insertmacro MUI_LANGUAGE "Belarusian"
;!insertmacro MUI_LANGUAGE "Icelandic"
;!insertmacro MUI_LANGUAGE "Malay"
;!insertmacro MUI_LANGUAGE "Bosnian"
;!insertmacro MUI_LANGUAGE "Kurdish"
;--------------------------------
;Reserve Files
old_nsis_not_installed: ;These files should be inserted before other files in the data block
;Keep these lines before any File command
;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
; Check for DirectX 8.0 (to be moved to the right section later) !insertmacro MUI_RESERVEFILE_LANGDLL
; We only use this for sound. Actually, I could probably make the sound
; work with an earlier one; I'm not sure if that's needed or not. For one
; thing, forcing people to upgrade drivers is somewhat of a good thing;
; but upgrading to DX8 if you really don't have to is also somewhat
; annoying, too ... -g
ReadRegStr $0 HKEY_LOCAL_MACHINE "Software\Microsoft\DirectX" "Version"
StrCpy $1 $0 2 2 ; 8.1 is "4.08.01.0810"
IntCmpU $1 8 check_subversion old_dx ok
check_subversion:
StrCpy $1 $0 2 5
IntCmpU $1 0 ok old_dx ok
; We can function without it (using WaveOut), so don't *require* this. ;--------------------------------
old_dx: ;Installer Sections
MessageBox MB_YESNO|MB_ICONINFORMATION "The latest version of DirectX (8.1 or higher) is strongly recommended.$\n Do you wish to visit Microsoft's site now?" IDNO ok
ExecShell "" "http://www.microsoft.com/directx/"
Abort
ok: Section "Main Section" SecMain
FunctionEnd
;
; The default install section
;
Section ""
; write out uninstaller ; write out uninstaller
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
@@ -235,7 +255,7 @@ File "Program\dbghelp.dll"
File "Program\zlib1.dll" File "Program\zlib1.dll"
SetOverwrite off SetOverwrite off
SetOutPath "$INSTDIR\Data\MachineProfile" SetOutPath "$INSTDIR\Save\MachineProfile"
File "Docs\Stats.xml" File "Docs\Stats.xml"
SetOverwrite on SetOverwrite on
@@ -258,13 +278,14 @@ File "NEWS"
;IfFileExists "$INSTDIR\${PRODUCT_NAME}.ini" stepmania_ini_present ;IfFileExists "$INSTDIR\${PRODUCT_NAME}.ini" stepmania_ini_present
;IfFileExists "$INSTDIR\Data\${PRODUCT_NAME}.ini" stepmania_ini_present ;IfFileExists "$INSTDIR\Data\${PRODUCT_NAME}.ini" stepmania_ini_present
;IfFileExists "$INSTDIR\Save\${PRODUCT_NAME}.ini" stepmania_ini_present
;Goto stepmania_ini_not_present ;Goto stepmania_ini_not_present
;stepmania_ini_present: ;stepmania_ini_present:
;MessageBox MB_YESNO|MB_ICONQUESTION "Your settings from the previous installation of ${PRODUCT_ID} were found.$\nWould you like to keep these settings?" IDNO stepmania_ini_not_present ;MessageBox MB_YESNO|MB_ICONQUESTION "Your settings from the previous installation of ${PRODUCT_ID} were found.$\nWould you like to keep these settings?" IDNO stepmania_ini_not_present
;Delete "$INSTDIR\Data\${PRODUCT_NAME}.ini" ;Delete "$INSTDIR\Save\${PRODUCT_NAME}.ini"
;stepmania_ini_not_present: ;stepmania_ini_not_present:
;; Move ini into Data\ ;; Move ini into Save\
;Rename "$INSTDIR\Data\${PRODUCT_NAME}.ini" "$INSTDIR\${PRODUCT_NAME}.ini" ;Rename "$INSTDIR\Save\${PRODUCT_NAME}.ini" "$INSTDIR\${PRODUCT_NAME}.ini"
; Create Start Menu icons ; Create Start Menu icons
SetShellVarContext current # 'all' doesn't work on Win9x SetShellVarContext current # 'all' doesn't work on Win9x
@@ -272,11 +293,11 @@ CreateDirectory "$SMPROGRAMS\${PRODUCT_ID}\"
CreateShortCut "$DESKTOP\${PRODUCT_NAME_VER}.lnk" "$INSTDIR\Program\${PRODUCT_NAME}.exe" CreateShortCut "$DESKTOP\${PRODUCT_NAME_VER}.lnk" "$INSTDIR\Program\${PRODUCT_NAME}.exe"
CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\${PRODUCT_NAME_VER}.lnk" "$INSTDIR\Program\${PRODUCT_NAME}.exe" CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\${PRODUCT_NAME_VER}.lnk" "$INSTDIR\Program\${PRODUCT_NAME}.exe"
CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\Open ${PRODUCT_NAME} Program Folder.lnk" "$WINDIR\explorer.exe" "$INSTDIR\" CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\Open ${PRODUCT_NAME} Program Folder.lnk" "$WINDIR\explorer.exe" "$INSTDIR\"
CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\View Machine Statistics.lnk" "$INSTDIR\Data\MachineProfile\Stats.xml" CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\View Machine Statistics.lnk" "$INSTDIR\Save\MachineProfile\Stats.xml"
CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\${PRODUCT_NAME} Tools and Package Exporter.lnk" "$INSTDIR\Program\smpackage.exe" CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\${PRODUCT_NAME} Tools and Package Exporter.lnk" "$INSTDIR\Program\smpackage.exe"
CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\README-FIRST.lnk" "$INSTDIR\README-FIRST.html" CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\README-FIRST.lnk" "$INSTDIR\README-FIRST.html"
CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\Uninstall ${PRODUCT_NAME_VER}.lnk" "$INSTDIR\uninstall.exe" CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\Uninstall ${PRODUCT_NAME_VER}.lnk" "$INSTDIR\uninstall.exe"
CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\Go To ${PRODUCT_NAME} web site.lnk" "${PRODUCT_URL}" CreateShortCut "$SMPROGRAMS\${PRODUCT_ID}\Go To the ${PRODUCT_NAME} web site.lnk" "${PRODUCT_URL}"
CreateShortCut "$INSTDIR\${PRODUCT_NAME}.lnk" "$INSTDIR\Program\${PRODUCT_NAME}.exe" CreateShortCut "$INSTDIR\${PRODUCT_NAME}.lnk" "$INSTDIR\Program\${PRODUCT_NAME}.exe"
@@ -293,15 +314,91 @@ Delete "$DESKTOP\Play StepMania 3.9 alpha 3.lnk"
Exec '$WINDIR\explorer.exe "$SMPROGRAMS\${PRODUCT_ID}\"' Exec '$WINDIR\explorer.exe "$SMPROGRAMS\${PRODUCT_ID}\"'
SectionEnd ; end of default section SectionEnd
;--------------------------------
;Installer Functions
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
; force uninstall of previous version using NSIS
; We need to wait until the uninstaller finishes before continuing, since it's possible
; to click the next button again before the uninstaller's window appears and takes focus.
; This is tricky: we can't just ExecWait the uninstaller, since it copies off the uninstaller
; EXE and exec's that (otherwise it couldn't delete itself), so it appears to exit immediately.
; We need to copy it off ourself, run it with the hidden parameter to tell it it's a copy,
; and then delete the copy ourself. There's one more trick: the hidden parameter changed
; between NSIS 1 and 2: in 1.x it was _=C:\Foo, in 2.x it's _?=C:\Foo. Rename the installer
; for newer versions, so we can tell the difference: "uninst.exe" is the old 1.x uninstaller,
; "uninstall.exe" is 2.x.
StrCpy $R1 "$INSTDIR\uninst.exe"
StrCpy $R2 "_="
IfFileExists "$R1" prompt_uninstall_nsis
StrCpy $R1 "$INSTDIR\uninstall.exe"
StrCpy $R2 "_?="
IfFileExists "$R1" prompt_uninstall_nsis old_nsis_not_installed
prompt_uninstall_nsis:
MessageBox MB_YESNO|MB_ICONINFORMATION "The previous version of ${PRODUCT_ID} must be uninstalled before continuing.$\nDo you wish to continue?" IDYES do_uninstall_nsis
Abort
do_uninstall_nsis:
GetTempFileName $R3
CopyFiles /SILENT $R1 $R3
ExecWait '$R3 $R2$INSTDIR' $R4
; Delete the copy of the installer.
Delete $R3
; $R4 is the exit value of the uninstaller. 0 means success, anything else is
; failure (eg. aborted).
IntCmp $R4 0 old_nsis_not_installed ; jump if 0
MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONINFORMATION "Uninstallation failed. Install anyway?" IDYES old_nsis_not_installed
Abort
; old_nsis_not_installed:
; begin uninstall settings/section
;
UninstallText "This will uninstall ${PRODUCT_ID} from your system.$\nAny add-on packs or songs you have installed will not be deleted."
Section Uninstall ; Check for DirectX 8.0 (to be moved to the right section later)
; We only use this for sound. Actually, I could probably make the sound
; work with an earlier one; I'm not sure if that's needed or not. For one
; thing, forcing people to upgrade drivers is somewhat of a good thing;
; but upgrading to DX8 if you really don't have to is also somewhat
; annoying, too ... -g
ReadRegStr $0 HKEY_LOCAL_MACHINE "Software\Microsoft\DirectX" "Version"
StrCpy $1 $0 2 2 ; 8.1 is "4.08.01.0810"
IntCmpU $1 8 check_subversion old_dx ok
check_subversion:
StrCpy $1 $0 2 5
IntCmpU $1 0 ok old_dx ok
; We can function without it (using WaveOut), so don't *require* this.
old_dx:
MessageBox MB_YESNO|MB_ICONINFORMATION "The latest version of DirectX (8.1 or higher) is strongly recommended.$\n Do you wish to visit Microsoft's site now?" IDNO ok
ExecShell "" "http://www.microsoft.com/directx/"
Abort
ok:
FunctionEnd
;--------------------------------
;Descriptions
;USE A LANGUAGE STRING IF YOU WANT YOUR DESCRIPTIONS TO BE LANGAUGE SPECIFIC
;Assign descriptions to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecMain} "A test section."
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
; add delete commands to delete whatever files/registry keys/etc you installed here. ; add delete commands to delete whatever files/registry keys/etc you installed here.
Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\uninstall.exe"
@@ -372,10 +469,6 @@ RMDir "$INSTDIR\Docs"
; Don't delete high scores. ; Don't delete high scores.
Delete "$INSTDIR\Data\Translations.xml" Delete "$INSTDIR\Data\Translations.xml"
Delete "$INSTDIR\Data\AI.ini" Delete "$INSTDIR\Data\AI.ini"
; Don't delete setting files so that they remain after an upgrade.
;Delete "$INSTDIR\Data\${PRODUCT_NAME}.ini"
;Delete "$INSTDIR\Data\Keymaps.ini"
;Delete "$INSTDIR\Data\GamePrefs.ini"
Delete "$INSTDIR\Data\splash.png" Delete "$INSTDIR\Data\splash.png"
RMDir "$INSTDIR\Data" RMDir "$INSTDIR\Data"
@@ -395,8 +488,8 @@ RMDir "$INSTDIR\Program"
; It's harmless to delete this, as long as we leave Stats.xml alone; it'll be rewritten ; It's harmless to delete this, as long as we leave Stats.xml alone; it'll be rewritten
; by the program the next time it's run. ; by the program the next time it's run.
Delete "$INSTDIR\Data\MachineProfile\stats.html" Delete "$INSTDIR\Save\MachineProfile\stats.html"
RMDir "$INSTDIR\Data\MachineProfile" RMDir "$INSTDIR\Save\MachineProfile"
Delete "$INSTDIR\COPYING.txt" Delete "$INSTDIR\COPYING.txt"
Delete "$INSTDIR\README-FIRST.html" Delete "$INSTDIR\README-FIRST.html"
@@ -415,6 +508,17 @@ Delete "$DESKTOP\${PRODUCT_NAME_VER}.lnk"
Delete "$SMPROGRAMS\${PRODUCT_ID}\*.*" Delete "$SMPROGRAMS\${PRODUCT_ID}\*.*"
RMDir "$SMPROGRAMS\${PRODUCT_ID}" RMDir "$SMPROGRAMS\${PRODUCT_ID}"
SectionEnd ; end of uninstall section Delete "$INSTDIR\Uninstall.exe"
; eof DeleteRegKey /ifempty HKEY_LOCAL_MACHINE "SOFTWARE\${PRODUCT_NAME}\${PRODUCT_ID}"
SectionEnd
;--------------------------------
;Uninstaller Functions
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd