Advertisement
Kenix157

Untitled

Dec 16th, 2016
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 96.34 KB | None | 0 0
  1. !addincludedir "NSIS dirs\Include"
  2. !addplugindir "NSIS dirs\Plugins"
  3. !include nsDialogs.nsh
  4. !include LogicLib.nsh
  5. !include Sections.nsh
  6. !include UAC.nsh
  7. !include GameExplorer.nsh
  8. !include WinVer.nsh
  9. !include nsArray.nsh
  10. !include Utils.nsh
  11. !include WordFunc.nsh
  12.  
  13. XPStyle on
  14. RequestExecutionLevel user
  15. SetCompressor /SOLID lzma
  16.  
  17. !include textlog.nsh
  18. Var GTA_DIR
  19. Var Install_Dir
  20. Var CreateSMShortcuts
  21. Var CreateDesktopIcon
  22. Var RegisterProtocol
  23. Var AddToGameExplorer
  24. Var ExeMD5
  25. Var PatchInstalled
  26. Var DEFAULT_INSTDIR
  27. Var LAST_INSTDIR
  28. Var CUSTOM_INSTDIR
  29. Var WhichRadio
  30. Var ShowLastUsed
  31.  
  32. ; Games explorer: With each new X.X, update this GUID and the file at MTA10\launch\NEU\GDFImp.gdf.xml
  33. !define GUID "{DF780162-2450-4665-9BA2-EAB14ED640A3}"
  34.  
  35.  
  36. !ifndef MAJOR_VER
  37. !define MAJOR_VER "1"
  38. !define MINOR_VER "4"
  39. !define MAINT_VER "0"
  40. !endif
  41. !define 0.0 "${MAJOR_VER}.${MINOR_VER}"
  42. !define 0.0.0 "${MAJOR_VER}.${MINOR_VER}.${MAINT_VER}"
  43.  
  44. ; ###########################################################################################################
  45. !ifndef FILES_ROOT
  46. !define LIGHTBUILD ; enable LIGHTBUILD for nightly
  47. !define FILES_ROOT "../../InstallFiles"
  48. !define SERVER_FILES_ROOT "${FILES_ROOT}/server"
  49. !define FILES_MODULE_SDK "${FILES_ROOT}/development/publicsdk"
  50. !define INSTALL_OUTPUT "mtasa-${0.0.0}-unstable-00000-0-000-nsis.exe"
  51. !define PRODUCT_VERSION "v${0.0.0}-unstable-00000-0-000"
  52. !define REVISION "0"
  53. !endif
  54. !ifndef LIGHTBUILD
  55. !define INCLUDE_DEVELOPMENT
  56. !define INCLUDE_EDITOR
  57. !endif
  58. !ifndef PRODUCT_VERSION
  59. !define PRODUCT_VERSION "v${0.0.0}"
  60. !endif
  61. !define EXPAND_DIALOG_X 134
  62. !define EXPAND_DIALOG_Y 60
  63. !define DIALOG_X 450
  64. ; ###########################################################################################################
  65.  
  66. ;ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
  67. !ifdef REVISION
  68. !define REVISION_TAG "(r${REVISION})"
  69. !else
  70. !define REVISION_TAG ""
  71. !endif
  72.  
  73. !define PRODUCT_NAME "MTA:SA ${0.0}"
  74. !define PRODUCT_NAME_NO_VER "MTA:SA"
  75.  
  76. !define PRODUCT_PUBLISHER "Multi Theft Auto"
  77. !define PRODUCT_WEB_SITE "http://www.multitheftauto.com"
  78. !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Multi Theft Auto ${0.0}.exe"
  79. !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  80. !define PRODUCT_UNINST_ROOT_KEY "HKLM"
  81.  
  82. ; Set file version information
  83. !ifndef VI_PRODUCT_VERSION
  84. !ifdef REVISION
  85. !define VI_PRODUCT_VERSION "${0.0.0}.${REVISION}"
  86. !else
  87. !define VI_PRODUCT_VERSION "${0.0.0}.0"
  88. !endif
  89. !define VI_PRODUCT_NAME "MTA San Andreas"
  90. !define VI_COMPANY_NAME "Multi Theft Auto"
  91. !define /date DATE_YEAR "%Y"
  92. !define VI_LEGAL_COPYRIGHT "(C) 2003 - ${DATE_YEAR} Multi Theft Auto"
  93. !ifndef LIGHTBUILD
  94. !define VI_FILE_DESCRIPTION "Multi Theft Auto Full Installer"
  95. !else
  96. !define VI_FILE_DESCRIPTION "Multi Theft Auto Nightly Installer"
  97. !endif
  98. !endif
  99. VIProductVersion "${VI_PRODUCT_VERSION}"
  100. VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${VI_PRODUCT_NAME}"
  101. VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "${VI_COMPANY_NAME}"
  102. VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${VI_LEGAL_COPYRIGHT}"
  103. VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${VI_FILE_DESCRIPTION}"
  104. VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VI_PRODUCT_VERSION}"
  105. VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${VI_PRODUCT_VERSION}"
  106.  
  107. ; MUI 1.67 compatible ------
  108. !include "MUI.nsh"
  109. !include "ReplaceSubStr.nsh"
  110. !include "FileIfMD5.nsh"
  111.  
  112. ; MUI Settings
  113. !define MUI_ABORTWARNING
  114. !define MUI_ICON "mta.ico"
  115. !define MUI_UNICON "mta.ico"
  116. !define MUI_HEADERIMAGE
  117. !define MUI_HEADERIMAGE_BITMAP "mta_install_header.bmp"
  118. !define MUI_HEADERIMAGE_BITMAP_RTL "mta_install_header_rtl.bmp"
  119.  
  120. ; Welcome page
  121. !define MUI_WELCOMEPAGE_TITLE_3LINES
  122. !define MUI_WELCOMEPAGE_TEXT "$(WELCOME_TEXT)"
  123. !define MUI_PAGE_CUSTOMFUNCTION_PRE "WelcomePreProc"
  124. !define MUI_PAGE_CUSTOMFUNCTION_SHOW "WelcomeShowProc"
  125. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE "WelcomeLeaveProc"
  126. !insertmacro MUI_PAGE_WELCOME
  127.  
  128. ; License page
  129. !define MUI_PAGE_CUSTOMFUNCTION_SHOW "LicenseShowProc"
  130. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE "LicenseLeaveProc"
  131. !insertmacro MUI_PAGE_LICENSE "eula.txt"
  132.  
  133. Page custom CustomNetMessagePage CustomNetMessagePageLeave
  134.  
  135. ; Components page
  136. !define MUI_PAGE_CUSTOMFUNCTION_SHOW "ComponentsShowProc"
  137. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE "ComponentsLeaveProc"
  138. !insertmacro MUI_PAGE_COMPONENTS
  139.  
  140. ; Game directory page
  141. #!define MUI_PAGE_CUSTOMFUNCTION_SHOW "DirectoryShowProc"
  142. #!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeaveProc"
  143. #!define MUI_CUSTOMFUNCTION_ABORT "DirectoryAbort"
  144. #!define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR
  145. #!insertmacro MUI_PAGE_DIRECTORY
  146. Page custom CustomDirectoryPage CustomDirectoryPageLeave
  147.  
  148. ; Language Tools ----
  149. ;Note: Assumes NSIS Unicode edition compiler
  150. !define MUI_LANGDLL_ALLLANGUAGES
  151. !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
  152. !define MUI_LANGDLL_REGISTRY_KEY "SOFTWARE\Multi Theft Auto: San Andreas All\${0.0}"
  153. !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
  154. !insertmacro MUI_RESERVEFILE_LANGDLL ;Solid compression optimization for multilang
  155.  
  156. ; INSERT OUR PAGES
  157. !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipDirectoryPage
  158. !define MUI_PAGE_HEADER_TEXT "$(HEADER_Text)"
  159. !define MUI_PAGE_HEADER_SUBTEXT ""
  160. !define MUI_DIRECTORYPAGE_TEXT_DESTINATION "$(DIRECTORY_Text_Dest)"
  161. !define MUI_DIRECTORYPAGE_TEXT_TOP "$(DIRECTORY_Text_Top)"
  162. !define MUI_DIRECTORYPAGE_VARIABLE $GTA_DIR
  163. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE "GTADirectoryLeaveProc"
  164. !insertmacro MUI_PAGE_DIRECTORY
  165.  
  166. ; Instfiles page
  167. !insertmacro MUI_PAGE_INSTFILES
  168.  
  169. ; Finish page
  170. !define MUI_FINISHPAGE_TITLE_3LINES
  171. ; Launch from installer with user privileges
  172. !define MUI_FINISHPAGE_RUN ""
  173. !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
  174. !insertmacro MUI_PAGE_FINISH
  175.  
  176. ; Uninstaller pages
  177. !insertmacro MUI_UNPAGE_INSTFILES
  178.  
  179. ; INSERT OUR LANGUAGE STRINGS -----
  180. !insertmacro MUI_LANGUAGE "English"
  181. ;@INSERT_TRANSLATIONS@
  182.  
  183. LangString GET_XPVISTA_PLEASE ${LANG_ENGLISH} "The version of MTA:SA you've downloaded does not support Windows XP or Vista. Please download an alternative version from www.mtasa.com."
  184. LangString GET_MASTER_PLEASE ${LANG_ENGLISH} "The version of MTA:SA is designed for old versions of Windows. Please download the newest version from www.mtasa.com."
  185. LangString WELCOME_TEXT ${LANG_ENGLISH} "This wizard will guide you through the installation or update of $(^Name) ${REVISION_TAG}\n\n\
  186. It is recommended that you close all other applications before starting Setup.\n\n\
  187. [Admin access may be requested for Vista and up]\n\n\
  188. Click Next to continue."
  189. LangString HEADER_Text ${LANG_ENGLISH} "Grand Theft Auto: San Andreas location"
  190. LangString DIRECTORY_Text_Dest ${LANG_ENGLISH} "Grand Theft Auto: San Andreas folder"
  191. LangString DIRECTORY_Text_Top ${LANG_ENGLISH} "Please select your Grand Theft Auto: San Andreas folder.$\n$\nYou MUST have Grand Theft Auto: San Andreas 1.0 installed to use MTA:SA, it does not support any other versions.$\n$\nClick Install to begin installing."
  192.  
  193. ; Language files
  194. LangString DESC_Section10 ${LANG_ENGLISH} "Create a Start Menu group for installed applications"
  195. LangString DESC_Section11 ${LANG_ENGLISH} "Create a Desktop Shortcut for the MTA:SA Client."
  196. LangString DESC_Section12 ${LANG_ENGLISH} "Register mtasa:// protocol for browser clickable-ness."
  197. LangString DESC_Section13 ${LANG_ENGLISH} "Add to Windows Games Explorer (if present)."
  198. LangString DESC_Section1 ${LANG_ENGLISH} "The core components required to run Multi Theft Auto."
  199. LangString DESC_Section2 ${LANG_ENGLISH} "The MTA:SA modification, allowing you to play online."
  200. ;LangString DESC_Section3 ${LANG_ENGLISH} "The Multi Theft Auto:Editor for MTA:SA, allowing you to create and edit maps."
  201. ;LangString DESC_SectionGroupMods ${LANG_ENGLISH} "Modifications for Multi Theft Auto. Without at least one of these, you cannot play Multi Theft Auto."
  202. LangString DESC_SectionGroupServer ${LANG_ENGLISH} "The Multi Theft Auto Server. This allows you to host games from your computer. This requires a fast internet connection."
  203. LangString DESC_Section4 ${LANG_ENGLISH} "The Multi Theft Auto server. This is a required component."
  204. LangString DESC_Section5 ${LANG_ENGLISH} "The MTA:SA modification for the server."
  205. LangString DESC_Section6 ${LANG_ENGLISH} "This is a set of required resources for your server."
  206. LangString DESC_Section7 ${LANG_ENGLISH} "This is an optional set of gamemodes and maps for your server."
  207. LangString DESC_Section8 ${LANG_ENGLISH} "The MTA:SA 1.0 Map Editor. This can be used to create your very own maps for use in gamemodes for MTA."
  208. LangString DESC_Section9 ${LANG_ENGLISH} "This is the SDK for creating binary modules for the MTA server. Only install if you have a good understanding of C++!"
  209. ;LangString DESC_Blank ${LANG_ENGLISH} ""
  210. LangString DESC_SectionGroupDev ${LANG_ENGLISH} "Development code and tools that aid in the creation of mods for Multi Theft Auto"
  211. LangString DESC_SectionGroupClient ${LANG_ENGLISH} "The client is the program you run to play on a Multi Theft Auto server"
  212.  
  213.  
  214. Function LaunchLink
  215. SetOutPath "$INSTDIR"
  216. # Problem: 'non-admin nsis' and 'admin nsis' run at the same time and can have different values for $INSTDIR
  217. # Fix: Copy to temp variable
  218. StrCpy $1 "$INSTDIR\Multi Theft Auto.exe"
  219. !insertmacro UAC_AsUser_ExecShell "" "$1" "" "" ""
  220. FunctionEnd
  221.  
  222. Function .onInstFailed
  223. ${LogText} "+Function begin - .onInstFailed"
  224. FunctionEnd
  225.  
  226. Function .onInit
  227.  
  228. ${IfNot} ${UAC_IsInnerInstance}
  229. !insertmacro MUI_LANGDLL_DISPLAY # Only display our language selection in the outer (non-admin) instance
  230. ${Else}
  231. !insertmacro UAC_AsUser_GetGlobalVar $LANGUAGE # Copy our selected language from the outer to the inner instance
  232. ${EndIf}
  233.  
  234.  
  235. ${If} ${AtMostWinVista}
  236. MessageBox MB_OK "$(GET_XPVISTA_PLEASE)"
  237. ExecShell "open" "http://mtasa.com"
  238. Quit
  239. ${EndIf}
  240.  
  241. File /oname=$TEMP\image.bmp "connect.bmp"
  242.  
  243. ; #############################################
  244. ; Remove old shortcuts put in rand(user,admin) startmenu by previous installers (shortcuts now go in all users)
  245. SetShellVarContext current
  246. ; Delete shortcuts
  247. Delete "$SMPROGRAMS\\MTA San Andreas ${0.0}\MTA San Andreas.lnk"
  248. Delete "$SMPROGRAMS\\MTA San Andreas ${0.0}\Uninstall MTA San Andreas.lnk"
  249. Delete "$DESKTOP\MTA San Andreas ${0.0}.lnk"
  250.  
  251. ; Delete shortcuts
  252. Delete "$SMPROGRAMS\\MTA San Andreas ${0.0}\MTA Server.lnk"
  253. Delete "$SMPROGRAMS\\MTA San Andreas ${0.0}\Uninstall MTA San Andreas Server.lnk"
  254. RmDir /r "$SMPROGRAMS\\MTA San Andreas ${0.0}"
  255. ; #############################################
  256.  
  257. SetShellVarContext all
  258.  
  259. ${LogSetFileName} "$APPDATA\MTA San Andreas All\Common\Installer" "nsis.log"
  260. ${LogText} "${PRODUCT_VERSION} ${REVISION_TAG}"
  261. ${LogText} "+Function begin - .onInit"
  262.  
  263. ; Try to find previously saved MTA:SA install path
  264. ReadRegStr $Install_Dir HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\${0.0}" "Last Install Location"
  265. ${If} $Install_Dir == ""
  266. ReadRegStr $Install_Dir HKLM "SOFTWARE\Multi Theft Auto: San Andreas ${0.0}" "Last Install Location"
  267. ${EndIf}
  268. ${If} $Install_Dir != ""
  269. Call NoteMTAWasPresent
  270. ${EndIf}
  271.  
  272. ${If} $Install_Dir == ""
  273. strcpy $Install_Dir "$PROGRAMFILES\MTA San Andreas ${0.0}"
  274. ${EndIf}
  275. strcpy $INSTDIR $Install_Dir
  276. ${LogText} "Using install directory:'$INSTDIR'"
  277.  
  278. ; Setup for install dir dialog
  279. strcpy $DEFAULT_INSTDIR "$PROGRAMFILES\MTA San Andreas ${0.0}"
  280. strcpy $LAST_INSTDIR $Install_Dir
  281. strcpy $CUSTOM_INSTDIR $DEFAULT_INSTDIR
  282. ${If} $DEFAULT_INSTDIR == $LAST_INSTDIR
  283. StrCpy $WhichRadio "default"
  284. StrCpy $ShowLastUsed "0"
  285. ${Else}
  286. Push $LAST_INSTDIR
  287. Call GetInstallType
  288. Pop $0
  289. Pop $1
  290. ${If} $0 == "overwrite"
  291. # Ignore last used if it contains different major MTA version
  292. StrCpy $WhichRadio "default"
  293. StrCpy $ShowLastUsed "0"
  294. ${Else}
  295. StrCpy $WhichRadio "last"
  296. StrCpy $ShowLastUsed "1"
  297. ${EndIf}
  298. ${EndIf}
  299.  
  300. ; Try to find previously saved GTA:SA install path
  301. ReadRegStr $2 HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\Common" "GTA:SA Path"
  302. ${If} $2 == ""
  303. ReadRegStr $2 HKCU "SOFTWARE\Multi Theft Auto: San Andreas" "GTA:SA Path"
  304. ${EndIf}
  305. ${If} $2 == ""
  306. ReadRegStr $2 HKLM "SOFTWARE\Rockstar Games\GTA San Andreas\Installation" "ExePath"
  307. ${EndIf}
  308. ${If} $2 == ""
  309. ReadRegStr $2 HKLM "SOFTWARE\Multi Theft Auto: San Andreas" "GTA:SA Path"
  310. ${EndIf}
  311. ${If} $2 == ""
  312. ReadRegStr $3 HKCU "Software\Valve\Steam\Apps\12120" "Installed"
  313. StrCpy $3 $3 1
  314. ${If} $3 == "1"
  315. ReadRegStr $3 HKCU "Software\Valve\Steam" "SteamPath"
  316. StrCpy $2 "$3\steamapps\common\grand theft auto san andreas"
  317. ${EndIf}
  318. ${EndIf}
  319. ${If} $2 == ""
  320. ReadRegStr $2 HKCU "SOFTWARE\Multi Theft Auto: San Andreas ${0.0}" "GTA:SA Path Backup"
  321. ${EndIf}
  322.  
  323. ; Report previous install status
  324. ${If} $2 != ""
  325. Call NoteGTAWasPresent
  326. ${EndIf}
  327.  
  328. ; Remove exe name from path
  329. !insertmacro ReplaceSubStr $2 "gta_sa.exe" ""
  330. ; Conform slash types
  331. !insertmacro ReplaceSubStr $MODIFIED_STR "/" "\"
  332. ; Remove quotes
  333. strcpy $3 '"'
  334. !insertmacro ReplaceSubStr $MODIFIED_STR $3 ""
  335. ; Store result
  336. strcpy $GTA_DIR $MODIFIED_STR
  337.  
  338. ; Default to standard path if nothing defined
  339. ${If} $GTA_DIR == ""
  340. strcpy $GTA_DIR "$PROGRAMFILES\Rockstar Games\GTA San Andreas\"
  341. ${EndIf}
  342.  
  343. ${LogText} "Default GTA install directory:'$GTA_DIR'"
  344.  
  345. InitPluginsDir
  346. ;File /oname=$PLUGINSDIR\serialdialog.ini "serialdialog.ini"
  347. ${LogText} "-Function end - .onInit"
  348. FunctionEnd
  349.  
  350. Function .onInstSuccess
  351. ${LogText} "+Function begin - .onInstSuccess"
  352. SetShellVarContext all
  353.  
  354. WriteRegStr HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\Common" "GTA:SA Path" $GTA_DIR
  355. WriteRegStr HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\${0.0}" "Last Install Location" $INSTDIR
  356.  
  357. ; Start menu items
  358. ${If} $CreateSMShortcuts == 1
  359. CreateDirectory "$SMPROGRAMS\MTA San Andreas ${0.0}"
  360.  
  361. IfFileExists "$INSTDIR\Multi Theft Auto.exe" 0 skip1
  362. SetOutPath "$INSTDIR"
  363. Delete "$SMPROGRAMS\\MTA San Andreas ${0.0}\Play MTA San Andreas.lnk"
  364. CreateShortCut "$SMPROGRAMS\\MTA San Andreas ${0.0}\MTA San Andreas.lnk" "$INSTDIR\Multi Theft Auto.exe" \
  365. "" "$INSTDIR\Multi Theft Auto.exe" 0 SW_SHOWNORMAL \
  366. "" "Play Multi Theft Auto: San Andreas ${0.0}"
  367. skip1:
  368.  
  369. IfFileExists "$INSTDIR\Server\MTA Server.exe" 0 skip2
  370. SetOutPath "$INSTDIR\Server"
  371. CreateShortCut "$SMPROGRAMS\\MTA San Andreas ${0.0}\MTA Server.lnk" "$INSTDIR\Server\MTA Server.exe" \
  372. "" "$INSTDIR\Server\MTA Server.exe" 2 SW_SHOWNORMAL \
  373. "" "Run the Multi Theft Auto: San Andreas ${0.0} Server"
  374. skip2:
  375.  
  376. IfFileExists "$INSTDIR\Uninstall.exe" 0 skip3
  377. SetOutPath "$INSTDIR"
  378. CreateShortCut "$SMPROGRAMS\\MTA San Andreas ${0.0}\Uninstall MTA San Andreas.lnk" "$INSTDIR\Uninstall.exe" \
  379. "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \
  380. "" "Uninstall Multi Theft Auto: San Andreas ${0.0}"
  381. skip3:
  382. ${EndIf}
  383.  
  384. ${If} $CreateDesktopIcon == 1
  385. IfFileExists "$INSTDIR\Multi Theft Auto.exe" 0 skip4
  386. SetOutPath "$INSTDIR"
  387. Delete "$DESKTOP\Play MTA San Andreas ${0.0}.lnk"
  388. CreateShortCut "$DESKTOP\MTA San Andreas ${0.0}.lnk" "$INSTDIR\Multi Theft Auto.exe" \
  389. "" "$INSTDIR\Multi Theft Auto.exe" 0 SW_SHOWNORMAL \
  390. "" "Play Multi Theft Auto: San Andreas ${0.0}"
  391. AccessControl::GrantOnFile "$DESKTOP\MTA San Andreas ${0.0}.lnk" "(BU)" "FullAccess"
  392.  
  393. skip4:
  394. ${EndIf}
  395.  
  396. ${If} $RegisterProtocol == 1
  397. ; Add the protocol handler
  398. WriteRegStr HKCR "mtasa" "" "URL:MTA San Andreas Protocol"
  399. WriteRegStr HKCR "mtasa" "URL Protocol" ""
  400. WriteRegStr HKCR "mtasa\DefaultIcon" "" "$INSTDIR\Multi Theft Auto.exe"
  401. WriteRegStr HKCR "mtasa\shell\open\command" "" '"$INSTDIR\Multi Theft Auto.exe"%1'
  402. ${EndIf}
  403.  
  404. ;UAC::Unload ;Must call unload!
  405. ${LogText} "-Function end - .onInstSuccess"
  406. FunctionEnd
  407.  
  408. LangString INST_CLIENTSERVER ${LANG_ENGLISH} "Client and Server"
  409. LangString INST_SERVER ${LANG_ENGLISH} "Server only"
  410.  
  411.  
  412. InstType "$(INST_CLIENTSERVER)"
  413. InstType "$(INST_SERVER)"
  414.  
  415. Name "${PRODUCT_NAME_NO_VER} ${PRODUCT_VERSION}"
  416. OutFile "${INSTALL_OUTPUT}"
  417.  
  418. ;InstallDir "$PROGRAMfiles San Andreas"
  419. InstallDirRegKey HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\${0.0}" "Last Install Location"
  420. ShowInstDetails show
  421. ShowUnInstDetails show
  422.  
  423. LangString INST_STARTMENU_GROUP ${LANG_ENGLISH} "Start menu group"
  424. LangString INST_DESKTOP_ICON ${LANG_ENGLISH} "Desktop icon"
  425. LangString INST_PROTOCOL ${LANG_ENGLISH} "Register mtasa:// protocol"
  426. LangString INST_GAMES_EXPLORER ${LANG_ENGLISH} "Add to Games Explorer"
  427.  
  428. Section "$(INST_STARTMENU_GROUP)" SEC10
  429. SectionIn 1 2
  430. StrCpy $CreateSMShortcuts 1
  431. SectionEnd
  432.  
  433. Section "$(INST_DESKTOP_ICON)" SEC11
  434. SectionIn 1 2
  435. StrCpy $CreateDesktopIcon 1
  436. SectionEnd
  437.  
  438. Section "$(INST_PROTOCOL)" SEC12
  439. SectionIn 1 2
  440. StrCpy $RegisterProtocol 1
  441. SectionEnd
  442.  
  443. Section "$(INST_GAMES_EXPLORER)" SEC13
  444. SectionIn 1 2
  445. StrCpy $AddToGameExplorer 1
  446. SectionEnd
  447.  
  448. LangString INST_SEC_CLIENT ${LANG_ENGLISH} "Game client"
  449. LangString INST_SEC_SERVER ${LANG_ENGLISH} "Dedicated server"
  450. LangString INST_SEC_CORE ${LANG_ENGLISH} "Core components"
  451. LangString INST_SEC_GAME ${LANG_ENGLISH} "Game module"
  452.  
  453. LangString INFO_INPLACE_UPGRADE ${LANG_ENGLISH} "Performing in-place upgrade..."
  454. LangString INFO_UPDATE_PERMISSIONS ${LANG_ENGLISH} "Updating permissions. This could take a few minutes..."
  455. LangString MSGBOX_INVALID_GTASA ${LANG_ENGLISH} "A valid Windows version of Grand Theft Auto: San Andreas was not detected.\
  456. $\r$\nHowever installation will continue.\
  457. $\r$\nPlease reinstall if there are problems later."
  458. LangString INST_SEC_CORE_RESOURCES ${LANG_ENGLISH} "Core Resources"
  459. LangString INST_SEC_OPTIONAL_RESOURCES ${LANG_ENGLISH} "Optional Resources"
  460. LangString INST_SEC_EDITOR ${LANG_ENGLISH} "Editor"
  461.  
  462. SectionGroup /e "$(INST_SEC_CLIENT)" SECGCLIENT
  463. Section "$(INST_SEC_CORE)" SEC01
  464. SectionIn 1 RO ; section is required
  465. ${LogText} "+Section begin - CLIENT CORE"
  466.  
  467. Call UpdateVCRedistributables
  468.  
  469. SetShellVarContext all
  470.  
  471. #############################################################
  472. # Show that upgrade is catered for
  473. Push $INSTDIR
  474. Call GetInstallType
  475. Pop $0
  476. Pop $1
  477.  
  478. ${If} $0 == "upgrade"
  479. DetailPrint "$(INFO_INPLACE_UPGRADE)"
  480. Sleep 1000
  481. ${EndIf}
  482. #############################################################
  483.  
  484. WriteRegStr HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\Common" "GTA:SA Path" $GTA_DIR
  485. WriteRegStr HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\${0.0}" "Last Install Location" $INSTDIR
  486.  
  487. # Create fixed path data directories
  488. CreateDirectory "$APPDATA\MTA San Andreas All\Common"
  489. CreateDirectory "$APPDATA\MTA San Andreas All\${0.0}"
  490.  
  491. # Ensure install dir exists so the permissions can be set
  492. SetOutPath "$INSTDIR\MTA"
  493. SetOverwrite on
  494.  
  495. #############################################################
  496. # Make the directory "$INSTDIR" read write accessible by all users
  497. # Make the directory "$APPDATA\MTA San Andreas All" read write accessible by all users
  498. # Make the directory "$GTA_DIR" read write accessible by all users
  499.  
  500. ${If} ${AtLeastWinVista}
  501. DetailPrint "$(INFO_UPDATE_PERMISSIONS)"
  502.  
  503. # Fix permissions for MTA install directory
  504.  
  505. # Check if install path begins with "..Program Files (x86)\M" or "..Program Files\M"
  506. StrCpy $3 "0"
  507. StrCpy $0 "$PROGRAMFILES\M"
  508. StrLen $2 $0
  509. StrCpy $1 "$INSTDIR" $2
  510. ${If} $0 == $1
  511. StrCpy $3 "1"
  512. ${EndIf}
  513.  
  514. StrCpy $0 "$PROGRAMFILES64\M"
  515. StrLen $2 $0
  516. StrCpy $1 "$INSTDIR" $2
  517. ${If} $0 == $1
  518. StrCpy $3 "1"
  519. ${EndIf}
  520.  
  521. ${LogText} "FullAccess $INSTDIR"
  522. ${If} $3 == "1"
  523. FastPerms::FullAccessPlox "$INSTDIR"
  524. ${Else}
  525. # More conservative permissions blat if install directory it too different from default
  526. CreateDirectory "$INSTDIR\mods"
  527. CreateDirectory "$INSTDIR\screenshots"
  528. CreateDirectory "$INSTDIR\server"
  529. CreateDirectory "$INSTDIR\skins"
  530. FastPerms::FullAccessPlox "$INSTDIR\mods"
  531. FastPerms::FullAccessPlox "$INSTDIR\MTA"
  532. FastPerms::FullAccessPlox "$INSTDIR\screenshots"
  533. FastPerms::FullAccessPlox "$INSTDIR\server"
  534. FastPerms::FullAccessPlox "$INSTDIR\skins"
  535. ${EndIf}
  536. ${LogText} "FullAccess $APPDATA\MTA San Andreas All"
  537. FastPerms::FullAccessPlox "$APPDATA\MTA San Andreas All"
  538.  
  539. # Remove MTA virtual store
  540. StrCpy $0 $INSTDIR
  541. !insertmacro UAC_AsUser_Call Function RemoveVirtualStore ${UAC_SYNCREGISTERS}
  542. StrCpy $0 $INSTDIR
  543. Call RemoveVirtualStore
  544.  
  545. IfFileExists $GTA_DIR\gta_sa.exe +1 0
  546. IfFileExists $GTA_DIR\gta-sa.exe 0 PathBad
  547. # Fix permissions for GTA install directory
  548. FastPerms::FullAccessPlox "$GTA_DIR"
  549.  
  550. # Remove GTA virtual store
  551. StrCpy $0 $GTA_DIR
  552. !insertmacro UAC_AsUser_Call Function RemoveVirtualStore ${UAC_SYNCREGISTERS}
  553. StrCpy $0 $GTA_DIR
  554. Call RemoveVirtualStore
  555. PathBad:
  556. ${EndIf}
  557. #############################################################
  558.  
  559. #############################################################
  560. # Patch our San Andreas .exe if it is required
  561.  
  562. IfFileExists $GTA_DIR\gta_sa.exe 0 TrySteamExe
  563. # Check gta_sa.exe is greater than 1MB (Previous Steam patching may have failed)
  564. ${GetSize} "$GTA_DIR" "/M=gta_sa.exe /S=0M /G=0" $0 $1 $2
  565. StrCmp "$0" "0" TrySteamExe
  566. !insertmacro GetMD5 $GTA_DIR\gta_sa.exe $ExeMD5
  567. DetailPrint "gta_sa.exe successfully detected ($ExeMD5)"
  568. ${LogText} "GetMD5 $GTA_DIR\gta_sa.exe $ExeMD5"
  569. ${Switch} $ExeMD5
  570. ${Case} "bf25c28e9f6c13bd2d9e28f151899373" #US 2.00
  571. ${Case} "7fd5f9436bd66af716ac584ff32eb483" #US 1.01
  572. ${Case} "d84326ba0e0ace89f87288ffe7504da4" #EU 3.00 Steam Mac
  573. ${Case} "4e99d762f44b1d5e7652dfa7e73d6b6f" #EU 2.00
  574. ${Case} "2ac4b81b3e85c8d0f9846591df9597d3" #EU 1.01
  575. ${Case} "d0ad36071f0e9bead7bddea4fbda583f" #EU 1.01 GamersGate
  576. ${Case} "25405921d1c47747fd01fd0bfe0a05ae" #EU 1.01 DEViANCE
  577. ${Case} "9effcaf66b59b9f8fb8dff920b3f6e63" #DE 2.00
  578. ${Case} "fa490564cd9811978085a7a8f8ed7b2a" #DE 1.01
  579. ${Case} "49dd417760484a18017805df46b308b8" #DE 1.00
  580. ${Case} "185f0970f5913d0912a89789af175ffe" #?? ?.?? 4,496,063 bytes
  581. #Create a backup of the GTA exe before patching
  582. CopyFiles "$GTA_DIR\gta_sa.exe" "$GTA_DIR\gta_sa.exe.bak"
  583. Call InstallPatch
  584. ${If} $PatchInstalled == "1"
  585. Goto CompletePatchProc
  586. ${EndIf}
  587. Goto NoExeFound
  588. ${Break}
  589. ${Default}
  590. Goto CompletePatchProc #This gta_sa.exe doesn't need patching, let's continue
  591. ${Break}
  592. ${EndSwitch}
  593. TrySteamExe:
  594. # Try with gta-sa.exe, then testapp.exe
  595. nsArray::SetList array "gta-sa.exe" "testapp.exe" /end
  596. ${ForEachIn} array $0 $1
  597. IfFileExists $GTA_DIR\$1 0 TrySteamNext
  598. !insertmacro GetMD5 $GTA_DIR\$1 $ExeMD5
  599. DetailPrint "$1 successfully detected ($ExeMD5)"
  600. ${LogText} "GetMD5 $GTA_DIR\gta_sa.exe $ExeMD5"
  601. ${Switch} $ExeMD5
  602. ${Case} "0fd315d1af41e26e536a78b4d4556488" #EU 3.00 Steam 2007-12-04 11:50:50 5697536
  603. ${Case} "2ed36a3cee7b77da86a343838e3516b6" #EU 3.01 Steam (2014 Nov update) 2014-10-14 21:58:05 5971456
  604. ${Case} "5bfd4dd83989a8264de4b8e771f237fd" #EU 3.02 Steam (2014 Dec update) 2014-12-01 20:43:21 5971456
  605. ${Case} "d9cb35c898d3298ca904a63e10ee18d7" #DE 3.02 Steam (2014 Dec update) 2016-08-11 20:57:22 5971456
  606. #Copy gta-sa.exe to gta_sa.exe and commence patching process
  607. CopyFiles "$GTA_DIR\$1" "$GTA_DIR\gta_sa.exe.bak"
  608. Call InstallPatch
  609. ${If} $PatchInstalled == "1"
  610. Goto CompletePatchProc
  611. ${EndIf}
  612. Goto TrySteamNext
  613. ${Break}
  614. ${Default}
  615. Goto TrySteamNext
  616. ${Break}
  617. ${EndSwitch}
  618. TrySteamNext:
  619. ${Next}
  620.  
  621. NoExeFound:
  622. MessageBox MB_ICONSTOP "$(MSGBOX_INVALID_GTASA)"
  623. CompletePatchProc:
  624.  
  625. #############################################################
  626. # Fix missing or incorrect VS2013 redist files
  627. SetOutPath $SYSDIR
  628. Push $SYSDIR\msvcp120.dll
  629. Call IsDll32Bit
  630. Pop $0
  631. ${If} $0 != 1
  632. File "${FILES_ROOT}\redist\msvcp120.dll"
  633. ${EndIf}
  634.  
  635. Push $SYSDIR\msvcr120.dll
  636. Call IsDll32Bit
  637. Pop $0
  638. ${If} $0 != 1
  639. File "${FILES_ROOT}\redist\msvcr120.dll"
  640. ${EndIf}
  641. #############################################################
  642.  
  643. #############################################################
  644. # For XP, install Microsoft Internationalized Domain Names (IDN) Mitigation APIs
  645. SetOutPath "$TEMP"
  646. ${If} ${AtMostWinXP}
  647. ${IfNot} ${FileExists} $SYSDIR\normaliz.dll
  648. ${LogText} "Did not find $SYSDIR\normaliz.dll"
  649. File "${FILES_ROOT}\redist\idndl.x86.exe"
  650. ExecWait '"$TEMP\idndl.x86.exe" /passive'
  651. ${EndIf}
  652. ${EndIf}
  653. #############################################################
  654.  
  655. SetOutPath "$INSTDIR\MTA"
  656. SetOverwrite on
  657.  
  658. # Make some keys in HKLM read write accessible by all users
  659. AccessControl::GrantOnRegKey HKLM "SOFTWARE\Multi Theft Auto: San Andreas All" "(BU)" "FullAccess"
  660.  
  661. SetOutPath "$INSTDIR\MTA"
  662. File "${FILES_ROOT}\mta\cgui.dll"
  663. File "${FILES_ROOT}\mta\core.dll"
  664. File "${FILES_ROOT}\mta\xmll.dll"
  665. File "${FILES_ROOT}\mta\game_sa.dll"
  666. File "${FILES_ROOT}\mta\multiplayer_sa.dll"
  667. File "${FILES_ROOT}\mta\netc.dll"
  668. File "${FILES_ROOT}\mta\libcurl.dll"
  669. File "${FILES_ROOT}\mta\loader.dll"
  670. File "${FILES_ROOT}\mta\pthread.dll"
  671. File "${FILES_ROOT}\mta\cefweb.dll"
  672.  
  673. SetOutPath "$INSTDIR\MTA"
  674. File "${FILES_ROOT}\mta\libcef.dll"
  675. File "${FILES_ROOT}\mta\icudtl.dat"
  676. File "${FILES_ROOT}\mta\libEGL.dll"
  677. File "${FILES_ROOT}\mta\libGLESv2.dll"
  678. File "${FILES_ROOT}\mta\natives_blob.bin"
  679. File "${FILES_ROOT}\mta\snapshot_blob.bin"
  680.  
  681. SetOutPath "$INSTDIR\MTA\CEF"
  682. File "${FILES_ROOT}\mta\CEF\CEFLauncher.exe"
  683. File "${FILES_ROOT}\mta\CEF\CEFLauncher_DLL.dll"
  684. File "${FILES_ROOT}\mta\CEF\cef.pak"
  685. File "${FILES_ROOT}\mta\CEF\cef_100_percent.pak"
  686. File "${FILES_ROOT}\mta\CEF\cef_200_percent.pak"
  687. File "${FILES_ROOT}\mta\CEF\devtools_resources.pak"
  688. #File "${FILES_ROOT}\mta\CEF\cef_extensions.pak"
  689.  
  690. SetOutPath "$INSTDIR\MTA\CEF\locales"
  691. File "${FILES_ROOT}\mta\CEF\locales\en-US.pak"
  692.  
  693.  
  694. ${If} "$(LANGUAGE_CODE)" != ""
  695. # Write our language to registry
  696. WriteRegStr HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\${0.0}\Settings\general" "locale" "$(LANGUAGE_CODE)"
  697. ${EndIf}
  698.  
  699. !ifndef LIGHTBUILD
  700.  
  701. SetOutPath "$INSTDIR\MTA"
  702. File "${FILES_ROOT}\mta\d3dx9_42.dll"
  703. File "${FILES_ROOT}\mta\D3DCompiler_42.dll"
  704. File "${FILES_ROOT}\mta\bass.dll"
  705. File "${FILES_ROOT}\mta\basswma.dll"
  706. File "${FILES_ROOT}\mta\bassmidi.dll"
  707. File "${FILES_ROOT}\mta\bassflac.dll"
  708. File "${FILES_ROOT}\mta\bass_aac.dll"
  709. File "${FILES_ROOT}\mta\bass_ac3.dll"
  710. File "${FILES_ROOT}\mta\bassmix.dll"
  711. File "${FILES_ROOT}\mta\bass_fx.dll"
  712. File "${FILES_ROOT}\mta\bassopus.dll"
  713. File "${FILES_ROOT}\mta\tags.dll"
  714. File "${FILES_ROOT}\mta\sa.dat"
  715. File "${FILES_ROOT}\mta\vea.dll"
  716. File "${FILES_ROOT}\mta\vog.dll"
  717. File "${FILES_ROOT}\mta\vvo.dll"
  718. File "${FILES_ROOT}\mta\vvof.dll"
  719. File "${FILES_ROOT}\mta\XInput9_1_0_mta.dll"
  720.  
  721. File "${FILES_ROOT}\mta\d3dcompiler_43.dll"
  722. File "${FILES_ROOT}\mta\d3dcompiler_47.dll"
  723.  
  724. SetOutPath "$INSTDIR\MTA\config"
  725. File "${FILES_ROOT}\mta\config\chatboxpresets.xml"
  726.  
  727. SetOutPath "$INSTDIR\skins\Classic"
  728. File "${FILES_ROOT}\skins\Classic\CGUI.is.xml"
  729. File "${FILES_ROOT}\skins\Classic\CGUI.lnf.xml"
  730. File "${FILES_ROOT}\skins\Classic\CGUI.png"
  731. File "${FILES_ROOT}\skins\Classic\CGUI.xml"
  732.  
  733. SetOutPath "$INSTDIR\skins\Default"
  734. File "${FILES_ROOT}\skins\Default\CGUI.is.xml"
  735. File "${FILES_ROOT}\skins\Default\CGUI.lnf.xml"
  736. File "${FILES_ROOT}\skins\Default\CGUI.png"
  737. File "${FILES_ROOT}\skins\Default\CGUI.xml"
  738.  
  739. SetOutPath "$INSTDIR\skins\Lighter black"
  740. File "${FILES_ROOT}\skins\Lighter black\CGUI.is.xml"
  741. File "${FILES_ROOT}\skins\Lighter black\CGUI.lnf.xml"
  742. File "${FILES_ROOT}\skins\Lighter black\CGUI.png"
  743. File "${FILES_ROOT}\skins\Lighter black\CGUI.xml"
  744.  
  745. SetOutPath "$INSTDIR\MTA\cgui"
  746. File "${FILES_ROOT}\mta\cgui\Falagard.xsd"
  747. File "${FILES_ROOT}\mta\cgui\Font.xsd"
  748. File "${FILES_ROOT}\mta\cgui\GUIScheme.xsd"
  749. File "${FILES_ROOT}\mta\cgui\Imageset.xsd"
  750. File "${FILES_ROOT}\mta\cgui\pricedown.ttf"
  751. File "${FILES_ROOT}\mta\cgui\sabankgothic.ttf"
  752. File "${FILES_ROOT}\mta\cgui\sagothic.ttf"
  753. File "${FILES_ROOT}\mta\cgui\saheader.ttf"
  754. File "${FILES_ROOT}\mta\cgui\sans.ttf"
  755. File "${FILES_ROOT}\mta\cgui\unifont-5.1.20080907.ttf"
  756.  
  757. SetOutPath "$INSTDIR\MTA\cgui\images"
  758. File "${FILES_ROOT}\mta\cgui\images\*.png"
  759. File "${FILES_ROOT}\mta\cgui\images\*.jpg"
  760.  
  761. SetOutPath "$INSTDIR\MTA\cgui\images\radarset"
  762. File "${FILES_ROOT}\mta\cgui\images\radarset\*.png"
  763.  
  764. SetOutPath "$INSTDIR\MTA\cgui\images\transferset"
  765. File "${FILES_ROOT}\mta\cgui\images\transferset\*.png"
  766.  
  767. SetOutPath "$INSTDIR\MTA\cgui\images\serverbrowser"
  768. File "${FILES_ROOT}\mta\cgui\images\serverbrowser\*.png"
  769.  
  770. !endif
  771.  
  772. SetOutPath "$INSTDIR\MTA\locale\"
  773. File /r "${FILES_ROOT}\mta\locale\*.png"
  774. File /r "${FILES_ROOT}\mta\locale\*.po"
  775.  
  776. SetOutPath "$INSTDIR"
  777. File "${FILES_ROOT}\Multi Theft Auto.exe"
  778.  
  779. # Ensure exe file can be updated without admin
  780. AccessControl::GrantOnFile "$INSTDIR\Multi Theft Auto.exe" "(BU)" "FullAccess"
  781.  
  782. ${If} $AddToGameExplorer == 1
  783. ${GameExplorer_UpdateGame} ${GUID}
  784. ${If} ${Errors}
  785. ${GameExplorer_AddGame} all "$INSTDIR\Multi Theft Auto.exe" "$INSTDIR" "$INSTDIR\Multi Theft Auto.exe" ${GUID}
  786. CreateDirectory $APPDATA\Microsoft\Windows\GameExplorer\${GUID}\SupportTasks\0
  787. CreateShortcut "$APPDATA\Microsoft\Windows\GameExplorer\$0\SupportTasks\0\Client Manual.lnk" \ "http://wiki.multitheftauto.com/wiki/Client_Manual"
  788. ${EndIf}
  789. ${EndIf}
  790.  
  791. Call DoServiceInstall
  792. ${LogText} "-Section end - CLIENT CORE"
  793. SectionEnd
  794.  
  795. Section "$(INST_SEC_GAME)" SEC02
  796. ${LogText} "+Section begin - CLIENT GAME"
  797. SectionIn 1 RO
  798. SetOutPath "$INSTDIR\mods\deathmatch"
  799. File "${FILES_ROOT}\mods\deathmatch\Client.dll"
  800. File "${FILES_ROOT}\mods\deathmatch\pcre3.dll"
  801. SetOutPath "$INSTDIR\mods\deathmatch\resources"
  802. ${LogText} "-Section end - CLIENT GAME"
  803. SectionEnd
  804. SectionGroupEnd
  805.  
  806. SectionGroup /e "$(INST_SEC_SERVER)" SECGSERVER
  807. Section "$(INST_SEC_CORE)" SEC04
  808. ${LogText} "+Section begin - SERVER CORE"
  809. SectionIn 1 2 RO ; section is required
  810.  
  811. Call UpdateVCRedistributables
  812.  
  813. SetOutPath "$INSTDIR\server"
  814. SetOverwrite on
  815. File "${SERVER_FILES_ROOT}\core.dll"
  816. File "${FILES_ROOT}\mta\xmll.dll"
  817. File "${SERVER_FILES_ROOT}\MTA Server.exe"
  818. File "${SERVER_FILES_ROOT}\net.dll"
  819. File "${FILES_ROOT}\mta\libcurl.dll"
  820. File "${FILES_ROOT}\mta\pthread.dll"
  821. ${LogText} "-Section end - SERVER CORE"
  822. SectionEnd
  823.  
  824. Section "$(INST_SEC_GAME)" SEC05
  825. ${LogText} "+Section begin - SERVER GAME"
  826. SectionIn 1 2 RO ; section is required
  827. SetOutPath "$INSTDIR\server\mods\deathmatch"
  828.  
  829. SetOverwrite on
  830. File "${SERVER_FILES_ROOT}\mods\deathmatch\deathmatch.dll"
  831. File "${SERVER_FILES_ROOT}\mods\deathmatch\lua5.1.dll"
  832. File "${FILES_ROOT}\mods\deathmatch\pcre3.dll"
  833. File "${SERVER_FILES_ROOT}\mods\deathmatch\dbconmy.dll"
  834. !ifndef LIGHTBUILD
  835. File "${SERVER_FILES_ROOT}\mods\deathmatch\libmysql.dll"
  836. !endif
  837.  
  838. ;Only overwrite the following files if previous versions were bugged and explicitly need replacing
  839. !insertmacro FileIfMD5 "${SERVER_FILES_ROOT}\mods\deathmatch\editor_acl.xml" "711185d8f4ebb355542053ce408b82b3"
  840. !insertmacro FileIfMD5 "${SERVER_FILES_ROOT}\mods\deathmatch\editor_acl.xml" "706869E53F508919F987A2F7F2653AD2"
  841.  
  842. SetOverwrite off
  843. File "${SERVER_FILES_ROOT}\mods\deathmatch\acl.xml"
  844. File "${SERVER_FILES_ROOT}\mods\deathmatch\editor_acl.xml"
  845. File "${SERVER_FILES_ROOT}\mods\deathmatch\banlist.xml"
  846. File "${SERVER_FILES_ROOT}\mods\deathmatch\mtaserver.conf"
  847. File "${SERVER_FILES_ROOT}\mods\deathmatch\local.conf"
  848. File "${SERVER_FILES_ROOT}\mods\deathmatch\editor.conf"
  849. File "${SERVER_FILES_ROOT}\mods\deathmatch\vehiclecolors.conf"
  850.  
  851. !ifndef LIGHTBUILD
  852. File "${SERVER_FILES_ROOT}\mods\deathmatch\local.conf"
  853.  
  854. SetOutPath "$INSTDIR\server\mods\deathmatch\resources"
  855. SetOutPath "$INSTDIR\server\mods\deathmatch\resource-cache"
  856. SetOutPath "$INSTDIR\server\mods\deathmatch\logs"
  857. !endif
  858. ${LogText} "-Section end - SERVER GAME"
  859. SectionEnd
  860.  
  861. !ifndef LIGHTBUILD
  862. Section "$(INST_SEC_CORE_RESOURCES)" SEC06
  863. ${LogText} "+Section begin - SERVER CORE_RESOURCES"
  864. SectionIn 1 2 ; RO section is now optional
  865. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\"
  866. File "${SERVER_FILES_ROOT}\mods\deathmatch\resources\Directory layout readme.txt"
  867.  
  868. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[admin]"
  869. SetOverwrite ifnewer
  870. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[admin]\admin.zip"
  871. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[admin]\runcode.zip"
  872. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[admin]\acpanel.zip"
  873. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[admin]\ipb.zip"
  874. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[play]"
  875. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[play]\*.zip"
  876. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gameplay]"
  877. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gameplay]\*.zip"
  878. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[managers]"
  879. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[managers]\*.zip"
  880. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[web]"
  881. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[web]\*.zip"
  882. ${LogText} "-Section end - SERVER CORE_RESOURCES"
  883. SectionEnd
  884. !endif
  885.  
  886. !ifndef LIGHTBUILD
  887. SectionGroup "$(INST_SEC_OPTIONAL_RESOURCES)" SEC07
  888. Section "AMX Emulation package"
  889. SectionIn 1 2
  890. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[amx]"
  891. SetOverwrite ifnewer
  892. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[amx]\amx"
  893. SectionEnd
  894. Section "Assault Gamemode"
  895. SectionIn 1 2
  896. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[assault]"
  897. SetOverwrite ifnewer
  898. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[assault]\*.zip"
  899. SectionEnd
  900. Section "Briefcase Race Gamemode"
  901. SectionIn 1 2
  902. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[briefcaserace]"
  903. SetOverwrite ifnewer
  904. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[briefcaserace]\*.zip"
  905. SectionEnd
  906. Section "Classic Deathmatch Gamemode"
  907. SectionIn 1 2
  908. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[cdm]"
  909. SetOverwrite ifnewer
  910. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[cdm]\*.zip"
  911. SectionEnd
  912. Section "Capture the Flag Gamemode"
  913. SectionIn 1 2
  914. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[ctf]"
  915. SetOverwrite ifnewer
  916. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[ctf]\*.zip"
  917. SectionEnd
  918. Section "Capture the Vehicle Gamemode"
  919. SectionIn 1 2
  920. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[ctv]"
  921. SetOverwrite ifnewer
  922. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[ctv]\*.zip"
  923. SectionEnd
  924. Section "Deathmatch Gamemode"
  925. SectionIn 1 2
  926. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[deathmatch]"
  927. SetOverwrite ifnewer
  928. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[deathmatch]\*.zip"
  929. SectionEnd
  930. Section "Fallout Gamemode"
  931. SectionIn 1 2
  932. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[fallout]"
  933. SetOverwrite ifnewer
  934. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[fallout]\*.zip"
  935. SectionEnd
  936. Section "Hay Gamemode"
  937. SectionIn 1 2
  938. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[hay]"
  939. SetOverwrite ifnewer
  940. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[hay]\*.zip"
  941. SectionEnd
  942. Section "Race Gamemode"
  943. SectionIn 1 2
  944. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[race]"
  945. SetOverwrite ifnewer
  946. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[race]\*.zip"
  947. SectionEnd
  948. Section "Stealth Gamemode"
  949. SectionIn 1 2
  950. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[stealth]"
  951. SetOverwrite ifnewer
  952. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[stealth]\*.zip"
  953. SectionEnd
  954. Section "Team Deathmatch Arena Gamemode"
  955. SectionIn 1 2
  956. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[gamemodes]\[tdm]"
  957. SetOverwrite ifnewer
  958. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[gamemodes]\[tdm]\*.zip"
  959. SectionEnd
  960. SectionGroupEnd
  961. !endif
  962.  
  963. !ifdef INCLUDE_EDITOR
  964. Section "$(INST_SEC_EDITOR)" SEC08
  965. SectionIn 1 2
  966. SetOutPath "$INSTDIR\server\mods\deathmatch\resources\[editor]"
  967. SetOverwrite ifnewer
  968. File /r "${SERVER_FILES_ROOT}\mods\deathmatch\resources\[editor]\*.zip"
  969. SectionEnd
  970. !endif
  971.  
  972. SectionGroupEnd
  973.  
  974. LangString INST_SEC_DEVELOPER ${LANG_ENGLISH} "Development"
  975. !ifdef INCLUDE_DEVELOPMENT
  976. SectionGroup /e "$(INST_SEC_DEVELOPER)" SECGDEV
  977. Section /o "Module SDK" SEC09
  978. SetOutPath "$INSTDIR\development\module SDK"
  979. SetOverwrite ifnewer
  980. File /r "${FILES_MODULE_SDK}\"
  981. SectionEnd
  982. SectionGroupEnd
  983. !endif
  984.  
  985. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  986. !insertmacro MUI_DESCRIPTION_TEXT ${SEC10} $(DESC_Section10)
  987. !insertmacro MUI_DESCRIPTION_TEXT ${SEC11} $(DESC_Section11)
  988. !insertmacro MUI_DESCRIPTION_TEXT ${SEC12} $(DESC_Section12)
  989. !insertmacro MUI_DESCRIPTION_TEXT ${SEC13} $(DESC_Section13)
  990. !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(DESC_Section1)
  991. !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} $(DESC_Section2)
  992. ;!insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $(DESC_Section3)
  993. ;!insertmacro MUI_DESCRIPTION_TEXT ${SECGMODS} $(DESC_SectionGroupMods)
  994. !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $(DESC_Section4)
  995. !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} $(DESC_Section5)
  996. !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} $(DESC_Section6)
  997. !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} $(DESC_Section7)
  998. !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} $(DESC_Section8)
  999. !insertmacro MUI_DESCRIPTION_TEXT ${SEC09} $(DESC_Section9)
  1000. ;!insertmacro MUI_DESCRIPTION_TEXT ${SECBLANK} $(DESC_Blank)
  1001. !insertmacro MUI_DESCRIPTION_TEXT ${SECGSERVER} $(DESC_SectionGroupServer)
  1002. !insertmacro MUI_DESCRIPTION_TEXT ${SECGDEV} $(DESC_SectionGroupDev)
  1003. !insertmacro MUI_DESCRIPTION_TEXT ${SECGCLIENT} $(DESC_SectionGroupClient)
  1004. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  1005.  
  1006.  
  1007. Section -Post
  1008. ${LogText} "+Section begin - -Post"
  1009. WriteUninstaller "$INSTDIR\Uninstall.exe"
  1010. ;WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Multi Theft Auto.exe"
  1011.  
  1012. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  1013. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
  1014. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Multi Theft Auto.exe"
  1015. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  1016. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  1017. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
  1018. ${LogText} "-Section end - -Post"
  1019. SectionEnd
  1020.  
  1021. LangString UNINST_SUCCESS ${LANG_ENGLISH} "$(^Name) was successfully removed from your computer."
  1022. Function un.onUninstSuccess
  1023. HideWindow
  1024. MessageBox MB_ICONINFORMATION|MB_OK "$(UNINST_SUCCESS)"
  1025. ;UAC::Unload ;Must call unload! ; #3017 fix
  1026. FunctionEnd
  1027.  
  1028. LangString UNINST_FAIL ${LANG_ENGLISH} "Uninstallation has failed!"
  1029. Function un.OnUnInstFailed
  1030. HideWindow
  1031. MessageBox MB_ICONSTOP|MB_OK "$(UNINST_FAIL)"
  1032. ;UAC::Unload ;Must call unload! ; #3017 fix
  1033. FunctionEnd
  1034.  
  1035.  
  1036. LangString UNINST_REQUEST ${LANG_ENGLISH} "Are you sure you want to completely remove $(^Name) and all of its components?"
  1037. LangString UNINST_REQUEST_NOTE ${LANG_ENGLISH} "Uninstalling before update?\
  1038. $\r$\nIt is not necessary to uninstall before installing a new version of MTA:SA\
  1039. $\r$\nRun the new installer to upgrade and preserve your settings."
  1040.  
  1041. Function un.onInit
  1042. Call un.DoRightsElevation
  1043. SetShellVarContext all
  1044. MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UNINST_REQUEST_NOTE)$\r$\n$\r$\n$\r$\n$(UNINST_REQUEST)" IDYES +2
  1045. Abort
  1046.  
  1047. !insertmacro MUI_UNGETLANGUAGE
  1048. FunctionEnd
  1049.  
  1050. LangString UNINST_DATA_REQUEST ${LANG_ENGLISH} "Would you like to keep your data files (such as resources, screenshots and server configuration)? If you click no, any resources, configurations or screenshots you have created will be lost."
  1051. Section Uninstall
  1052. IfFileExists "$INSTDIR\server\mods\deathmatch\resources\*.*" ask 0 ;no maps folder, so delete everything
  1053. IfFileExists "$INSTDIR\screenshots\*.*" ask 0 ;no maps folder, so delete everything
  1054. IfFileExists "$INSTDIR\mods\deathmatch\resources\*.*" ask deleteall ;no maps folder, so delete everything
  1055. ask:
  1056. MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UNINST_DATA_REQUEST)" IDYES preservemapsfolder
  1057.  
  1058. deleteall:
  1059. Call un.DoServiceUninstall
  1060. RmDir /r "$INSTDIR\mods"
  1061. RmDir /r "$INSTDIR\MTA"
  1062.  
  1063. RmDir /r "$INSTDIR\server"
  1064.  
  1065. !ifdef INCLUDE_DEVELOPMENT ; start of fix for #3889
  1066. RmDir /r "$INSTDIR\development\module sdk\publicsdk"
  1067. RmDir "$INSTDIR\development\module sdk"
  1068. RmDir "$INSTDIR\development"
  1069. !endif ; end of fix for #3889
  1070.  
  1071. preservemapsfolder:
  1072. Call un.DoServiceUninstall
  1073. ; server CORE FILES
  1074. Delete "$INSTDIR\server\core.dll"
  1075. Delete "$INSTDIR\server\xmll.dll"
  1076. Delete "$INSTDIR\server\MTA Server.exe"
  1077. Delete "$INSTDIR\server\net.dll"
  1078. Delete "$INSTDIR\server\libcurl.dll"
  1079.  
  1080. ; server files
  1081. Delete "$INSTDIR\server\mods\deathmatch\deathmatch.dll"
  1082. Delete "$INSTDIR\server\mods\deathmatch\lua5.1.dll"
  1083. Delete "$INSTDIR\server\mods\deathmatch\pcre3.dll"
  1084. Delete "$INSTDIR\server\mods\deathmatch\pthreadVC2.dll"
  1085. Delete "$INSTDIR\server\mods\deathmatch\pthread.dll"
  1086. Delete "$INSTDIR\server\mods\deathmatch\sqlite3.dll"
  1087. Delete "$INSTDIR\server\mods\deathmatch\dbconmy.dll"
  1088. Delete "$INSTDIR\server\mods\deathmatch\libmysql.dll"
  1089.  
  1090. Delete "$INSTDIR\Multi Theft Auto.exe"
  1091. Delete "$INSTDIR\Multi Theft Auto.exe.dat"
  1092. Delete "$INSTDIR\Uninstall.exe"
  1093.  
  1094. Delete "$INSTDIR\mods\deathmatch\Client.dll"
  1095. Delete "$INSTDIR\mods\deathmatch\lua5.1c.dll"
  1096. Delete "$INSTDIR\mods\deathmatch\pcre3.dll"
  1097.  
  1098. RmDir /r "$INSTDIR\MTA\cgui"
  1099. RmDir /r "$INSTDIR\MTA\data"
  1100. Delete "$INSTDIR\MTA\*.dll"
  1101. Delete "$INSTDIR\MTA\*.ax"
  1102. Delete "$INSTDIR\MTA\*.txt"
  1103. Delete "$INSTDIR\MTA\*.dat"
  1104.  
  1105. RmDir /r "$APPDATA\MTA San Andreas All\${0.0}"
  1106. ; TODO if $APPDATA\MTA San Andreas All\Common is the only one left, delete it
  1107.  
  1108. DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  1109. DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  1110. DeleteRegKey HKLM "SOFTWARE\Multi Theft Auto: San Andreas ${0.0}"
  1111. DeleteRegKey HKCU "SOFTWARE\Multi Theft Auto: San Andreas ${0.0}"
  1112. DeleteRegKey HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\${0.0}"
  1113. ; TODO if HKLM "SOFTWARE\Multi Theft Auto: San Andreas All\Common is the only one left, delete it
  1114.  
  1115. ${GameExplorer_RemoveGame} ${GUID}
  1116.  
  1117. ; Delete client shortcuts
  1118. Delete "$SMPROGRAMS\\MTA San Andreas ${0.0}\MTA San Andreas.lnk"
  1119. Delete "$SMPROGRAMS\\MTA San Andreas ${0.0}\Uninstall MTA San Andreas.lnk"
  1120. Delete "$DESKTOP\MTA San Andreas ${0.0}.lnk"
  1121.  
  1122. RmDir "$INSTDIR" ; fix for #3898
  1123.  
  1124. ; Delete server shortcuts
  1125. Delete "$SMPROGRAMS\\MTA San Andreas ${0.0}\MTA Server.lnk"
  1126. Delete "$SMPROGRAMS\\MTA San Andreas ${0.0}\Uninstall MTA San Andreas Server.lnk"
  1127. RmDir /r "$SMPROGRAMS\\MTA San Andreas ${0.0}"
  1128.  
  1129. SetAutoClose true
  1130. SectionEnd
  1131.  
  1132. ; Function that skips the game directory page if client is not selected
  1133. Function SkipDirectoryPage
  1134. SectionGetFlags ${SEC01} $R0
  1135. IntOp $R0 $R0 & ${SF_SELECTED}
  1136. IntCmp $R0 ${SF_SELECTED} +2 0
  1137. Abort
  1138. FunctionEnd
  1139.  
  1140.  
  1141. ;====================================================================================
  1142. ; Download and install Microsoft Visual Studio redistributables if required
  1143. ;====================================================================================
  1144. Var DONEUPDATE
  1145. Function UpdateVCRedistributables
  1146. ; Only check once
  1147. ${If} $DONEUPDATE == "1"
  1148. Return
  1149. ${EndIf}
  1150. StrCpy $DONEUPDATE "1"
  1151.  
  1152. Call ShouldInstallVC12Redistributable
  1153. ${If} $0 == "1"
  1154. Call InstallVC12Redistributable
  1155. ${EndIf}
  1156. Call ShouldInstallVC14Redistributable
  1157. ${If} $0 == "1"
  1158. Call InstallVC14Redistributable
  1159. ${EndIf}
  1160. FunctionEnd
  1161.  
  1162.  
  1163. ;====================================================================================
  1164. ; Download and install Microsoft Visual Studio 2013 redistributable
  1165. ;====================================================================================
  1166. Var REDISTVC12
  1167.  
  1168. LangString MSGBOX_VC12RED_ERROR1 ${LANG_ENGLISH} "Unable to download Microsoft Visual Studio 2013 redistributable"
  1169. LangString MSGBOX_VC12RED_ERROR2 ${LANG_ENGLISH} "Unable to install Microsoft Visual Studio 2013 redistributable"
  1170. LangString MSGBOX_VC12RED_ERROR3 ${LANG_ENGLISH} "Unable to download Microsoft Visual Studio 2013 redistributable.\
  1171. $\r$\nHowever installation will continue.\
  1172. $\r$\nPlease reinstall if there are problems later."
  1173. Function InstallVC12Redistributable
  1174. ${LogText} "+Function begin - InstallVC12Redistributable"
  1175. DetailPrint "Installing Microsoft Visual Studio 2013 redistributable ..."
  1176. StrCpy $REDISTVC12 "$TEMP\vcredist12_x86.exe"
  1177. NSISdl::download "http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe" $REDISTVC12
  1178. Pop $0
  1179.  
  1180. ${If} $0 != "success"
  1181. DetailPrint "* Download of Microsoft Visual Studio 2013 redistributable failed:"
  1182. DetailPrint "* $0"
  1183. DetailPrint "* Installation continuing anyway"
  1184. MessageBox MB_ICONSTOP "$(MSGBOX_VC12RED_ERROR3)"
  1185. ${Else}
  1186. ; /passive = 'This option will display a progress dialog (but requires no user interaction) and perform an install.'
  1187. ; /quiet = 'This option will suppress all UI and perform an install.'
  1188. ExecWait '"$REDISTVC12" /quiet'
  1189. Call IsVC12RedistributableInstalled
  1190. ${If} $0 != "1"
  1191. DetailPrint "* Some error occured installing Microsoft Visual Studio 2013 redistributable"
  1192. DetailPrint "* It is required in order to run Multi Theft Auto : San Andreas"
  1193. DetailPrint "* Installation continuing anyway"
  1194. MessageBox MB_ICONSTOP "$(MSGBOX_VC12RED_ERROR2)"
  1195. MessageBox MB_ICONSTOP "$(MSGBOX_VC12RED_ERROR3)"
  1196. ${EndIf}
  1197. ${EndIf}
  1198.  
  1199. ${LogText} "-Function end - InstallVC12Redistributable"
  1200. FunctionEnd
  1201.  
  1202. ;----------------------------------------
  1203. ; Out $0 = result ("1" = yes, "0" = no)
  1204. Function ShouldInstallVC12Redistributable
  1205. Call IsVC12RedistributableInstalled
  1206. IntOp $0 $0 ^ 1
  1207. FunctionEnd
  1208.  
  1209. ;----------------------------------------
  1210. ; Out $0 = result ("1" = yes, "0" = no)
  1211. Function IsVC12RedistributableInstalled
  1212. ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\DevDiv\vc\Servicing\12.0\RuntimeMinimum" "Install"
  1213. ${If} $0 != "1"
  1214. StrCpy $0 "0"
  1215. ${EndIf}
  1216. FunctionEnd
  1217.  
  1218.  
  1219. ;====================================================================================
  1220. ; Download and install Microsoft Visual Studio 2015 redistributable
  1221. ;====================================================================================
  1222. !define VC14_REDIST_VER "14.0.24210" ; Version number of update 3
  1223. Var REDISTVC14
  1224.  
  1225. LangString MSGBOX_VC14RED_ERROR1 ${LANG_ENGLISH} "Unable to download Microsoft Visual Studio 2015 redistributable"
  1226. LangString MSGBOX_VC14RED_ERROR2 ${LANG_ENGLISH} "Unable to install Microsoft Visual Studio 2015 redistributable"
  1227. LangString MSGBOX_VC14RED_ERROR3 ${LANG_ENGLISH} "Unable to download Microsoft Visual Studio 2015 redistributable.\
  1228. $\r$\nHowever installation will continue.\
  1229. $\r$\nPlease reinstall if there are problems later."
  1230. Function InstallVC14Redistributable
  1231. ${LogText} "+Function begin - InstallVC14Redistributable"
  1232. DetailPrint "Installing Microsoft Visual Studio 2015 redistributable ..."
  1233. StrCpy $REDISTVC14 "$TEMP\vcredist14_x86.exe"
  1234. NSISdl::download "http://mirror.multitheftauto.com/mtasa/installer/10700/vcredist_2015_x86.exe" $REDISTVC14
  1235. Pop $0
  1236.  
  1237. ${If} $0 != "success"
  1238. DetailPrint "* Download of Microsoft Visual Studio 2015 redistributable failed:"
  1239. DetailPrint "* $0"
  1240. DetailPrint "* Installation continuing anyway"
  1241. MessageBox MB_ICONSTOP "$(MSGBOX_VC14RED_ERROR3)"
  1242. ${Else}
  1243. ; /passive = 'This option will display a progress dialog (but requires no user interaction) and perform an install.'
  1244. ; /quiet = 'This option will suppress all UI and perform an install.'
  1245. ExecWait '"$REDISTVC14" /repair /passive /norestart'
  1246. Call IsVC14RedistributableInstalled
  1247. ${If} $0 != "1"
  1248. DetailPrint "* Some error occured installing Microsoft Visual Studio 2015 redistributable"
  1249. DetailPrint "* It is required in order to run Multi Theft Auto : San Andreas"
  1250. DetailPrint "* Installation continuing anyway"
  1251. MessageBox MB_ICONSTOP "$(MSGBOX_VC14RED_ERROR2)"
  1252. MessageBox MB_ICONSTOP "$(MSGBOX_VC14RED_ERROR3)"
  1253. ${EndIf}
  1254. ${EndIf}
  1255.  
  1256. ${LogText} "-Function end - InstallVC14Redistributable"
  1257. FunctionEnd
  1258.  
  1259. ;----------------------------------------
  1260. ; Out $0 = result ("1" = yes, "0" = no)
  1261. Function ShouldInstallVC14Redistributable
  1262. ${If} ${AtMostWin7}
  1263. IfFileExists "$WINDIR\System32\api-ms-win-crt-runtime-*.dll" FileFound 0
  1264. ${LogText} "api-ms-win-crt-runtime-*.dll not found"
  1265. StrCpy $0 "1"
  1266. Return
  1267. FileFound:
  1268. ${EndIf}
  1269. Call IsVC14RedistributableInstalled
  1270. IntOp $0 $0 ^ 1
  1271. FunctionEnd
  1272.  
  1273. ;----------------------------------------
  1274. ; Out $0 = result ("1" = yes, "0" = no)
  1275. Function IsVC14RedistributableInstalled
  1276. ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum" "Install"
  1277. ${If} $0 == "1"
  1278. ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum" "Version"
  1279.  
  1280. ; ${VersionCompare} "[Version1]" "[Version2]" $result
  1281. ; 0 = Versions are equal
  1282. ; 1 = Version1 is newer
  1283. ; 2 = Version2 is newer
  1284. ${VersionCompare} $0 ${VC14_REDIST_VER} $1
  1285. ${If} $1 != "2" ; Version2 is not newer
  1286. StrCpy $0 "1"
  1287. Return
  1288. ${EndIf}
  1289.  
  1290. ${EndIf}
  1291. StrCpy $0 "0"
  1292. FunctionEnd
  1293.  
  1294. ;====================================================================================
  1295. ; Patcher related functions
  1296. ;====================================================================================
  1297. Var PATCHFILE
  1298.  
  1299. LangString MSGBOX_PATCH_FAIL1 ${LANG_ENGLISH} "Unable to download the patch file for your version of Grand Theft Auto: San Andreas"
  1300. LangString MSGBOX_PATCH_FAIL2 ${LANG_ENGLISH} "Unable to install the patch file for your version of Grand Theft Auto: San Andreas"
  1301. Function InstallPatch
  1302. ${LogText} "+Function begin - InstallPatch"
  1303. DetailPrint "Incompatible version of San Andreas detected. Patching executable..."
  1304. StrCpy $PATCHFILE "$TEMP\$ExeMD5.GTASAPatch"
  1305. NSISdl::download "http://mirror.multitheftauto.com/gdata/$ExeMD5.GTASAPatch" $PATCHFILE
  1306. Pop $0
  1307. ${If} $0 != "success"
  1308. DetailPrint "* Download of patch file failed:"
  1309. DetailPrint "* $0"
  1310. DetailPrint "* Installation continuing anyway"
  1311. MessageBox MB_ICONSTOP "$(MSGBOX_PATCH_FAIL1)"
  1312. StrCpy $PatchInstalled "0"
  1313. ${Else}
  1314. DetailPrint "Patch download successful. Installing patch..."
  1315. vpatch::vpatchfile "$PATCHFILE" "$GTA_DIR\gta_sa.exe.bak" "$GTA_DIR\gta_sa.exe"
  1316. Pop $R0
  1317. ${If} $R0 == "OK"
  1318. StrCpy $PatchInstalled "1"
  1319. ${ElseIf} $R0 == "OK, new version already installed"
  1320. StrCpy $PatchInstalled "1"
  1321. ${Else}
  1322. StrCpy $PatchInstalled "0"
  1323. DetailPrint "* Some error occured installing the patch for Grand Theft Auto: San Andreas:"
  1324. DetailPrint "* $R0"
  1325. DetailPrint "* It is required in order to run Multi Theft Auto : San Andreas"
  1326. DetailPrint "* Installation continuing anyway"
  1327. MessageBox MB_ICONSTOP MSGBOX_PATCH_FAIL2
  1328. ${EndIf}
  1329. ${EndIf}
  1330. ${LogText} "-Function end - InstallPatch"
  1331. FunctionEnd
  1332.  
  1333. ;====================================================================================
  1334. ; UAC related functions
  1335. ;====================================================================================
  1336. LangString UAC_RIGHTS1 ${LANG_ENGLISH} "This installer requires admin access, try again"
  1337. LangString UAC_RIGHTS_UN ${LANG_ENGLISH} "This uninstaller requires admin access, try again"
  1338. LangString UAC_RIGHTS3 ${LANG_ENGLISH} "Logon service not running, aborting!"
  1339. LangString UAC_RIGHTS4 ${LANG_ENGLISH} "Unable to elevate"
  1340. !macro RightsElevation AdminError
  1341. uac_tryagain:
  1342. !insertmacro UAC_RunElevated
  1343. #MessageBox mb_TopMost "0=$0 1=$1 2=$2 3=$3"
  1344. ${Switch} $0
  1345. ${Case} 0
  1346. ${IfThen} $1 = 1 ${|} Quit ${|} ; we are the outer process, the inner process has done its work, we are done
  1347. ${IfThen} $3 <> 0 ${|} ${Break} ${|} ; we are admin, let the show go on
  1348. ${If} $1 = 3 ; RunAs completed successfully, but with a non-admin user
  1349. MessageBox mb_IconExclamation|mb_TopMost|mb_SetForeground "${AdminError}" /SD IDNO IDOK uac_tryagain IDNO 0
  1350. ${EndIf}
  1351. ;fall-through and die
  1352. ${Case} 1223
  1353. MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "${AdminError}"
  1354. Quit
  1355. ${Case} 1062
  1356. MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "$(UAC_RIGHTS3)"
  1357. Quit
  1358. ${Default}
  1359. MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "$(UAC_RIGHTS4), error $0"
  1360. Quit
  1361. ${EndSwitch}
  1362. !macroend
  1363.  
  1364. Function DoRightsElevation
  1365. ${LogText} "+Function begin - RightsElevation"
  1366. !insertmacro RightsElevation "$(UAC_RIGHTS1)"
  1367. ${LogText} "-Function end - RightsElevation"
  1368. FunctionEnd
  1369.  
  1370. Function un.DoRightsElevation
  1371. !insertmacro RightsElevation "$(UAC_RIGHTS_UN)"
  1372. FunctionEnd
  1373.  
  1374.  
  1375. ;****************************************************************
  1376. ;
  1377. ; Functions relating to the resizing of the 'Components' dialog.
  1378. ;
  1379. ;****************************************************************
  1380.  
  1381. Var HWND
  1382. Var RECT_X
  1383. Var RECT_Y
  1384. Var RECT_W
  1385. Var RECT_H
  1386.  
  1387. ; In: $HWND $RECT_X $RECT_Y
  1388. ; Out: $RECT_X $RECT_Y
  1389. Function ScreenToClient
  1390. ;Save existing register values to the stack
  1391. Push $1
  1392. Push $2
  1393. Push $3
  1394.  
  1395. ; Allocate a 2 int struct in $1
  1396. System::Call "*(i $RECT_X, i $RECT_Y) i.r1"
  1397. ${If} $1 == 0
  1398. DetailPrint "Memory problem"
  1399. ${Else}
  1400. ; Call ScreenToClient
  1401. System::Call "User32::ScreenToClient(i, i) i ($HWND, r1r1) .r5"
  1402. System::Call "*$1(i .r2, i .r3)"
  1403.  
  1404. ; Set return values
  1405. StrCpy $RECT_X $2
  1406. StrCpy $RECT_Y $3
  1407.  
  1408. ; Free 2 int struct
  1409. System::Free $1
  1410. ${EndIf}
  1411.  
  1412. ;Restore register values from the stack
  1413. Pop $3
  1414. Pop $2
  1415. Pop $1
  1416.  
  1417. FunctionEnd
  1418.  
  1419.  
  1420. ; In: $HWND
  1421. ; Out: $RECT_X $RECT_Y $RECT_W $RECT_D
  1422. Function GetWindowRect
  1423. ;Save existing register values to the stack
  1424. Push $1
  1425. Push $2
  1426. Push $3
  1427. Push $4
  1428. Push $5
  1429.  
  1430. ; Allocate a 4 int struct in $1
  1431. System::Call "*(i 0, i 0, i 0, i 0) i.r1"
  1432. ${If} $1 == 0
  1433. DetailPrint "Memory problem"
  1434. ${Else}
  1435. ; Call GetWindowRect
  1436. System::Call "User32::GetWindowRect(i, i) i ($HWND, r1) .r5"
  1437. System::Call "*$1(i .r2, i .r3, i .r4, i .r5)"
  1438.  
  1439. ; Set return values
  1440. StrCpy $RECT_X $2
  1441. StrCpy $RECT_Y $3
  1442. IntOp $RECT_W $4 - $2
  1443. IntOp $RECT_H $5 - $3
  1444.  
  1445. ; Free 4 int struct
  1446. System::Free $1
  1447. ${EndIf}
  1448.  
  1449. ;Restore register values from the stack
  1450. Pop $5
  1451. Pop $4
  1452. Pop $3
  1453. Pop $2
  1454. Pop $1
  1455.  
  1456. FunctionEnd
  1457.  
  1458.  
  1459. ; In: $HWND
  1460. ; Out: $RECT_X $RECT_Y $RECT_W $RECT_D
  1461. Function GetChildRect
  1462. ;Save existing register values to the stack
  1463. Push $1
  1464.  
  1465. Call GetWindowRect
  1466.  
  1467. System::Call "User32::GetParent(i) i ($HWND) .r1"
  1468. StrCpy $HWND $1
  1469.  
  1470. Call ScreenToClient
  1471.  
  1472. ;Restore register values from the stack
  1473. Pop $1
  1474. FunctionEnd
  1475.  
  1476.  
  1477. Var ITEM_HWND
  1478. Var ITEM_PARENT
  1479. Var ITEM_ID
  1480. Var X
  1481. Var Y
  1482. Var CX
  1483. Var CY
  1484.  
  1485. ; Input:
  1486. ; $ITEM_PARENT - Parent window
  1487. ; $ITEM_ID - Dialog ID
  1488. ; $X $Y - Position change
  1489. ; $CX $CY - Size change
  1490. Function MoveDialogItem
  1491. ;Save existing register values to the stack
  1492. Push $1
  1493. Push $2
  1494. Push $3
  1495. Push $4
  1496.  
  1497. ; Get item handle
  1498. GetDlgItem $ITEM_HWND $ITEM_PARENT $ITEM_ID
  1499.  
  1500. StrCpy $HWND $ITEM_HWND
  1501. Call GetChildRect
  1502.  
  1503. ; Calculate new dims
  1504. IntOp $1 $RECT_X + $X
  1505. IntOp $2 $RECT_Y + $Y
  1506. IntOp $3 $RECT_W + $CX
  1507. IntOp $4 $RECT_H + $CY
  1508.  
  1509. ; Set new dims
  1510. System::Call "User32::MoveWindow(i, i, i, i, i, b) b ($ITEM_HWND, $1, $2, $3, $4, true)"
  1511.  
  1512. ;Restore register values from the stack
  1513. Pop $4
  1514. Pop $3
  1515. Pop $2
  1516. Pop $1
  1517.  
  1518. FunctionEnd
  1519.  
  1520.  
  1521. Var HWND_DIALOG
  1522. Var RESIZE_X
  1523. Var RESIZE_Y
  1524.  
  1525.  
  1526. Function HideBackButton
  1527. GetDlgItem $ITEM_HWND $HWNDPARENT 3
  1528. ShowWindow $ITEM_HWND ${SW_HIDE}
  1529. FunctionEnd
  1530.  
  1531.  
  1532. ; Input:
  1533. ; $RESIZE_X $RESIZE_Y - Resize amount
  1534. Function ResizeComponentsDialogContents
  1535.  
  1536. FindWindow $HWND_DIALOG "#32770" "" $HWNDPARENT
  1537.  
  1538. ;Move description right and stretch down
  1539. StrCpy $X $RESIZE_X
  1540. StrCpy $Y 0
  1541. StrCpy $CX 0
  1542. StrCpy $CY $RESIZE_Y
  1543. ${If} "$(LANGUAGE_RTL)" == "1"
  1544. StrCpy $X 0
  1545. ${EndIf}
  1546.  
  1547. StrCpy $ITEM_PARENT $HWND_DIALOG
  1548. StrCpy $ITEM_ID 1043 ; Static - "Position your mouse over a component to see its description."
  1549. Call MoveDialogItem
  1550.  
  1551. StrCpy $ITEM_PARENT $HWND_DIALOG
  1552. StrCpy $ITEM_ID 1042 ; Button - Description
  1553. Call MoveDialogItem
  1554.  
  1555. ${If} "$(LANGUAGE_RTL)" == "1"
  1556. StrCpy $X $RESIZE_X
  1557. StrCpy $Y 0
  1558. StrCpy $CX 0
  1559. StrCpy $CY 0
  1560.  
  1561. StrCpy $ITEM_PARENT $HWND_DIALOG
  1562. StrCpy $ITEM_ID 1021 ; Static - "Select the type of install."
  1563. Call MoveDialogItem
  1564.  
  1565. StrCpy $ITEM_PARENT $HWND_DIALOG
  1566. StrCpy $ITEM_ID 1022 ; Static - "Or, select the optional components you wish to install."
  1567. Call MoveDialogItem
  1568.  
  1569. StrCpy $ITEM_PARENT $HWND_DIALOG
  1570. StrCpy $ITEM_ID 1023 ; Static - "Space required: XX MB."
  1571. Call MoveDialogItem
  1572. ${EndIf}
  1573.  
  1574. ;Middle zone bigger
  1575. StrCpy $X 0
  1576. StrCpy $Y 0
  1577. StrCpy $CX $RESIZE_X
  1578. StrCpy $CY $RESIZE_Y
  1579. StrCpy $ITEM_PARENT $HWNDPARENT
  1580. StrCpy $ITEM_ID 0 ; Sub dialog
  1581. Call MoveDialogItem
  1582.  
  1583. ;Make tree view bigger
  1584. StrCpy $X 0
  1585. StrCpy $Y 0
  1586. StrCpy $CX $RESIZE_X
  1587. StrCpy $CY $RESIZE_Y
  1588. StrCpy $ITEM_PARENT $HWND_DIALOG
  1589. StrCpy $ITEM_ID 1032 ; Tree view
  1590. Call MoveDialogItem
  1591.  
  1592. ;Stretch combo box to the right
  1593. StrCpy $X 0
  1594. StrCpy $Y 0
  1595. StrCpy $CX $RESIZE_X
  1596. StrCpy $CY 0
  1597.  
  1598. StrCpy $ITEM_PARENT $HWND_DIALOG
  1599. StrCpy $ITEM_ID 1017 ; Combo box
  1600. Call MoveDialogItem
  1601.  
  1602. ;Move space required text down
  1603. StrCpy $X 0
  1604. StrCpy $Y $RESIZE_Y
  1605. StrCpy $CX 0
  1606. StrCpy $CY 0
  1607.  
  1608. StrCpy $ITEM_PARENT $HWND_DIALOG
  1609. StrCpy $ITEM_ID 1023 ; Static
  1610. Call MoveDialogItem
  1611.  
  1612. FunctionEnd
  1613.  
  1614.  
  1615. ; Input:
  1616. ; $RESIZE_X $RESIZE_X - Resize amount
  1617. Function ResizeSharedDialogContents
  1618.  
  1619. ;Move buttons down and right
  1620. StrCpy $X $RESIZE_X
  1621. StrCpy $Y $RESIZE_Y
  1622. StrCpy $CX 0
  1623. StrCpy $CY 0
  1624.  
  1625. StrCpy $ITEM_PARENT $HWNDPARENT
  1626. StrCpy $ITEM_ID 1 ; Button - Next
  1627. Call MoveDialogItem
  1628.  
  1629. StrCpy $ITEM_PARENT $HWNDPARENT
  1630. StrCpy $ITEM_ID 2 ; Button - Cancel
  1631. Call MoveDialogItem
  1632.  
  1633. StrCpy $ITEM_PARENT $HWNDPARENT
  1634. StrCpy $ITEM_ID 3 ; Button - Back
  1635. Call MoveDialogItem
  1636.  
  1637. ;Move branding text down
  1638. StrCpy $X 0
  1639. StrCpy $Y $RESIZE_Y
  1640. StrCpy $CX 0
  1641. StrCpy $CY 0
  1642.  
  1643. StrCpy $ITEM_PARENT $HWNDPARENT
  1644. StrCpy $ITEM_ID 1256 ; Static - "Nullsoft Install System..."
  1645. Call MoveDialogItem
  1646.  
  1647. StrCpy $ITEM_PARENT $HWNDPARENT
  1648. StrCpy $ITEM_ID 1028 ; Static - "Nullsoft Install System..."
  1649. Call MoveDialogItem
  1650.  
  1651. ;Move lower horizontal line down and stretch to the right
  1652. StrCpy $X 0
  1653. StrCpy $Y $RESIZE_Y
  1654. StrCpy $CX $RESIZE_X
  1655. StrCpy $CY 0
  1656. StrCpy $ITEM_PARENT $HWNDPARENT
  1657. StrCpy $ITEM_ID 1035 ; Static - Line
  1658. Call MoveDialogItem
  1659.  
  1660. ;Stretch header to the right
  1661. StrCpy $X 0
  1662. StrCpy $Y 0
  1663. StrCpy $CX $RESIZE_X
  1664. StrCpy $CY 0
  1665. StrCpy $ITEM_PARENT $HWNDPARENT
  1666. StrCpy $ITEM_ID 1034 ; Static - White bar
  1667. Call MoveDialogItem
  1668.  
  1669. StrCpy $ITEM_PARENT $HWNDPARENT
  1670. StrCpy $ITEM_ID 1036 ; Static - Line
  1671. Call MoveDialogItem
  1672.  
  1673. ;Move header text to the right
  1674. StrCpy $X $RESIZE_X
  1675. StrCpy $Y 0
  1676. StrCpy $CX 0
  1677. StrCpy $CY 0
  1678. StrCpy $ITEM_PARENT $HWNDPARENT
  1679. StrCpy $ITEM_ID 1037 ; Static - "Choose Components"
  1680. Call MoveDialogItem
  1681.  
  1682. StrCpy $ITEM_PARENT $HWNDPARENT
  1683. StrCpy $ITEM_ID 1038 ; Static - "Choose which features of MTA:SA v1.0 you want to install."
  1684. Call MoveDialogItem
  1685.  
  1686. ${If} "$(LANGUAGE_RTL)" == "1"
  1687. ;Move image to the right most end if RTL
  1688. StrCpy $X $RESIZE_X
  1689. StrCpy $Y 0
  1690. StrCpy $CX 0
  1691. StrCpy $CY 0
  1692.  
  1693. StrCpy $ITEM_PARENT $HWNDPARENT
  1694. StrCpy $ITEM_ID 1046 ; Static - mta_install_header_rtl.bmp
  1695. Call MoveDialogItem
  1696. ${EndIf}
  1697.  
  1698. FunctionEnd
  1699.  
  1700.  
  1701. !define SWP_NOOWNERZORDER 0x0200
  1702.  
  1703. ; Input:
  1704. ; $RESIZE_X $RESIZE_X - Resize amount
  1705. Function ResizeMainWindow
  1706. ;Save existing register values to the stack
  1707. Push $0
  1708. Push $1
  1709. Push $2
  1710. Push $3
  1711. Push $4
  1712.  
  1713. StrCpy $HWND $HWNDPARENT
  1714. Call GetWindowRect
  1715.  
  1716. IntOp $0 $RESIZE_X / 2
  1717. IntOp $1 $RECT_X - $0
  1718.  
  1719. IntOp $0 $RESIZE_Y / 2
  1720. IntOp $2 $RECT_Y - $0
  1721.  
  1722. IntOp $3 $RECT_W + $RESIZE_X
  1723. IntOp $4 $RECT_H + $RESIZE_Y
  1724.  
  1725. System::Call "User32::SetWindowPos(i, i, i, i, i, i, i) b ($HWNDPARENT, 0, $1, $2, $3, $4, ${SWP_NOOWNERZORDER})"
  1726.  
  1727. ;Restore register values from the stack
  1728. Pop $4
  1729. Pop $3
  1730. Pop $2
  1731. Pop $1
  1732. Pop $0
  1733.  
  1734. FunctionEnd
  1735.  
  1736.  
  1737. Var COMPONENTS_EXPAND_STATUS
  1738.  
  1739. Function "WelcomePreProc"
  1740. ${LogText} "+Function begin - WelcomePreProc"
  1741. !insertmacro UAC_IsInnerInstance
  1742. ${If} ${UAC_IsInnerInstance}
  1743. ; If switched to admin, don't show welcome window again
  1744. ${LogText} "-Function end - WelcomePreProc (IsInnerInstance)"
  1745. Abort
  1746. ${EndIf}
  1747. ${LogText} "-Function end - WelcomePreProc"
  1748. FunctionEnd
  1749.  
  1750. Function "WelcomeShowProc"
  1751. ${LogText} "+Function begin - WelcomeShowProc"
  1752. BringToFront
  1753. ${LogText} "-Function end - WelcomeShowProc"
  1754. FunctionEnd
  1755.  
  1756. Function "WelcomeLeaveProc"
  1757. ${LogText} "+Function begin - WelcomeLeaveProc"
  1758. HideWindow
  1759. ; Maybe switch to admin after welcome window
  1760. Call DoRightsElevation
  1761. ShowWindow $HWNDPARENT ${SW_SHOW}
  1762. ${LogText} "-Function end - WelcomeLeaveProc"
  1763. FunctionEnd
  1764.  
  1765.  
  1766. Function "LicenseShowProc"
  1767. ${LogText} "+Function begin - LicenseShowProc"
  1768. Call UnexpandComponentsPage
  1769. Call HideBackButton
  1770. BringToFront
  1771. ${LogText} "-Function end - LicenseShowProc"
  1772. FunctionEnd
  1773.  
  1774. Function "LicenseLeaveProc"
  1775. ${LogText} "+Function begin - LicenseLeaveProc"
  1776. ${LogText} "-Function end - LicenseLeaveProc"
  1777. FunctionEnd
  1778.  
  1779.  
  1780. Function "ComponentsShowProc"
  1781. ${LogText} "+Function begin - ComponentsShowProc"
  1782. Call ExpandComponentsPage
  1783. ${LogText} "-Function end - ComponentsShowProc"
  1784. FunctionEnd
  1785.  
  1786. Function "ComponentsLeaveProc"
  1787. ${LogText} "+Function begin - ComponentsLeaveProc"
  1788. ${LogText} "-Function end - ComponentsLeaveProc"
  1789. FunctionEnd
  1790.  
  1791.  
  1792. Function "ExpandComponentsPage"
  1793. ${LogText} "+Function begin - ExpandComponentsPage"
  1794. ${If} $COMPONENTS_EXPAND_STATUS != 1
  1795. ${LogText} "Doing expand"
  1796. StrCpy $COMPONENTS_EXPAND_STATUS 1
  1797. IntOp $RESIZE_X 0 + ${EXPAND_DIALOG_X}
  1798. IntOp $RESIZE_Y 0 + ${EXPAND_DIALOG_Y}
  1799. Call ResizeComponentsDialogContents
  1800. Call ResizeSharedDialogContents
  1801. Call ResizeMainWindow
  1802. ${Endif}
  1803. ${LogText} "-Function end - ExpandComponentsPage"
  1804. FunctionEnd
  1805.  
  1806. Function "UnexpandComponentsPage"
  1807. ${LogText} "+Function begin - UnexpandComponentsPage"
  1808. ${If} $COMPONENTS_EXPAND_STATUS == 1
  1809. ${LogText} "Doing unexpand"
  1810. StrCpy $COMPONENTS_EXPAND_STATUS 0
  1811. IntOp $RESIZE_X 0 - ${EXPAND_DIALOG_X}
  1812. IntOp $RESIZE_Y 0 - ${EXPAND_DIALOG_Y}
  1813. Call ResizeSharedDialogContents
  1814. Call ResizeMainWindow
  1815. ${Endif}
  1816. ${LogText} "-Function end - UnexpandComponentsPage"
  1817. FunctionEnd
  1818.  
  1819.  
  1820. ;****************************************************************
  1821. ;
  1822. ; Remove virtual store version of path
  1823. ;
  1824. ;****************************************************************
  1825. ; In $0 = install path
  1826. Function RemoveVirtualStore
  1827. StrCpy $2 $0 "" 3 # Skip first 3 chars
  1828. StrCpy $3 "$LOCALAPPDATA\VirtualStore\$2"
  1829. StrCpy $4 "$0\FromVirtualStore"
  1830. IfFileExists $3 0 NoVirtualStore
  1831. ${LogText} "Moving VirtualStore files from $3 to $4"
  1832. CopyFiles $3\*.* $4
  1833. RmDir /r "$3"
  1834. Goto done
  1835. NoVirtualStore:
  1836. ${LogText} "NoVirtualStore detected at $3"
  1837. done:
  1838. FunctionEnd
  1839.  
  1840.  
  1841. ;****************************************************************
  1842. ;
  1843. ; Returns 1 if file exists and is 32 bit.
  1844. ;
  1845. ;****************************************************************
  1846. Function IsDll32Bit
  1847. Pop $3
  1848. StrCpy $2 ""
  1849. ClearErrors
  1850. FileOpen $0 $3 r
  1851. IfErrors done
  1852. FileSeek $0 60 ; IMAGE_DOS_HEADER->e_lfanew
  1853. FileReadWord $0 $1
  1854. FileSeek $0 $1 ; IMAGE_NT_HEADERS
  1855. FileSeek $0 4 CUR ; IMAGE_FILE_HEADER->Machine
  1856. FileReadWord $0 $2 ; $2 = Machine
  1857. FileClose $0
  1858. done:
  1859. StrCpy $1 "0"
  1860. ${If} $2 == 332 ; 0x014c IMAGE_FILE_MACHINE_I386
  1861. StrCpy $1 "1"
  1862. ${EndIf}
  1863. ${LogText} "IsDll32Bit($3) result:$1"
  1864. Push $1
  1865. FunctionEnd
  1866.  
  1867.  
  1868. ;****************************************************************
  1869. ;
  1870. ; Determine if install/upgrade this version/previous version
  1871. ;
  1872. ;****************************************************************
  1873.  
  1874. ; In <stack> = install path
  1875. ; Out <stack> = "new" - New install
  1876. ; "upgrade" - In place copy with same Major.Minor
  1877. ; "overwrite" - In place copy different Major.Minor
  1878. ; <stack> = "Maj.Min"
  1879. Function GetInstallType
  1880. ${LogText} "+Function begin - GetInstallType"
  1881. Pop $0
  1882. Push $0
  1883. Call GetVersionAtLocation
  1884. StrCpy $1 $0 3 # First 3 chars
  1885.  
  1886. ${If} $1 == "0.0"
  1887. StrCpy $2 "new"
  1888. ${ElseIf} $1 == ${0.0}
  1889. StrCpy $2 "upgrade"
  1890. ${Else}
  1891. StrCpy $2 "overwrite"
  1892. ${EndIf}
  1893. Pop $0
  1894. ${LogText} "GetInstallType($0) result:$1,$2"
  1895. Push $1
  1896. Push $2
  1897. ${LogText} "-Function end - GetInstallType"
  1898. FunctionEnd
  1899.  
  1900.  
  1901. ; In $0 = install path
  1902. ; Out $0 = "1.1.0.3306"
  1903. ; "0.0.0.0" if no file
  1904. Function GetVersionAtLocation
  1905. ; Check installed version at this location
  1906. StrCpy $5 "$0\MTA\core.dll"
  1907.  
  1908. ClearErrors
  1909. GetDLLVersion $5 $R0 $R1
  1910. IfErrors 0 cont
  1911. IntOp $R0 0 + 0x00000000
  1912. IntOp $R1 0 + 0x00000000
  1913. IfFileExists $5 cont
  1914. IntOp $R0 0 + 0x00000000
  1915. IntOp $R1 0 + 0x00000000
  1916. cont:
  1917. IntOp $R2 $R0 >> 16
  1918. IntOp $R2 $R2 & 0x0000FFFF ; $R2 now contains major version
  1919. IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
  1920. IntOp $R4 $R1 >> 16
  1921. IntOp $R4 $R4 & 0x0000FFFF ; $R4 now contains release
  1922. IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
  1923. StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"
  1924. FunctionEnd
  1925.  
  1926.  
  1927. LangString INST_MTA_CONFLICT ${LANG_ENGLISH} "A different major version of MTA ($1) already exists at that path.$\n$\n\
  1928. MTA is designed for major versions to be installed in different paths.$\n \
  1929. Are you sure you want to overwrite MTA $1 at \
  1930. $INSTDIR ?"
  1931. LangString INST_GTA_CONFLICT ${LANG_ENGLISH} "MTA cannot be installed into the same directory as GTA:SA.$\n$\n\
  1932. Do you want to use the default install directory$\n\
  1933. $DEFAULT_INSTDIR ?"
  1934. LangString INST_GTA_ERROR1 ${LANG_ENGLISH} "The selected directory does not exist.$\n$\n\
  1935. Please select the GTA:SA install directory"
  1936. LangString INST_GTA_ERROR2 ${LANG_ENGLISH} "Could not find GTA:SA installed at $GTA_DIR $\n$\n\
  1937. Are you sure you want to continue ?"
  1938.  
  1939. Function "CustomDirectoryPageLeave"
  1940. ${LogText} "+Function begin - CustomDirectoryPageLeave"
  1941. Call CustomDirectoryPageUpdateINSTDIR
  1942.  
  1943. # Check if user is trying to install MTA into GTA directory
  1944. Push $INSTDIR
  1945. Call IsGtaDirectory
  1946. Pop $0
  1947. ${If} $0 == "gta"
  1948.  
  1949. # Don't allow install into GTA directory unless MTA is already there
  1950. Push $INSTDIR
  1951. Call GetInstallType
  1952. Pop $0
  1953. Pop $1
  1954. ${If} $0 != "upgrade"
  1955. MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_TOPMOST|MB_SETFOREGROUND \
  1956. "$(INST_GTA_CONFLICT)" \
  1957. IDOK cont2
  1958. ${LogText} "-Function end - CustomDirectoryPageLeave (GTA_CONFLICT)"
  1959. Abort
  1960. cont2:
  1961. StrCpy $INSTDIR $DEFAULT_INSTDIR
  1962. ${Endif}
  1963. ${Endif}
  1964.  
  1965. # Check if user is trying to install over a different major version of MTA
  1966. Push $INSTDIR
  1967. Call GetInstallType
  1968. Pop $0
  1969. Pop $1
  1970. ${If} $0 == "overwrite"
  1971. MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_TOPMOST|MB_SETFOREGROUND \
  1972. "$(INST_MTA_CONFLICT)" \
  1973. IDOK cont
  1974. ${LogText} "-Function end - CustomDirectoryPageLeave (MTA_CONFLICT)"
  1975. Abort
  1976. cont:
  1977. ${Endif}
  1978. ${LogText} "-Function end - CustomDirectoryPageLeave"
  1979. FunctionEnd
  1980.  
  1981.  
  1982. Function "GTADirectoryLeaveProc"
  1983. ${LogText} "+Function begin - GTADirectoryLeaveProc"
  1984.  
  1985. ; Directory must exist
  1986. IfFileExists "$GTA_DIR\*.*" hasdir
  1987. MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND \
  1988. "$(INST_GTA_ERROR1)"
  1989. ${LogText} "-Function end - GTADirectoryLeaveProc (GTA_ERROR1)"
  1990. Abort
  1991. hasdir:
  1992.  
  1993. ; data subdirectory should exist
  1994. IfFileExists "$GTA_DIR\data\*.*" cont
  1995. MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_TOPMOST|MB_SETFOREGROUND \
  1996. "$(INST_GTA_ERROR2)" \
  1997. IDOK cont1
  1998. ${LogText} "-Function end - GTADirectoryLeaveProc (GTA_ERROR2)"
  1999. Abort
  2000. cont1:
  2001. cont:
  2002. ${LogText} "-Function end - GTADirectoryLeaveProc"
  2003. FunctionEnd
  2004.  
  2005. ;****************************************************************
  2006. ;
  2007. ; Determine if gta is installed at supplied directory path
  2008. ;
  2009. ;****************************************************************
  2010.  
  2011. ; In <stack> = directory path
  2012. ; Out <stack> = "" - gta not detected at path
  2013. ; "gta" - gta detected at path
  2014. Function IsGtaDirectory
  2015. Pop $0
  2016. StrCpy $1 "gta"
  2017.  
  2018. ; gta_sa.exe or gta-sa.exe should exist
  2019. IfFileExists "$0\gta_sa.exe" cont1
  2020. IfFileExists "$0\gta-sa.exe" cont1
  2021. StrCpy $1 ""
  2022. cont1:
  2023.  
  2024. ; data subdirectory should exist
  2025. IfFileExists "$0\data\*.*" cont2
  2026. StrCpy $1 ""
  2027. cont2:
  2028.  
  2029. Push $1
  2030. FunctionEnd
  2031.  
  2032. ;****************************************************************
  2033. ;
  2034. ; Custom MTA directory page
  2035. ;
  2036. ; To make sure the directory exists when 'Browse...' is clicked
  2037. ;
  2038. ;****************************************************************
  2039. Var Dialog
  2040. Var UpgradeLabel
  2041. Var BrowseButton
  2042. Var SetDefaultButton
  2043. Var DirRequest
  2044. Var RadioDefault
  2045. Var LabelDefault
  2046. Var RadioLastUsed
  2047. Var LabelLastUsed
  2048. Var RadioCustom
  2049. Var Length
  2050. Var SizeX
  2051. Var SizeY
  2052. Var PosX
  2053. Var PosY
  2054. !define LT_GREY "0xf0f0f0"
  2055. !define MID_GREY "0xb0b0b0"
  2056. !define BLACK "0x000000"
  2057. !define MID_GREY2K "0x808080"
  2058. !define LT_GREY2K "0xD1CEC9"
  2059.  
  2060. LangString INST_CHOOSE_LOC_TOP ${LANG_ENGLISH} "Choose Install Location"
  2061. LangString INST_CHOOSE_LOC ${LANG_ENGLISH} "Choose the folder in which to install ${PRODUCT_NAME_NO_VER} ${PRODUCT_VERSION}"
  2062. LangString INST_CHOOSE_LOC2 ${LANG_ENGLISH} "${PRODUCT_NAME_NO_VER} ${PRODUCT_VERSION} will be installed in the following folder.$\n\
  2063. To install in a different folder, click Browse and select another folder.$\n$\n Click Next to continue."
  2064. LangString INST_CHOOSE_LOC3 ${LANG_ENGLISH} "Destination Folder"
  2065. LangString INST_CHOOSE_LOC_BROWSE ${LANG_ENGLISH} "Browse..."
  2066. LangString INST_CHOOSE_LOC_DEFAULT ${LANG_ENGLISH} "Default"
  2067. LangString INST_CHOOSE_LOC_LAST_USED ${LANG_ENGLISH} "Last used"
  2068. LangString INST_CHOOSE_LOC_CUSTOM ${LANG_ENGLISH} "Custom"
  2069. Function CustomDirectoryPage
  2070. ${LogText} "+Function begin - CustomDirectoryPage"
  2071.  
  2072. nsDialogs::Create 1018
  2073. Pop $Dialog
  2074. ${If} $Dialog == error
  2075. ${LogText} "-Function end - CustomDirectoryPage (error)"
  2076. Abort
  2077. ${EndIf}
  2078. ${LogText} "nsDialogs::Create success"
  2079.  
  2080. GetDlgItem $0 $HWNDPARENT 1037
  2081. ${NSD_SetText} $0 "$(INST_CHOOSE_LOC)"
  2082. GetDlgItem $0 $HWNDPARENT 1038
  2083. ${NSD_SetText} $0 "$(INST_CHOOSE_LOC)"
  2084.  
  2085. ${NSD_CreateLabel} 0 0 100% 50u "$(INST_CHOOSE_LOC2)"
  2086. Pop $0
  2087. ${LogText} "Did CreateLabel"
  2088.  
  2089. # Calculate size and position of install dir options
  2090. IntOp $SizeY 27 + 90 # 27 + 30 + 30 + 30
  2091. ${If} $ShowLastUsed == "0"
  2092. IntOp $SizeY $SizeY - 30
  2093. ${EndIf}
  2094. IntOp $PosY 187 - $SizeY
  2095.  
  2096. # Add group box
  2097. ${NSD_CreateGroupBox} 0 $PosY 100% $SizeY "$(INST_CHOOSE_LOC3)"
  2098. Pop $0
  2099. IntOp $PosY $PosY + 24
  2100.  
  2101. # Pick the longest string and use that as SizeX
  2102. !insertmacro GetTextExtent "$(INST_CHOOSE_LOC_DEFAULT)" $SizeX
  2103. !insertmacro GetTextExtent "$(INST_CHOOSE_LOC_LAST_USED)" $Length
  2104. !insertmacro Max $SizeX $Length
  2105. !insertmacro GetTextExtent "$(INST_CHOOSE_LOC_CUSTOM)" $Length
  2106. !insertmacro Max $SizeX $Length
  2107.  
  2108. IntOp $SizeX $SizeX + 6 # Take into account the radio button itself
  2109. IntOp $PosX $SizeX + 20 # Take into account the x padding of 10, plus spacing of 15
  2110. IntOp $Length ${DIALOG_X} - $PosX # [Total width] - [radio button width]
  2111. IntOp $Length $Length - 10 # [Total width] - [radio button width] - [padding]
  2112. # Add default option
  2113. ${NSD_CreateRadioButton} 10 $PosY $SizeX 12u "$(INST_CHOOSE_LOC_DEFAULT)"
  2114. Pop $RadioDefault
  2115. ${NSD_CreateText} $PosX $PosY $Length 12u $DEFAULT_INSTDIR
  2116. Pop $LabelDefault
  2117. SendMessage $LabelDefault ${EM_SETREADONLY} 1 0
  2118. ${LogText} "Did SendMessage"
  2119. IntOp $PosY $PosY + 30
  2120.  
  2121. # Add last used option
  2122. ${If} $ShowLastUsed != "0"
  2123. ${NSD_CreateRadioButton} 10 $PosY $SizeX 12u "$(INST_CHOOSE_LOC_LAST_USED)"
  2124. Pop $RadioLastUsed
  2125. ${NSD_CreateText} $PosX $PosY $Length 12u $LAST_INSTDIR
  2126. Pop $LabelLastUsed
  2127. SendMessage $LabelLastUsed ${EM_SETREADONLY} 1 0
  2128. IntOp $PosY $PosY + 30
  2129. ${EndIf}
  2130.  
  2131. # Add custom option
  2132. ${NSD_CreateRadioButton} 10 $PosY $SizeX 12u "$(INST_CHOOSE_LOC_CUSTOM)"
  2133. Pop $RadioCustom
  2134.  
  2135. !insertmacro GetTextExtent "$(INST_CHOOSE_LOC_BROWSE)" $R9
  2136. IntOp $R9 $R9 + 5 # Add spacing for the button on top of text
  2137. IntOp $Length $Length - $R9
  2138. ${NSD_CreateDirRequest} $PosX $PosY $Length 12u $CUSTOM_INSTDIR
  2139. Pop $DirRequest
  2140. IntOp $PosY $PosY - 1
  2141. IntOp $PosX ${DIALOG_X} - $R9
  2142. IntOp $PosX $PosX - 10
  2143. ${NSD_CreateBrowseButton} $PosX $PosY $R9 13u "$(INST_CHOOSE_LOC_BROWSE)"
  2144. Pop $BrowseButton
  2145. IntOp $PosY $PosY + 31
  2146.  
  2147. ${NSD_OnClick} $RadioDefault CustomDirectoryPageRadioClick
  2148. ${NSD_OnClick} $RadioLastUsed CustomDirectoryPageRadioClick
  2149. ${NSD_OnClick} $RadioCustom CustomDirectoryPageRadioClick
  2150. ${NSD_OnClick} $BrowseButton CustomDirectoryPageBrowseButtonClick
  2151. ${NSD_OnClick} $SetDefaultButton CustomDirectoryPageSetDefaultButtonClick
  2152. ${NSD_OnChange} $DirRequest CustomDirectoryPageDirRequestChange
  2153. ${LogText} "Did Ons"
  2154.  
  2155. # Install type message
  2156. ${NSD_CreateLabel} 0 203 100% 12u ""
  2157. Pop $UpgradeLabel
  2158. Call CustomDirectoryPageSetUpgradeMessage
  2159.  
  2160. Call CustomDirectoryPageShowWhichRadio
  2161.  
  2162. Call UnexpandComponentsPage
  2163. nsDialogs::Show
  2164. ${LogText} "-Function end - CustomDirectoryPage"
  2165. FunctionEnd
  2166.  
  2167. # Called when radion button is clicked
  2168. Function CustomDirectoryPageRadioClick
  2169. Pop $0
  2170. ${Switch} $0
  2171. ${Case} $RadioDefault
  2172. StrCpy $WhichRadio "default"
  2173. ${Break}
  2174. ${Case} $RadioLastUsed
  2175. StrCpy $WhichRadio "last"
  2176. ${Break}
  2177. ${Case} $RadioCustom
  2178. StrCpy $WhichRadio "custom"
  2179. ${Break}
  2180. ${EndSwitch}
  2181. Call CustomDirectoryPageShowWhichRadio
  2182. FunctionEnd
  2183.  
  2184. # Ensure GUI reflects $WhichRadio
  2185. Function CustomDirectoryPageShowWhichRadio
  2186. # Set all options as not selected
  2187. Call IsWindowsClassicTheme
  2188. Pop $0
  2189. ${If} $0 == 1
  2190. SetCtlColors $LabelDefault ${MID_GREY2K} ${LT_GREY2K}
  2191. SetCtlColors $LabelLastUsed ${MID_GREY2K} ${LT_GREY2K}
  2192. SetCtlColors $DirRequest ${MID_GREY2K} ${LT_GREY2K}
  2193. ${Else}
  2194. SetCtlColors $LabelDefault ${MID_GREY} ${LT_GREY}
  2195. SetCtlColors $LabelLastUsed ${MID_GREY} ${LT_GREY}
  2196. SetCtlColors $DirRequest ${MID_GREY} ${LT_GREY}
  2197. ${EndIf}
  2198.  
  2199. SendMessage $DirRequest ${EM_SETREADONLY} 1 0
  2200. EnableWindow $BrowseButton 0
  2201.  
  2202. # Highlight selected option
  2203. ${Switch} $WhichRadio
  2204. ${Case} "default"
  2205. StrCpy $INSTDIR $DEFAULT_INSTDIR
  2206. ${NSD_SetState} $RadioDefault ${BST_CHECKED}
  2207. SetCtlColors $LabelDefault ${BLACK}
  2208. ${Break}
  2209. ${Case} "last"
  2210. StrCpy $INSTDIR $LAST_INSTDIR
  2211. ${NSD_SetState} $RadioLastUsed ${BST_CHECKED}
  2212. SetCtlColors $LabelLastUsed ${BLACK}
  2213. ${Break}
  2214. ${Case} "custom"
  2215. StrCpy $INSTDIR $CUSTOM_INSTDIR
  2216. ${NSD_SetState} $RadioCustom ${BST_CHECKED}
  2217. SetCtlColors $DirRequest ${BLACK}
  2218. SendMessage $DirRequest ${EM_SETREADONLY} 0 0
  2219. EnableWindow $BrowseButton 1
  2220. ${Break}
  2221. ${EndSwitch}
  2222.  
  2223. # Redraw controls
  2224. ${NSD_GetText} $LabelDefault $0
  2225. ${NSD_SetText} $LabelDefault $0
  2226. ${NSD_GetText} $LabelLastUsed $0
  2227. ${NSD_SetText} $LabelLastUsed $0
  2228. ${NSD_GetText} $DirRequest $0
  2229. ${NSD_SetText} $DirRequest $0
  2230. FunctionEnd
  2231.  
  2232. Function CustomDirectoryPageDirRequestChange
  2233. ${NSD_GetText} $DirRequest $0
  2234. ${If} $0 != error
  2235. StrCpy $CUSTOM_INSTDIR $0
  2236. Call CustomDirectoryPageSetUpgradeMessage
  2237. ${EndIf}
  2238. FunctionEnd
  2239.  
  2240. Function CustomDirectoryPageSetDefaultButtonClick
  2241. StrCpy $INSTDIR "$PROGRAMFILES\MTA San Andreas ${0.0}"
  2242. ${NSD_SetText} $DirRequest $INSTDIR
  2243. Call CustomDirectoryPageSetUpgradeMessage
  2244. FunctionEnd
  2245.  
  2246. LangString INST_CHOOSE_LOC4 ${LANG_ENGLISH} "Select the folder to install ${PRODUCT_NAME_NO_VER} ${PRODUCT_VERSION} in:"
  2247.  
  2248. Function CustomDirectoryPageBrowseButtonClick
  2249. ${NSD_GetText} $DirRequest $0
  2250.  
  2251. Call CreateDirectoryAndRememberWhichOnesWeDid
  2252. nsDialogs::SelectFolderDialog "$(INST_CHOOSE_LOC4)" $0
  2253. Pop $0
  2254.  
  2255. Call RemoveDirectoriesWhichWeDid
  2256.  
  2257. ${If} $0 != error
  2258. StrCpy $CUSTOM_INSTDIR $0
  2259. ${NSD_SetText} $DirRequest $0
  2260. Call CustomDirectoryPageSetUpgradeMessage
  2261. ${EndIf}
  2262. FunctionEnd
  2263.  
  2264. LangString INST_LOC_OW ${LANG_ENGLISH} "Warning: A different major version of MTA ($1) already exists at that path."
  2265. LangString INST_LOC_UPGRADE ${LANG_ENGLISH} "Installation type: Upgrade"
  2266. Function CustomDirectoryPageSetUpgradeMessage
  2267. Call CustomDirectoryPageUpdateINSTDIR
  2268. Push $INSTDIR
  2269. Call GetInstallType
  2270. Pop $0
  2271. Pop $1
  2272.  
  2273. ${NSD_SetText} $UpgradeLabel ""
  2274. ${If} $0 == "overwrite"
  2275. ${NSD_SetText} $UpgradeLabel "$(INST_LOC_OW)"
  2276. ${Endif}
  2277. ${If} $0 == "upgrade"
  2278. ${NSD_SetText} $UpgradeLabel "$(INST_LOC_UPGRADE)"
  2279. ${Endif}
  2280. FunctionEnd
  2281.  
  2282. # Make absolutely sure $INSTDIR is correct
  2283. Function CustomDirectoryPageUpdateINSTDIR
  2284. ${Switch} $WhichRadio
  2285. ${Case} "default"
  2286. StrCpy $INSTDIR $DEFAULT_INSTDIR
  2287. ${Break}
  2288. ${Case} "last"
  2289. StrCpy $INSTDIR $LAST_INSTDIR
  2290. ${Break}
  2291. ${Case} "custom"
  2292. StrCpy $INSTDIR $CUSTOM_INSTDIR
  2293. ${Break}
  2294. ${EndSwitch}
  2295. FunctionEnd
  2296.  
  2297. Function IsWindowsClassicTheme
  2298. ; Out <stack> = "1" - Is Windows Classic
  2299. System::Call "UxTheme::IsThemeActive() i .r3"
  2300. StrCpy $1 "1"
  2301. ${If} $3 == 1
  2302. StrCpy $1 "0"
  2303. ${EndIf}
  2304. Push $1
  2305. FunctionEnd
  2306.  
  2307. ;****************************************************************
  2308. ;
  2309. ; Keep track of temp directories created
  2310. ;
  2311. ;****************************************************************
  2312. Var SAVED_PATH_TO
  2313. Var SAVED_CREATE_DEPTH
  2314.  
  2315. ; In $0 = path
  2316. Function CreateDirectoryAndRememberWhichOnesWeDid
  2317. Push $0
  2318. Push $1
  2319. Push $2
  2320. Push $8
  2321. StrCpy $8 $0
  2322.  
  2323. StrCpy $0 $8
  2324. Call HowManyDepthsNotExist
  2325.  
  2326. StrCpy $SAVED_PATH_TO $8
  2327. StrCpy $SAVED_CREATE_DEPTH $2
  2328.  
  2329. #MessageBox mb_TopMost "CreateDirectoryAndRememberWhichOnesWeDid $\n\
  2330. # path-to=$SAVED_PATH_TO $\n\
  2331. # create-depth=$SAVED_CREATE_DEPTH $\n\
  2332. # "
  2333.  
  2334. CreateDirectory $SAVED_PATH_TO
  2335.  
  2336. Pop $8
  2337. Pop $2
  2338. Pop $1
  2339. Pop $0
  2340. FunctionEnd
  2341.  
  2342. ; In $0 = path
  2343. ; Out $2 = result
  2344. Function HowManyDepthsNotExist
  2345. Push $0
  2346. Push $1
  2347. Push $8
  2348. Push $9
  2349. StrCpy $8 $0
  2350. StrCpy $9 0
  2351. ${Do}
  2352. StrCpy $0 $8
  2353. StrCpy $1 $9
  2354. Call RemoveEndsFromPath
  2355.  
  2356. StrCpy $0 $2
  2357. Call DoesDirExist
  2358.  
  2359. #MessageBox mb_TopMost "HowManyDepthsNotExist $\n\
  2360. # 8-path=$8 $\n\
  2361. # 9-count=$9 $\n\
  2362. # 2-path-shrunk=$2 $\n\
  2363. # 1-dir-exist=$1 $\n\
  2364. # "
  2365.  
  2366. IntOp $9 $9 + 1
  2367. ${LoopUntil} $1 = 1
  2368.  
  2369. IntOp $2 $9 - 1
  2370. Pop $9
  2371. Pop $8
  2372. Pop $1
  2373. Pop $0
  2374. FunctionEnd
  2375.  
  2376. Function RemoveDirectoriesWhichWeDid
  2377. Push $0
  2378. Push $1
  2379. Push $2
  2380. Push $3
  2381.  
  2382. ${If} $SAVED_PATH_TO != ""
  2383.  
  2384. #MessageBox mb_TopMost "RemoveDirectoriesWhichWeDid $\n\
  2385. # path=$SAVED_PATH_TO $\n\
  2386. # depth=$SAVED_CREATE_DEPTH $\n\
  2387. # "
  2388.  
  2389. IntOp $3 $SAVED_CREATE_DEPTH - 1
  2390. ${ForEach} $2 0 $3 + 1
  2391. StrCpy $0 $SAVED_PATH_TO
  2392. StrCpy $1 $2
  2393. Call RemoveDirectoryAtNegDepth
  2394.  
  2395. ${Next}
  2396.  
  2397. ${EndIf}
  2398.  
  2399. StrCpy $SAVED_PATH_TO ""
  2400. StrCpy $SAVED_CREATE_DEPTH ""
  2401.  
  2402. Pop $3
  2403. Pop $2
  2404. Pop $1
  2405. Pop $0
  2406. FunctionEnd
  2407.  
  2408. ; In $0 = path
  2409. ; In $1 = how many end bits to remove
  2410. Function RemoveDirectoryAtNegDepth
  2411. Push $2
  2412. Call RemoveEndsFromPath
  2413.  
  2414. #MessageBox mb_TopMost "RemoveDirectoryAtNegDepth $\n\
  2415. # 2-result=$2 $\n\
  2416. # "
  2417.  
  2418. RmDir $2
  2419. Pop $2
  2420. FunctionEnd
  2421.  
  2422. ; In $0 = path
  2423. ; In $1 = how many end bits to remove
  2424. ; Out $2 = result
  2425. Function RemoveEndsFromPath
  2426. nsArray::Clear my_array
  2427. nsArray::Split my_array $0 \ /noempty
  2428.  
  2429. ${ForEach} $2 1 $1 + 1
  2430. nsArray::Remove my_array /at=-1
  2431. ${Next}
  2432.  
  2433. nsArray::Join my_array \ /noempty
  2434. Pop $2
  2435. FunctionEnd
  2436.  
  2437. ; In $0 = path
  2438. ; Out $0 = result
  2439. Function ConformDirectoryPath
  2440. nsArray::Clear my_array
  2441. nsArray::Split my_array $0 \ /noempty
  2442. nsArray::Join my_array \ /noempty
  2443. Pop $0
  2444. FunctionEnd
  2445.  
  2446. ; In $0 = path
  2447. ; Out $1 = result 0/1
  2448. Function DoesDirExist
  2449. StrCpy $1 1
  2450. IfFileExists "$0\*.*" alreadyexists
  2451. StrCpy $1 0
  2452. alreadyexists:
  2453. FunctionEnd
  2454.  
  2455.  
  2456. ;****************************************************************
  2457. ;
  2458. ; Service maintenance
  2459. ;
  2460. ;****************************************************************
  2461. Var ServiceModified
  2462.  
  2463. Function DoServiceInstall
  2464. ${If} $ServiceModified != 1
  2465. ; Check loader can do command
  2466. GetDLLVersion "$INSTDIR\mta\loader.dll" $R0 $R1
  2467. IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
  2468. ${If} $R5 > 4909
  2469. Exec '"$INSTDIR\Multi Theft Auto.exe" /nolaunch /kdinstall'
  2470. StrCpy $ServiceModified 1
  2471. ${EndIf}
  2472. ${EndIf}
  2473. FunctionEnd
  2474.  
  2475. Function un.DoServiceUninstall
  2476. ${If} $ServiceModified != 2
  2477. ; Check loader can do command
  2478. GetDLLVersion "$INSTDIR\mta\loader.dll" $R0 $R1
  2479. IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
  2480. ${If} $R5 > 4909
  2481. Exec '"$INSTDIR\Multi Theft Auto.exe" /nolaunch /kduninstall'
  2482. StrCpy $ServiceModified 2
  2483. ${EndIf}
  2484. ${EndIf}
  2485. FunctionEnd
  2486.  
  2487.  
  2488. ;****************************************************************
  2489. ;
  2490. ; CustomNetMessagePage
  2491. ;
  2492. ; Show message to get user to unblock installer from firewall or similar
  2493. ;
  2494. ;****************************************************************
  2495. Var NetDialog
  2496. Var NetStatusLabel1
  2497. Var NetStatusLabel2
  2498. Var NetTryCount
  2499. Var NetDone
  2500. Var NetImage
  2501. Var NetImageHandle
  2502. Var NetMsgURL
  2503. Var NetPrevInfo
  2504. Var NetEnableNext
  2505. Var NetOtherSuccessCount
  2506. Var NetMirror
  2507. !define NEXT_BUTTON_ID 1
  2508. LangString NETTEST_TITLE1 ${LANG_ENGLISH} "Online update"
  2509. LangString NETTEST_TITLE2 ${LANG_ENGLISH} "Checking for update information"
  2510. LangString NETTEST_STATUS1 ${LANG_ENGLISH} "Checking for installer update information..."
  2511. LangString NETTEST_STATUS2 ${LANG_ENGLISH} "Please ensure your firewall is not blocking"
  2512.  
  2513. Function CustomNetMessagePage
  2514. ${LogText} "+Function begin - CustomNetMessagePage"
  2515. # Initial try with blank page
  2516. Call TryToSendInfo
  2517. ${If} $NetDone == 1
  2518. # If it works, then skip this page
  2519. ${LogText} "-Function end - CustomNetMessagePage (NetDone)"
  2520. Return
  2521. ${EndIf}
  2522.  
  2523. # Setup page
  2524. nsDialogs::Create 1018
  2525. Pop $NetDialog
  2526. ${If} $NetDialog == error
  2527. ${LogText} "-Function end - CustomNetMessagePage (error)"
  2528. Abort
  2529. ${EndIf}
  2530.  
  2531. GetDlgItem $0 $HWNDPARENT 1037
  2532. ${NSD_SetText} $0 "$(NETTEST_TITLE1)"
  2533.  
  2534. GetDlgItem $0 $HWNDPARENT 1038
  2535. ${NSD_SetText} $0 "$(NETTEST_TITLE2)"
  2536.  
  2537. ${NSD_CreateLabel} 0 20 100% 15 "$(NETTEST_STATUS1)"
  2538. Pop $NetStatusLabel1
  2539. ${NSD_AddStyle} $NetStatusLabel1 ${SS_CENTER}
  2540.  
  2541. ${NSD_CreateLabel} 0 155 100% 15 "$(NETTEST_STATUS2)"
  2542. Pop $NetStatusLabel2
  2543. ${NSD_AddStyle} $NetStatusLabel2 ${SS_CENTER}
  2544.  
  2545. ${NSD_CreateBitmap} 155 71 100% 100% ""
  2546. Pop $NetImage
  2547. ${NSD_SetImage} $NetImage $TEMP\image.bmp $NetImageHandle
  2548.  
  2549. # Disable Next button maybe
  2550. ${If} $NetEnableNext != 1
  2551. GetDlgItem $0 $HWNDPARENT ${NEXT_BUTTON_ID}
  2552. EnableWindow $0 0
  2553. ${EndIf}
  2554.  
  2555. Call UnexpandComponentsPage
  2556. ${NSD_CreateTimer} NetFuncTimer 1000
  2557. nsDialogs::Show
  2558. ${NSD_FreeImage} $NetImageHandle
  2559. ${LogText} "-Function end - CustomNetMessagePage"
  2560. FunctionEnd
  2561.  
  2562. Function CustomNetMessagePageLeave
  2563. ${LogText} "+Function begin - CustomNetMessagePageLeave"
  2564. ${NSD_KillTimer} NetFuncTimer
  2565. Call TryToSendInfo
  2566. Call UnexpandComponentsPage
  2567. ${LogText} "-Function end - CustomNetMessagePageLeave"
  2568. FunctionEnd
  2569.  
  2570. Function NetFuncTimer
  2571. ${LogText} "+Function begin - NetFuncTimer"
  2572. ${NSD_KillTimer} NetFuncTimer
  2573. IntOp $NetTryCount $NetTryCount + 1
  2574. Call TryToSendInfo
  2575.  
  2576. # Allow Next button after a number of tries
  2577. ${If} $NetTryCount > 3
  2578. StrCpy $NetEnableNext 1
  2579. ${EndIf}
  2580.  
  2581. ${If} $NetEnableNext == 1
  2582. GetDlgItem $0 $HWNDPARENT ${NEXT_BUTTON_ID}
  2583. EnableWindow $0 1
  2584. ${EndIf}
  2585.  
  2586. ${If} $NetDone == 1
  2587. # If it works now, then proceed to the next page
  2588. SendMessage $HWNDPARENT "0x408" "1" "" # GotoNextPage
  2589. ${Else}
  2590. # Otherwise, try again in a second
  2591. ${NSD_CreateTimer} NetFuncTimer 1000
  2592. ${EndIf}
  2593. ${LogText} "-Function end - NetFuncTimer"
  2594. FunctionEnd
  2595.  
  2596. ;--------------------------
  2597. ; Out $NetDone = result (1 = success)
  2598. Function TryToSendInfo
  2599. # Check if already done
  2600. ${If} $NetDone == 1
  2601. Return
  2602. ${EndIf}
  2603.  
  2604. ${LogText} "+Function begin - TryToSendInfo"
  2605.  
  2606. # Do attempt
  2607. Call NetComposeURL
  2608. StrCpy $0 $NetMsgURL
  2609. StrCpy $1 3000
  2610. Call DoSendInfo
  2611.  
  2612. # Set result
  2613. ${If} $0 == 1
  2614. StrCpy $NetDone 1
  2615. ${Else}
  2616. # Check if anything else is contactable
  2617. StrCpy $0 "http://www.google.com/"
  2618. StrCpy $1 1000
  2619. Call DoSendInfo
  2620. ${If} $0 == 1
  2621. StrCpy $NetEnableNext 1
  2622. IntOp $NetOtherSuccessCount $NetOtherSuccessCount + 1
  2623. ${If} $NetOtherSuccessCount > 3
  2624. StrCpy $NetDone 1
  2625. ${EndIf}
  2626. ${EndIf}
  2627. ${EndIf}
  2628. ${LogText} "-Function end - TryToSendInfo"
  2629. FunctionEnd
  2630.  
  2631. ;--------------------------
  2632. ; In $0 = URL
  2633. ; In $1 = Timeout
  2634. ; Out $0 = result (1 = success)
  2635. Function DoSendInfo
  2636. ${LogText} "+Function begin - DoSendInfo($0,$1)"
  2637. NSISdl::download_quiet /TIMEOUT=$1 "$0" "$TEMP\prev_install"
  2638. Pop $R0
  2639. ${LogText} "NSISdl::download_quiet result:$R0"
  2640.  
  2641. # Allow for server errors #1
  2642. StrCpy $0 $R0 14
  2643. ${If} $0 == "Server did not"
  2644. StrCpy $R0 "success"
  2645. ${EndIf}
  2646.  
  2647. # Allow for server errors #2
  2648. StrCpy $0 $R0 4
  2649. ${If} $0 == "HTTP"
  2650. StrCpy $R0 "success"
  2651. ${EndIf}
  2652.  
  2653. # Set result
  2654. StrCpy $0 0
  2655. ${If} $R0 == "success"
  2656. StrCpy $0 1
  2657. ${EndIf}
  2658. ${LogText} "-Function end - DoSendInfo result:$0"
  2659. FunctionEnd
  2660.  
  2661. ;--------------------------
  2662. ; Out $NetMsgURL = URL
  2663. Function NetComposeURL
  2664. ${If} $NetMsgURL == ""
  2665. IfFileExists "$APPDATA\MTA San Andreas All" 0 skip
  2666. StrCpy $NetPrevInfo "$NetPrevInfo&pp=1"
  2667. skip:
  2668. StrCpy $NetPrevInfo "$NetPrevInfo&ver=${0.0.0}"
  2669. !ifndef LIGHTBUILD
  2670. StrCpy $NetPrevInfo "$NetPrevInfo&n=1"
  2671. !endif
  2672. !ifdef REVISION
  2673. StrCpy $NetPrevInfo "$NetPrevInfo&rev=${REVISION}"
  2674. !endif
  2675. ${EndIf}
  2676.  
  2677. IntOp $NetMirror $NetMirror + 1
  2678. IntOp $NetMirror $NetMirror % 2
  2679. ${Switch} $NetMirror
  2680. ${Case} 0
  2681. StrCpy $NetMsgURL "http://updatesa.multitheftauto.com/sa/install/1/?x=0"
  2682. ${Break}
  2683. ${Default}
  2684. StrCpy $NetMsgURL "http://updatesa.mtasa.com/sa/install/1/?x=0"
  2685. ${Break}
  2686. ${EndSwitch}
  2687. StrCpy $NetMsgURL "$NetMsgURL$NetPrevInfo"
  2688. StrCpy $NetMsgURL "$NetMsgURL&try=$NetTryCount"
  2689. StrCpy $NetMsgURL "$NetMsgURL&other=$NetOtherSuccessCount"
  2690. ${LogText} "NetComposeURL result:$NetMsgURL"
  2691. FunctionEnd
  2692.  
  2693. Function NoteMTAWasPresent
  2694. StrCpy $NetPrevInfo "$NetPrevInfo&pm=1"
  2695. FunctionEnd
  2696.  
  2697. Function NoteGTAWasPresent
  2698. StrCpy $NetPrevInfo "$NetPrevInfo&pg=1"
  2699. FunctionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement