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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
|
!ifndef WINAMP_PAGES_INSTALL_HEADER
!define WINAMP_PAGES_INSTALL_HEADER
!include ".\ui.nsh"
!include "nx.nsh"
!ifdef EXPRESS_MODE
!define WINAMP_LICENSE_AGREEMENT ${LICENSE_PATH}
!define WINAMP_PRIVACY_POLICY ${PRIVACY_POLICY_PATH}
!endif ; defined(EXPRESS_MODE)
Var waui.button.advanced
!ifdef EXPRESS_MODE
Var waui.WelcomePage.PrivacyNote
!endif ; defined(EXPRESS_MODE)
Var waui.WelcomePage.IsLicensePresented
Function UI_OnInit
Push $R0
StrCpy $R0 0
StrCpy $IDX_INSTTYPE_FULL $R0
!ifdef FULL
InstTypeSetText $R0 $(installFull)
IntOp $R0 $R0 + 1
!endif ; FULL
StrCpy $IDX_INSTTYPE_STANDARD $R0
!ifdef FULL
InstTypeSetText $R0 $(installStandard)
IntOp $R0 $R0 + 1
!endif ; FULL
InstTypeSetText $R0 $(installLite)
IntOp $R0 $R0 + 1
InstTypeSetText $R0 $(installMinimal)
StrCpy $IDX_INSTTYPE_PREVIOUS $R0
StrCpy $waui.WelcomePage.IsLicensePresented "no"
${ExpressMode_InitializePage}
FunctionEnd
Function .onGUIEnd
FunctionEnd
!ifdef EXPRESS_MODE
Function onXPClickLink
Pop $0 ; don't forget to pop HWND of the stack
ExecShell open "http://www.winamp.com/legal/eula/pc"
FunctionEnd
!endif
Function UI_OnWelcomePageShow
!ifdef EXPRESS_MODE
${If} ${AtLeastWinVista}
${NX_GetMappedWindowRect} $mui.WelcomePage.Image $mui.WelcomePage $2 $3 $4 $5
; Adjust Image Control Size
IntOp $4 $4 - $2
IntOp $5 $R1 - $3
${NX_SetWindowSize} $mui.WelcomePage.Image $4 $5
; Clear previous image
${NSD_ClearImage} $mui.WelcomePage.Image
${NSD_FreeImage} $mui.WelcomePage.Image.Bitmap
StrCpy $mui.WelcomePage.Image.Bitmap 0
; Reload Banner Image
${If} $PLUGINSDIR == ""
${OrIfNot} ${FileExists} "$PLUGINSDIR"
InitPluginsDir
${EndIf}
StrCpy $0 "$PLUGINSDIR\welcomeImage.bmp"
${IfNot} ${FileExists} "$0"
ReserveFile "${WELCOMEFINISH_IMAGE_PATH}"
File /oname=$0 "${WELCOMEFINISH_IMAGE_PATH}"
${EndIf}
System::Call 'user32::LoadImageW(i 0, w "$0", i ${IMAGE_BITMAP}, i $4, i $5, i ${LR_LOADFROMFILE}) i.s'
Pop $mui.WelcomePage.Image.Bitmap
SendMessage $mui.WelcomePage.Image ${STM_SETIMAGE} \
${IMAGE_BITMAP} \
$mui.WelcomePage.Image.Bitmap
; Get Dialog Height
${NX_GetWindowSize} $mui.WelcomePage $2 $R2
; Create License and Privacy Note
IntOp $0 $R1 + 0
IntOp $1 $R2 - $0
IntOp $1 $1 - 4
StrCpy $2 "$(IDS_PAGE_WELCOME_LEGAL)"
; TODO really don't want to have to do this as it's pretty lame as reason is
; on XP, using a SysLink will crash when it's destroyed i.e. page change
${If} ${IsWinXP}
IntOp $R2 $R2 - 16
${NSD_CreateLink} 8u $R2 316u 16 "By clicking “Next”, you agree to the Winamp License Agreement."
Pop $waui.WelcomePage.PrivacyNote
${NSD_OnClick} $waui.WelcomePage.PrivacyNote onXPClickLink
SetCtlColors $waui.WelcomePage.PrivacyNote 0xFF0000 transparent
${Else}
nsDialogs::CreateControl "SysLink" \
${WS_CHILD}|${WS_TABSTOP}|${WS_VISIBLE}\
|${WS_CLIPSIBLINGS}\
|${LWS_TRANSPARENT}|${LWS_NOPREFIX} \
${WS_EX_NOPARENTNOTIFY} \
8u $0 316u $1 $2
Pop $waui.WelcomePage.PrivacyNote
${EndIf}
${If} $waui.WelcomePage.PrivacyNote != 0
${NSD_OnNotify} $waui.WelcomePage.PrivacyNote UI_OnWelcomePageNotify
SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $0
SendMessage $waui.WelcomePage.PrivacyNote ${WM_SETFONT} $0 0
${IfNot} ${IsWinXP}
; Adjust Link Control Size & Position
${NX_GetMappedWindowRect} $waui.WelcomePage.PrivacyNote $mui.WelcomePage $2 $3 $4 $5
IntOp $4 $4 - $2 ; Link Control Max Width
IntOp $5 $5 - $3 ; Link Control Max Height
System::Call '*${stSIZE}($4, $5) .r1'
SendMessage $waui.WelcomePage.PrivacyNote ${LM_GETIDEALSIZE} $4 $1 $0
${If} $0 <= $5
System::Call "*$1${stSIZE} (.r6, .r7)"
IntOp $8 $4 - $6
IntOp $2 $2 + $8
IntOp $8 $5 - $0
IntOp $3 $3 + $8
${NX_SetWindowPosAndSize} $waui.WelcomePage.PrivacyNote $2 $3 $6 $0
${EndIf}
System::Free $1
${EndIf}
StrCpy $waui.WelcomePage.IsLicensePresented "yes"
${EndIf}
${EndIf}
!endif ; EXPRESS_MODE
FunctionEnd
!ifdef EXPRESS_MODE
Function UI_OnWelcomePageNotify
Exch $R0
Exch
Exch $R1
Exch 2
Exch $R2
${If} $R1 = ${NM_CLICK}
${OrIf} $R1 = ${NM_RETURN}
Push $R3
Push $R4
Push $0
System::Call `*$R2(i, i, i, i, i, i, i, &w48 .R3)`
${If} $R3 == "winamp_eula"
StrCpy $R4 "http://www.winamp.com/legal/eula/pc"
${ElseIf} $R3 == "winamp_privacy_policy"
StrCpy $R4 "http://www.winamp.com/legal/privacy"
${Else}
StrCpy $R4 ""
${EndIf}
${If} $R4 != ""
Call ConnectInternet
Pop $0
${If} $0 == "online"
Call IsInternetAvailable
Pop $0
${EndIf}
${Else}
StrCpy $0 "offline"
${EndIf}
${If} $0 != "online"
${If} $PLUGINSDIR == ""
${OrIfNot} ${FileExists} "$PLUGINSDIR"
InitPluginsDir
${EndIf}
${If} $R3 == "winamp_eula"
StrCpy $R4 "${WINAMP_LICENSE_AGREEMENT}"
${ElseIf} $R3 == "winamp_privacy_policy"
StrCpy $R4 "${WINAMP_PRIVACY_POLICY}"
${Else}
StrCpy $R4 ""
${EndIf}
${If} $R4 != ""
${GetFileName} $R4 $R4
StrCpy $R4 "$PLUGINSDIR\$R4"
${IfNot} ${FileExists} "$R4"
${If} $R3 == "winamp_eula"
ReserveFile "${WINAMP_LICENSE_AGREEMENT}"
File /oname=$R4 "${WINAMP_LICENSE_AGREEMENT}"
${ElseIf} $R3 == "winamp_privacy_policy"
ReserveFile "${WINAMP_PRIVACY_POLICY}"
File /oname=$R4 "${WINAMP_PRIVACY_POLICY}"
${EndIf}
${EndIf}
ExecShell open $R4
${EndIf}
${Else}
ExecShell open $R4
${EndIf}
Pop $0
Pop $R4
Pop $R3
${EndIf}
Pop $R2
Pop $R0
Pop $R1
FunctionEnd
!endif ;defined(EXPRESS_MODE)
Function UI_OnDirectoryPagePre
Push $0
${ExpressMode_IsEnabled} $0
${If} $0 == "yes"
Pop $0
Call UI_OnDirectoryPageLeave
Abort
${EndIf}
Pop $0
FunctionEnd
Function UI_OnDirectoryPageShow
FindWindow $1 "#32770" "" $HWNDPARENT
GetDlgItem $0 $1 0x3FF
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 0x02
${NX_GetMappedWindowRect} $0 $HWNDPARENT $2 $3 $4 $5
IntOp $4 $4 - $2
IntOp $5 $5 - $3
System::Call `user32::CreateWindowExW(i 0, w "BUTTON", w "Advanced...", i ${WS_TABSTOP}|${WS_CHILD}, i 12, i r3, i r4 , i r5, i $HWNDPARENT, i 0, i 0, i 0) i.s`
Pop $waui.button.advanced
SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $0
SendMessage $waui.button.advanced ${WM_SETFONT} $0 0
FunctionEnd
Function UI_OnDirectoryPageLeave
${NX_Log} "Directory page leave!!!"
${If} $waui.button.advanced <> 0
System::Call "${fnDestroyWindow}($waui.button.advanced)"
StrCpy $waui.button.advanced 0
${EndIf}
Call SetupWinampDirectories
FunctionEnd
Function UI_OnLicensePagePre
${If} $waui.WelcomePage.IsLicensePresented == "yes"
Call UI_OnLicensePageLeave
Abort
${EndIf}
FunctionEnd
Function UI_OnLicensePageShow
${If} $waui.button.advanced <> 0
System::Call "${fnDestroyWindow}($waui.button.advanced)"
StrCpy $waui.button.advanced 0
${EndIf}
FunctionEnd
Function UI_OnLicensePageLeave
FunctionEnd
Function UI_OnComponentsPagePre
Push $0
${ExpressMode_IsEnabled} $0
${If} $0 == "yes"
Pop $0
Abort
${EndIf}
Pop $0
FunctionEnd
Function UI_OnComponentsPageShow
Push $0
Push $1
Push $2
Push $3
Push $R1
${If} $mui.ComponentsPage.DescriptionText <> 0
${AndIf} $mui.ComponentsPage.DescriptionTitle <> 0
${NX_GetMappedWindowRect} $mui.ComponentsPage.DescriptionTitle \
$mui.ComponentsPage \
$0 $1 $2 $3
${NX_ConvertHorzDLU} $mui.ComponentsPage 5 $R1
IntOp $0 $0 + $R1
${NX_ConvertHorzDLU} $mui.ComponentsPage 1 $R1
IntOp $3 $3 - $R1
${NX_ConvertVertDLU} $mui.ComponentsPage 10 $R1
IntOp $1 $1 + $R1
${If} $R1 > 10
IntOp $1 $1 - 1 ; rollback 1px
${EndIf}
${NX_ConvertVertDLU} $mui.ComponentsPage 1 $R1
IntOp $2 $2 - $R1
IntOp $2 $2 - $0
IntOp $3 $3 - $1
${NX_SetWindowPosAndSize} $mui.ComponentsPage.DescriptionText \
$0 $1 \
$2 $3
${EndIf}
Pop $R1
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
Function UI_OnMouseOverSection
Push $0
Call GetSectionDescription
Exch $0
EnableWindow $mui.ComponentsPage.DescriptionText 1
SendMessage $mui.ComponentsPage.DescriptionText ${WM_SETTEXT} 0 "STR:$0"
Pop $0
FunctionEnd
Function UI_OnFinsihPagePre
Push $0
!ifndef _DEBUG
${ExpressMode_IsEnabled} $0
${If} $0 == "yes"
Pop $0
!ifndef MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
Call UI_OnFinishPageReadMe
!endif
Abort
${EndIf}
!endif ; defined(_DEBUG)
Pop $0
FunctionEnd
Function UI_OnFinishPageReadMe
SetPluginUnload alwaysoff
; Find Window info for the window we're displaying
System::Call "*${stRECT} .r1"
System::Call 'User32::GetWindowRect(i, i) i ($HWNDPARENT, r1) .r2'
; Get left/top/right/bottom
System::Call "*$1${stRECT} (.r2, .r3, .r4, .r5)"
System::Free $1
WriteINIStr "$WINAMPINI" "SETUP" "left" $2
WriteINIStr "$WINAMPINI" "SETUP" "top" $3
WriteINIStr "$WINAMPINI" "SETUP" "right" $4
WriteINIStr "$WINAMPINI" "SETUP" "bottom" $5
;SetPluginUnload manual
HideWindow
Push $1
StrCpy $1 1
File "/oname=$PLUGINSDIR\ShellDispatch.dll" "${NSISDIR}\Plugins\x86-unicode\ShellDispatch.dll"
${If} ${FileExists} "$PLUGINSDIR\ShellDispatch.dll"
${AndIf} ${FileExists} "$INSTDIR\${WINAMPEXE}"
Push $0
StrCpy $0 ""
ClearErrors
GetFullPathName /SHORT $0 "$PLUGINSDIR\ShellDispatch.dll"
${IfNot} ${Errors}
${AndIf} $0 != ""
ExecWait 'rundll32.exe $0,RunDll_ShellExecute "open" "$INSTDIR\${WINAMPEXE}" "/NEW /REG=S" "$INSTDIR" 1' $1
${If} ${Errors}
StrCpy $1 1
${EndIf}
${EndIf}
Pop $0
${EndIf}
${If} $1 != 0
Exec "$INSTDIR\${WINAMPEXE} /NEW /REG=S"
${EndIf}
Pop $1
Sleep 500
FunctionEnd
!endif
|