Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;--------------------------------
- !macro BIMAGE IMAGE PARMS
- Push $0
- GetTempFileName $0
- File /oname=$0 "${IMAGE}"
- SetBrandingImage ${PARMS} $0
- Delete $0
- Pop $0
- !macroend
- Name "Alice-installer"
- Caption "Installing Alice and GTAIV-downgrade at GTAIV"
- UninstallCaption "Remove Alice files and restore GTAIV to version7"
- !include "Locate.nsh"
- OutFile "Alice-installer.exe"
- SetFont /LANG=${LANG_ENGLISH} "verdana" 8
- InstallDir "$PROGRAMFILES\Rockstar Games\Grand Theft Auto IV"
- BrandingText /TRIMCENTER "Alice for ever"
- AddBrandingImage left 140
- Icon "C:\09 Anwendungen\NSIS_neu\NSIS\Contrib\Graphics\Icons\Alice.ico"
- UninstallIcon "C:\09 Anwendungen\NSIS_neu\NSIS\Contrib\Graphics\Icons\todo_list_remove.ico"
- ShowInstDetails nevershow
- ;--------------------------------
- ; Pages
- Page directory instImage
- DirText "This installs Alice and change GTAIV version7 into version5, please select GTAIV folder" "" "" "Select your Grand Theft Auto IV folder to install Alice"
- Page instfiles
- ;--------------------------------
- Section "Alice-installer"
- IfFileExists $INSTDIR\GTAIV.exe Good
- MessageBox MB_OK "GTAIV.exe was not found"
- Quit
- Good:
- CreateDirectory "$INSTDIR\Alice"
- CreateDirectory "$INSTDIR\Backup"
- SetOutPath $INSTDIR\Alice
- File CLEAR_WANTED_LEVEL.lua
- SetOutPath $INSTDIR
- GetDLLVersion "$INSTDIR\GTAIV.exe" $R0 $R1
- IntOp $R2 $R0 >> 16
- IntOp $R2 $R2 & 0x0000FFFF ; $R2 now contains major version
- IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
- IntOp $R4 $R1 >> 16
- IntOp $R4 $R4 & 0x0000FFFF ; $R4 now contains release
- IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
- StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"
- IntCmp $R4 7 is7 lessthan7 morethan7
- is7:
- StrCpy $0 "$R2.$R3.$R4.$R5"
- DetailPrint "version: $0"
- Goto done
- lessthan7:
- StrCpy $0 "$R2.$R3.$R4.$R5"
- DetailPrint "version: $0"
- MessageBox MB_OK "your current GTAIV.exe is NOT version 7 but version: $0"
- Goto done
- morethan7:
- StrCpy $0 "$R2.$R3.$R4.$R5"
- DetailPrint "version: $0"
- MessageBox MB_OK "your current GTAIV.exe is NOT version 7 but version: $0"
- Goto done
- done:
- IfFileExists $INSTDIR\Backup\GTAIV-backup.exe report
- Rename GTAIV.exe Backup\GTAIV-backup.exe
- Goto continue
- report:
- 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
- true:
- MessageBox MB_OKCANCEL "At this time i don't make a backup of your current GTAIV.exe" IDOK conf IDCANCEL deni
- conf:
- Delete "$INSTDIR\GTAIV.exe"
- Goto continue
- deni:
- Quit
- false:
- Quit
- continue:
- IfFileExists $INSTDIR\ScriptHook.dll movehook
- Goto step1
- movehook:
- Rename ScriptHook.dll Backup\ScriptHook.dll
- step1:
- IfFileExists $INSTDIR\dsound.dll movedsound
- Goto step2
- movedsound:
- Rename dsound.dll Backup\dsound.dll
- step2:
- IfFileExists $INSTDIR\ScriptHookDotNet.asi DotNet
- Goto modrun
- DotNet:
- Rename ScriptHookDotNet.asi Backup\ScriptHookDotNet.asi
- modrun:
- ${locate::Open} "$INSTDIR" "/F=1 /D=0 /M=*.asi /B=1 /G=0" $R0
- StrCmp $R0 0 0 loop
- Quit
- loop:
- ${locate::Find} $R0 $R1 $R2 $R3 $R4 $R5 $R6
- StrCmp $R1 '' close
- StrCmp $R4 '' 0 +2
- goto +2
- Rename $R1 $R2\Backup\$R3
- goto loop
- close:
- ${locate::Close} $R0
- ${locate::Unload}
- File readme.txt
- ExecShell "open" "$INSTDIR\readme.txt"
- File xlive.dll
- File Alice.asi
- File lua51.dll
- File GTAIV.exe
- WriteUninstaller "uninstall-Alice.exe"
- CreateDirectory "$DOCUMENTS\Rockstar Games\Gta iv\savegames"
- BringToFront
- SectionEnd
- Function instImage
- !insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\alicez.bmp" /RESIZETOFIT
- FunctionEnd
- ;--------------------------------
- UninstPage uninstConfirm un.uninstImage
- UninstallText "This removes Alice files and change GTAIV version5 into version7" "remove Alice"
- UninstPage instfiles
- ; Uninstaller
- Function un.uninstImage
- !insertmacro BIMAGE "${NSISDIR}\Contrib\Graphics\alicez.bmp" /RESIZETOFIT
- FunctionEnd
- Function un.isEmptyDir
- # Stack -> # Stack: <directory>
- Exch $0 # Stack: $0
- Push $1 # Stack: $1, $0
- FindFirst $0 $1 "$0\*.*"
- strcmp $1 "." 0 _notempty
- FindNext $0 $1
- strcmp $1 ".." 0 _notempty
- ClearErrors
- FindNext $0 $1
- IfErrors 0 _notempty
- FindClose $0
- Pop $1 # Stack: $0
- StrCpy $0 1
- Exch $0 # Stack: 1 (true)
- goto _end
- _notempty:
- FindClose $0
- ClearErrors
- Pop $1 # Stack: $0
- StrCpy $0 0
- Exch $0 # Stack: 0 (false)
- _end:
- FunctionEnd
- Section "uninstall"
- SetDetailsView show
- IfFileExists $INSTDIR\Backup\GTAIV-backup.exe next
- MessageBox MB_OK "GTAIV-backup.exe was not found in Backup folder"
- Quit
- next:
- GetDLLVersion "$INSTDIR\Backup\GTAIV-backup.exe" $R0 $R1
- IntOp $R2 $R0 >> 16
- IntOp $R2 $R2 & 0x0000FFFF ; $R2 now contains major version
- IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
- IntOp $R4 $R1 >> 16
- IntOp $R4 $R4 & 0x0000FFFF ; $R4 now contains release
- IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
- StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"
- IntCmp $R4 7 is007 lessthan007 morethan007
- is007:
- StrCpy $0 "$R2.$R3.$R4.$R5"
- DetailPrint "GTAIV-backup.exe version: $0"
- ;MessageBox MB_OK "version: $0"
- Goto donend
- lessthan007:
- StrCpy $0 "$R2.$R3.$R4.$R5"
- DetailPrint "version: $0"
- 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
- morethan007:
- StrCpy $0 "$R2.$R3.$R4.$R5"
- DetailPrint "version: $0"
- 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
- abruch1:
- Quit
- donend:
- IfFileExists $INSTDIR\Alice\*.* check
- Goto restore
- check:
- Push "$INSTDIR\Alice"
- Call un.isEmptyDir
- Pop $0
- StrCmp $0 1 0 +2
- ;MessageBox MB_OK "Directory is empty"
- Goto restore
- StrCmp $0 0 0 +2
- ;MessageBox MB_OK "Directory is NOT empty"
- MessageBox MB_YESNO "do you want to backup the Alice scripts?" IDYES true IDNO false
- true:
- DetailPrint "Alice scripts are saved at My Documents\Alice"
- CreateDirectory "$DOCUMENTS\Alice"
- CopyFiles $INSTDIR\Alice\*.* $DOCUMENTS\Alice
- MessageBox MB_OK "Alice scripts are saved at My Documents\Alice"
- Goto restore
- false:
- DetailPrint "All Alice scripts have been deleted"
- restore:
- IfFileExists $INSTDIR\Backup\ScriptHook.dll move_uhook
- Goto step_u1
- move_uhook:
- CreateDirectory "$DOCUMENTS\AliceUninstfiles"
- Rename $INSTDIR\Backup\ScriptHook.dll $DOCUMENTS\AliceUninstfiles\ScriptHook.dll
- step_u1:
- IfFileExists $INSTDIR\Backup\dsound.dll move_udsound
- Goto step_u2
- move_udsound:
- CreateDirectory "$DOCUMENTS\AliceUninstfiles"
- Rename $INSTDIR\Backup\dsound.dll $DOCUMENTS\AliceUninstfiles\dsound.dll
- step_u2:
- IfFileExists $INSTDIR\Backup\ScriptHookDotNet.asi Dot_uNet
- Goto mod_urun
- Dot_uNet:
- CreateDirectory "$DOCUMENTS\AliceUninstfiles"
- Rename $INSTDIR\Backup\ScriptHookDotNet.asi $DOCUMENTS\AliceUninstfiles\ScriptHookDotNet.asi
- mod_urun:
- ${locate::Open} "$INSTDIR\Backup" "/F=1 /D=0 /M=*.asi /B=1 /G=0" $R0
- StrCmp $R0 0 0 loop
- Quit
- loop:
- ${locate::Find} $R0 $R1 $R2 $R3 $R4 $R5 $R6
- StrCmp $R1 '' close
- StrCmp $R4 '' 0 +2
- goto +3
- CreateDirectory "$DOCUMENTS\AliceUninstfiles"
- Rename $R1 $DOCUMENTS\AliceUninstfiles\$R3
- goto loop
- close:
- ${locate::Close} $R0
- ${locate::Unload}
- Delete "$INSTDIR\GTAIV.exe"
- Rename $INSTDIR\Backup\GTAIV-backup.exe $INSTDIR\GTAIV.exe
- Delete "$INSTDIR\xlive.dll"
- Delete "$INSTDIR\Alice.asi"
- Delete "$INSTDIR\lua51.dll"
- Delete "$INSTDIR\Alice.log"
- Delete "$INSTDIR\asilog.txt"
- Delete "$INSTDIR\readme.txt"
- Delete "$INSTDIR\ScriptHook.log"
- Delete "$INSTDIR\ScriptHookDotNet.log"
- RMDir /r "$INSTDIR\Alice"
- RMDir /r "$INSTDIR\Backup"
- Delete "$INSTDIR\uninstall-Alice.exe"
- SectionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement