Advertisement
Faguss

FCM.nsi

Dec 21st, 2018
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; NSIS Script for Flashpoint Cutscene Maker installation v1.3
  2.  
  3.  
  4. ;------Header---------------
  5.  
  6. !include "MUI2.nsh"
  7. !include "logiclib.nsh"
  8. !include "WordFunc.nsh"
  9.  
  10. SetCompressor /solid lzma
  11. ShowInstDetails nevershow
  12. RequestExecutionLevel user
  13. ;BrandingText "NSIS script by Faguss (ofp-faguss.com)"
  14. InstallDir $INSTDIR
  15. ;InstallDirRegKey HKLM "Software\Codemasters\Operation Flashpoint" "MAIN"
  16.  
  17.  
  18.  
  19. ;------Strings--------------
  20.  
  21. VIAddVersionKey "ProductName" "FCM Installer"
  22. VIAddVersionKey "Comments" "Script for Operation Flashpoint: Resistance 1.96 and ArmA: Cold War Assault 1.99"
  23. VIAddVersionKey "CompanyName" "ofp-faguss.com"
  24. VIAddVersionKey "LegalTrademarks" "Public Domain"
  25. VIAddVersionKey "LegalCopyright" "Public Domain"
  26. VIAddVersionKey "FileDescription" "Install FCM script"
  27. VIAddVersionKey "FileVersion" "1.1.2.0"
  28. VIProductVersion "1.1.2.0"
  29.  
  30.  
  31.  
  32.  
  33. ;------Variables------------
  34.  
  35. Var finishpagetext
  36. Var parameters
  37. Var runtext
  38. Var exename
  39.  
  40.  
  41. ;------Customize------------
  42.  
  43. Name "FCM"
  44. OutFile "flashpoint_cutscene_maker.exe"
  45. !define MUI_ICON "img\orange-install.ico"
  46. !define MUI_WELCOMEFINISHPAGE_BITMAP "img\Installer_Welcome.bmp"
  47.  
  48. !define MUI_WELCOMEPAGE_TITLE "Flashpoint Cutscene Maker v1.12"
  49. !define MUI_WELCOMEPAGE_TEXT "This will install Cutscene Maker for$\n$\n$\tOperation Flashpoint: Resistance 1.96$\n$\tArmA: Cold War Assault 1.99$\n$\n$\nFwatch 1.15 included."
  50. !define MUI_HEADERIMAGE
  51. !define MUI_HEADERIMAGE_BITMAP "img\Installer_Header.bmp"
  52. !define MUI_HEADERIMAGE_RIGHT
  53. !define MUI_DIRECTORYPAGE_TEXT_TOP "Make sure this path leads to the game directory.$\n$\nGame must have been run at least once."
  54. ;!define MUI_FINISHPAGE_NOAUTOCLOSE
  55. !define MUI_FINISHPAGE_RUN $exename
  56. !define MUI_FINISHPAGE_RUN_PARAMETERS $parameters
  57. !define MUI_FINISHPAGE_RUN_TEXT $runtext
  58. !define MUI_FINISHPAGE_LINK "On-line readme"
  59. !define MUI_FINISHPAGE_LINK_LOCATION "http://www.ofp-faguss.com/files/flashpoint_cutscene_maker.pdf"
  60. !define MUI_FINISHPAGE_TITLE_3LINES
  61. !define MUI_FINISHPAGE_TEXT $finishpagetext
  62.  
  63. !define MUI_FINISHPAGE_SHOWREADME ""
  64. ;!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  65. !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
  66. !define MUI_FINISHPAGE_SHOWREADME_FUNCTION finishpageaction
  67.  
  68. !insertmacro MUI_PAGE_WELCOME
  69. !insertmacro MUI_PAGE_DIRECTORY
  70. !insertmacro MUI_PAGE_INSTFILES
  71. !insertmacro MUI_PAGE_FINISH
  72.  
  73. !define MUI_LANGDLL_ALLLANGUAGES
  74. !insertmacro MUI_LANGUAGE "English"
  75. !insertmacro MUI_RESERVEFILE_LANGDLL
  76.  
  77.  
  78. ;------Functions------------
  79.  
  80. ; This reads CWA reg key if OFP is not present
  81. Function .onInit
  82.     ${If} $INSTDIR == ""
  83.         ReadRegStr $INSTDIR HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 65790" "InstallLocation"
  84.     ${EndIf}
  85.    
  86.     ${If} $INSTDIR == ""
  87.         ReadRegStr $INSTDIR HKLM "SOFTWARE\Bohemia Interactive Studio\ColdWarAssault" "MAIN"
  88.     ${EndIf}
  89.  
  90.     ${If} $INSTDIR == ""
  91.         ReadRegStr $INSTDIR HKLM "Software\Codemasters\Operation Flashpoint" "MAIN"
  92.     ${EndIf}
  93.  
  94.     ${If} $INSTDIR == ""
  95.         StrCpy $INSTDIR "D:\Games\Operation Flashpoint"
  96.     ${EndIf}
  97. FunctionEnd
  98.  
  99. ; This creates a shortcut
  100. Function finishpageaction
  101.     SetOutPath "$INSTDIR\"
  102.     StrCpy $9 "Fwatch.lnk"
  103.    
  104.     IfFileExists $INSTDIR\flashpoint.cfg 0 +2
  105.         StrCpy $9 "Fwatch OFP.lnk"
  106.     IfFileExists $INSTDIR\ColdWarAssault.cfg 0 +2
  107.         StrCpy $9 "Fwatch CWA.lnk"
  108.    
  109.     IfFileExists "$DESKTOP\$9" +2 0
  110.     CreateShortCut "$DESKTOP\$9" "$INSTDIR\$exename" "$parameters"
  111. FunctionEnd
  112.  
  113.  
  114. ;------Sections------------
  115.  
  116. Section
  117.  
  118. ; Set some string variables =======================================
  119.  
  120.   StrCpy $finishpagetext ""
  121.   StrCpy $parameters " -nosplash -gamespy=master.ofpisnotdead.com"
  122.   StrCpy $runtext "Launch game with the Fwatch"
  123.   StrCpy $exename "fwatch.exe"
  124.  
  125.  
  126.  
  127.  
  128. ; Copy FCM ========================================================
  129.  
  130.   SetOutPath "$INSTDIR\FlashpointCutsceneMaker\"
  131.   File /r "FlashpointCutsceneMaker\*"
  132.  
  133.  
  134.  
  135.  
  136. ; Copy FCM demo mission ===========================================
  137.  
  138.     SetOutPath "$INSTDIR"
  139.     SetOverwrite ifnewer
  140.     ; If there's no "users" directory then don't copy anything
  141.     IfFileExists "$INSTDIR\Users\*.*" getUser endDemos
  142.  
  143.  
  144.    
  145.     ; Read key from registry about the current user
  146.     getUser:
  147.     StrCpy $7 ""
  148.     IfFileExists $INSTDIR\flashpoint.cfg 0 +2
  149.         ReadRegStr $7 HKCU "Software\Codemasters\Operation Flashpoint" "Player Name"
  150.     IfFileExists $INSTDIR\ColdWarAssault.cfg 0 +2
  151.         ReadRegStr $7 HKCU "Software\Bohemia Interactive Studio\ColdWarAssault" "Player Name"
  152.    
  153.     ${If} $7 != ""
  154.         IfFileExists "$INSTDIR\Users\$7\*.*" userDemos 0
  155.         StrCpy $7 ""
  156.     ${EndIf}
  157.    
  158.    
  159.     ; If no key then find first folder
  160.     FindFirst $0 $1 "$INSTDIR\Users\*"
  161.     loop:
  162.         DetailPrint $1
  163.         StrCmp $1 "" done
  164.         StrCmp $1 "." next
  165.         StrCmp $1 ".." next
  166.         DetailPrint "check: $1"
  167.         IfFileExists "$INSTDIR\Users\$1\*.*" 0 next
  168.             StrCpy $7 $1
  169.             DetailPrint "found: $7"
  170.             Goto done
  171.         next:
  172.         FindNext $0 $1
  173.     Goto loop
  174.     done:
  175.     FindClose $0
  176.  
  177.    
  178.     ; No folder
  179.     StrCmp $7 "" endDemos
  180.  
  181.  
  182.     userDemos:
  183.         CreateDirectory "$INSTDIR\Users\$7\missions"
  184.         SetOutPath "$INSTDIR\Users\$7\missions\"
  185.         File /r "missions\*"
  186.         StrCpy $finishpagetext "$finishpagetext$\n$\nOpen FCM_demo in Mission Editor"
  187.    
  188.     endDemos:
  189.     SetOutPath "$INSTDIR\"
  190.  
  191.    
  192.    
  193.  
  194.  
  195.  
  196.  
  197. ; Install Fwatch if it's missing or if it's old version ===========
  198.  
  199.     SetOverwrite ifnewer
  200.     SetOutPath "$INSTDIR\"
  201.     File /r "data\*"
  202.    
  203.   IfFileExists $INSTDIR\flashpoint.cfg 0 +2
  204.     File "fwatch.exe"
  205.   IfFileExists $INSTDIR\ColdWarAssault.cfg 0 +3
  206.     File "fwatchCWA.exe"
  207.     StrCpy $exename "fwatchCWA.exe"
  208.    
  209.    
  210.    
  211.    
  212. ; Check game executable ===========================================
  213.  
  214.     ; Check if this is Steam version
  215.     ${WordFind} $INSTDIR "SteamApps\common" "E+1{" $R0
  216.     IfErrors notfound found
  217.         found:
  218.             StrCpy $parameters "$parameters -steam"
  219.             StrCpy $runtext "Launch game with Steam"
  220.             GoTo allDone
  221.         notfound:
  222.        
  223.   IfFileExists "$INSTDIR\flashpointresistance.exe" allDone 0
  224.   IfFileExists "$INSTDIR\ofp.exe" allDone 0
  225.   IfFileExists "$INSTDIR\flashpointbeta.exe" allDone 0
  226.   IfFileExists "$INSTDIR\operationflashpoint.exe" allDone 0
  227.   IfFileExists "$INSTDIR\operationflashpointbeta.exe" allDone 0
  228.   IfFileExists "$INSTDIR\ColdWarAssault.exe" allDone 0
  229.     StrCpy $parameters "$parameters -nolaunch "
  230.     StrCpy $runtext "Launch Fwatch"
  231.     StrCpy $finishpagetext "$finishpagetext$\n$\nYou will have to start the game manually."
  232.  
  233.   allDone:
  234.   ;if empty string then change it to 'all done'
  235.   StrCmp $finishpagetext "" +1 +2
  236.     StrCpy $finishpagetext "All Done"
  237.    
  238.  
  239.     SetOutPath "$INSTDIR\"
  240.    
  241. SectionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement