Advertisement
Guest User

Installing Alice and GTAIV-downgrade to GTAIV v5

a guest
Jun 10th, 2011
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.21 KB | None | 0 0
  1. ;--------------------------------
  2. !macro BIMAGE IMAGE PARMS
  3.     Push $0
  4.     GetTempFileName $0
  5.     File /oname=$0 "${IMAGE}"
  6.     SetBrandingImage ${PARMS} $0
  7.     Delete $0
  8.     Pop $0
  9. !macroend
  10.  
  11. Name "Alice-installer"
  12. Caption "Installing Alice and GTAIV-downgrade at GTAIV"
  13. UninstallCaption "Remove Alice files and restore GTAIV to version7"
  14. !include "Locate.nsh"
  15.  
  16. OutFile "Alice-installer.exe"
  17. SetFont /LANG=${LANG_ENGLISH} "verdana" 8
  18. InstallDir "$PROGRAMFILES\Rockstar Games\Grand Theft Auto IV"
  19. BrandingText /TRIMCENTER "Alice for ever"
  20. AddBrandingImage left 140
  21.  
  22. Icon "C:\09 Anwendungen\NSIS_neu\NSIS\Contrib\Graphics\Icons\Alice.ico"
  23. UninstallIcon "C:\09 Anwendungen\NSIS_neu\NSIS\Contrib\Graphics\Icons\todo_list_remove.ico"
  24. ShowInstDetails nevershow
  25. ;--------------------------------
  26. ; Pages
  27. Page directory instImage
  28. DirText "This installs Alice and change GTAIV version7 into version5, please select GTAIV folder" "" "" "Select your Grand Theft Auto IV folder to install Alice"
  29. Page instfiles
  30.  
  31. ;--------------------------------
  32. Section "Alice-installer"
  33. IfFileExists $INSTDIR\GTAIV.exe Good
  34.   MessageBox MB_OK "GTAIV.exe was not found"
  35.   Quit
  36.   Good:
  37.   CreateDirectory "$INSTDIR\Alice"
  38.   CreateDirectory "$INSTDIR\Backup"
  39.   SetOutPath $INSTDIR\Alice
  40.   File  CLEAR_WANTED_LEVEL.lua
  41.   SetOutPath $INSTDIR
  42.  
  43.     GetDLLVersion "$INSTDIR\GTAIV.exe" $R0 $R1
  44.     IntOp $R2 $R0 >> 16
  45.     IntOp $R2 $R2 & 0x0000FFFF ; $R2 now contains major version
  46.     IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
  47.     IntOp $R4 $R1 >> 16
  48.     IntOp $R4 $R4 & 0x0000FFFF ; $R4 now contains release
  49.     IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
  50.     StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"
  51.     IntCmp $R4 7 is7 lessthan7 morethan7
  52. is7:
  53.   StrCpy $0 "$R2.$R3.$R4.$R5"
  54.   DetailPrint "version: $0"
  55.   Goto done
  56. lessthan7:
  57.    StrCpy $0 "$R2.$R3.$R4.$R5"
  58.   DetailPrint "version: $0"
  59.   MessageBox MB_OK "your current GTAIV.exe is NOT version 7 but version: $0"
  60.   Goto done
  61. morethan7:
  62.   StrCpy $0 "$R2.$R3.$R4.$R5"
  63.   DetailPrint "version: $0"
  64.   MessageBox MB_OK "your current GTAIV.exe is NOT version 7 but version: $0"
  65.   Goto done
  66. done:
  67.  
  68.  IfFileExists $INSTDIR\Backup\GTAIV-backup.exe report
  69.   Rename GTAIV.exe Backup\GTAIV-backup.exe
  70.   Goto continue
  71.   report:
  72.   MessageBox MB_YESNO "This installation was allready done$\r$\n because GTAIV-backup.exe allready exist.$\r$\n Do you want to install it again?" IDYES true IDNO false
  73. true:
  74.   MessageBox MB_OKCANCEL "At this time i don't make a backup of your current GTAIV.exe" IDOK conf IDCANCEL deni
  75. conf:
  76.   Delete "$INSTDIR\GTAIV.exe"
  77.   Goto continue
  78. deni:
  79. Quit  
  80. false:
  81. Quit
  82.  
  83.   continue:
  84.   IfFileExists $INSTDIR\ScriptHook.dll movehook
  85.   Goto step1
  86.   movehook:
  87.   Rename ScriptHook.dll Backup\ScriptHook.dll
  88.  
  89.   step1:
  90.   IfFileExists $INSTDIR\dsound.dll movedsound
  91.   Goto step2
  92.   movedsound:
  93.   Rename dsound.dll Backup\dsound.dll  
  94.  
  95.   step2:
  96.   IfFileExists $INSTDIR\ScriptHookDotNet.asi DotNet
  97.   Goto modrun
  98.   DotNet:
  99.   Rename ScriptHookDotNet.asi Backup\ScriptHookDotNet.asi
  100.  
  101.   modrun:  
  102.     ${locate::Open} "$INSTDIR" "/F=1 /D=0 /M=*.asi /B=1 /G=0" $R0
  103.     StrCmp $R0 0 0 loop
  104.     Quit
  105.     loop:
  106.     ${locate::Find} $R0 $R1 $R2 $R3 $R4 $R5 $R6
  107.     StrCmp $R1 '' close
  108.     StrCmp $R4 '' 0 +2
  109.     goto +2
  110.     Rename $R1 $R2\Backup\$R3
  111.     goto loop
  112.     close:
  113.     ${locate::Close} $R0
  114.     ${locate::Unload}
  115.  
  116.   File  readme.txt
  117.   ExecShell "open" "$INSTDIR\readme.txt"
  118.   File  xlive.dll
  119.   File  Alice.asi
  120.   File  lua51.dll
  121.   File  GTAIV.exe
  122.  
  123.   WriteUninstaller "uninstall-Alice.exe"
  124.   CreateDirectory "$DOCUMENTS\Rockstar Games\Gta iv\savegames"
  125.  
  126.   BringToFront
  127.  
  128. SectionEnd
  129.  
  130. Function instImage
  131.     !insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\alicez.bmp" /RESIZETOFIT
  132. FunctionEnd
  133.  
  134. ;--------------------------------
  135.  
  136. UninstPage uninstConfirm un.uninstImage
  137. UninstallText "This removes Alice files and change GTAIV version5 into version7" "remove Alice"
  138. UninstPage instfiles
  139.  
  140. ; Uninstaller
  141. Function un.uninstImage
  142.     !insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\alicez.bmp" /RESIZETOFIT
  143. FunctionEnd
  144.  
  145. Function un.isEmptyDir
  146.   # Stack ->                    # Stack: <directory>
  147.  Exch $0                       # Stack: $0
  148.  Push $1                       # Stack: $1, $0
  149.  FindFirst $0 $1 "$0\*.*"
  150.   strcmp $1 "." 0 _notempty
  151.     FindNext $0 $1
  152.     strcmp $1 ".." 0 _notempty
  153.       ClearErrors
  154.       FindNext $0 $1
  155.       IfErrors 0 _notempty
  156.         FindClose $0
  157.         Pop $1                  # Stack: $0
  158.        StrCpy $0 1
  159.         Exch $0                 # Stack: 1 (true)
  160.        goto _end
  161.      _notempty:
  162.        FindClose $0
  163.        ClearErrors
  164.        Pop $1                   # Stack: $0
  165.       StrCpy $0 0
  166.        Exch $0                  # Stack: 0 (false)
  167.  _end:
  168. FunctionEnd
  169.  
  170.  
  171.  
  172. Section "uninstall"
  173. SetDetailsView show
  174. IfFileExists $INSTDIR\Backup\GTAIV-backup.exe next
  175.   MessageBox MB_OK "GTAIV-backup.exe was not found in Backup folder"
  176.   Quit
  177. next:
  178.  
  179.  
  180.     GetDLLVersion "$INSTDIR\Backup\GTAIV-backup.exe" $R0 $R1
  181.     IntOp $R2 $R0 >> 16
  182.     IntOp $R2 $R2 & 0x0000FFFF ; $R2 now contains major version
  183.     IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
  184.     IntOp $R4 $R1 >> 16
  185.     IntOp $R4 $R4 & 0x0000FFFF ; $R4 now contains release
  186.     IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
  187.     StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"
  188.     IntCmp $R4 7 is007 lessthan007 morethan007
  189. is007:
  190.   StrCpy $0 "$R2.$R3.$R4.$R5"
  191.   DetailPrint "GTAIV-backup.exe version: $0"
  192.   ;MessageBox MB_OK "version: $0"
  193.   Goto donend
  194. lessthan007:
  195.    StrCpy $0 "$R2.$R3.$R4.$R5"
  196.   DetailPrint "version: $0"
  197.   MessageBox MB_OKCANCEL "not possible to restore Game to actually version$\r$\n because GTAIV-backup.exe is NOT version 7$\r$\n but version: $0" IDOK donend IDCANCEL abruch1
  198. morethan007:
  199.   StrCpy $0 "$R2.$R3.$R4.$R5"
  200.   DetailPrint "version: $0"
  201.   MessageBox MB_OKCANCEL "not possible to restore Game to actually version because$\r$\n GTAIV-backup.exe is NOT version 7$\r$\n but version: $0" IDOK donend IDCANCEL abruch1
  202.   abruch1:
  203.   Quit
  204.   donend:
  205.  
  206.  
  207.  
  208.  
  209. IfFileExists $INSTDIR\Alice\*.* check
  210.   Goto restore
  211. check:
  212. Push "$INSTDIR\Alice"
  213. Call un.isEmptyDir
  214. Pop $0
  215. StrCmp $0 1 0 +2
  216.   ;MessageBox MB_OK "Directory is empty"
  217. Goto restore
  218.   StrCmp $0 0 0 +2
  219.   ;MessageBox MB_OK "Directory is NOT empty"   
  220. MessageBox MB_YESNO "do you want to backup the Alice scripts?" IDYES true IDNO false
  221. true:
  222.   DetailPrint "Alice scripts are saved at My Documents\Alice"
  223.   CreateDirectory "$DOCUMENTS\Alice"
  224.   CopyFiles $INSTDIR\Alice\*.* $DOCUMENTS\Alice
  225.   MessageBox MB_OK "Alice scripts are saved at My Documents\Alice"
  226.   Goto restore
  227. false:
  228.   DetailPrint "All Alice scripts have been deleted"
  229. restore:
  230.  
  231. IfFileExists $INSTDIR\Backup\ScriptHook.dll move_uhook
  232.   Goto step_u1
  233.   move_uhook:
  234.   CreateDirectory "$DOCUMENTS\AliceUninstfiles"
  235.   Rename $INSTDIR\Backup\ScriptHook.dll $DOCUMENTS\AliceUninstfiles\ScriptHook.dll
  236.  
  237.   step_u1:
  238.   IfFileExists $INSTDIR\Backup\dsound.dll move_udsound
  239.   Goto step_u2
  240.   move_udsound:
  241.   CreateDirectory "$DOCUMENTS\AliceUninstfiles"
  242.   Rename $INSTDIR\Backup\dsound.dll $DOCUMENTS\AliceUninstfiles\dsound.dll  
  243.  
  244.   step_u2:
  245.   IfFileExists $INSTDIR\Backup\ScriptHookDotNet.asi Dot_uNet
  246.   Goto mod_urun
  247.   Dot_uNet:
  248.   CreateDirectory "$DOCUMENTS\AliceUninstfiles"
  249.   Rename $INSTDIR\Backup\ScriptHookDotNet.asi $DOCUMENTS\AliceUninstfiles\ScriptHookDotNet.asi
  250.  
  251.   mod_urun:  
  252.     ${locate::Open} "$INSTDIR\Backup" "/F=1 /D=0 /M=*.asi /B=1 /G=0" $R0
  253.     StrCmp $R0 0 0 loop
  254.     Quit
  255.     loop:
  256.     ${locate::Find} $R0 $R1 $R2 $R3 $R4 $R5 $R6
  257.     StrCmp $R1 '' close
  258.     StrCmp $R4 '' 0 +2
  259.     goto +3
  260.     CreateDirectory "$DOCUMENTS\AliceUninstfiles"
  261.     Rename $R1 $DOCUMENTS\AliceUninstfiles\$R3
  262.     goto loop
  263.     close:
  264.     ${locate::Close} $R0
  265.     ${locate::Unload}
  266.  
  267.  
  268.  
  269.   Delete "$INSTDIR\GTAIV.exe"
  270.   Rename $INSTDIR\Backup\GTAIV-backup.exe $INSTDIR\GTAIV.exe
  271.   Delete "$INSTDIR\xlive.dll"
  272.   Delete "$INSTDIR\Alice.asi"
  273.   Delete "$INSTDIR\lua51.dll"
  274.   Delete "$INSTDIR\Alice.log"
  275.   Delete "$INSTDIR\asilog.txt"
  276.   Delete "$INSTDIR\readme.txt"
  277.   Delete "$INSTDIR\ScriptHook.log"
  278.   Delete "$INSTDIR\ScriptHookDotNet.log"
  279.   RMDir /r "$INSTDIR\Alice"
  280.   RMDir /r "$INSTDIR\Backup"
  281.   Delete "$INSTDIR\uninstall-Alice.exe"
  282. SectionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement