| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- !include "LogicLib.nsh"
- !define INSTALLER_SOURCE_DIR "${__FILEDIR__}\..\installer"
- !define /ifndef INSTALLER_BUILD_DIR "${__FILEDIR__}\..\.desktop-build\targets\win-x64\installer-ui"
- !ifndef BUILD_UNINSTALLER
- ManifestDPIAware true
- !define MUI_CUSTOMFUNCTION_GUIINIT InstallerGuiInit
- !endif
- !macro customHeader
- !include "${INSTALLER_SOURCE_DIR}\strings.nsh"
- !ifndef BUILD_UNINSTALLER
- !include "${INSTALLER_SOURCE_DIR}\theme.nsh"
- !include "${INSTALLER_SOURCE_DIR}\pages.nsh"
- !include "${INSTALLER_SOURCE_DIR}\lifecycle.nsh"
- !endif
- !macroend
- !macro customInit
- ${If} ${isForAllUsers}
- MessageBox MB_OK|MB_ICONEXCLAMATION "$(INSTALLER_PER_USER)" /SD IDOK
- SetErrorLevel 2
- Quit
- ${EndIf}
- ReadRegStr $0 HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation
- ${If} $0 != ""
- MessageBox MB_OK|MB_ICONEXCLAMATION "$(INSTALLER_PER_USER)" /SD IDOK
- SetErrorLevel 2
- Quit
- ${EndIf}
- !insertmacro setInstallModePerUser
- StrCpy $hasPerMachineInstallation 0
- StrCpy $hasPerUserInstallation 1
- StrCpy $InstallerPath $INSTDIR
- StrCpy $InstallerTheme "auto"
- ${GetParameters} $0
- ${GetOptions} $0 "/THEME=" $1
- ${IfNot} ${Errors}
- ${If} $1 == "light"
- ${OrIf} $1 == "dark"
- ${OrIf} $1 == "auto"
- StrCpy $InstallerTheme $1
- ${Else}
- MessageBox MB_OK|MB_ICONEXCLAMATION "$(INSTALLER_THEME_ERROR)" /SD IDOK
- SetErrorLevel 2
- Quit
- ${EndIf}
- ${EndIf}
- Call InstallerResolveTheme
- InitPluginsDir
- File "/oname=$PLUGINSDIR\brand.bmp" "${INSTALLER_BUILD_DIR}\brand.bmp"
- File "/oname=$PLUGINSDIR\brand-2x.bmp" "${INSTALLER_BUILD_DIR}\brand-2x.bmp"
- File "/oname=$PLUGINSDIR\brand-dark.bmp" "${INSTALLER_BUILD_DIR}\brand-dark.bmp"
- File "/oname=$PLUGINSDIR\brand-dark-2x.bmp" "${INSTALLER_BUILD_DIR}\brand-dark-2x.bmp"
- File "/oname=$PLUGINSDIR\window-frame.dll" "${INSTALLER_BUILD_DIR}\window-frame.dll"
- ${If} ${Silent}
- Call InstallerPreflight
- ${If} $InstallerError != ""
- SetErrorLevel 2
- Quit
- ${EndIf}
- ${EndIf}
- !macroend
- !macro customInstallMode
- ; Preserve the directory selected on the custom welcome page.
- StrCpy $installMode CurrentUser
- SetShellVarContext current
- Abort
- !macroend
- !macro customWelcomePage
- Page custom InstallerWelcome InstallerWelcomeLeave
- !macroend
- !macro customPageAfterChangeDir
- !define MUI_PAGE_CUSTOMFUNCTION_PRE InstallerBeforeInstall
- !define MUI_PAGE_CUSTOMFUNCTION_SHOW InstallerProgressShow
- !macroend
- !macro customFinishPage
- Page custom InstallerFinish InstallerFinishLeave
- !macroend
- ; The pinned builder's extraction hooks only publish stages; its worker owns all file operations.
- !macro InstallerPublishStage Stage
- ; Extraction owns the stack and error flag across these callbacks.
- Push $0
- StrCpy $0 0
- ${If} ${Errors}
- StrCpy $0 1
- ${EndIf}
- System::Store /NOUNLOAD "S"
- System::Call /NOUNLOAD 'user32::SetPropW(p $HWNDPARENT, w "HarnessInstaller.Stage", p ${Stage})'
- System::Store "L"
- ${If} $0 == 1
- SetErrors
- ${Else}
- ClearErrors
- ${EndIf}
- Pop $0
- !macroend
- !macro customInstallerExtractStart
- !insertmacro InstallerPublishStage 1
- !macroend
- !macro customInstallerCopyStart
- !insertmacro InstallerPublishStage 2
- !macroend
- !macro customInstallerFilesReady
- !insertmacro InstallerPublishStage 3
- !macroend
- !macro customCheckAppRunning
- !ifdef BUILD_UNINSTALLER
- InitPluginsDir
- File "/oname=$PLUGINSDIR\window-frame.dll" "${INSTALLER_BUILD_DIR}\window-frame.dll"
- !endif
- System::Call '$PLUGINSDIR\window-frame.dll::InstallerFindProcess(w "$INSTDIR\${APP_EXECUTABLE_FILENAME}") i.R0 ?c'
- ${If} $R0 == 0
- ${If} ${isUpdated}
- StrCpy $R1 0
- ${DoWhile} $R0 == 0
- Sleep 250
- System::Call '$PLUGINSDIR\window-frame.dll::InstallerFindProcess(w "$INSTDIR\${APP_EXECUTABLE_FILENAME}") i.R0 ?c'
- IntOp $R1 $R1 + 1
- ${If} $R1 >= 40
- ${ExitDo}
- ${EndIf}
- ${Loop}
- ${EndIf}
- ${If} $R0 == 0
- MessageBox MB_OK|MB_ICONINFORMATION "$(INSTALLER_RUNNING)" /SD IDOK
- SetErrorLevel 2
- Quit
- ${EndIf}
- ${EndIf}
- ${If} $R0 < 0
- MessageBox MB_OK|MB_ICONEXCLAMATION "$(INSTALLER_UI_ERROR)" /SD IDOK
- SetErrorLevel 2
- Quit
- ${EndIf}
- !macroend
- !ifndef BUILD_UNINSTALLER
- !include "${__FILEDIR__}\installer-directories.nsh"
- !endif
- !macro customInstall
- Push $0
- StrCpy $0 0
- ${If} ${Errors}
- StrCpy $0 1
- ${EndIf}
- ; Finish can launch the app while NSIS removes its remaining plugin directory.
- !insertmacro InstallerPublishStage 4
- !insertmacro dshFinishDirectories
- RMDir /r "$PLUGINSDIR\7z-out"
- ${If} $0 == 1
- SetErrors
- ${Else}
- ClearErrors
- ${EndIf}
- Pop $0
- !macroend
|