ac_patch.nsi 10 KB

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