uiEvents.nsh 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. !ifndef WINAMP_PAGES_INSTALL_HEADER
  2. !define WINAMP_PAGES_INSTALL_HEADER
  3. !include ".\ui.nsh"
  4. !include "nx.nsh"
  5. !ifdef EXPRESS_MODE
  6. !define WINAMP_LICENSE_AGREEMENT ${LICENSE_PATH}
  7. !define WINAMP_PRIVACY_POLICY ${PRIVACY_POLICY_PATH}
  8. !endif ; defined(EXPRESS_MODE)
  9. Var waui.button.advanced
  10. !ifdef EXPRESS_MODE
  11. Var waui.WelcomePage.PrivacyNote
  12. !endif ; defined(EXPRESS_MODE)
  13. Var waui.WelcomePage.IsLicensePresented
  14. Function UI_OnInit
  15. Push $R0
  16. StrCpy $R0 0
  17. StrCpy $IDX_INSTTYPE_FULL $R0
  18. !ifdef FULL
  19. InstTypeSetText $R0 $(installFull)
  20. IntOp $R0 $R0 + 1
  21. !endif ; FULL
  22. StrCpy $IDX_INSTTYPE_STANDARD $R0
  23. !ifdef FULL
  24. InstTypeSetText $R0 $(installStandard)
  25. IntOp $R0 $R0 + 1
  26. !endif ; FULL
  27. InstTypeSetText $R0 $(installLite)
  28. IntOp $R0 $R0 + 1
  29. InstTypeSetText $R0 $(installMinimal)
  30. StrCpy $IDX_INSTTYPE_PREVIOUS $R0
  31. StrCpy $waui.WelcomePage.IsLicensePresented "no"
  32. ${ExpressMode_InitializePage}
  33. FunctionEnd
  34. Function .onGUIEnd
  35. FunctionEnd
  36. !ifdef EXPRESS_MODE
  37. Function onXPClickLink
  38. Pop $0 ; don't forget to pop HWND of the stack
  39. ExecShell open "http://www.winamp.com/legal/eula/pc"
  40. FunctionEnd
  41. !endif
  42. Function UI_OnWelcomePageShow
  43. !ifdef EXPRESS_MODE
  44. ${If} ${AtLeastWinVista}
  45. ${NX_GetMappedWindowRect} $mui.WelcomePage.Image $mui.WelcomePage $2 $3 $4 $5
  46. ; Adjust Image Control Size
  47. IntOp $4 $4 - $2
  48. IntOp $5 $R1 - $3
  49. ${NX_SetWindowSize} $mui.WelcomePage.Image $4 $5
  50. ; Clear previous image
  51. ${NSD_ClearImage} $mui.WelcomePage.Image
  52. ${NSD_FreeImage} $mui.WelcomePage.Image.Bitmap
  53. StrCpy $mui.WelcomePage.Image.Bitmap 0
  54. ; Reload Banner Image
  55. ${If} $PLUGINSDIR == ""
  56. ${OrIfNot} ${FileExists} "$PLUGINSDIR"
  57. InitPluginsDir
  58. ${EndIf}
  59. StrCpy $0 "$PLUGINSDIR\welcomeImage.bmp"
  60. ${IfNot} ${FileExists} "$0"
  61. ReserveFile "${WELCOMEFINISH_IMAGE_PATH}"
  62. File /oname=$0 "${WELCOMEFINISH_IMAGE_PATH}"
  63. ${EndIf}
  64. System::Call 'user32::LoadImageW(i 0, w "$0", i ${IMAGE_BITMAP}, i $4, i $5, i ${LR_LOADFROMFILE}) i.s'
  65. Pop $mui.WelcomePage.Image.Bitmap
  66. SendMessage $mui.WelcomePage.Image ${STM_SETIMAGE} \
  67. ${IMAGE_BITMAP} \
  68. $mui.WelcomePage.Image.Bitmap
  69. ; Get Dialog Height
  70. ${NX_GetWindowSize} $mui.WelcomePage $2 $R2
  71. ; Create License and Privacy Note
  72. IntOp $0 $R1 + 0
  73. IntOp $1 $R2 - $0
  74. IntOp $1 $1 - 4
  75. StrCpy $2 "$(IDS_PAGE_WELCOME_LEGAL)"
  76. ; TODO really don't want to have to do this as it's pretty lame as reason is
  77. ; on XP, using a SysLink will crash when it's destroyed i.e. page change
  78. ${If} ${IsWinXP}
  79. IntOp $R2 $R2 - 16
  80. ${NSD_CreateLink} 8u $R2 316u 16 "By clicking “Next”, you agree to the Winamp License Agreement."
  81. Pop $waui.WelcomePage.PrivacyNote
  82. ${NSD_OnClick} $waui.WelcomePage.PrivacyNote onXPClickLink
  83. SetCtlColors $waui.WelcomePage.PrivacyNote 0xFF0000 transparent
  84. ${Else}
  85. nsDialogs::CreateControl "SysLink" \
  86. ${WS_CHILD}|${WS_TABSTOP}|${WS_VISIBLE}\
  87. |${WS_CLIPSIBLINGS}\
  88. |${LWS_TRANSPARENT}|${LWS_NOPREFIX} \
  89. ${WS_EX_NOPARENTNOTIFY} \
  90. 8u $0 316u $1 $2
  91. Pop $waui.WelcomePage.PrivacyNote
  92. ${EndIf}
  93. ${If} $waui.WelcomePage.PrivacyNote != 0
  94. ${NSD_OnNotify} $waui.WelcomePage.PrivacyNote UI_OnWelcomePageNotify
  95. SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $0
  96. SendMessage $waui.WelcomePage.PrivacyNote ${WM_SETFONT} $0 0
  97. ${IfNot} ${IsWinXP}
  98. ; Adjust Link Control Size & Position
  99. ${NX_GetMappedWindowRect} $waui.WelcomePage.PrivacyNote $mui.WelcomePage $2 $3 $4 $5
  100. IntOp $4 $4 - $2 ; Link Control Max Width
  101. IntOp $5 $5 - $3 ; Link Control Max Height
  102. System::Call '*${stSIZE}($4, $5) .r1'
  103. SendMessage $waui.WelcomePage.PrivacyNote ${LM_GETIDEALSIZE} $4 $1 $0
  104. ${If} $0 <= $5
  105. System::Call "*$1${stSIZE} (.r6, .r7)"
  106. IntOp $8 $4 - $6
  107. IntOp $2 $2 + $8
  108. IntOp $8 $5 - $0
  109. IntOp $3 $3 + $8
  110. ${NX_SetWindowPosAndSize} $waui.WelcomePage.PrivacyNote $2 $3 $6 $0
  111. ${EndIf}
  112. System::Free $1
  113. ${EndIf}
  114. StrCpy $waui.WelcomePage.IsLicensePresented "yes"
  115. ${EndIf}
  116. ${EndIf}
  117. !endif ; EXPRESS_MODE
  118. FunctionEnd
  119. !ifdef EXPRESS_MODE
  120. Function UI_OnWelcomePageNotify
  121. Exch $R0
  122. Exch
  123. Exch $R1
  124. Exch 2
  125. Exch $R2
  126. ${If} $R1 = ${NM_CLICK}
  127. ${OrIf} $R1 = ${NM_RETURN}
  128. Push $R3
  129. Push $R4
  130. Push $0
  131. System::Call `*$R2(i, i, i, i, i, i, i, &w48 .R3)`
  132. ${If} $R3 == "winamp_eula"
  133. StrCpy $R4 "http://www.winamp.com/legal/eula/pc"
  134. ${ElseIf} $R3 == "winamp_privacy_policy"
  135. StrCpy $R4 "http://www.winamp.com/legal/privacy"
  136. ${Else}
  137. StrCpy $R4 ""
  138. ${EndIf}
  139. ${If} $R4 != ""
  140. Call ConnectInternet
  141. Pop $0
  142. ${If} $0 == "online"
  143. Call IsInternetAvailable
  144. Pop $0
  145. ${EndIf}
  146. ${Else}
  147. StrCpy $0 "offline"
  148. ${EndIf}
  149. ${If} $0 != "online"
  150. ${If} $PLUGINSDIR == ""
  151. ${OrIfNot} ${FileExists} "$PLUGINSDIR"
  152. InitPluginsDir
  153. ${EndIf}
  154. ${If} $R3 == "winamp_eula"
  155. StrCpy $R4 "${WINAMP_LICENSE_AGREEMENT}"
  156. ${ElseIf} $R3 == "winamp_privacy_policy"
  157. StrCpy $R4 "${WINAMP_PRIVACY_POLICY}"
  158. ${Else}
  159. StrCpy $R4 ""
  160. ${EndIf}
  161. ${If} $R4 != ""
  162. ${GetFileName} $R4 $R4
  163. StrCpy $R4 "$PLUGINSDIR\$R4"
  164. ${IfNot} ${FileExists} "$R4"
  165. ${If} $R3 == "winamp_eula"
  166. ReserveFile "${WINAMP_LICENSE_AGREEMENT}"
  167. File /oname=$R4 "${WINAMP_LICENSE_AGREEMENT}"
  168. ${ElseIf} $R3 == "winamp_privacy_policy"
  169. ReserveFile "${WINAMP_PRIVACY_POLICY}"
  170. File /oname=$R4 "${WINAMP_PRIVACY_POLICY}"
  171. ${EndIf}
  172. ${EndIf}
  173. ExecShell open $R4
  174. ${EndIf}
  175. ${Else}
  176. ExecShell open $R4
  177. ${EndIf}
  178. Pop $0
  179. Pop $R4
  180. Pop $R3
  181. ${EndIf}
  182. Pop $R2
  183. Pop $R0
  184. Pop $R1
  185. FunctionEnd
  186. !endif ;defined(EXPRESS_MODE)
  187. Function UI_OnDirectoryPagePre
  188. Push $0
  189. ${ExpressMode_IsEnabled} $0
  190. ${If} $0 == "yes"
  191. Pop $0
  192. Call UI_OnDirectoryPageLeave
  193. Abort
  194. ${EndIf}
  195. Pop $0
  196. FunctionEnd
  197. Function UI_OnDirectoryPageShow
  198. FindWindow $1 "#32770" "" $HWNDPARENT
  199. GetDlgItem $0 $1 0x3FF
  200. ShowWindow $0 ${SW_HIDE}
  201. GetDlgItem $0 $HWNDPARENT 0x02
  202. ${NX_GetMappedWindowRect} $0 $HWNDPARENT $2 $3 $4 $5
  203. IntOp $4 $4 - $2
  204. IntOp $5 $5 - $3
  205. 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`
  206. Pop $waui.button.advanced
  207. SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $0
  208. SendMessage $waui.button.advanced ${WM_SETFONT} $0 0
  209. FunctionEnd
  210. Function UI_OnDirectoryPageLeave
  211. ${NX_Log} "Directory page leave!!!"
  212. ${If} $waui.button.advanced <> 0
  213. System::Call "${fnDestroyWindow}($waui.button.advanced)"
  214. StrCpy $waui.button.advanced 0
  215. ${EndIf}
  216. Call SetupWinampDirectories
  217. FunctionEnd
  218. Function UI_OnLicensePagePre
  219. ${If} $waui.WelcomePage.IsLicensePresented == "yes"
  220. Call UI_OnLicensePageLeave
  221. Abort
  222. ${EndIf}
  223. FunctionEnd
  224. Function UI_OnLicensePageShow
  225. ${If} $waui.button.advanced <> 0
  226. System::Call "${fnDestroyWindow}($waui.button.advanced)"
  227. StrCpy $waui.button.advanced 0
  228. ${EndIf}
  229. FunctionEnd
  230. Function UI_OnLicensePageLeave
  231. FunctionEnd
  232. Function UI_OnComponentsPagePre
  233. Push $0
  234. ${ExpressMode_IsEnabled} $0
  235. ${If} $0 == "yes"
  236. Pop $0
  237. Abort
  238. ${EndIf}
  239. Pop $0
  240. FunctionEnd
  241. Function UI_OnComponentsPageShow
  242. Push $0
  243. Push $1
  244. Push $2
  245. Push $3
  246. Push $R1
  247. ${If} $mui.ComponentsPage.DescriptionText <> 0
  248. ${AndIf} $mui.ComponentsPage.DescriptionTitle <> 0
  249. ${NX_GetMappedWindowRect} $mui.ComponentsPage.DescriptionTitle \
  250. $mui.ComponentsPage \
  251. $0 $1 $2 $3
  252. ${NX_ConvertHorzDLU} $mui.ComponentsPage 5 $R1
  253. IntOp $0 $0 + $R1
  254. ${NX_ConvertHorzDLU} $mui.ComponentsPage 1 $R1
  255. IntOp $3 $3 - $R1
  256. ${NX_ConvertVertDLU} $mui.ComponentsPage 10 $R1
  257. IntOp $1 $1 + $R1
  258. ${If} $R1 > 10
  259. IntOp $1 $1 - 1 ; rollback 1px
  260. ${EndIf}
  261. ${NX_ConvertVertDLU} $mui.ComponentsPage 1 $R1
  262. IntOp $2 $2 - $R1
  263. IntOp $2 $2 - $0
  264. IntOp $3 $3 - $1
  265. ${NX_SetWindowPosAndSize} $mui.ComponentsPage.DescriptionText \
  266. $0 $1 \
  267. $2 $3
  268. ${EndIf}
  269. Pop $R1
  270. Pop $3
  271. Pop $2
  272. Pop $1
  273. Pop $0
  274. FunctionEnd
  275. Function UI_OnMouseOverSection
  276. Push $0
  277. Call GetSectionDescription
  278. Exch $0
  279. EnableWindow $mui.ComponentsPage.DescriptionText 1
  280. SendMessage $mui.ComponentsPage.DescriptionText ${WM_SETTEXT} 0 "STR:$0"
  281. Pop $0
  282. FunctionEnd
  283. Function UI_OnFinsihPagePre
  284. Push $0
  285. !ifndef _DEBUG
  286. ${ExpressMode_IsEnabled} $0
  287. ${If} $0 == "yes"
  288. Pop $0
  289. !ifndef MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  290. Call UI_OnFinishPageReadMe
  291. !endif
  292. Abort
  293. ${EndIf}
  294. !endif ; defined(_DEBUG)
  295. Pop $0
  296. FunctionEnd
  297. Function UI_OnFinishPageReadMe
  298. SetPluginUnload alwaysoff
  299. ; Find Window info for the window we're displaying
  300. System::Call "*${stRECT} .r1"
  301. System::Call 'User32::GetWindowRect(i, i) i ($HWNDPARENT, r1) .r2'
  302. ; Get left/top/right/bottom
  303. System::Call "*$1${stRECT} (.r2, .r3, .r4, .r5)"
  304. System::Free $1
  305. WriteINIStr "$WINAMPINI" "SETUP" "left" $2
  306. WriteINIStr "$WINAMPINI" "SETUP" "top" $3
  307. WriteINIStr "$WINAMPINI" "SETUP" "right" $4
  308. WriteINIStr "$WINAMPINI" "SETUP" "bottom" $5
  309. ;SetPluginUnload manual
  310. HideWindow
  311. Push $1
  312. StrCpy $1 1
  313. File "/oname=$PLUGINSDIR\ShellDispatch.dll" "${NSISDIR}\Plugins\x86-unicode\ShellDispatch.dll"
  314. ${If} ${FileExists} "$PLUGINSDIR\ShellDispatch.dll"
  315. ${AndIf} ${FileExists} "$INSTDIR\${WINAMPEXE}"
  316. Push $0
  317. StrCpy $0 ""
  318. ClearErrors
  319. GetFullPathName /SHORT $0 "$PLUGINSDIR\ShellDispatch.dll"
  320. ${IfNot} ${Errors}
  321. ${AndIf} $0 != ""
  322. ExecWait 'rundll32.exe $0,RunDll_ShellExecute "open" "$INSTDIR\${WINAMPEXE}" "/NEW /REG=S" "$INSTDIR" 1' $1
  323. ${If} ${Errors}
  324. StrCpy $1 1
  325. ${EndIf}
  326. ${EndIf}
  327. Pop $0
  328. ${EndIf}
  329. ${If} $1 != 0
  330. Exec "$INSTDIR\${WINAMPEXE} /NEW /REG=S"
  331. ${EndIf}
  332. Pop $1
  333. Sleep 500
  334. FunctionEnd
  335. !endif