;-------------------------------- ;Include Modern UI !include "MUI2.nsh" !include nsDialogs.nsh !include LogicLib.nsh RequestExecutionLevel admin ;-------------------------------- ;Configuration ;General Name "Project Reality" OutFile "PR-Downloader.exe" BrandingText "RealityMod.com - Installer by Sir. Oddsodz Build 0.856" SetCompress auto ;was off SetCompressorDictSize 128 XPStyle on ;Folder selection page InstallDirRegKey HKLM "SOFTWARE\Electronic Arts\EA Games\Battlefield 2" "InstallDir" InstallDir "$PROGRAMFILES\No Battlefield 2 mod folder found" SetOverwrite ifdiff SetPluginUnload alwaysoff ;Get install folder from registry if available ;InstallDirRegKey HKCU "Software\NSISbt" "" ;-------------------------------- ;Variables Var STARTMENU_FOLDER Var Dialog Var Label Var Text ;-------------------------------- ;Modern UI Configuration !define MUI_HEADERIMAGE !define MUI_ABORTWARNING !insertmacro MUI_PAGE_WELCOME Page custom nsDialogsPage1 Page custom nsDialogsPage2 !insertmacro MUI_PAGE_LICENSE "License.txt" ;-------------------------------- ;Pages ; Page custom CustomPageA_Pre CustomPageA_Post ;!insertmacro MUI_WELCOMEPAGE_TEXT text ;Page custom nsDialogsWelcome ;!insertmacro MUI_PAGE_DIRECTORY Page custom nsDialogsPage3 ;Start Menu Folder Page Configuration ; !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" ; !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\NSISbt" ; !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" ; !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH ;!insertmacro MUI_FINISHPAGE_TEXT "runpr.txt" !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ;Languages !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ;Reserve Files ;These files should be inserted before other files in the data block ;Keep these lines before any File command ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA) ReserveFile "btdownloadnsis.py" ;!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ;-------------------------------- ;Installer Sections Section "Project Reality" SecDummy SetOutPath "$INSTDIR" Push "asdef" call GetParameters Pop $R0 ;Display a messagebox if check box was checked ;ADD YOUR OWN STUFF HERE! ;CreateDirectory $INSTDIR\pr_sp_07 ;CopyFiles /SILENT $INSTDIR\pr\levels\*.* $INSTDIR\pr_sp_07\levels SetOutPath "$PLUGINSDIR\NSISbt" File nsisbt.exe SetOutPath "$INSTDIR\mods\pr\readme\icon" File pr.ico SetOutPath "$PLUGINSDIR\NSISbt\bt" File "btdownloadnsis.py" File /r "dist\*" SetShellVarContext all SetOutPath "$INSTDIR\mods\.." CreateShortCut "$DESKTOP\Project Reality.lnk" "$INSTDIR\BF2.exe" "+modPath mods/pr +menu 1 +fullscreen 1" "$INSTDIR\mods\pr\readme\icon\pr.ico" CreateShortCut "$DESKTOP\Project Reality Wiki.lnk" "$INSTDIR\mods\pr\readme\icons\projectreality.url" "" "$INSTDIR\mods\pr\readme\icon\pr.ico" CreateShortCut "$DESKTOP\Project Reality Manual.lnk" "$INSTDIR\mods\pr\readme\PR_Manual.pdf" "" "" CreateDirectory "$SMPROGRAMS\Project Reality" CreateShortCut "$SMPROGRAMS\Project Reality\Project Reality.lnk" "$INSTDIR\BF2.exe" "+modPath mods/pr +menu 1 +fullscreen 1" "$INSTDIR\mods\pr\readme\icon\pr.ico" CreateShortCut "$SMPROGRAMS\Project Reality\Project Reality Manual.lnk" "$INSTDIR\mods\pr\readme\PR_Manual.pdf" "" "" CreateShortCut "$SMPROGRAMS\Project Reality\Project Reality Wiki.lnk" "$INSTDIR\mods\pr\readme\icons\projectreality.url" "" "$INSTDIR\mods\pr\readme\icon\pr.ico" CreateShortCut "$SMPROGRAMS\Project Reality\Uninstall Project Reality.lnk" "$INSTDIR\mods\PRUninstall.exe" "" "" ;Create uninstaller WriteUninstaller "mods\PRUninstall.exe" ;Create shortcuts ; CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" ; CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$PROGRAMFILES\NSISbt\Uninstall.exe" ; CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\TheGreyAlbum.lnk" "$INSTDIR\The Grey Album" ; !insertmacro MUI_STARTMENU_WRITE_END !insertmacro MUI_HEADER_TEXT "Downloading Game Files Now" "This will take some time. Please read the manual" call ConnectInternet SetOutPath "$PLUGINSDIR\NSISbt\bt" StrCpy $R0 "$CMDLINE http://www.oddsodz.com/downloads/rbtt/torrents/pr.torrent" StrCpy $R1 "$INSTDIR\mods" NSISdl::execFile "$PLUGINSDIR\NSISbt\bt\btdownloadnsis.py" Pop $R2 IfErrors msgerror msgresult msgresult: StrCmp $R1 "error" msgerror msgdone msgerror: StrCpy $R3 "c:\temp\install.log" Push $R3 call DumpLog MessageBox MB_OK "error running $PLUGINSDIR\btdownloadnsis.py, log written to $R3" msgdone: SectionEnd !define LVM_GETITEMCOUNT 0x1004 !define LVM_GETITEMTEXT 0x102D Function DumpLog Exch $5 Push $0 Push $1 Push $2 Push $3 Push $4 Push $6 FindWindow $0 "#32770" "" $HWNDPARENT GetDlgItem $0 $0 1016 StrCmp $0 0 error FileOpen $5 $5 "w" StrCmp $5 0 error SendMessage $0 ${LVM_GETITEMCOUNT} 0 0 $6 System::Alloc ${NSIS_MAX_STRLEN} Pop $3 StrCpy $2 0 System::Call "*(i, i, i, i, i, i, i, i, i) i \ (0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1" loop: StrCmp $2 $6 done System::Call "User32::SendMessageA(i, i, i, i) i \ ($0, ${LVM_GETITEMTEXT}, $2, r1)" System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)" FileWrite $5 "$4$\r$\n" IntOp $2 $2 + 1 Goto loop done: FileClose $5 System::Free $1 System::Free $3 Goto exit error: MessageBox MB_OK error exit: Pop $6 Pop $4 Pop $3 Pop $2 Pop $1 Pop $0 Exch $5 FunctionEnd Function .onInit ;Extract Install Options files ;$PLUGINSDIR will automatically be removed when the installer closes InitPluginsDir ;Extract InstallOptions INI files ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioA.ini" ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "_socket.pyd" ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "_sre.pyd" ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "_ssl.pyd" ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "_winreg.pyd" ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "login.exe" ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "python23.dll" ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "unicodedata.pyd" ; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "zlib.pyd" # the plugins dir is automatically deleted when the installer exits InitPluginsDir File /oname=$PLUGINSDIR\splash.bmp "prsplash.bmp" #optional #File /oname=$PLUGINSDIR\splash.wav "C:\myprog\sound.wav" advsplash::show 5000 600 400 -1 $PLUGINSDIR\splash Pop $0 ; $0 has '1' if the user closed the splash screen early, ; '0' if everything closed normally, and '-1' if some error occurred. Delete $PLUGINSDIR\splash.bmp FunctionEnd ;-------------------------------- ;Descriptions LangString DESC_SecDummy ${LANG_ENGLISH} "Project Reality" !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section Var MUI_TEMP Section "Uninstall" ;ADD YOUR OWN STUFF HERE! SetShellVarContext all RMDir /r "$INSTDIR\NSISbt" RMDir /r "$INSTDIR\pr\*.*" Delete "$DESKTOP\Project Reality.lnk" Delete "$DESKTOP\Project Reality Wiki.lnk" Delete "$DESKTOP\Project Reality Manual.lnk" Delete "$SMPROGRAMS\Project Reality\*.*" ;Delete "$SMPROGRAMS\Sir. Community ™\Uninstall SandBox.lnk" RMDir "$SMPROGRAMS\Project Reality" !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP RMDir /r "$SMPROGRAMS\$MUI_TEMP" DeleteRegKey /ifempty HKCU "Software\NSISbt" Delete "$INSTDIR\PRUninstall.exe" SectionEnd Function ConnectInternet Push $R0 ClearErrors Dialer::AttemptConnect IfErrors noie3 Pop $R0 StrCmp $R0 "online" connected MessageBox MB_OK|MB_ICONSTOP "Cannot connect to the internet." Quit noie3: ; IE3 not installed MessageBox MB_OK|MB_ICONINFORMATION "Please connect to the internet now." connected: Pop $R0 FunctionEnd ; GetParameters ; input, none ; output, top of stack (replaces, with e.g. whatever) ; modifies no other variables. Function GetParameters Push $R0 Push $R1 Push $R2 Push $R3 StrCpy $R2 1 StrLen $R3 $CMDLINE ;Check for quote or space StrCpy $R0 $CMDLINE $R2 StrCmp $R0 '"' 0 +3 StrCpy $R1 '"' Goto loop StrCpy $R1 " " loop: IntOp $R2 $R2 + 1 StrCpy $R0 $CMDLINE 1 $R2 StrCmp $R0 $R1 get StrCmp $R2 $R3 get Goto loop get: IntOp $R2 $R2 + 1 StrCpy $R0 $CMDLINE 1 $R2 StrCmp $R0 " " get StrCpy $R0 $CMDLINE "" $R2 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd Function un.onUninstSuccess MessageBox MB_OK "You have successfully uninstalled Project Reality." FunctionEnd Function nsDialogsPage1 nsDialogs::Create /NOUNLOAD 1018 Pop $Dialog ${If} $Dialog == error Abort ${EndIf} ${NSD_CreateLabel} 0 0 100% 12u "Important installation about Project Reality." Pop $Label ;${NSD_CreateText} 0 13u 100% -13u "You Must have the latest version of Project Reality installed before you can play Project Reality Single Player. Also. You must use the desktop shortcut or the Windows Start Menu short cuts to play." nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "IMPORTANT INSTALLATION INFORMATION$\r$\n$\r$\nBE SURE TO UNINSTALL ALL PREVIOUS VERSIONS OF PROJECT REALITY BEFORE INSTALLING THIS VERSION.$\r$\n$\r$\nPlease Visit www.realitymod.com for more information." Pop $Text nsDialogs::Show FunctionEnd Function nsDialogsPage2 nsDialogs::Create /NOUNLOAD 1018 Pop $Dialog ${If} $Dialog == error Abort ${EndIf} ${NSD_CreateLabel} 0 0 100% 12u "Important information about Project Reality." Pop $Label ;${NSD_CreateText} 0 13u 100% -13u "You Must have the latest version of Project Reality installed before you can play Project Reality Single Player. Also. You must use the desktop shortcut or the Windows Start Menu short cuts to play." nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "You must have Battlefield 2 installed before you can install and play Project Reality.$\r$\n$\r$\nAlso. You must use the desktop shortcut or the Windows Start Menu shortcut to play.$\r$\n$\r$\nPlease Visit www.realitymod.com for more information." Pop $Text nsDialogs::Show FunctionEnd Function nsDialogsPage3 nsDialogs::Create /NOUNLOAD 1018 Pop $Dialog ${If} $Dialog == error Abort ${EndIf} ${NSD_CreateLabel} 0 0 100% 12u "Extra install information about Project Reality." Pop $Label ;${NSD_CreateText} 0 13u 100% -13u "You Must have the latest version of Project Reality installed before you can play Project Reality Single Player. Also. You must use the desktop shortcut or the Windows Start Menu short cuts to play." nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "Project Reality installer will now attempt to download and install all game files.$\r$\n$\r$\nYou must have a working internet connection.$\r$\n$\r$\nPlease make sure that your Firewall or Router is not blocking this installer or port 6881." Pop $Text nsDialogs::Show FunctionEnd