Readme Page Based on MUI License Page: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
m (description update)
Line 1: Line 1:
{{PageAuthor|Red Wine}}
{{PageAuthor|Red Wine}}
== Description ==
== Description ==
Shows the user a readme page based on the MUI license page. Use ${ReadmeLanguage} and ${Un.ReadmeLanguage} to define the strings for individual languages and MUI_PAGE_README MUI_UNPAGE_README to show the page.<BR> For example: ... ${ReadmeLanguage} 'some defaults'... !insertmacro MUI_PAGE_README ...<BR>
Shows the user a readme page based on the MUI license page. Use ${ReadmeLanguage} and ${Un.ReadmeLanguage} to define the strings for individual languages and MUI_PAGE_README or MUI_UNPAGE_README to show the page, just as you'd show any other MUI page. A complete usage example is available below.


== The Header ==
== The Header ==

Revision as of 17:30, 20 January 2007

Author: Red Wine (talk, contrib)


Description

Shows the user a readme page based on the MUI license page. Use ${ReadmeLanguage} and ${Un.ReadmeLanguage} to define the strings for individual languages and MUI_PAGE_README or MUI_UNPAGE_README to show the page, just as you'd show any other MUI page. A complete usage example is available below.

The Header

#   MUI_EXTRAPAGES.nsh
 
!ifndef _MUI_EXTRAPAGES_NSH
!define _MUI_EXTRAPAGES_NSH
 
!ifmacrondef MUI_EXTRAPAGE_README & MUI_PAGE_README & MUI_UNPAGE_README & ReadmeLangStrings
 
!macro MUI_EXTRAPAGE_README UN ReadmeFile
   !define MUI_PAGE_HEADER_TEXT "$(${UN}ReadmeHeader)"
   !define MUI_PAGE_HEADER_SUBTEXT "$(${UN}ReadmeSubHeader)"
   !define MUI_LICENSEPAGE_TEXT_TOP "$(${UN}ReadmeTextTop)"
   !define MUI_LICENSEPAGE_TEXT_BOTTOM "$(${UN}ReadmeTextBottom)"
   !define MUI_LICENSEPAGE_BUTTON "$(^NextBtn)"
   !insertmacro MUI_${UN}PAGE_LICENSE "${ReadmeFile}"
!macroend
 
!define ReadmeRun "!insertmacro MUI_EXTRAPAGE_README"
 
 
!macro MUI_PAGE_README ReadmeFile
    ${ReadmeRun} "" "${ReadmeFile}"
!macroend
 
 
!macro MUI_UNPAGE_README ReadmeFile
    ${ReadmeRun} "UN" "${ReadmeFile}"
!macroend
 
 
!macro ReadmeLangStrings UN MUI_LANG ReadmeHeader ReadmeSubHeader ReadmeTextTop ReadmeTextBottom
    LangString ${UN}ReadmeHeader     ${MUI_LANG} "${ReadmeHeader}"
    LangString ${UN}ReadmeSubHeader  ${MUI_LANG} "${ReadmeSubHeader}"
    LangString ${UN}ReadmeTextTop    ${MUI_LANG} "${ReadmeTextTop}"
    LangString ${UN}ReadmeTextBottom ${MUI_LANG} "${ReadmeTextBottom}"
!macroend
 
!define ReadmeLanguage '!insertmacro ReadmeLangStrings ""'
 
!define Un.ReadmeLanguage '!insertmacro ReadmeLangStrings "UN"'
 
!endif
!endif

Usage Example

;NSIS Modern User Interface
;Welcome/Finish Page Example Script
;Written by Joost Verburg
;--------------------------------
;Include Modern UI
 
  !include "MUI.nsh"
  ;include the header
  !include "MUI_EXTRAPAGES.nsh"
;--------------------------------
;General
 
  ;Name and file
  Name "Modern UI Test"
  OutFile "WelcomeFinish.exe"
 
  ;Default installation folder
  InstallDir "$PROGRAMFILES\Modern UI Test"
 
  ;Get installation folder from registry if available
  InstallDirRegKey HKCU "Software\Modern UI Test" ""
 
;--------------------------------
;Interface Settings
 
  !define MUI_ABORTWARNING
 
;--------------------------------
;Pages
  !insertmacro MUI_PAGE_WELCOME
  !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
 
   ;add the read me page
  !insertmacro MUI_PAGE_README '${NSISDIR}\Docs\Modern UI\Changelog.txt'
 
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY
  !insertmacro MUI_PAGE_INSTFILES
  !insertmacro MUI_PAGE_FINISH
 
  !insertmacro MUI_UNPAGE_WELCOME
 
   ;add the uninstall read me page
  !insertmacro MUI_UNPAGE_README '${NSISDIR}\License.txt'
 
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
  !insertmacro MUI_UNPAGE_FINISH
 
;--------------------------------
;Languages
 
  !insertmacro MUI_LANGUAGE "English"
  ;set up lang strings for 1st lang
  ${ReadmeLanguage} '${LANG_ENGLISH}' \
          'Read Me' \
          'Please review the following important information.' \
          'About $(^name):' \
          '$\n  Click on scrollbar arrows or press Page Down to review the entire text.'
 
  ${Un.ReadmeLanguage} '${LANG_ENGLISH}' \
          'Read Me' \
          'Please review the following important Uninstall information.' \
          'About $(^name) Uninstall:' \
          '$\n  Click on scrollbar arrows or press Page Down to review the entire text.'
 
 
  !insertmacro MUI_LANGUAGE "Greek"
  ;set up lang strings for second lang
  ${ReadmeLanguage} '${LANG_GREEK}' \
          'Read Me' \
          'Please review the following important information' \
          'About $(^name):' \
          '$\n  Click on scrollbar arrows or press Page Down to review the entire text.'
 
 
  ${Un.ReadmeLanguage} '${LANG_GREEK}' \
          'Read Me' \
          'Please review the following important Uninstall information' \
          'About $(^name) Uninstall:' \
          '$\n  Click on scrollbar arrows or press Page Down to review the entire text.'
 
;--------------------------------
;Installer Sections
 
Section "Dummy Section" SecDummy
 
  SetOutPath "$INSTDIR"
 
  ;ADD YOUR OWN FILES HERE...
 
  ;Store installation folder
  WriteRegStr HKCU "Software\Modern UI Test" "" $INSTDIR
 
  ;Create uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"
 
SectionEnd
 
;--------------------------------
;Descriptions
 
  ;Language strings
  LangString DESC_SecDummy ${LANG_ENGLISH} "A test section."
 
  ;Assign language strings to sections
  !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
    !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
  !insertmacro MUI_FUNCTION_DESCRIPTION_END
 
;--------------------------------
;Uninstaller Section
 
Section "Uninstall"
 
  ;ADD YOUR OWN FILES HERE...
 
  Delete "$INSTDIR\Uninstall.exe"
 
  RMDir "$INSTDIR"
 
  DeleteRegKey /ifempty HKCU "Software\Modern UI Test"
 
SectionEnd
 
;-------------------------------
 
Function .onInit
 
  !insertmacro MUI_LANGDLL_DISPLAY
 
FunctionEnd
 
Function un.onInit
 
  !insertmacro MUI_UNGETLANGUAGE
 
FunctionEnd

License

This header file is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this header file.

Permission is granted to anyone to use this header file for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this header file must not be misrepresented; you must not claim that you wrote the original header file. If you use this header file in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered versions must be plainly marked as such, and must not be misrepresented as being the original header file.
  3. This notice may not be removed or altered from any distribution.