scriptable-client-installers/T7x/Contrib/Modern UI 2/Pages/Directory.nsh
2023-12-15 15:41:40 -05:00

144 lines
4.0 KiB
Plaintext

/*
NSIS Modern User Interface
Directory page
*/
;--------------------------------
;Page interface settings and variables
!macro MUI_DIRECTORYPAGE_INTERFACE
!ifndef MUI_DIRECTORYPAGE_INTERFACE
!define MUI_DIRECTORYPAGE_INTERFACE
Var mui.DirectoryPage
Var mui.DirectoryPage.Text
Var mui.DirectoryPage.DirectoryBox
Var mui.DirectoryPage.Directory
Var mui.DirectoryPage.BrowseButton
Var mui.DirectoryPage.SpaceRequired
Var mui.DirectoryPage.SpaceAvailable
!endif
!macroend
;--------------------------------
;Page declaration
!macro MUI_PAGEDECLARATION_DIRECTORY
!insertmacro MUI_SET MUI_${MUI_PAGE_UNINSTALLER_PREFIX}DIRECTORYPAGE ""
!insertmacro MUI_DIRECTORYPAGE_INTERFACE
!insertmacro MUI_DEFAULT MUI_DIRECTORYPAGE_TEXT_TOP "SAMPLETEXT"
!insertmacro MUI_DEFAULT MUI_DIRECTORYPAGE_TEXT_DESTINATION "Location:"
PageEx ${MUI_PAGE_UNINSTALLER_FUNCPREFIX}directory
PageCallbacks ${MUI_PAGE_UNINSTALLER_FUNCPREFIX}mui.DirectoryPre_${MUI_UNIQUEID} ${MUI_PAGE_UNINSTALLER_FUNCPREFIX}mui.DirectoryShow_${MUI_UNIQUEID} ${MUI_PAGE_UNINSTALLER_FUNCPREFIX}mui.DirectoryLeave_${MUI_UNIQUEID}
Caption " "
DirText "${MUI_DIRECTORYPAGE_TEXT_TOP}" "${MUI_DIRECTORYPAGE_TEXT_DESTINATION}"
!ifdef MUI_DIRECTORYPAGE_VARIABLE
DirVar "${MUI_DIRECTORYPAGE_VARIABLE}"
!endif
!ifdef MUI_DIRECTORYPAGE_VERIFYONLEAVE
DirVerify leave
!endif
PageExEnd
!insertmacro MUI_FUNCTION_DIRECTORYPAGE ${MUI_PAGE_UNINSTALLER_FUNCPREFIX}mui.DirectoryPre_${MUI_UNIQUEID} ${MUI_PAGE_UNINSTALLER_FUNCPREFIX}mui.DirectoryShow_${MUI_UNIQUEID} ${MUI_PAGE_UNINSTALLER_FUNCPREFIX}mui.DirectoryLeave_${MUI_UNIQUEID}
!undef MUI_DIRECTORYPAGE_TEXT_TOP
!undef MUI_DIRECTORYPAGE_TEXT_DESTINATION
!insertmacro MUI_UNSET MUI_DIRECTORYPAGE_VARIABLE
!insertmacro MUI_UNSET MUI_DIRECTORYPAGE_VERIFYONLEAVE
!macroend
!macro MUI_PAGE_DIRECTORY
!verbose push
!verbose ${MUI_VERBOSE}
!insertmacro MUI_PAGE_INIT
!insertmacro MUI_PAGEDECLARATION_DIRECTORY
!verbose pop
!macroend
!macro MUI_UNPAGE_DIRECTORY
!verbose push
!verbose ${MUI_VERBOSE}
!insertmacro MUI_UNPAGE_INIT
!insertmacro MUI_PAGEDECLARATION_DIRECTORY
!verbose pop
!macroend
;--------------------------------
;Page functions
!macro MUI_FUNCTION_DIRECTORYPAGE PRE SHOW LEAVE
Function "${PRE}"
!insertmacro MUI_PAGE_FUNCTION_CUSTOM PRE
!insertmacro MUI_HEADER_TEXT_PAGE $(MUI_${MUI_PAGE_UNINSTALLER_PREFIX}TEXT_DIRECTORY_TITLE) $(MUI_${MUI_PAGE_UNINSTALLER_PREFIX}TEXT_DIRECTORY_SUBTITLE)
ReadRegStr $0 HKLM "SOFTWARE\Activision\Call of Duty WAW" "InstallPath"
ReadRegStr $1 HKLM "SOFTWARE\UGX-Mods\Map Installer" "InstallPath"
;If the key has already been created by a past installation, and if it matches the key found for the install path, continue
${if} $0 != ""
${AndIf} $0 == $1
Abort
${EndIf}
${if} $0 != ""
StrCpy $INSTDIR $0
WriteRegStr HKLM "Software\UGX-Mods\Map Installer" "InstallPath" "$INSTDIR"
Abort
${EndIf}
;If we haven't aborted yet, then this is a first time install and their installation key is missing from registry. Let them find their directory and then we will save it to the registry later in InstallFiles.nsh
FunctionEnd
Function "${SHOW}"
;Get control handles
FindWindow $mui.DirectoryPage "#32770" "" $HWNDPARENT
GetDlgItem $mui.DirectoryPage.Text $mui.DirectoryPage 1006
GetDlgItem $mui.DirectoryPage.DirectoryBox $mui.DirectoryPage 1020
GetDlgItem $mui.DirectoryPage.Directory $mui.DirectoryPage 1019
GetDlgItem $mui.DirectoryPage.BrowseButton $mui.DirectoryPage 1001
GetDlgItem $mui.DirectoryPage.SpaceRequired $mui.DirectoryPage 1023
GetDlgItem $mui.DirectoryPage.SpaceAvailable $mui.DirectoryPage 1024
!ifdef MUI_DIRECTORYPAGE_BGCOLOR
SetCtlColors $mui.DirectoryPage.Directory "" "${MUI_DIRECTORYPAGE_BGCOLOR}"
!endif
!insertmacro MUI_PAGE_FUNCTION_CUSTOM SHOW
FunctionEnd
Function "${LEAVE}"
!insertmacro MUI_PAGE_FUNCTION_CUSTOM LEAVE
FunctionEnd
!macroend