ac_patch.nsi 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. !include MUI.nsh
  2. !include Sections.nsh
  3. !include FileFunc.nsh
  4. ## TOOLS
  5. # Open Browser Window
  6. # Uses $0
  7. Function openLinkNewWindow
  8. Push $3
  9. Push $2
  10. Push $1
  11. Push $0
  12. ReadRegStr $0 HKCR "http\shell\open\command" ""
  13. # Get browser path
  14. DetailPrint $0
  15. StrCpy $2 '"'
  16. StrCpy $1 $0 1
  17. StrCmp $1 $2 +2 # if path is not enclosed in " look for space as final char
  18. StrCpy $2 ' '
  19. StrCpy $3 1
  20. loop:
  21. StrCpy $1 $0 1 $3
  22. DetailPrint $1
  23. StrCmp $1 $2 found
  24. StrCmp $1 "" found
  25. IntOp $3 $3 + 1
  26. Goto loop
  27. found:
  28. StrCpy $1 $0 $3
  29. StrCmp $2 " " +2
  30. StrCpy $1 '$1"'
  31. Pop $0
  32. Exec '$1 $0'
  33. Pop $1
  34. Pop $2
  35. Pop $3
  36. FunctionEnd
  37. ; CONFIGURATION
  38. ; general
  39. SetCompressor /SOLID lzma
  40. !define CURPATH ".\" ; must include the installer graphics and the AC_NEWPATCHDIR directory
  41. !define AC_FULLVERSIONINT "1.2.0.2"
  42. !define AC_FULLVERSION "v${AC_FULLVERSIONINT}"
  43. !define AC_SHORTNAME "AssaultCube"
  44. !define AC_FULLNAME "AssaultCube ${AC_FULLVERSIONINT}"
  45. !define AC_FULLNAMESAVE "AssaultCube_${AC_FULLVERSION}"
  46. !define AC_MAJORVERSIONINT 1
  47. !define AC_MINORVERSIONINT 2
  48. !define AC_NEWPATCHDIR "AC_patch" ; directory with prepared new AC patch
  49. Name "${AC_SHORTNAME}"
  50. OutFile "AssaultCube_${AC_FULLVERSION}-Update.exe"
  51. InstallDir "$PROGRAMFILES\${AC_SHORTNAME}"
  52. InstallDirRegKey HKLM "Software\${AC_SHORTNAME}" ""
  53. !define ARP "Software\Microsoft\Windows\CurrentVersion\Uninstall\${AC_SHORTNAME}"
  54. RequestExecutionLevel admin ; require admin in Vista/7
  55. ; Variables
  56. Var EstimatedSize
  57. Var Day
  58. Var Month
  59. Var Year
  60. Var DoW
  61. Var Hour
  62. Var Minute
  63. Var Second
  64. ; Interface Configuration
  65. !define MUI_HEADERIMAGE
  66. !define MUI_HEADERIMAGE_BITMAP "${CURPATH}\header.bmp" ; optional
  67. ; icon
  68. XPStyle on
  69. Icon "${CURPATH}\icon.ico"
  70. !define MUI_ICON "${CURPATH}\icon.ico"
  71. ; Pages
  72. Page custom WelcomePage
  73. !insertmacro MUI_PAGE_LICENSE "${CURPATH}\mui_page_license.txt"
  74. !insertmacro MUI_PAGE_COMPONENTS
  75. !insertmacro MUI_PAGE_DIRECTORY
  76. !insertmacro MUI_PAGE_INSTFILES
  77. Page custom FinishPage
  78. !insertmacro MUI_LANGUAGE "English"
  79. ; Custom Welcome Page
  80. !define WS_CHILD 0x40000000
  81. !define WS_VISIBLE 0x10000000
  82. !define WS_DISABLED 0x08000000
  83. !define WS_CLIPSIBLINGS 0x04000000
  84. !define WS_MAXIMIZE 0x01000000
  85. !define WS_VSCROLL 0x00200000
  86. !define WS_HSCROLL 0x00100000
  87. !define WS_GROUP 0x00020000
  88. !define WS_TABSTOP 0x00010000
  89. !define ES_LEFT 0x00000000
  90. !define ES_CENTER 0x00000001
  91. !define ES_RIGHT 0x00000002
  92. !define ES_MULTILINE 0x00000004
  93. !define ES_UPPERCASE 0x00000008
  94. !define ES_LOWERCASE 0x00000010
  95. !define ES_PASSWORD 0x00000020
  96. !define ES_AUTOVSCROLL 0x00000040
  97. !define ES_AUTOHSCROLL 0x00000080
  98. !define ES_NOHIDESEL 0x00000100
  99. !define ES_OEMCONVERT 0x00000400
  100. !define ES_READONLY 0x00000800
  101. !define ES_WANTRETURN 0x00001000
  102. !define ES_NUMBER 0x00002000
  103. !define SS_LEFT 0x00000000
  104. !define SS_CENTER 0x00000001
  105. !define SS_RIGHT 0x00000002
  106. !define SS_ICON 0x00000003
  107. !define SS_BLACKRECT 0x00000004
  108. !define SS_GRAYRECT 0x00000005
  109. !define SS_WHITERECT 0x00000006
  110. !define SS_BLACKFRAME 0x00000007
  111. !define SS_GRAYFRAME 0x00000008
  112. !define SS_WHITEFRAME 0x00000009
  113. !define SS_USERITEM 0x0000000A
  114. !define SS_SIMPLE 0x0000000B
  115. !define SS_LEFTNOWORDWRAP 0x0000000C
  116. !define SS_OWNERDRAW 0x0000000D
  117. !define SS_BITMAP 0x0000000E
  118. !define SS_ENHMETAFILE 0x0000000F
  119. !define SS_ETCHEDHORZ 0x00000010
  120. !define SS_ETCHEDVERT 0x00000011
  121. !define SS_ETCHEDFRAME 0x00000012
  122. !define SS_TYPEMASK 0x0000001F
  123. !define SS_REALSIZECONTROL 0x00000040
  124. !define SS_NOPREFIX 0x00000080
  125. !define SS_NOTIFY 0x00000100
  126. !define SS_CENTERIMAGE 0x00000200
  127. !define SS_RIGHTJUST 0x00000400
  128. !define SS_REALSIZEIMAGE 0x00000800
  129. !define SS_SUNKEN 0x00001000
  130. !define SS_EDITCONTROL 0x00002000
  131. !define SS_ENDELLIPSIS 0x00004000
  132. !define SS_PATHELLIPSIS 0x00008000
  133. !define SS_WORDELLIPSIS 0x0000C000
  134. !define SS_ELLIPSISMASK 0x0000C000
  135. !define BS_PUSHBUTTON 0x00000000
  136. !define BS_DEFPUSHBUTTON 0x00000001
  137. !define BS_CHECKBOX 0x00000002
  138. !define BS_AUTOCHECKBOX 0x00000003
  139. !define BS_RADIOBUTTON 0x00000004
  140. !define BS_3STATE 0x00000005
  141. !define BS_AUTO3STATE 0x00000006
  142. !define BS_GROUPBOX 0x00000007
  143. !define BS_USERBUTTON 0x00000008
  144. !define BS_AUTORADIOBUTTON 0x00000009
  145. !define BS_PUSHBOX 0x0000000A
  146. !define BS_OWNERDRAW 0x0000000B
  147. !define BS_TYPEMASK 0x0000000F
  148. !define BS_LEFTTEXT 0x00000020
  149. !define BS_TEXT 0x00000000
  150. !define BS_ICON 0x00000040
  151. !define BS_BITMAP 0x00000080
  152. !define BS_LEFT 0x00000100
  153. !define BS_RIGHT 0x00000200
  154. !define BS_CENTER 0x00000300
  155. !define BS_TOP 0x00000400
  156. !define BS_BOTTOM 0x00000800
  157. !define BS_VCENTER 0x00000C00
  158. !define BS_PUSHLIKE 0x00001000
  159. !define BS_MULTILINE 0x00002000
  160. !define BS_NOTIFY 0x00004000
  161. !define BS_FLAT 0x00008000
  162. !define BS_RIGHTBUTTON ${BS_LEFTTEXT}
  163. !define LR_DEFAULTCOLOR 0x0000
  164. !define LR_MONOCHROME 0x0001
  165. !define LR_COLOR 0x0002
  166. !define LR_COPYRETURNORG 0x0004
  167. !define LR_COPYDELETEORG 0x0008
  168. !define LR_LOADFROMFILE 0x0010
  169. !define LR_LOADTRANSPARENT 0x0020
  170. !define LR_DEFAULTSIZE 0x0040
  171. !define LR_VGACOLOR 0x0080
  172. !define LR_LOADMAP3DCOLORS 0x1000
  173. !define LR_CREATEDIBSECTION 0x2000
  174. !define LR_COPYFROMRESOURCE 0x4000
  175. !define LR_SHARED 0x8000
  176. !define IMAGE_BITMAP 0
  177. !define IMAGE_ICON 1
  178. !define IMAGE_CURSOR 2
  179. !define IMAGE_ENHMETAFILE 3
  180. Var DIALOG
  181. Var HEADLINE
  182. Var TEXT
  183. Var IMAGECTL
  184. Var IMAGE
  185. Function .onInit
  186. InitPluginsDir
  187. File /oname=$TEMP\welcome.bmp "${CURPATH}\welcome.bmp"
  188. FunctionEnd
  189. Function .onInstSuccess
  190. StrCpy $0 "http://assault.cubers.net/releasenotes/v${AC_MAJORVERSIONINT}.${AC_MINORVERSIONINT}/"
  191. Call openLinkNewWindow
  192. FunctionEnd
  193. Function HideControls
  194. LockWindow on
  195. GetDlgItem $0 $HWNDPARENT 1028
  196. ShowWindow $0 ${SW_HIDE}
  197. GetDlgItem $0 $HWNDPARENT 1256
  198. ShowWindow $0 ${SW_HIDE}
  199. GetDlgItem $0 $HWNDPARENT 1035
  200. ShowWindow $0 ${SW_HIDE}
  201. GetDlgItem $0 $HWNDPARENT 1037
  202. ShowWindow $0 ${SW_HIDE}
  203. GetDlgItem $0 $HWNDPARENT 1038
  204. ShowWindow $0 ${SW_HIDE}
  205. GetDlgItem $0 $HWNDPARENT 1039
  206. ShowWindow $0 ${SW_HIDE}
  207. GetDlgItem $0 $HWNDPARENT 1045
  208. ShowWindow $0 ${SW_NORMAL}
  209. LockWindow off
  210. FunctionEnd
  211. Function ShowControls
  212. LockWindow on
  213. GetDlgItem $0 $HWNDPARENT 1028
  214. ShowWindow $0 ${SW_NORMAL}
  215. GetDlgItem $0 $HWNDPARENT 1256
  216. ShowWindow $0 ${SW_NORMAL}
  217. GetDlgItem $0 $HWNDPARENT 1035
  218. ShowWindow $0 ${SW_NORMAL}
  219. GetDlgItem $0 $HWNDPARENT 1037
  220. ShowWindow $0 ${SW_NORMAL}
  221. GetDlgItem $0 $HWNDPARENT 1038
  222. ShowWindow $0 ${SW_NORMAL}
  223. GetDlgItem $0 $HWNDPARENT 1039
  224. ShowWindow $0 ${SW_NORMAL}
  225. GetDlgItem $0 $HWNDPARENT 1045
  226. ShowWindow $0 ${SW_HIDE}
  227. LockWindow off
  228. FunctionEnd
  229. Function WelcomePage
  230. nsDialogs::Create /NOUNLOAD 1044
  231. Pop $DIALOG
  232. nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
  233. Pop $IMAGECTL
  234. StrCpy $0 $TEMP\welcome.bmp
  235. System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}) i.s'
  236. Pop $IMAGE
  237. SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
  238. nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to the AssaultCube Update Wizard"
  239. Pop $HEADLINE
  240. SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
  241. nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "This wizard will guide you through the update of AssaultCube ${AC_FULLVERSIONINT}.$\r$\n$\r$\nClick Next to continue."
  242. Pop $TEXT
  243. SetCtlColors $DIALOG "" 0xffffff
  244. SetCtlColors $HEADLINE "" 0xffffff
  245. SetCtlColors $TEXT "" 0xffffff
  246. Call HideControls
  247. nsDialogs::Show
  248. Call ShowControls
  249. System::Call gdi32::DeleteObject(i$IMAGE)
  250. # MessageBox MB_OK "This is a TEST BUILD, do NOT redistribute this file! This is NOT a final release!"
  251. # validate existing installation
  252. ClearErrors
  253. ReadRegStr $0 HKLM "Software\${AC_SHORTNAME}" ""
  254. IfErrors 0 success
  255. MessageBox MB_OK|MB_ICONSTOP "Could not find an existing installation of AssaultCube that could be updated with this Update package. Please get the full package at http://assault.cubers.net/download.html"
  256. Quit
  257. success:
  258. ClearErrors
  259. ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${AC_SHORTNAME}" "InstallLocation"
  260. ${IfNot} ${Errors}
  261. StrCpy $INSTDIR $0
  262. ${EndIf}
  263. FunctionEnd
  264. Function FinishPage
  265. nsDialogs::Create /NOUNLOAD 1044
  266. Pop $DIALOG
  267. nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
  268. Pop $IMAGECTL
  269. StrCpy $0 $TEMP\welcome.bmp
  270. System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}) i.s'
  271. Pop $IMAGE
  272. SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
  273. nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Completing the AssaultCube Setup Wizard"
  274. Pop $HEADLINE
  275. SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
  276. nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "AssaultCube has been installed on your computer.$\r$\n$\r$\nClick Finish to close this wizard."
  277. Pop $TEXT
  278. SetCtlColors $DIALOG "" 0xffffff
  279. SetCtlColors $HEADLINE "" 0xffffff
  280. SetCtlColors $TEXT "" 0xffffff
  281. Call HideControls
  282. nsDialogs::Show
  283. Call ShowControls
  284. System::Call gdi32::DeleteObject(i$IMAGE)
  285. FunctionEnd
  286. ; Installer Sections
  287. Section "AssaultCube ${AC_FULLVERSIONINT} Update" PATCH
  288. SectionIn RO
  289. SetOutPath "$INSTDIR"
  290. File /r "${AC_NEWPATCHDIR}\*.*"
  291. ; Determine installed size (will include all files, even user placed in $INSTDIR!)
  292. ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  293. IntFmt $EstimatedSize "0x%08X" $0
  294. ${GetTime} "" "LS" $Day $Month $Year $DoW $Hour $Minute $Second
  295. WriteRegStr HKLM "${ARP}" "DisplayVersion" "${AC_FULLVERSIONINT}"
  296. WriteRegStr HKLM "${ARP}" "InstallDate" "$Year$Month$Day"
  297. WriteRegDWORD HKLM "${ARP}" "EstimatedSize" "$EstimatedSize"
  298. SectionEnd
  299. ; set descriptions
  300. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  301. !insertmacro MUI_DESCRIPTION_TEXT ${PATCH} "Updates the AssaultCube core files"
  302. !insertmacro MUI_FUNCTION_DESCRIPTION_END