diff --git a/Contrib/Modern UI/Changelog.txt b/Contrib/Modern UI/Changelog.txt index 117097b8..6ef64780 100644 --- a/Contrib/Modern UI/Changelog.txt +++ b/Contrib/Modern UI/Changelog.txt @@ -4,9 +4,11 @@ NSIS Modern User Interface - VERSION HISTORY * Support for a bitmap in the wizard header * New defines to change the description area * MUI_SYSTEM inserted automatically +* Single macro for language selection dialog * Removed page description in window title * Easier to customize resource files * New system for custom functions +* Start Menu folder registry key automatically written * New InstallOptions macro's that do not remove the return value from the stack * Support for custom pages before the finish page diff --git a/Contrib/Modern UI/Readme.html b/Contrib/Modern UI/Readme.html index d10c9434..c827346f 100644 --- a/Contrib/Modern UI/Readme.html +++ b/Contrib/Modern UI/Readme.html @@ -184,9 +184,10 @@ follow these steps:

shortcuts.

MUI_STARTMENUPAGE_REGISTRY_ROOT, MUI_STARTMENUPAGE_REGISTRY_KEY, MUI_STARTMENUPAGE_REGISTRY_VALUENAME
- If your installer saves the Start Menu folder of a previous installation - in a registry, define these values and the Modern UI will use the saved - value as default folder.

+ The registry key to store the Start Menu folder. The page will use it to + remember the users preference. You should also use it in the uninstaller to + remove the Start Menu folders. Don't forget to remove this key in the + uninstaller.

MUI_FINISHPAGE
Show the finish page. The finish page tells that the installation is succesful. @@ -306,12 +307,23 @@ follow these steps:

Have a look at the language files for a complete list of all the string names.

-

If you are using the LangDLL for a language selection dialog +

If you want the installer to display a language selection dialog (have a look at the - MultiLanguage.nsi example) use MUI_LANGDLL_PUSH to add the name of the - language (in the language itself) to the stack:

+ MultiLanguage.nsi example), insert the MUI_LANGDLL_DISPLAY macro in .onInit:

-!insertmacro MUI_LANGDLL_PUSH "English" ;Parameter = Language file name in English
+Function .onInit + + !insertmacro MUI_LANGDLL_DISPLAY + +FunctionEnd + +

To customize the texts on the language selection dialog, define + MUI_TEXT_LANGDLL_WINDOWTITLE and MUI_TEXT_LANGDLL_INFO before inserting the macro.

+

If you want the installer to remember the users language + preference, define MUI_STARTMENUPAGE_REGISTRY_ROOT, MUI_STARTMENUPAGE_REGISTRY_KEY + and MUI_STARTMENUPAGE_REGISTRY_VALUENAME to set a registry key to store the + language. You can also use it in the uninstaller to display the right language. + Don't forget to remove this key in the uninstaller.

9. Insert the MUI_SECTIONS_FINISHHEADER macro

If you are not using a Finish page without defining MUI_FINISHPAGE_NOAUTOCLOSEWINDOW and have not set AutoCloseWindow @@ -564,9 +576,11 @@ FunctionEnd

  • Support for a bitmap in the wizard header
  • New defines to change the description area
  • MUI_SYSTEM inserted automatically
  • +
  • Single macro for language selection dialog
  • Removed page description in window title
  • Easier to customize resource files
  • New system for custom functions
  • +
  • Start Menu folder registry key automatically written
  • New InstallOptions macro's that do not remove the return value from the stack
  • Support for custom pages before the finish page
  • diff --git a/Contrib/Modern UI/System.nsh b/Contrib/Modern UI/System.nsh index eb90e5b6..8fffd6ab 100644 --- a/Contrib/Modern UI/System.nsh +++ b/Contrib/Modern UI/System.nsh @@ -2,8 +2,7 @@ ;Macro System ;Written by Joost Verburg -;Have a look the scripts in the 'Examples\Modern UI' -;directory for examples of usage. +;Have a look the scripts in the 'Examples\Modern UI' directory for examples of usage. ;-------------------------------- @@ -15,7 +14,7 @@ !define MUI_MACROS_USED -!include "${NSISDIR}\Include\WinMessages.nsh" +!include "WinMessages.nsh" !define MUI_TEMP1 $R0 !define MUI_TEMP2 $R1 @@ -254,7 +253,7 @@ StrCmp $0 ${VAR} "" +3 SendMessage ${MUI_TEMP1} ${WM_SETTEXT} 0 "STR:${TEXT}" - Goto done + Goto description_done !ifndef MUI_NOVERBOSE !ifndef MUI_MANUALVERBOSE @@ -272,7 +271,7 @@ !endif !endif - done: + description_done: Pop ${MUI_TEMP1} !ifndef MUI_NOVERBOSE @@ -439,16 +438,9 @@ !macro MUI_LANGDLL_PUSH LANGUAGE - !ifndef MUI_MANUALVERBOSE - !verbose 3 - !endif + ;1.62 compatibility - Push "${LANG_${LANGUAGE}}" - Push "${MUI_${LANGUAGE}_LANGNAME}" - - !ifndef MUI_MANUALVERBOSE - !verbose 4 - !endif + !error "To use the language selection dialog, you only have to add '!insertmacro MUI_LANGDLL_DISPLAY' to .onInit now. You should remove all the other code and Push commands." !macroend @@ -470,6 +462,10 @@ !macro MUI_STARTMENU_WRITE_END !verbose 3 + + !ifdef MUI_STARTMENUPAGE_REGISTRY_ROOT & MUI_STARTMENUPAGE_REGISTRY_KEY & MUI_STARTMENUPAGE_REGISTRY_VALUENAME + WriteRegStr "${MUI_STARTMENUPAGE_REGISTRY_ROOT}" "${MUI_STARTMENUPAGE_REGISTRY_KEY}" "${MUI_STARTMENUPAGE_REGISTRY_VALUENAME}" "${MUI_STARTMENUPAGE_VARIABLE}" + !endif no_startmenu_shortcuts: @@ -477,6 +473,49 @@ !macroend +!macro MUI_LANGDLL_DISPLAY + + !ifndef MUI_MANUALVERBOSE + !verbose 3 + !endif + + !ifndef MUI_TEXT_LANGDLL_WINDOWTITLE + !define MUI_TEXT_LANGDLL_WINDOWTITLE "Installer Language" + !endif + + !ifndef MUI_TEXT_LANGDLL_INFO + !define MUI_TEXT_LANGDLL_INFO "Please select a language." + !endif + + !ifdef MUI_LANGDLL_REGISTRY_ROOT & MUI_LANGDLL_REGISTRY_KEY & MUI_LANGDLL_REGISTRY_VALUENAME + Push ${MUI_TEMP1} + + ReadRegStr ${MUI_TEMP1} "${MUI_LANGDLL_REGISTRY_ROOT}" "${MUI_LANGDLL_REGISTRY_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" + StrCmp ${MUI_TEMP1} "" showlangdialog + StrCpy $LANGUAGE ${MUI_TEMP1} + Goto langdll_done + showlangdialog: + + Pop ${MUI_TEMP1} + !endif + + LangDLL::LangDialog "${MUI_TEXT_LANGDLL_WINDOWTITLE}" "${MUI_TEXT_LANGDLL_INFO}" AF ${MUI_LANGDLL_PUSHLIST} "" 8 "${MUI_FONT}" + + Pop $LANGUAGE + StrCmp $LANGUAGE "cancel" 0 +2 + Abort + + !ifdef MUI_LANGDLL_REGISTRY_ROOT & MUI_LANGDLL_REGISTRY_KEY & MUI_LANGDLL_REGISTRY_VALUENAME + WriteRegStr "${MUI_LANGDLL_REGISTRY_ROOT}" "${MUI_LANGDLL_REGISTRY_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" $LANGUAGE + langdll_done: + !endif + + !ifndef MUI_MANUALVERBOSE + !verbose 4 + !endif + +!macroend + ;-------------------------------- ;PAGE COMMANDS @@ -1201,7 +1240,7 @@ !insertmacro MUI_HEADER_TEXT $(MUI_TEXT_STARTMENU_TITLE) $(MUI_TEXT_STARTMENU_SUBTITLE) !ifdef MUI_STARTMENUPAGE_REGISTRY_ROOT & MUI_STARTMENUPAGE_REGISTRY_KEY & MUI_STARTMENUPAGE_REGISTRY_VALUENAME - + StrCmp "${MUI_STARTMENUPAGE_VARIABLE}" "" "" +4 ReadRegStr ${MUI_TEMP1} "${MUI_STARTMENUPAGE_REGISTRY_ROOT}" "${MUI_STARTMENUPAGE_REGISTRY_KEY}" "${MUI_STARTMENUPAGE_REGISTRY_VALUENAME}" @@ -1796,8 +1835,10 @@ !macro MUI_SYSTEM - !ifndef MUI_MANUALVERBOSE - !verbose 3 + !ifndef MUI_NOVERBOSE + !ifndef MUI_MANUALVERBOSE + !verbose 3 + !endif !endif !ifndef MUI_SYSTEM_INSERTED @@ -1806,25 +1847,24 @@ ;1.62 compatibility !ifdef MUI_STARTMENU_VARIABLE || MUI_STARTMENU_DEFAULTFOLDER || MUI_STARTMENU_REGISTRY_ROOT - !error "The Start Menu Folder page defines have been renamed from MUI_STARTMENU_??? to MUI_STARTMENUPAGE_???. Please change this in your script." + !error "The Start Menu Folder page defines have been renamed from MUI_STARTMENU_??? to MUI_STARTMENUPAGE_???. Please rename these defines in your script." !endif - !define MUI_NOVERBOSE - !insertmacro MUI_INTERFACE !insertmacro MUI_BASIC !insertmacro MUI_UNBASIC - - !undef MUI_NOVERBOSE !else + ;1.62 compatibility !warning "The MUI_SYSTEM macro is now being inserted automatically. You can remove '!insertmacro MUI_SYSTEM' from your script." !endif - !ifndef MUI_MANUALVERBOSE - !verbose 4 + !ifndef MUI_NOVERBOSE + !ifndef MUI_MANUALVERBOSE + !verbose 4 + !endif !endif !macroend @@ -1882,7 +1922,10 @@ !ifndef MUI_SYSTEM_INSERT !define MUI_SYSTEM_INSERT - !insertmacro MUI_SYSTEM + + !define MUI_NOVERBOSE + !insertmacro MUI_SYSTEM + !undef MUI_NOVERBOSE !endif @@ -1989,7 +2032,18 @@ !macro MUI_LANGUAGEFILE_END !insertmacro MUI_LANGUAGEFILE_DEFINE "MUI_${LANGUAGE}_LANGNAME" "MUI_LANGNAME" - + + !ifndef MUI_LANGDLL_PUSHLIST + !define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} " + !else + !ifdef MUI_LANGDLL_PUSHLIST_TEMP + !undef MUI_LANGDLL_PUSHLIST_TEMP + !endif + !define MUI_LANGDLL_PUSHLIST_TEMP "${MUI_LANGDLL_PUSHLIST}" + !undef MUI_LANGDLL_PUSHLIST + !define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} ${MUI_LANGDLL_PUSHLIST_TEMP}" + !endif + !insertmacro MUI_LANGUAGEFILE_NSISCOMMAND "Name" "MUI_NAME" SubCaption 0 " " diff --git a/Examples/Modern UI/Basic.nsi b/Examples/Modern UI/Basic.nsi index fd13ec10..2da7d3e8 100644 --- a/Examples/Modern UI/Basic.nsi +++ b/Examples/Modern UI/Basic.nsi @@ -15,6 +15,9 @@ ;Folder selection page InstallDir "$PROGRAMFILES\${MUI_PRODUCT}" + + ;Remember install folder + InstallDirRegKey HKCU "Softare\${MUI_PRODUCT}" "" ;-------------------------------- ;Modern UI Configuration @@ -54,6 +57,9 @@ Section "modern.exe" SecCopyUI SetOutPath "$INSTDIR" File "${NSISDIR}\Contrib\UIs\modern.exe" + ;Store install folder + WriteRegStr HKCU "Softare\${MUI_PRODUCT}" "" $INSTDIR + ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" @@ -82,6 +88,8 @@ Section "Uninstall" RMDir "$INSTDIR" + DeleteRegKey /ifempty HKCU "Software\${MUI_PRODUCT}" + ;Display the Finish header !insertmacro MUI_UNFINISHHEADER diff --git a/Examples/Modern UI/HeaderBitmap.nsi b/Examples/Modern UI/HeaderBitmap.nsi index a67dfe55..3dd763b7 100644 --- a/Examples/Modern UI/HeaderBitmap.nsi +++ b/Examples/Modern UI/HeaderBitmap.nsi @@ -15,6 +15,9 @@ ;Folder selection page InstallDir "$PROGRAMFILES\${MUI_PRODUCT}" + + ;Remember install folder + InstallDirRegKey HKCU "Softare\${MUI_PRODUCT}" "" ;-------------------------------- ;Modern UI Configuration @@ -56,6 +59,9 @@ Section "modern.exe" SecCopyUI SetOutPath "$INSTDIR" File "${NSISDIR}\Contrib\UIs\modern.exe" + ;Store install folder + WriteRegStr HKCU "Softare\${MUI_PRODUCT}" "" $INSTDIR + ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" @@ -84,6 +90,8 @@ Section "Uninstall" RMDir "$INSTDIR" + DeleteRegKey /ifempty HKCU "Software\${MUI_PRODUCT}" + ;Display the Finish header !insertmacro MUI_UNFINISHHEADER diff --git a/Examples/Modern UI/InstallOptions.nsi b/Examples/Modern UI/InstallOptions.nsi index f15f02e6..c65eae6c 100644 --- a/Examples/Modern UI/InstallOptions.nsi +++ b/Examples/Modern UI/InstallOptions.nsi @@ -17,6 +17,9 @@ ;Folder selection page InstallDir "$PROGRAMFILES\${MUI_PRODUCT}" + + ;Remember install folder + InstallDirRegKey HKCU "Softare\${MUI_PRODUCT}" "" ;-------------------------------- ;Modern UI Configuration @@ -89,6 +92,9 @@ Section "modern.exe" SecCopyUI SetOutPath "$INSTDIR" File "${NSISDIR}\Contrib\UIs\modern.exe" + ;Store install folder + WriteRegStr HKCU "Softare\${MUI_PRODUCT}" "" $INSTDIR + ;Read a value from an InstallOptions INI File !insertmacro MUI_INSTALLOPTIONS_READ ${TEMP} "ioC.ini" "Field 2" "State" StrCmp ${TEMP} "1" "" +2 @@ -150,6 +156,8 @@ Section "Uninstall" RMDir "$INSTDIR" + DeleteRegKey /ifempty HKCU "Software\${MUI_PRODUCT}" + !insertmacro MUI_UNFINISHHEADER SectionEnd \ No newline at end of file diff --git a/Examples/Modern UI/MultiLanguage.nsi b/Examples/Modern UI/MultiLanguage.nsi index a8b2e403..5af575f5 100644 --- a/Examples/Modern UI/MultiLanguage.nsi +++ b/Examples/Modern UI/MultiLanguage.nsi @@ -15,6 +15,14 @@ ;Folder selection page InstallDir "$PROGRAMFILES\${MUI_PRODUCT}" + + ;Remember install folder + InstallDirRegKey HKCU "Softare\${MUI_PRODUCT}" "" + + ;Remember the installer language + !define MUI_LANGDLL_REGISTRY_ROOT "HKCU" + !define MUI_LANGDLL_REGISTRY_KEY "Software\${MUI_PRODUCT}" + !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" ;-------------------------------- ;Modern UI Configuration @@ -133,8 +141,8 @@ Section "modern.exe" SecCopyUI SetOutPath "$INSTDIR" File "${NSISDIR}\Contrib\UIs\modern.exe" - ;Write language to the registry (for the uninstaller) - WriteRegStr HKCU "Software\${MUI_PRODUCT}" "Installer Language" $LANGUAGE + ;Store install folder + WriteRegStr HKCU "Softare\${MUI_PRODUCT}" "" $INSTDIR WriteUninstaller "$INSTDIR\Uninstall.exe" @@ -149,46 +157,7 @@ SectionEnd Function .onInit - ;Language selection - - ;Font - Push Tahoma - Push 8 - - ;Languages - !insertmacro MUI_LANGDLL_PUSH "English" - !insertmacro MUI_LANGDLL_PUSH "French" - !insertmacro MUI_LANGDLL_PUSH "German" - !insertmacro MUI_LANGDLL_PUSH "Spanish" - !insertmacro MUI_LANGDLL_PUSH "SimpChinese" - !insertmacro MUI_LANGDLL_PUSH "TradChinese" - !insertmacro MUI_LANGDLL_PUSH "Japanese" - !insertmacro MUI_LANGDLL_PUSH "Korean" - !insertmacro MUI_LANGDLL_PUSH "Italian" - !insertmacro MUI_LANGDLL_PUSH "Dutch" - !insertmacro MUI_LANGDLL_PUSH "Danish" - !insertmacro MUI_LANGDLL_PUSH "Greek" - !insertmacro MUI_LANGDLL_PUSH "Russian" - !insertmacro MUI_LANGDLL_PUSH "PortugueseBR" - !insertmacro MUI_LANGDLL_PUSH "Polish" - !insertmacro MUI_LANGDLL_PUSH "Ukrainian" - !insertmacro MUI_LANGDLL_PUSH "Czech" - !insertmacro MUI_LANGDLL_PUSH "Slovak" - !insertmacro MUI_LANGDLL_PUSH "Croatian" - !insertmacro MUI_LANGDLL_PUSH "Bulgarian" - !insertmacro MUI_LANGDLL_PUSH "Hungarian" - !insertmacro MUI_LANGDLL_PUSH "Thai" - !insertmacro MUI_LANGDLL_PUSH "Romanian" - !insertmacro MUI_LANGDLL_PUSH "Macedonian" - !insertmacro MUI_LANGDLL_PUSH "Turkish" - - Push 25F ;25 = number of languages, F = change font - - LangDLL::LangDialog "Installer Language" "Please select a language." - - Pop $LANGUAGE - StrCmp $LANGUAGE "cancel" 0 +2 - Abort + !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd @@ -210,8 +179,8 @@ Section "Uninstall" Delete "$INSTDIR\Uninstall.exe" RMDir "$INSTDIR" - - DeleteRegValue HKCU "Software\${MUI_PRODUCT}" "Installer Language" + + DeleteRegKey /ifempty HKCU "Software\${MUI_PRODUCT}" ;Display the Finish header !insertmacro MUI_UNFINISHHEADER diff --git a/Examples/Modern UI/StartMenu.nsi b/Examples/Modern UI/StartMenu.nsi index 6458af18..2d03dbe6 100644 --- a/Examples/Modern UI/StartMenu.nsi +++ b/Examples/Modern UI/StartMenu.nsi @@ -16,6 +16,9 @@ ;Folder selection page InstallDir "$PROGRAMFILES\${MUI_PRODUCT}" + ;Remember install folder + InstallDirRegKey HKCU "Softare\${MUI_PRODUCT}" "" + ;$9 is being used to store the Start Menu Folder. ;Do not use this variable in your script (or Push/Pop it)! @@ -69,6 +72,9 @@ Section "modern.exe" SecCopyUI SetOutPath "$INSTDIR" File "${NSISDIR}\Contrib\UIs\modern.exe" + ;Store install folder + WriteRegStr HKCU "Softare\${MUI_PRODUCT}" "" $INSTDIR + !insertmacro MUI_STARTMENU_WRITE_BEGIN ;Create shortcuts @@ -76,9 +82,6 @@ Section "modern.exe" SecCopyUI CreateShortCut "$SMPROGRAMS\${MUI_STARTMENUPAGE_VARIABLE}\Modern UI.lnk" "$INSTDIR\modern.exe" CreateShortCut "$SMPROGRAMS\${MUI_STARTMENUPAGE_VARIABLE}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" - ;Write shortcut location to the registry (for Uninstaller) - WriteRegStr HKCU "Software\${MUI_PRODUCT}" "Start Menu Folder" "${MUI_STARTMENUPAGE_VARIABLE}" - !insertmacro MUI_STARTMENU_WRITE_END ;Create uninstaller @@ -108,7 +111,7 @@ Section "Uninstall" Delete "$INSTDIR\Uninstall.exe" ;Remove shortcut - ReadRegStr ${TEMP} HKCU "Software\${MUI_PRODUCT}" "Start Menu Folder" + ReadRegStr ${TEMP} "${MUI_STARTMENUPAGE_REGISTRY_ROOT}" "${MUI_STARTMENUPAGE_REGISTRY_KEY}" "${MUI_STARTMENUPAGE_REGISTRY_VALUENAME}" StrCmp ${TEMP} "" noshortcuts @@ -119,8 +122,8 @@ Section "Uninstall" noshortcuts: RMDir "$INSTDIR" - - DeleteRegValue HKCU "Software\${MUI_PRODUCT}" "Start Menu Folder" + + DeleteRegKey /ifempty HKCU "Software\${MUI_PRODUCT}" ;Display the Finish header !insertmacro MUI_UNFINISHHEADER diff --git a/Examples/Modern UI/WelcomeFinish.nsi b/Examples/Modern UI/WelcomeFinish.nsi index 569a3fff..7cc27060 100644 --- a/Examples/Modern UI/WelcomeFinish.nsi +++ b/Examples/Modern UI/WelcomeFinish.nsi @@ -15,6 +15,9 @@ ;Folder selection page InstallDir "$PROGRAMFILES\${MUI_PRODUCT}" + + ;Remember install folder + InstallDirRegKey HKCU "Softare\${MUI_PRODUCT}" "" ;-------------------------------- ;Modern UI Configuration @@ -63,6 +66,9 @@ Section "modern.exe" SecCopyUI SetOutPath "$INSTDIR" File "${NSISDIR}\Contrib\UIs\modern.exe" + + ;Store install folder + WriteRegStr HKCU "Softare\${MUI_PRODUCT}" "" $INSTDIR ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" @@ -88,6 +94,8 @@ Section "Uninstall" RMDir "$INSTDIR" + DeleteRegKey /ifempty HKCU "Software\${MUI_PRODUCT}" + !insertmacro MUI_UNFINISHHEADER SectionEnd \ No newline at end of file