forked from PCSX2/pcsx2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpcsx2_shared_init.nsi
210 lines (162 loc) · 5.92 KB
/
pcsx2_shared_init.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
; PCSX2 Pre-Installer Script
; Copyright (C) 2019 PCSX2 Team
!include "SharedDefs.nsh"
RequestExecutionLevel user
!define OUTFILE_POSTFIX "setup"
OutFile "pcsx2-${APP_VERSION}-${OUTFILE_POSTFIX}.exe"
; Dialogs and Controls
Var PreInstall_Dialog
Var PreInstall_DlgBack
Var PreInstall_DlgNext
Var InstallMode_Dialog
Var InstallMode_DlgBack
Var InstallMode_DlgNext
Var InstallMode_Label
# Normal installer mode (writes to Program Files)
Var InstallMode_Normal
# Portable installer mode
Var InstallMode_Portable
!include "nsDialogs.nsh"
Page Custom IsUserAdmin
Page Custom PreInstallDialog
Page Custom InstallMode InstallModeLeave
; Function located in SharedDefs
Section ""
Call IsUserAdmin
IfSilent 0 +5
Call TempFilesOut
${If} $option_portable == 0
Call StartFullInstaller
${EndIf}
SectionEnd
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
;-----------------------------------------
; 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!"
Call TempFilesOut
${NSD_CreateLabel} 0 45 100% 10u "Moving on"
;-----------------------------------------
Call PreInstall_UsrWait
SendMessage $HWNDPARENT ${WM_COMMAND} 1 0
FunctionEnd
Function TempFilesOut
SetOutPath "$TEMP\PCSX2 ${APP_VERSION}"
File ..\bin\pcsx2.exe
File ..\bin\GameIndex.yaml
File ..\bin\cheats_ws.zip
File ..\bin\PCSX2_keys.ini.default
SetOutPath "$TEMP\PCSX2 ${APP_VERSION}\Docs"
File ..\bin\docs\*
SetOutPath "$TEMP\PCSX2 ${APP_VERSION}\Shaders"
File ..\bin\shaders\GSdx.fx
File ..\bin\shaders\GSdx_FX_Settings.ini
SetOutPath "$TEMP\PCSX2 ${APP_VERSION}\Plugins"
File /nonfatal ..\bin\Plugins\gsdx32-sse2.dll
File /nonfatal ..\bin\Plugins\gsdx32-sse4.dll
File /nonfatal ..\bin\Plugins\gsdx32-avx2.dll
SetOutPath "$TEMP\PCSX2 ${APP_VERSION}\Langs"
File /nonfatal /r ..\bin\Langs\*.mo
FunctionEnd
Function PreInstall_UsrWait
GetDlgItem $PreInstall_DlgNext $HWNDPARENT 1
EnableWindow $PreInstall_DlgNext 1
FunctionEnd
# Creates the first dialog "section" to display a choice of installer modes.
Function InstallMode
nsDialogs::Create /NOUNLOAD 1018
Pop $InstallMode_Dialog
GetDlgItem $InstallMode_DlgBack $HWNDPARENT 3
EnableWindow $InstallMode_DlgBack 0
GetDlgItem $InstallMode_DlgNext $HWNDPARENT 1
EnableWindow $InstallMode_DlgNext 0
${NSD_CreateLabel} 0 0 100% 10u "Select an installation mode for PCSX2."
Pop $InstallMode_Label
${NSD_CreateRadioButton} 0 35 100% 10u "Normal Installation"
Pop $InstallMode_Normal
# If the user doesn't have admin rights, disable the button for the normal (non-portable) installer
${If} $IsAdmin == 0
EnableWindow $InstallMode_Normal 0
${EndIf}
# Create labels/buttons for the normal installation
${NSD_OnClick} $InstallMode_Normal InstallMode_UsrWait
${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."
# Create labels/buttons for the portable installation
${NSD_CreateRadioButton} 0 95 100% 10u "Portable Installation"
Pop $InstallMode_Portable
${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."
nsDialogs::Show
FunctionEnd
# Disables the "next" button until a selection has been made
Function InstallMode_UsrWait
GetDlgItem $InstallMode_DlgNext $HWNDPARENT 1
EnableWindow $InstallMode_DlgNext 1
# 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}
FunctionEnd
# Runs the elevated installer and quits the current one
# If they chose portable mode, the current (unelevated installer)
# will still be used.
Function InstallModeLeave
${NSD_GetState} $InstallMode_Normal $0
${NSD_GetState} $InstallMode_Portable $1
${If} ${BST_CHECKED} == $0
Call StartFullInstaller
${EndIf}
FunctionEnd
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
; ----------------------------------
; 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.
InstallDir "$DOCUMENTS\PCSX2 ${APP_VERSION}"
; Path references for the core files here
!include "SharedCore.nsh"
Section "" INST_PORTABLE
SetOutPath "$INSTDIR"
File portable.ini
RMDir /r "$TEMP\PCSX2 ${APP_VERSION}"
SectionEnd
Section "" SID_PCSX2
SectionEnd
# Gives the user a fancy checkbox to run PCSX2 right from the installer!
Function ModifyRunCheckbox
${IfNot} ${SectionIsSelected} ${SID_PCSX2}
SendMessage $MUI.FINISHPAGE.RUN ${BM_SETCHECK} ${BST_UNCHECKED} 0
EnableWindow $MUI.FINISHPAGE.RUN 0
${EndIf}
FunctionEnd