| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- !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
- ; Installation work publishes stage changes without disturbing the NSIS caller.
- !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 customInstallerExtract Archive
- !insertmacro InstallerPublishStage 1
- System::Store /NOUNLOAD "S"
- System::Call /NOUNLOAD '$PLUGINSDIR\window-frame.dll::InstallerExtract(p $HWNDPARENT, w "$PLUGINSDIR\dsh-7za.exe", w "${Archive}", w "$INSTDIR", w "$PLUGINSDIR\extract.log") i.s ?c'
- System::Store "L"
- Pop $R0
- StrCpy $R1 "$R0"
- ${If} $R0 != 0
- Push $0
- FileOpen $0 "$PLUGINSDIR\extract.log" r
- ${IfNot} ${Errors}
- FileRead $0 $R1
- FileClose $0
- ${EndIf}
- Pop $0
- ${EndIf}
- !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}
- !insertmacro InstallerPublishStage 4
- !insertmacro dshFinishDirectories
- ${If} $0 == 1
- SetErrors
- ${Else}
- ClearErrors
- ${EndIf}
- Pop $0
- !macroend
|