Advertisement
kenoxite

OFPmaterials_v11_installer.iss

Jun 1st, 2015
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Script generated by the Inno Script Studio Wizard.
  2. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
  3.  
  4. #define MyAppName "OFP Materials"
  5. #define MyAppVersion "1.1"
  6. #define MyAppPublisher "kenoxite"
  7. #define MyAppURL "http://forums.bistudio.com/showthread.php?190481"
  8. #define MyGroupName "OFP & CWA mods/OFP Materials"
  9. #define modDir "OFPmaterials"
  10.  
  11. [Setup]
  12. ; NOTE: The value of AppId uniquely identifies this application.
  13. ; Do not use the same AppId value in installers for other applications.
  14. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
  15. AppId=207A157A-FCB3-4EA7-884A-59F053F8198B
  16. AppName={#MyAppName}
  17. AppVersion={#MyAppVersion}
  18. ;AppVerName={#MyAppName} {#MyAppVersion}
  19. AppPublisher={#MyAppPublisher}
  20. AppPublisherURL={#MyAppURL}
  21. AppSupportURL={#MyAppURL}
  22. AppUpdatesURL={#MyAppURL}
  23. DefaultDirName={#modDir}
  24. OutputBaseFilename=OFP Materials v1.1 Setup
  25. SolidCompression=yes
  26. OutputDir=C:\Users\Usuario\Documents
  27. DisableDirPage=auto
  28. DisableReadyMemo=True    
  29. UsePreviousGroup=False
  30. AllowNoIcons=True
  31. AlwaysUsePersonalGroup=True
  32. DefaultGroupName={#MyGroupName}
  33. DisableWelcomePage=false
  34. DisableReadyPage=True
  35. WizardImageFile=userdocs:Installer_OFPmaterials\OFPMatInstallerimg1.bmp
  36. WizardSmallImageFile=userdocs:Installer_OFPmaterials\OFPMatInstallersmallimg1.bmp
  37.  
  38. [Messages]
  39. WelcomeLabel2=This will install the OFP Materials addon for OFP/CWA.%n%nOFP Materials provides material properties to all the vanilla textures and a numerous amount of user made addons.%n%nEverything look more vibrant and realistic than before, giving more contrast and depth to the game.
  40.  
  41. [CustomMessages]
  42. OptionsFormCaption=OFP Materials installed already...
  43. RepairButtonCaption=Repair
  44. UninstallButtonCaption=Uninstall
  45.  
  46. [Languages]
  47. Name: "english"; MessagesFile: "compiler:Default.isl"
  48. Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
  49. Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
  50. Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
  51. Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
  52. Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
  53. Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
  54. Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
  55. Name: "french"; MessagesFile: "compiler:Languages\French.isl"
  56. Name: "german"; MessagesFile: "compiler:Languages\German.isl"
  57. Name: "greek"; MessagesFile: "compiler:Languages\Greek.isl"
  58. Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
  59. Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
  60. Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
  61. Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
  62. Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
  63. Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
  64. Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
  65. Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
  66. Name: "scottishgaelic"; MessagesFile: "compiler:Languages\ScottishGaelic.isl"
  67. Name: "serbiancyrillic"; MessagesFile: "compiler:Languages\SerbianCyrillic.isl"
  68. Name: "serbianlatin"; MessagesFile: "compiler:Languages\SerbianLatin.isl"
  69. Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
  70. Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
  71. Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
  72. Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
  73.  
  74. [Tasks]
  75. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
  76. Name: "lowcontrast"; Description: "Install low contrast version"; GroupDescription: "The low contrast version is more visually compatible with dynamically spawned units and unsupported addons:"; Flags: unchecked
  77.  
  78. [Icons]
  79. Name: "{userdesktop}\OFP Materials"; Filename: "{code:getGamePath}"; Parameters: "-nosplash -mod=OFPmaterials"; Tasks: desktopicon
  80. Name: "{userdesktop}\OFP Materials (Steam)"; Filename: "{code:getGamePathSteam}"; Parameters: "-applaunch 65790 -nosplash -mod=OFPmaterials"; Tasks: desktopicon; Check: returnSteamCheck
  81. Name: "{group}\Play OFP Materials"; Filename: "{code:getGamePath}"; Parameters: "-nosplash -mod=OFPmaterials"
  82. Name: "{group}\Play OFP Materials (Steam)"; Filename: "{code:getGamePathSteam}"; Parameters: "-applaunch 65790 -nosplash -mod=OFPmaterials"; Check: returnSteamCheck
  83. Name: "{group}\View Readme"; Filename: "{app}\OFPMaterials-Readme.pdf"
  84. Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
  85.  
  86. [Files]
  87. Source: "OFPmaterials\low contrast\*"; DestDir: "{app}\low contrast"; Flags: ignoreversion createallsubdirs recursesubdirs
  88. Source: "OFPmaterials\high contrast\*"; DestDir: "{app}\high contrast"; Flags: ignoreversion createallsubdirs recursesubdirs
  89. Source: "OFPmaterials\addons\*"; DestDir: "{app}\addons"; Flags: ignoreversion createallsubdirs recursesubdirs
  90. Source: "OFPmaterials\_pbo\*"; DestDir: "{app}\_pbo"; Flags: ignoreversion createallsubdirs recursesubdirs
  91. Source: "OFPmaterials\_config_template\*"; DestDir: "{app}\_config_template"; Flags: ignoreversion createallsubdirs recursesubdirs
  92. Source: "OFPmaterials\OFPMaterials-Readme.pdf"; DestDir: "{app}"; Flags: ignoreversion isreadme
  93. Source: "OFPmaterials\OFPMaterials-Readme.txt"; DestDir: "{app}"; Flags: ignoreversion
  94. Source: "OFPmaterials\low contrast\ofp_matdef_core.pbo"; DestDir: "{app}\addons"; Flags: ignoreversion; Tasks: lowcontrast
  95.  
  96. [Run]
  97. Filename: {code:getGamePath}; Parameters: "-nosplash -mod=OFPmaterials"; Flags: nowait postinstall skipifsilent unchecked; Description: "Launch OFP Materials"
  98.  
  99. [UninstallDelete]
  100. Type: dirifempty; Name: "{app}\*"
  101.  
  102. [Code]
  103. const
  104.   mrRepair = 100;
  105.   mrUninstall = 101;
  106.  
  107. var
  108.   InstPath: string;
  109.   isSteam: boolean;
  110.  
  111. // Check if the selected installation directory has a CWA or OFP game
  112. function isCWA: Boolean;
  113. begin
  114.     Result := false;
  115.     if FileExists(ExpandConstant(InstPath+'coldwarassault.exe')) then
  116.         Result := true;
  117. end;
  118.  
  119. // Generates an installation path based on the one selected by the user
  120. function getInstallPath(Append: String): String;
  121. begin
  122.     Result := InstPath + Append;
  123. end;
  124.  
  125. // Generates a path to the game based on if it's an OFP or CWA installation and the directory selected by the user
  126. function getGamePath(Default: String): String;
  127. begin
  128.     if isCWA then begin
  129.         Result := InstPath + 'coldwarassault.exe';
  130.     end else begin
  131.         Result := InstPath + 'FLASHPOINTRESISTANCE.exe';
  132.     end;
  133. end;
  134.  
  135. // Get Steam path
  136. function getSteamPath(Default: String): String;
  137. begin
  138.     Result := '';
  139.     if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam') then
  140.         RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam','InstallPath', Result);
  141. end;
  142.  
  143. // Check if the selected installation directory belongs to Steam
  144. function isSteamGame: Boolean;
  145. var steamPath: string;
  146. begin
  147.     Result := false;
  148.     if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam') then begin
  149.         steamPath := getSteamPath('');
  150.         if InstPath = (steamPath + '\steamapps\common\ARMA Cold War Assault\') then begin
  151.             Result := true;
  152.         end;
  153.     end;
  154. end;
  155.  
  156. // Get Steam game path
  157. function getGamePathSteam(Default: String): String;
  158. begin
  159.     Result := getSteamPath('') + '\Steam.exe';
  160. end;
  161.  
  162. // Return the result of the Steam check
  163. // This seems a bit convoluted (lots of similar checks), but Inno doesn't seem to create the shortcuts otherwise
  164. function returnSteamCheck: Boolean;
  165. begin
  166.     Result := isSteam;
  167. end;
  168.  
  169. // Manage next button click event
  170. function NextButtonClick(CurPageID: Integer): Boolean;
  171. var
  172.     debugStr:string;
  173. begin
  174.   Result := True;
  175.     //MsgBox('Page is "' + IntToStr(CurPageID) + '"', mbInformation, MB_OK);
  176.     // Generate a new default install dir based on the installed games
  177.     if CurPageID = 1 then begin
  178.         WizardForm.DirEdit.Text := InstPath + '{#modDir}';
  179.     end;
  180.     if CurPageID = wpSelectProgramGroup then begin
  181.         isSteam := isSteamGame;
  182.     end;
  183. end;
  184.  
  185. // Repair or uninstall if the mod was already installed
  186. function ShowOptionsForm: TModalResult;
  187. var
  188.   OptionsForm: TSetupForm;
  189.   RepairButton: TNewButton;
  190.   UninstallButton: TNewButton;
  191. begin
  192.   Result := mrNone;
  193.   OptionsForm := CreateCustomForm;
  194.   try
  195.     OptionsForm.Width := 220;
  196.     OptionsForm.Caption := ExpandConstant('{cm:OptionsFormCaption}');
  197.     OptionsForm.Position := poScreenCenter;
  198.  
  199.     RepairButton := TNewButton.Create(OptionsForm);
  200.     RepairButton.Parent := OptionsForm;
  201.     RepairButton.Left := 8;
  202.     RepairButton.Top := 8;
  203.     RepairButton.Width := OptionsForm.ClientWidth - 16;
  204.     RepairButton.Caption := ExpandConstant('{cm:RepairButtonCaption}');
  205.     RepairButton.ModalResult := mrRepair;
  206.  
  207.     UninstallButton := TNewButton.Create(OptionsForm);
  208.     UninstallButton.Parent := OptionsForm;
  209.     UninstallButton.Left := 8;
  210.     UninstallButton.Top := RepairButton.Top + RepairButton.Height + 8;
  211.     UninstallButton.Width := OptionsForm.ClientWidth - 16;
  212.     UninstallButton.Caption := ExpandConstant('{cm:UninstallButtonCaption}');
  213.     UninstallButton.ModalResult := mrUninstall;
  214.  
  215.     OptionsForm.ClientHeight := RepairButton.Height + UninstallButton.Height + 24;
  216.     Result := OptionsForm.ShowModal;
  217.   finally
  218.     OptionsForm.Free;
  219.   end;
  220. end;
  221.  
  222. function GetUninstallerPath: string;
  223. var
  224.   RegKey: string;
  225. begin
  226.   Result := '';
  227.   RegKey := Format('%s\%s_is1', ['Software\Microsoft\Windows\CurrentVersion\Uninstall',
  228.     '{#emit SetupSetting("AppId")}']);
  229.   if not RegQueryStringValue(HKEY_LOCAL_MACHINE, RegKey, 'UninstallString', Result) then
  230.     RegQueryStringValue(HKEY_CURRENT_USER, RegKey, 'UninstallString', Result);
  231. end;
  232.  
  233. function InitializeSetup: Boolean;
  234. var
  235.   regPath: string;
  236.   UninstPath: string;
  237.   ResultCode: Integer;  
  238. begin
  239.   Result := True;
  240.   // Set default directory based on reg (OFP or CWA). CWA takes precedence over OFP
  241.   if RegQueryStringValue(HKLM, 'SOFTWARE\Codemasters\Operation Flashpoint', 'MAIN', regPath) then
  242.     InstPath := regPath + '\';
  243.   if RegQueryStringValue(HKLM, 'SOFTWARE\bohemia interactive studio\coldwarassault', 'MAIN', regPath) then
  244.     InstPath := regPath + '\';
  245.   if RegQueryStringValue(HKLM, 'SOFTWARE\WOW6432Node\bohemia interactive studio\coldwarassault', 'MAIN', regPath) then
  246.     InstPath := regPath + '\';
  247.  
  248.   // Get Uninstall path
  249.   UninstPath := RemoveQuotes(GetUninstallerPath);
  250.   if UninstPath <> '' then
  251.   begin
  252.     case ShowOptionsForm of
  253.       mrRepair: Result := True;
  254.       mrUninstall:
  255.       begin
  256.         Result := False;
  257.         if not Exec(UninstPath, '', '', SW_SHOW, ewNoWait, ResultCode) then
  258.           MsgBox(FmtMessage(SetupMessage(msgUninstallOpenError), [UninstPath]), mbError, MB_OK);
  259.       end;
  260.     else
  261.       Result := False;
  262.     end;
  263.   end;
  264. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement