diff --git a/Examples/Memento.nsi b/Examples/Memento.nsi new file mode 100644 index 00000000..6b2c24e2 --- /dev/null +++ b/Examples/Memento.nsi @@ -0,0 +1,77 @@ +!include LogicLib.nsh +!include Memento.nsh + +Name Memento +OutFile Memento.exe + +XPStyle on + +ShowInstDetails show + +Page components +Page instfiles + +# settings + +!define MEMENTO_REGISTRY_ROOT HKLM +!define MEMENTO_REGISTRY_KEY "Software\NSIS\Memento Test" + +# restore + +Function .onInit + + ${If} ${Cmd} `MessageBox MB_YESNO "Would you like to load an example state?" IDYES` + + DeleteRegKey HKLM "Software\NSIS\Memento Test" + + WriteRegStr HKLM "Software\NSIS\Memento Test" MementoSectionUsed "" + WriteRegDWORD HKLM "Software\NSIS\Memento Test" MementoSection_sec_horse 1 + WriteRegDWORD HKLM "Software\NSIS\Memento Test" MementoSection_sec_chicken 1 + WriteRegDWORD HKLM "Software\NSIS\Memento Test" MementoSection_sec_donkey 0 + WriteRegDWORD HKLM "Software\NSIS\Memento Test" MementoSection_sec_croc 0 + + ${EndIf} + + ${MementoSectionRestore} + +FunctionEnd + +# sections + +${MementoSection} horse sec_horse +${MementoSectionEnd} + +${MementoSection} donkey sec_donkey +${MementoSectionEnd} + +${MementoSection} chicken sec_chicken +${MementoSectionEnd} + +SectionGroup /e group + + SectionGroup /e group + + ${MementoSection} croc sec_croc + ${MementoSectionEnd} + + ${MementoSection} cow sec_cow + ${MementoSectionEnd} + + SectionGroupEnd + +SectionGroupEnd + +${MementoUnselectedSection} dinosaur sec_dinosaur +${MementoSectionEnd} + +# done... + +${MementoSectionDone} + +# save + +Function .onInstSuccess + + ${MementoSectionSave} + +FunctionEnd diff --git a/Examples/SConscript b/Examples/SConscript index 71bd7637..2fa2a301 100644 --- a/Examples/SConscript +++ b/Examples/SConscript @@ -11,6 +11,7 @@ examples = Split(""" LogicLib.nsi makensis.ini makensis.nsi + Memento.nsi one-section.nsi primes.nsi rtest.nsi diff --git a/Examples/makensis.nsi b/Examples/makensis.nsi index f4f2d08a..98d3f160 100644 --- a/Examples/makensis.nsi +++ b/Examples/makensis.nsi @@ -31,6 +31,7 @@ RequestExecutionLevel admin !include "MUI.nsh" !include "Sections.nsh" !include "LogicLib.nsh" +!include "Memento.nsh" ;-------------------------------- ;Definitions @@ -45,6 +46,10 @@ RequestExecutionLevel admin Name "NSIS" Caption "NSIS ${VERSION} Setup" +;Memento Settings +!define MEMENTO_REGISTRY_ROOT HKLM +!define MEMENTO_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" + ;Interface Settings !define MUI_ABORTWARNING @@ -97,7 +102,7 @@ Page custom PageReinstall PageLeaveReinstall ;-------------------------------- ;Installer Sections -Section "NSIS Core Files (required)" SecCore +${MementoSection} "NSIS Core Files (required)" SecCore SetDetailsPrint textonly DetailPrint "Installing NSIS Core Files..." @@ -142,6 +147,7 @@ Section "NSIS Core Files (required)" SecCore File ..\Include\WordFunc.nsh File ..\Include\WinVer.nsh File ..\Include\x64.nsh + File ..\Include\Memento.nsh SetOutPath $INSTDIR\Docs\StrFunc File ..\Docs\StrFunc\StrFunc.txt @@ -203,9 +209,9 @@ Section "NSIS Core Files (required)" SecCore System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' -SectionEnd +${MementoSectionEnd} -Section "Script Examples" SecExample +${MementoSection} "Script Examples" SecExample SetDetailsPrint textonly DetailPrint "Installing Script Examples..." @@ -240,17 +246,17 @@ Section "Script Examples" SecExample File ..\Examples\WordFunc.nsi File ..\Examples\WordFunc.ini File ..\Examples\WordFuncTest.nsi -SectionEnd +${MementoSectionEnd} !ifndef NO_STARTMENUSHORTCUTS -Section "Start Menu and Desktop Shortcuts" SecShortcuts +${MementoSection} "Start Menu and Desktop Shortcuts" SecShortcuts SetDetailsPrint textonly DetailPrint "Installing Start Menu and Desktop Shortcuts..." SetDetailsPrint listonly !else -Section "Desktop Shortcut" SecShortcuts +${MementoSection} "Desktop Shortcut" SecShortcuts SetDetailsPrint textonly DetailPrint "Installing Desktop Shortcut..." @@ -274,11 +280,11 @@ Section "Desktop Shortcut" SecShortcuts CreateShortCut "$DESKTOP\Nullsoft Install System.lnk" "$INSTDIR\NSIS.exe" -SectionEnd +${MementoSectionEnd} SectionGroup "User Interfaces" SecInterfaces -Section "Modern User Interface" SecInterfacesModernUI +${MementoSection} "Modern User Interface" SecInterfacesModernUI SetDetailsPrint textonly DetailPrint "Installing User Interfaces | Modern User Interface..." @@ -323,9 +329,9 @@ Section "Modern User Interface" SecInterfacesModernUI SetOutPath $INSTDIR\Include File "..\Include\MUI.nsh" -SectionEnd +${MementoSectionEnd} -Section "Default User Interface" SecInterfacesDefaultUI +${MementoSection} "Default User Interface" SecInterfacesDefaultUI SetDetailsPrint textonly DetailPrint "Installing User Interfaces | Default User Interface..." @@ -336,9 +342,9 @@ Section "Default User Interface" SecInterfacesDefaultUI SetOutPath "$INSTDIR\Contrib\UIs" File "..\Contrib\UIs\default.exe" -SectionEnd +${MementoSectionEnd} -Section "Tiny User Interface" SecInterfacesTinyUI +${MementoSection} "Tiny User Interface" SecInterfacesTinyUI SetDetailsPrint textonly DetailPrint "Installing User Interfaces | Tiny User Interface..." @@ -349,11 +355,11 @@ Section "Tiny User Interface" SecInterfacesTinyUI SetOutPath "$INSTDIR\Contrib\UIs" File "..\Contrib\UIs\sdbarker_tiny.exe" -SectionEnd +${MementoSectionEnd} SectionGroupEnd -Section "Graphics" SecGraphics +${MementoSection} "Graphics" SecGraphics SetDetailsPrint textonly DetailPrint "Installing Graphics..." @@ -367,9 +373,9 @@ Section "Graphics" SecGraphics SetOutPath $INSTDIR\Contrib\Graphics File /r "..\Contrib\Graphics\*.ico" File /r "..\Contrib\Graphics\*.bmp" -SectionEnd +${MementoSectionEnd} -Section "Language Files" SecLangFiles +${MementoSection} "Language Files" SecLangFiles SetDetailsPrint textonly DetailPrint "Installing Language Files..." @@ -389,11 +395,11 @@ Section "Language Files" SecLangFiles File "..\Contrib\Modern UI\Language files\*.nsh" nomui: -SectionEnd +${MementoSectionEnd} SectionGroup "Tools" SecTools -Section "Zip2Exe" SecToolsZ2E +${MementoSection} "Zip2Exe" SecToolsZ2E SetDetailsPrint textonly DetailPrint "Installing Tools | Zip2Exe..." @@ -408,13 +414,13 @@ Section "Zip2Exe" SecToolsZ2E File ..\Contrib\zip2exe\Modern.nsh File ..\Contrib\zip2exe\Classic.nsh -SectionEnd +${MementoSectionEnd} SectionGroupEnd SectionGroup "Plug-ins" SecPluginsPlugins -Section "Banner" SecPluginsBanner +${MementoSection} "Banner" SecPluginsBanner SetDetailsPrint textonly DetailPrint "Installing Plug-ins | Banner..." @@ -428,9 +434,9 @@ Section "Banner" SecPluginsBanner File ..\Docs\Banner\Readme.txt SetOutPath $INSTDIR\Examples\Banner File ..\Examples\Banner\Example.nsi -SectionEnd +${MementoSectionEnd} -Section "Language DLL" SecPluginsLangDLL +${MementoSection} "Language DLL" SecPluginsLangDLL SetDetailsPrint textonly DetailPrint "Installing Plug-ins | Language DLL..." @@ -439,9 +445,9 @@ Section "Language DLL" SecPluginsLangDLL SectionIn 1 SetOutPath $INSTDIR\Plugins File ..\Plugins\LangDLL.dll -SectionEnd +${MementoSectionEnd} -Section "nsExec" SecPluginsnsExec +${MementoSection} "nsExec" SecPluginsnsExec SetDetailsPrint textonly DetailPrint "Installing Plug-ins | nsExec..." @@ -455,9 +461,9 @@ Section "nsExec" SecPluginsnsExec File ..\Docs\nsExec\nsExec.txt SetOutPath $INSTDIR\Examples\nsExec File ..\Examples\nsExec\test.nsi -SectionEnd +${MementoSectionEnd} -Section "Splash" SecPluginsSplash +${MementoSection} "Splash" SecPluginsSplash SetDetailsPrint textonly DetailPrint "Installing Plug-ins | Splash..." @@ -471,9 +477,9 @@ Section "Splash" SecPluginsSplash File ..\Docs\Splash\splash.txt SetOutPath $INSTDIR\Examples\Splash File ..\Examples\Splash\Example.nsi -SectionEnd +${MementoSectionEnd} -Section "AdvSplash" SecPluginsSplashT +${MementoSection} "AdvSplash" SecPluginsSplashT SetDetailsPrint textonly DetailPrint "Installing Plug-ins | AdvSplash..." @@ -487,9 +493,9 @@ Section "AdvSplash" SecPluginsSplashT File ..\Docs\AdvSplash\advsplash.txt SetOutPath $INSTDIR\Examples\AdvSplash File ..\Examples\AdvSplash\Example.nsi -SectionEnd +${MementoSectionEnd} -Section "BgImage" SecPluginsBgImage +${MementoSection} "BgImage" SecPluginsBgImage SetDetailsPrint textonly DetailPrint "Installing Plug-ins | BgImage..." @@ -503,9 +509,9 @@ Section "BgImage" SecPluginsBgImage File ..\Docs\BgImage\BgImage.txt SetOutPath $INSTDIR\Examples\BgImage File ..\Examples\BgImage\Example.nsi -SectionEnd +${MementoSectionEnd} -Section "InstallOptions" SecPluginsIO +${MementoSection} "InstallOptions" SecPluginsIO SetDetailsPrint textonly DetailPrint "Installing Plug-ins | InstallOptions..." @@ -527,9 +533,9 @@ Section "InstallOptions" SecPluginsIO File ..\Examples\InstallOptions\testlink.nsi File ..\Examples\InstallOptions\testnotify.ini File ..\Examples\InstallOptions\testnotify.nsi -SectionEnd +${MementoSectionEnd} -Section "Math" SecPluginsMath +${MementoSection} "Math" SecPluginsMath SetDetailsPrint textonly DetailPrint "Installing Plug-ins | Math..." @@ -547,9 +553,9 @@ Section "Math" SecPluginsMath File ..\Examples\Math\mathtest.nsi File ..\Examples\Math\mathtest.ini -SectionEnd +${MementoSectionEnd} -Section "NSISdl" SecPluginsNSISDL +${MementoSection} "NSISdl" SecPluginsNSISDL SetDetailsPrint textonly DetailPrint "Installing Plug-ins | NSISdl..." @@ -562,9 +568,9 @@ Section "NSISdl" SecPluginsNSISDL SetOutPath $INSTDIR\Docs\NSISdl File ..\Docs\NSISdl\ReadMe.txt File ..\Docs\NSISdl\License.txt -SectionEnd +${MementoSectionEnd} -Section "System" SecPluginsSystem +${MementoSection} "System" SecPluginsSystem SetDetailsPrint textonly DetailPrint "Installing Plug-ins | System..." @@ -582,9 +588,9 @@ Section "System" SecPluginsSystem File ..\Examples\System\SysFunc.nsh File ..\Examples\System\System.nsh File ..\Examples\System\System.nsi -SectionEnd +${MementoSectionEnd} -Section "StartMenu" SecPluginsStartMenu +${MementoSection} "StartMenu" SecPluginsStartMenu SetDetailsPrint textonly DetailPrint "Installing Plug-ins | StartMenu..." @@ -598,9 +604,9 @@ Section "StartMenu" SecPluginsStartMenu File ..\Docs\StartMenu\Readme.txt SetOutPath $INSTDIR\Examples\StartMenu File ..\Examples\StartMenu\Example.nsi -SectionEnd +${MementoSectionEnd} -Section "UserInfo" SecPluginsUserInfo +${MementoSection} "UserInfo" SecPluginsUserInfo SetDetailsPrint textonly DetailPrint "Installing Plug-ins | UserInfo..." @@ -612,9 +618,9 @@ Section "UserInfo" SecPluginsUserInfo File ..\Plugins\UserInfo.dll SetOutPath $INSTDIR\Examples\UserInfo File ..\Examples\UserInfo\UserInfo.nsi -SectionEnd +${MementoSectionEnd} -Section "Dialer" SecPluginsDialer +${MementoSection} "Dialer" SecPluginsDialer SetDetailsPrint textonly DetailPrint "Installing Plug-ins | Dialer..." @@ -626,9 +632,9 @@ Section "Dialer" SecPluginsDialer File ..\Plugins\Dialer.dll SetOutPath $INSTDIR\Docs\Dialer File ..\Docs\Dialer\Dialer.txt -SectionEnd +${MementoSectionEnd} -Section "VPatch" SecPluginsVPatch +${MementoSection} "VPatch" SecPluginsVPatch SetDetailsPrint textonly DetailPrint "Installing Plug-ins | VPatch..." @@ -649,7 +655,9 @@ Section "VPatch" SecPluginsVPatch File ..\Bin\GenPat.exe SetOutPath $INSTDIR\Include File ..\Include\VPatchLib.nsh -SectionEnd +${MementoSectionEnd} + +${MementoSectionDone} SectionGroupEnd @@ -797,6 +805,8 @@ Section -post WriteUninstaller $INSTDIR\uninst-nsis.exe + ${MementoSectionSave} + SetDetailsPrint both SectionEnd @@ -836,14 +846,20 @@ SectionEnd ;-------------------------------- ;Installer Functions -!ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD - Function .onInit +!ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "makensis.ini" + +!endif + + ${MementoSectionRestore} FunctionEnd +!ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD + Function PageReinstall ReadRegStr $R0 HKLM "Software\NSIS" "" diff --git a/Include/Memento.nsh b/Include/Memento.nsh new file mode 100644 index 00000000..ea04f706 --- /dev/null +++ b/Include/Memento.nsh @@ -0,0 +1,522 @@ +!verbose push +!verbose 3 + +!include LogicLib.nsh +!include Sections.nsh + +!ifndef ___MEMENTO_NSH___ +!define ___MEMENTO_NSH___ + +##################################### +### Memento ### +##################################### + +/* + +Memento is a set of macros that allow installers to remember user selection +across separate runs of the installer. Currently, it can remember the state +of sections and mark new sections as bold. In the future, it'll integrate +InstallOptions and maybe even the Modern UI. + +A usage example can be found in `Examples\Memento.nsi`. + +*/ + +##################################### +### Usage Instructions ### +##################################### + +/* + +1. Declare usage of Memento by including Memento.nsh at the top of the script. + + !include Memento.nsh + +2. Define MEMENTO_REGISTRY_ROOT and MEMENTO_REGISTRY_KEY with the a registry key + where sections' state should be saved. + + !define MEMENTO_REGISTRY_ROOT HKLM + !define MEMENTO_REGISTRY_KEY \ + Software\Microsoft\Windows\CurrentVersion\Uninstall\MyProgram + +3. Replace Section with ${MementoSection} and SectionEnd with ${MementoSection} + for sections that whose state should be remembered by Memento. + + For sections that should be unselected by default, use ${MementoSection}'s + brother - ${MementoUnselectedSection}. + + Sections that don't already have an identifier must be assigned one. + + Section identifiers must stay the same across different versions of the + installer or their state will be forgotten. + +4. Add a call to ${MementoSectionRestore} to .onInit to restore the state + of all sections from the registry. + + Function .onInit + + ${MementoSectionRestore} + + FunctionEnd + +5. Add a call to ${MementoSectionSave} to .onInstSuccess to save the state + of all sections to the registry. + + Function .onInstSuccess + + ${MementoSectionSave} + + FunctionEnd + +6. Tattoo the location of the chosen registry key on your arm. + +*/ + +##################################### +### User API ### +##################################### + +; +; ${MementoSection} +; +; Defines a section whose state is remembered by Memento. +; +; Usage is similar to Section. +; +; ${MementoSection} "name" "some_id" +; + +!define MementoSection "!insertmacro MementoSection" + +; +; ${MementoSectionEnd} +; +; Ends a section previously opened using ${MementoSection}. +; +; Usage is similar to SectionEnd. +; +; ${MementoSection} "name" "some_id" +; # some code... +; ${MementoSectionEnd} +; + +; +; ${MementoUnselectedSection} +; +; Defines a section whose state is remembered by Memento and is +; unselected by default. +; +; Usage is similar to Section with the /o switch. +; +; ${MementoUnselectedSection} "name" "some_id" +; + +!define MementoUnselectedSection "!insertmacro MementoUnselectedSection" + +; +; ${MementoSectionEnd} +; +; Ends a section previously opened using ${MementoSection}. +; +; Usage is similar to SectionEnd. +; +; ${MementoSection} "name" "some_id" +; # some code... +; ${MementoSectionEnd} +; + +!define MementoSectionEnd "!insertmacro MementoSectionEnd" + +; +; ${MementoSectionDone} +; +; Used after all ${MementoSection} have been set. +; +; ${MementoSection} "name1" "some_id1" +; # some code... +; ${MementoSectionEnd} +; +; ${MementoSection} "name2" "some_id2" +; # some code... +; ${MementoSectionEnd} +; +; ${MementoSection} "name3" "some_id3" +; # some code... +; ${MementoSectionEnd} +; +; ${MementoSectionDone} +; + +!define MementoSectionDone "!insertmacro MementoSectionDone" + +; +; ${MementoSectionRestore} +; +; Restores the state of all Memento sections from the registry. +; +; Commonly used in .onInit. +; +; Function .onInit +; +; ${MementoSectionRestore} +; +; FunctionEnd +; + +!define MementoSectionRestore "!insertmacro MementoSectionRestore" + +; +; ${MementoSectionSave} +; +; Saves the state of all Memento sections to the registry. +; +; Commonly used in .onInstSuccess. +; +; Function .onInstSuccess +; +; ${MementoSectionSave} +; +; FunctionEnd +; + +!define MementoSectionSave "!insertmacro MementoSectionSave" + + +##################################### +### Internal Defines ### +##################################### + +!define __MementoSectionIndex 1 + +##################################### +### Internal Macros ### +##################################### + +!macro __MementoCheckSettings + + !ifndef MEMENTO_REGISTRY_ROOT | MEMENTO_REGISTRY_KEY + + !error "MEMENTO_REGISTRY_ROOT and MEMENTO_REGISTRY_KEY must be defined before using any of Memento's macros" + + !endif + +!macroend + +!macro __MementoSection flags name id + + !insertmacro __MementoCheckSettings + + !ifndef __MementoSectionIndex + + !error "MementoSectionDone already used!" + + !endif + + !define __MementoSectionLastSectionId `${id}` + + !verbose pop + + Section ${flags} `${name}` `${id}` + + !verbose push + !verbose 3 + +!macroend + +##################################### +### User Macros ### +##################################### + +!macro MementoSection name id + + !verbose push + !verbose 3 + + !insertmacro __MementoSection "" `${name}` `${id}` + + !verbose pop + +!macroend + +!macro MementoUnselectedSection name id + + !verbose push + !verbose 3 + + !insertmacro __MementoSection /o `${name}` `${id}` + + !define __MementoSectionUnselected + + !verbose pop + +!macroend + +!macro MementoSectionEnd + + SectionEnd + + !verbose push + !verbose 3 + + !insertmacro __MementoCheckSettings + + !ifndef __MementoSectionIndex + + !error "MementoSectionDone already used!" + + !endif + + !define /MATH __MementoSectionIndexNext \ + ${__MementoSectionIndex} + 1 + + Function __MementoSectionMarkNew${__MementoSectionIndex} + + ClearErrors + ReadRegDWORD $0 ${MEMENTO_REGISTRY_ROOT} `${MEMENTO_REGISTRY_KEY}` `MementoSection_${__MementoSectionLastSectionId}` + + ${If} ${Errors} + + !insertmacro SetSectionFlag `${${__MementoSectionLastSectionId}}` ${SF_BOLD} + + ${EndIf} + + GetFunctionAddress $0 __MementoSectionMarkNew${__MementoSectionIndexNext} + Goto $0 + + FunctionEnd + + Function __MementoSectionRestoreStatus${__MementoSectionIndex} + + ClearErrors + ReadRegDWORD $0 ${MEMENTO_REGISTRY_ROOT} `${MEMENTO_REGISTRY_KEY}` `MementoSection_${__MementoSectionLastSectionId}` + + !ifndef __MementoSectionUnselected + + ${If} ${Errors} + ${OrIf} $0 != 0 + + !insertmacro SelectSection `${${__MementoSectionLastSectionId}}` + + ${Else} + + !insertmacro UnselectSection `${${__MementoSectionLastSectionId}}` + + ${EndIf} + + !else + + !undef __MementoSectionUnselected + + ${If} ${Errors} + ${OrIf} $0 == 0 + + !insertmacro UnselectSection `${${__MementoSectionLastSectionId}}` + + ${Else} + + !insertmacro SelectSection `${${__MementoSectionLastSectionId}}` + + ${EndIf} + + !endif + + GetFunctionAddress $0 __MementoSectionRestoreStatus${__MementoSectionIndexNext} + Goto $0 + + FunctionEnd + + Function __MementoSectionSaveStatus${__MementoSectionIndex} + + ${If} ${SectionIsSelected} `${${__MementoSectionLastSectionId}}` + + WriteRegDWORD ${MEMENTO_REGISTRY_ROOT} `${MEMENTO_REGISTRY_KEY}` `MementoSection_${__MementoSectionLastSectionId}` 1 + + ${Else} + + WriteRegDWORD ${MEMENTO_REGISTRY_ROOT} `${MEMENTO_REGISTRY_KEY}` `MementoSection_${__MementoSectionLastSectionId}` 0 + + ${EndIf} + + GetFunctionAddress $0 __MementoSectionSaveStatus${__MementoSectionIndexNext} + Goto $0 + + FunctionEnd + + !undef __MementoSectionIndex + !define __MementoSectionIndex ${__MementoSectionIndexNext} + !undef __MementoSectionIndexNext + + !undef __MementoSectionLastSectionId + + !verbose pop + +!macroend + +!macro MementoSectionDone + + !verbose push + !verbose 3 + + !insertmacro __MementoCheckSettings + + Function __MementoSectionMarkNew${__MementoSectionIndex} + FunctionEnd + + Function __MementoSectionRestoreStatus${__MementoSectionIndex} + FunctionEnd + + Function __MementoSectionSaveStatus${__MementoSectionIndex} + FunctionEnd + + !undef __MementoSectionIndex + + !verbose pop + +!macroend + +!macro MementoSectionRestore + + !verbose push + !verbose 3 + + !insertmacro __MementoCheckSettings + + Push $0 + Push $1 + Push $2 + Push $3 + + # check for first usage + + ClearErrors + + ReadRegStr $0 ${MEMENTO_REGISTRY_ROOT} `${MEMENTO_REGISTRY_KEY}` MementoSectionUsed + + ${If} ${Errors} + + # use script defaults on first run + Return + + ${EndIf} + + # mark new components in bold + + Call __MementoSectionMarkNew1 + + # mark section groups in bold + + StrCpy $0 0 + StrCpy $1 "" + StrCpy $2 "" + StrCpy $3 "" + + loop: + + ClearErrors + + ${If} ${SectionIsBold} $0 + + ${If} $1 != "" + + !insertmacro SetSectionFlag $1 ${SF_BOLD} + + ${EndIf} + + ${If} $2 != "" + + !insertmacro SetSectionFlag $2 ${SF_BOLD} + + ${EndIf} + + ${If} $3 != "" + + !insertmacro SetSectionFlag $3 ${SF_BOLD} + + ${EndIf} + + ${ElseIf} ${Errors} + + Goto done + + ${EndIf} + + ${If} ${SectionIsSectionGroup} $0 + + ${If} $1 == "" + + StrCpy $1 $0 + + ${ElseIf} $2 == "" + + StrCpy $2 $0 + + ${ElseIf} $3 == "" + + StrCpy $3 $0 + + ${EndIf} + + ${EndIf} + + ${If} ${SectionIsSectionGroupEnd} $0 + + ${If} $3 != "" + + StrCpy $3 "" + + ${ElseIf} $2 != "" + + StrCpy $2 "" + + ${ElseIf} $1 != "" + + StrCpy $1 "" + + ${EndIf} + + ${EndIf} + + IntOp $0 $0 + 1 + + Goto loop + done: + + # restore sections' status + + Call __MementoSectionRestoreStatus1 + + # all done + + Pop $3 + Pop $2 + Pop $1 + Pop $0 + + !verbose pop + +!macroend + +!macro MementoSectionSave + + !verbose push + !verbose 3 + + !insertmacro __MementoCheckSettings + + Push $0 + + WriteRegStr ${MEMENTO_REGISTRY_ROOT} `${MEMENTO_REGISTRY_KEY}` MementoSectionUsed "" + + Call __MementoSectionSaveStatus1 + + Pop $0 + + !verbose pop + +!macroend + + + +!endif # ___MEMENTO_NSH___ + +!verbose pop diff --git a/Include/SConscript b/Include/SConscript index 11b87949..e5d09e9f 100644 --- a/Include/SConscript +++ b/Include/SConscript @@ -3,6 +3,7 @@ includes = Split(""" FileFunc.nsh Library.nsh LogicLib.nsh + Memento.nsh MUI.nsh Sections.nsh StrFunc.nsh