2017-03-13 22:46:15 +00:00
; PCSX2 Pre-Installer Script
2019-01-26 03:45:37 +00:00
; Copyright (C) 2019 PCSX2 Team
2017-03-13 22:46:15 +00:00
!include "SharedDefs.nsh"
RequestExecutionLevel user
!define OUTFILE_POSTFIX "setup"
OutFile "pcsx2-${APP_VERSION}-${OUTFILE_POSTFIX}.exe"
2019-01-26 03:45:37 +00:00
; Dialogs and Controls
2017-03-16 23:01:45 +00:00
Var PreInstall_Dialog
Var PreInstall_DlgBack
Var PreInstall_DlgNext
2017-03-13 22:46:15 +00:00
Var InstallMode_Dialog
2017-03-16 23:01:45 +00:00
Var InstallMode_DlgBack
2017-03-13 22:46:15 +00:00
Var InstallMode_DlgNext
Var InstallMode_Label
2019-01-26 03:45:37 +00:00
# Normal installer mode (writes to Program Files)
Var InstallMode_Normal
# Portable installer mode
2017-03-13 22:46:15 +00:00
Var InstallMode_Portable
2019-01-26 03:45:37 +00:00
2017-03-13 22:46:15 +00:00
!include "nsDialogs.nsh"
Page Custom IsUserAdmin
2017-03-16 23:01:45 +00:00
Page Custom PreInstallDialog
2017-03-13 22:46:15 +00:00
Page Custom InstallMode InstallModeLeave
2020-05-05 19:02:07 +00:00
; Function located in SharedDefs
Section ""
Call IsUserAdmin
2020-09-22 19:24:04 +00:00
IfSilent 0 +5
Call TempFilesOut
${If} $option_portable == 0
Call StartFullInstaller
${EndIf}
2020-05-05 19:02:07 +00:00
SectionEnd
2017-03-13 22:46:15 +00:00
2017-03-16 23:01:45 +00:00
Function PreInstallDialog
nsDialogs::Create /NOUNLOAD 1018
Pop $PreInstall_Dialog
GetDlgItem $PreInstall_DlgBack $HWNDPARENT 3
EnableWindow $PreInstall_DlgBack ${SW_HIDE}
GetDlgItem $PreInstall_DlgNext $HWNDPARENT 1
EnableWindow $PreInstall_DlgNext 0
${NSD_CreateTimer} NSD_Timer.Callback 1
nsDialogs::Show
FunctionEnd
Function NSD_Timer.Callback
${NSD_KillTimer} NSD_Timer.Callback
2020-02-21 23:05:53 +00:00
;-----------------------------------------
; Copy installer files to a temp directory instead of repacking twice (for each installer)
${NSD_CreateLabel} 0 45 80% 10u "Unpacking files. Maybe it's time to upgrade that computer!"
2020-09-22 19:24:04 +00:00
Call TempFilesOut
${NSD_CreateLabel} 0 45 100% 10u "Moving on"
;-----------------------------------------
Call PreInstall_UsrWait
SendMessage $HWNDPARENT ${WM_COMMAND} 1 0
FunctionEnd
Function TempFilesOut
2020-05-05 19:02:07 +00:00
SetOutPath "$TEMP\PCSX2 ${APP_VERSION}"
2020-02-21 23:05:53 +00:00
File ..\bin\pcsx2.exe
2020-12-16 22:32:08 +00:00
File ..\bin\GameIndex.yaml
2020-02-21 23:05:53 +00:00
File ..\bin\cheats_ws.zip
File ..\bin\PCSX2_keys.ini.default
2020-05-05 19:02:07 +00:00
SetOutPath "$TEMP\PCSX2 ${APP_VERSION}\Docs"
2020-02-21 23:05:53 +00:00
File ..\bin\docs\*
2020-05-05 19:02:07 +00:00
SetOutPath "$TEMP\PCSX2 ${APP_VERSION}\Shaders"
2021-07-04 01:09:48 +00:00
File ..\bin\shaders\GS.fx
File ..\bin\shaders\GS_FX_Settings.ini
2020-02-21 23:05:53 +00:00
2020-09-22 19:24:04 +00:00
SetOutPath "$TEMP\PCSX2 ${APP_VERSION}\Langs"
2020-02-21 23:05:53 +00:00
File /nonfatal /r ..\bin\Langs\*.mo
2017-03-16 23:01:45 +00:00
FunctionEnd
Function PreInstall_UsrWait
GetDlgItem $PreInstall_DlgNext $HWNDPARENT 1
EnableWindow $PreInstall_DlgNext 1
2017-03-13 22:46:15 +00:00
FunctionEnd
2019-01-26 03:45:37 +00:00
# Creates the first dialog "section" to display a choice of installer modes.
2017-03-13 22:46:15 +00:00
Function InstallMode
nsDialogs::Create /NOUNLOAD 1018
Pop $InstallMode_Dialog
2019-01-26 03:45:37 +00:00
GetDlgItem $InstallMode_DlgBack $HWNDPARENT 3
EnableWindow $InstallMode_DlgBack 0
2017-03-16 23:01:45 +00:00
2019-01-26 03:45:37 +00:00
GetDlgItem $InstallMode_DlgNext $HWNDPARENT 1
EnableWindow $InstallMode_DlgNext 0
2017-03-13 22:46:15 +00:00
${NSD_CreateLabel} 0 0 100% 10u "Select an installation mode for PCSX2."
Pop $InstallMode_Label
2019-01-26 03:45:37 +00:00
${NSD_CreateRadioButton} 0 35 100% 10u "Normal Installation"
Pop $InstallMode_Normal
2017-03-13 22:46:15 +00:00
2019-01-26 03:45:37 +00:00
# If the user doesn't have admin rights, disable the button for the normal (non-portable) installer
2017-03-13 22:46:15 +00:00
${If} $IsAdmin == 0
2019-01-26 03:45:37 +00:00
EnableWindow $InstallMode_Normal 0
2017-03-13 22:46:15 +00:00
${EndIf}
2019-01-26 03:45:37 +00:00
# Create labels/buttons for the normal installation
${NSD_OnClick} $InstallMode_Normal InstallMode_UsrWait
2017-03-16 23:01:45 +00:00
${NSD_CreateLabel} 10 55 100% 20u "PCSX2 will be installed in Program Files unless another directory is specified. User files are stored in the Documents/PCSX2 directory."
2019-01-26 03:45:37 +00:00
# Create labels/buttons for the portable installation
2017-03-16 23:01:45 +00:00
${NSD_CreateRadioButton} 0 95 100% 10u "Portable Installation"
2017-03-13 22:46:15 +00:00
Pop $InstallMode_Portable
2019-01-26 03:45:37 +00:00
${NSD_OnClick} $InstallMode_Portable InstallMode_UsrWait
${NSD_CreateLabel} 10 115 100% 20u "Install PCSX2 to any directory you want. Choose this option if you prefer to have all of your files in the same folder or frequently update PCSX2 through Orphis' Buildbot."
2017-03-13 22:46:15 +00:00
nsDialogs::Show
FunctionEnd
2019-01-26 03:45:37 +00:00
# Disables the "next" button until a selection has been made
2017-03-13 22:46:15 +00:00
Function InstallMode_UsrWait
GetDlgItem $InstallMode_DlgNext $HWNDPARENT 1
EnableWindow $InstallMode_DlgNext 1
2019-01-26 03:45:37 +00:00
# Displays a UAC shield on the button
${NSD_GetState} $InstallMode_Normal $0
${NSD_GetState} $InstallMode_Portable $1
${If} ${BST_CHECKED} == $0
SendMessage $InstallMode_DlgNext ${BCM_SETSHIELD} 0 1
${Else}
SendMessage $InstallMode_DlgNext ${BCM_SETSHIELD} 0 0
${EndIf}
2017-03-13 22:46:15 +00:00
FunctionEnd
2019-01-26 03:45:37 +00:00
# Runs the elevated installer and quits the current one
# If they chose portable mode, the current (unelevated installer)
# will still be used.
2017-03-13 22:46:15 +00:00
Function InstallModeLeave
2019-01-26 03:45:37 +00:00
${NSD_GetState} $InstallMode_Normal $0
2017-03-13 22:46:15 +00:00
${NSD_GetState} $InstallMode_Portable $1
${If} ${BST_CHECKED} == $0
2020-09-22 19:24:04 +00:00
Call StartFullInstaller
2017-03-13 22:46:15 +00:00
${EndIf}
FunctionEnd
2020-09-22 19:24:04 +00:00
Function StartFullInstaller
;Checks if install directory is changed from default with /D, and if not, changes to standard full install directory.
${If} $INSTDIR == "$DOCUMENTS\PCSX2 ${APP_VERSION}"
StrCpy $INSTDIR "$PROGRAMFILES\PCSX2"
${EndIf}
SetOutPath "$TEMP"
File "pcsx2-${APP_VERSION}-include_standard.exe"
ExecShell open "$TEMP\pcsx2-${APP_VERSION}-include_standard.exe" "$cmdLineParams /D=$INSTDIR"
Quit
FunctionEnd
2017-03-13 22:46:15 +00:00
; ----------------------------------
; Portable Install Section
; ----------------------------------
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\pcsx2.exe"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ModifyRunCheckbox
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!include "ApplyExeProps.nsh"
; The default installation directory for the portable binary.
2020-05-05 19:02:07 +00:00
InstallDir "$DOCUMENTS\PCSX2 ${APP_VERSION}"
2017-03-13 22:46:15 +00:00
2020-02-21 23:05:53 +00:00
; Path references for the core files here
2017-03-13 22:46:15 +00:00
!include "SharedCore.nsh"
Section "" INST_PORTABLE
SetOutPath "$INSTDIR"
File portable.ini
2020-05-05 19:02:07 +00:00
RMDir /r "$TEMP\PCSX2 ${APP_VERSION}"
2017-03-13 22:46:15 +00:00
SectionEnd
Section "" SID_PCSX2
SectionEnd
2019-01-26 03:45:37 +00:00
# Gives the user a fancy checkbox to run PCSX2 right from the installer!
2017-03-13 22:46:15 +00:00
Function ModifyRunCheckbox
${IfNot} ${SectionIsSelected} ${SID_PCSX2}
SendMessage $MUI.FINISHPAGE.RUN ${BM_SETCHECK} ${BST_UNCHECKED} 0
EnableWindow $MUI.FINISHPAGE.RUN 0
${EndIf}
2020-11-08 18:12:48 +00:00
FunctionEnd