kenoxite

WW4_EXT_v103_installer.iss

Jun 3rd, 2015
149
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 "WW4 Extended"
  5. #define MyAppVersion "1.0.3"
  6. #define MyAppPublisher "kenoxite"
  7. #define MyAppURL "http://forums.bistudio.com/showthread.php?154829"
  8. #define MyGroupName "OFP & CWA mods/WW4 Extended"
  9. #define modDir "WW4_EXT"
  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=E97A55E2-8D25-4BD9-A863-AC726887B9C3
  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=WW4 Extended v1.0.3 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. WizardImageFile=userdocs:Installer_WW4_EXT\EXTinstallerimg1.bmp
  35. WizardSmallImageFile=userdocs:Installer_WW4_EXT\EXTinstallersmallimg1.bmp
  36. DisableReadyPage=True
  37.  
  38. [Messages]
  39. WelcomeLabel2=This will install the OFP/CWA WW4 Extended (EXT) expansion for the WW4 mod.%n%nIf you haven't installed WW4 already you will be able to do so here.%n%nYou will also be able to install only the EXT components you want to.
  40.  
  41. [CustomMessages]
  42. OptionsFormCaption=WW4 Extended installed already...
  43. RepairButtonCaption=Repair
  44. UninstallButtonCaption=Uninstall
  45. aspectratio_header=OFP Aspect Ratio Fix for WW4 mod
  46. aspectratio_description=Here you can make WW4 mod compatible with widescreen resolutions
  47. aspectratio_Label1=Select your screen's aspect ratio:
  48. aspectratio_4_3=4:3
  49. aspectratio_5_4=5:4
  50. aspectratio_16_10=16:10
  51. aspectratio_16_9=16:9
  52. aspectratio_15_9=15:9
  53.  
  54. [Languages]
  55. Name: "english"; MessagesFile: "compiler:Default.isl"
  56. Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
  57. Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
  58. Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
  59. Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
  60. Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
  61. Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
  62. Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
  63. Name: "french"; MessagesFile: "compiler:Languages\French.isl"
  64. Name: "german"; MessagesFile: "compiler:Languages\German.isl"
  65. Name: "greek"; MessagesFile: "compiler:Languages\Greek.isl"
  66. Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
  67. Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
  68. Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
  69. Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
  70. Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
  71. Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
  72. Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
  73. Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
  74. Name: "scottishgaelic"; MessagesFile: "compiler:Languages\ScottishGaelic.isl"
  75. Name: "serbiancyrillic"; MessagesFile: "compiler:Languages\SerbianCyrillic.isl"
  76. Name: "serbianlatin"; MessagesFile: "compiler:Languages\SerbianLatin.isl"
  77. Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
  78. Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
  79. Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
  80. Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
  81.  
  82. [Tasks]
  83. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
  84. Name: "lowcontrast"; Description: "Install low contrast materials"; GroupDescription: "The low contrast version is more visually compatible with dynamically spawned units:"; Flags: unchecked
  85. Name: "aspectratio"; Description: "Apply aspect ratio fix"; GroupDescription: "Widescreen resolution compatibility for WW4:"; Components: base
  86. Name: "cloudlets"; Description: "Use performance friendly cloudlets"; GroupDescription: "You can use the WGL cloudlets definitions to increase performance:"; Components: base
  87. Name: "enableradio"; Description: "Enabling this will slow down AI reaction times and squad orders issued by players"; GroupDescription: "Enable radio chatter in WW4:"; Flags: unchecked; Components: base
  88.  
  89. [Icons]
  90. Name: "{userdesktop}\WW4 Extended"; Filename: "{code:getGamePath}"; IconFilename: "{app}\ww4ext.ico"; IconIndex: 0; Parameters: "{code:getLaunchedMods}"; Tasks: desktopicon
  91. Name: "{userdesktop}\WW4 Extended (Steam)"; Filename: "{code:getGamePathSteam}"; IconFilename: "{app}\ww4ext.ico"; IconIndex: 0; Parameters: "-applaunch 65790 {code:getLaunchedMods}"; Check: returnSteamCheck; Tasks: desktopicon
  92. Name: "{group}\Play WW4 Extended"; Filename: "{code:getGamePath}"; IconFilename: "{app}\ww4ext.ico"; IconIndex: 0; Parameters: "{code:getLaunchedMods}"; Components: main
  93. Name: "{group}\Play WW4 Extended (Steam)"; Filename: "{code:getGamePathSteam}"; IconFilename: "{app}\ww4ext.ico"; Parameters: "-applaunch 65790 {code:getLaunchedMods}"; Components: main; Check: returnSteamCheck
  94. Name: "{group}\Play WW4"; Filename: "{code:getGamePath}"; Parameters: "-nosplash -mod=@ww4mod25"; Components: main
  95. Name: "{group}\Play WW4 (Steam)"; Filename: "{code:getGamePathSteam}"; IconFilename: "{app}\ww4ext.ico"; Parameters: "-applaunch 65790 -nosplash -mod=@ww4mod25"; Components: main; Check: returnSteamCheck
  96. Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
  97. Name: "{group}\Documentation\View Main Readme"; Filename: "{app}\_docs\WW4Extendedv1.0.3-Readme.pdf"; Components: main
  98. Name: "{group}\Documentation\View Extra Features Manual"; Filename: "{app}\_docs\WW4Extended-ExtraFeaturesManual.pdf"; Components: main
  99. Name: "{group}\Documentation\View Flags Manual"; Filename: "{app}\_docs\WW4Extended-Flags.pdf"; Components: main
  100. Name: "{group}\Documentation\View Music track classes"; Filename: "{app}\_docs\WW4 EXT music.txt"; Components: main
  101. Name: "{group}\Documentation\View Main Credits"; Filename: "{app}\_docs\WW4Extended-Credits.pdf"; Components: main
  102. Name: "{group}\Documentation\View Main Changelog"; Filename: "{app}\_docs\WW4Extended-Changelog.pdf"; Components: main
  103. Name: "{group}\Documentation\View Cold War Readme"; Filename: "{code:getInstallPath|WW4EXT_CW\_docs\WW4ExtendedColdWarv1.0-Readme.pdf}"; Components: main\vehicles\coldwar
  104. Name: "{group}\Documentation\View Arctic Readme"; Filename: "{code:getInstallPath|WW4EXT_ARCTIC\_docs\WW4ExtendedArcticv1.2-Readme.pdf}"; Components: main\vehicles\coldwar\arctic
  105.  
  106. [Files]
  107. Source: "WW4_251\@ww4mod25\*"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: base
  108. Source: "WW4 cloudlets\WW4_cloudlets.hpp"; DestDir: "{code:getInstallPath|@ww4mod25\bin}"; DestName: "cloudlets.hpp"; Flags: ignoreversion; Components: base
  109. Source: "WW4 cloudlets\WGL_cloudlets.hpp"; DestDir: "{code:getInstallPath|@ww4mod25\bin}"; DestName: "cloudlets.hpp"; Flags: ignoreversion; Components: base; Tasks: cloudlets
  110. Source: "WW4_251\Bonus\*"; DestDir: "{code:getInstallPath|@ww4mod25\Bonus}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: base
  111. Source: "WW4_251\DMA_FlashUpdate.txt"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion; Components: base
  112. Source: "WW4_251\Gamelogics.txt"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion; Components: base
  113. Source: "WW4_251\READmePatch.txt"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion; Components: base
  114. Source: "WW4_251\Readme-WW4modpack25.txt"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion isreadme; Components: base
  115. Source: "ofpaspectratiofix\*"; DestDir: "{app}\ofpaspectratiofix"; Flags: ignoreversion createallsubdirs recursesubdirs deleteafterinstall; Components: base
  116. Source: "WW4_EXT\addons\*"; DestDir: "{app}\addons"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main; AfterInstall: copyOFPinfcfg
  117. Source: "v196_patch\ww4ext_inf_cfg.pbo.OFP"; DestDir: "{app}"; Flags: ignoreversion dontcopy; Components: main
  118. Source: "low contrast materials\*"; DestDir: "{app}\low contrast materials"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main
  119. Source: "high contrast materials\*"; DestDir: "{app}\high contrast materials"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main
  120. Source: "low contrast materials\ofp_matdef_core.pbo"; DestDir: "{app}\addons"; Flags: ignoreversion; Components: main; Tasks: lowcontrast
  121. Source: "WW4_EXT\ww4ext.ico"; DestDir: "{app}"; Flags: ignoreversion; Components: main
  122. Source: "WW4_EXT\_docs\*"; DestDir: "{app}\_docs"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main
  123. Source: "WW4_EXT\_docs\WW4Extendedv1.0.3-Readme.pdf"; DestDir: "{app}\_docs"; Flags: ignoreversion isreadme; Components: main
  124. Source: "WW4_EXT\_island intros\kodiak_anims\intro.kodiak_v1_1\*"; DestDir: "{code:getInstallPath|AddOns\kodiak_anims\intro.kodiak_v1_1}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main
  125. Source: "WW4_EXT\_missions\_Missions\ww4ext_TakeTheRedCar_v11.WW4_DesertAbel2.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended}"; Flags: ignoreversion; Components: main\vehicles
  126. Source: "WW4_EXT\_missions\_Missions\ww4ext_montignacassault_v13.Eden.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended}"; Flags: ignoreversion; Components: main\vehicles
  127. Source: "WW4_EXT\_missions\_Missions\badexfil_v11.WW4_DesertAbel2.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended}"; Flags: ignoreversion; Components: main\vehicles
  128. Source: "WW4_EXT\_missions\_Missions\_ww4ext_nationalAssault_v11.WW4_DesertAbel2.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended}"; Flags: ignoreversion; Components: main\vehicles
  129. Source: "WW4_EXT_VEH\addons\*"; DestDir: "{code:getInstallPath|WW4_EXT_VEH\addons}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles
  130. Source: "WW4EXT_CW\addons\*"; DestDir: "{code:getInstallPath|WW4EXT_CW\addons}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar
  131. Source: "WW4EXT_CW\_docs\*"; DestDir: "{code:getInstallPath|WW4EXT_CW\_docs}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar
  132. Source: "WW4EXT_CW\_docs\WW4ExtendedColdWarv1.0-Readme.pdf"; DestDir: "{code:getInstallPath|WW4EXT_CW\_docs}"; Flags: ignoreversion isreadme; Components: main\vehicles\coldwar
  133. Source: "WW4EXT_CW\_missions\WW4EXT_Battlefields_v1.Eden.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended - Cold War}"; Flags: ignoreversion; Components: main\vehicles\coldwar
  134. Source: "WW4EXT_ARCTIC\addons\*"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar\arctic
  135. Source: "WW4EXT_ARCTIC\_docs\*"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\_docs}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar\arctic
  136. Source: "WW4EXT_ARCTIC\_docs\WW4ExtendedArcticv1.2-Readme.pdf"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\_docs}"; Flags: ignoreversion isreadme; Components: main\vehicles\coldwar\arctic
  137. Source: "WW4EXT_ARCTIC\_missions\KZO Rabbit Hunt\kzo_rabbithunt.kegnoecain_snow.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended - Arctic}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  138. Source: "WW4EXT_ARCTIC\_missions\ww4ext_arctic_01Recon_preview.KEGnoecain_snow.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended - Arctic}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  139. Source: "WinterNogojev11\Readme-Winter Nogojev.txt"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\_docs}"; Flags: ignoreversion isreadme; Components: main\vehicles\coldwar\arctic
  140. Source: "WinterNogojev11\kegnoecain_snow.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  141. Source: "WinterNogojev11\KEGepack_snow.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  142. Source: "WinterNogojev11\KEGnoecainS_anim\*"; DestDir: "{code:getInstallPath|AddOns\KEGnoecainS_anim}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar\arctic
  143. Source: "WinterNogojev11\KEGak103.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  144. Source: "WinterNogojev11\KEGak107.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  145. Source: "WinterNogojev11\KEGmakarov.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  146. Source: "WinterNogojev11\KEGrpg7.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  147. Source: "WinterNogojev11\KEGrpk47.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  148. Source: "WinterNogojev11\KEGrpk74.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
  149.  
  150. [Components]
  151. Name: "base"; Description: "WW4 mod 2.5.1"; Types: full custom compact; Flags: checkablealone
  152. Name: "main"; Description: "WW4 Extended Core (Infantry units)"; Types: full custom compact; Flags: fixed checkablealone dontinheritcheck
  153. Name: "main\vehicles"; Description: "WW4 Extended Vehicles"; Types: full custom; Flags: checkablealone
  154. Name: "main\vehicles\coldwar"; Description: "Cold War vehicles and infantry units"; Types: full custom; Flags: dontinheritcheck checkablealone
  155. Name: "main\vehicles\coldwar\arctic"; Description: "Arctic vehicles and infantry units (includes Kegetys' Winter Nogojev)"; Types: full custom; Flags: dontinheritcheck checkablealone
  156.  
  157. [Run]
  158. Filename: {code:getGamePath}; Parameters: {code:getLaunchedMods}; Flags: nowait postinstall skipifsilent unchecked; Description: "Launch WW4 Extended"
  159.  
  160. [UninstallDelete]
  161. Type: files; Name: "{app}\addons\ww4ext_inf_cfg.pbo.CWA"
  162. Type: dirifempty; Name: "{app}\*"
  163.  
  164. [Code]
  165. const
  166.   mrRepair = 100;
  167.   mrUninstall = 101;
  168.  
  169. var
  170.   InstPath: string;
  171.   aspectratioPageID: Integer;
  172.   Label1: TLabel;
  173.   radioButton_4_3: TRadioButton;
  174.   radioButton_5_4: TRadioButton;
  175.   radioButton_16_10: TRadioButton;
  176.   radioButton_16_9: TRadioButton;
  177.   radioButton_15_9: TRadioButton;
  178.   aspectratio_ProgressPage: TOutputProgressWizardPage;
  179.   aspectratio_started: Boolean;
  180.   aspectratioSelected: String;
  181.   fovTop: String;
  182.   fovLeft: String;
  183.   uiTopLeftX: String;
  184.   uiTopLeftY: String;
  185.   uiBottomRightX: String;
  186.   uiBottomRightY: String;
  187.   isSteam: boolean;
  188.  
  189. // Generate mod list based on the installed components
  190. function getLaunchedMods(Default: String): String;
  191. begin
  192.     Result := '-nosplash -mod=@ww4mod25;WW4_EXT';
  193.     if IsComponentSelected('main\vehicles') then
  194.         Result := Result + ';WW4_EXT_VEH';
  195.     if IsComponentSelected('main\vehicles\coldwar') then
  196.         Result := Result + ';WW4EXT_CW';
  197.     if IsComponentSelected('main\vehicles\coldwar\arctic') then
  198.         Result := Result + ';WW4EXT_ARCTIC';
  199. end;
  200.  
  201. // Check if the selected installation directory has a CWA or OFP game
  202. function isCWA: Boolean;
  203. begin
  204.     Result := false;
  205.     if FileExists(ExpandConstant(InstPath+'coldwarassault.exe')) then
  206.         Result := true;
  207. end;
  208.  
  209. // Generates an installation path based on the one selected by the user
  210. function getInstallPath(Append: String): String;
  211. begin
  212.     Result := InstPath + Append;
  213. end;
  214.  
  215. // Generates a path to the game based on if it's an OFP or CWA installation and the directory selected by the user
  216. function getGamePath(Default: String): String;
  217. begin
  218.     if isCWA then begin
  219.         Result := InstPath + 'coldwarassault.exe';
  220.     end else begin
  221.         Result := InstPath + 'FLASHPOINTRESISTANCE.exe';
  222.     end;
  223. end;
  224.  
  225. // Get Steam path
  226. function getSteamPath(Default: String): String;
  227. begin
  228.     Result := '';
  229.     if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam') then
  230.         RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam','InstallPath', Result);
  231. end;
  232.  
  233. // Check if the selected installation directory belongs to Steam
  234. function isSteamGame: Boolean;
  235. var steamPath: string;
  236. begin
  237.     Result := false;
  238.     if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam') then begin
  239.         steamPath := getSteamPath('');
  240.         if InstPath = (steamPath + '\steamapps\common\ARMA Cold War Assault\') then begin
  241.             Result := true;
  242.         end;
  243.     end;
  244. end;
  245.  
  246. // Get Steam game path
  247. function getGamePathSteam(Default: String): String;
  248. begin
  249.     Result := getSteamPath('') + '\Steam.exe';
  250. end;
  251.  
  252. // Return the result of the Steam check
  253. // This seems a bit convoluted (lots of similar checks), but Inno doesn't seem to create the shortcuts otherwise
  254. function returnSteamCheck: Boolean;
  255. begin
  256.     Result := isSteam;
  257. end;
  258.  
  259. // Copy OFP compatible inf_cfg.pbo if not CWA
  260. procedure copyOFPinfcfg();
  261. begin
  262.     if not isCWA then begin
  263.         RenameFile(ExpandConstant('{app}\addons\ww4ext_inf_cfg.pbo'),ExpandConstant('{app}\addons\ww4ext_inf_cfg.pbo.CWA'));
  264.         ExtractTemporaryFile('ww4ext_inf_cfg.pbo.OFP');
  265.         FileCopy(ExpandConstant('{tmp}\ww4ext_inf_cfg.pbo.OFP'),ExpandConstant('{app}\addons\ww4ext_inf_cfg.pbo'), false);
  266.     end;
  267. end;
  268.  
  269. // Manage next button click event
  270. function NextButtonClick(CurPageID: Integer): Boolean;
  271. begin
  272.   Result := True;
  273.     //MsgBox('Page is "' + IntToStr(CurPageID) + '"', mbInformation, MB_OK);
  274.     // Generate a new default install dir based on the installed games
  275.     if CurPageID = 1 then begin
  276.         WizardForm.DirEdit.Text := InstPath + '{#modDir}';
  277.     end;
  278.     // Warning if WW4 isn't installed and user doesn't want to install it
  279.     if CurPageID = wpSelectComponents then begin
  280.         if not DirExists(ExpandConstant(getInstallPath('@ww4mod25'))) and not isComponentSelected('base') then begin
  281.             MsgBox('WARNING: WW4 is required for WW4 Extended to work and currently it''s not installed. You might want to reconsider skipping its installation.', mbInformation, MB_OK);
  282.         end;
  283.     end;
  284.     if CurPageID = wpSelectProgramGroup then begin
  285.         isSteam := isSteamGame;
  286.     end;
  287. end;
  288.  
  289. // Aspect Ratio wizard page
  290. function aspectratio_NextButtonClick(CustomPage: TWizardPage): Boolean;
  291. begin
  292.   Result := True;
  293.     if (radioButton_4_3.Checked) then begin
  294.         aspectratioSelected := '4_3';
  295.         fovTop := '0.75';
  296.         fovLeft := '1';
  297.         uiTopLeftX := '0';
  298.         uiTopLeftY := '0';
  299.         uiBottomRightX := '1';
  300.         uiBottomRightY := '1';
  301.     end else if (radioButton_5_4.Checked) then begin
  302.         aspectratioSelected := '5_4';
  303.         fovTop := '0.8';
  304.         fovLeft := '1';
  305.         uiTopLeftX := '0';
  306.         uiTopLeftY := '0.033333';
  307.         uiBottomRightX := '1';
  308.         uiBottomRightY := '0.966667';
  309.     end else if (radioButton_16_10.Checked) then begin
  310.         aspectratioSelected := '16_10';
  311.         fovTop := '0.75';
  312.         fovLeft := '1.2';
  313.         uiTopLeftX := '0.083333';
  314.         uiTopLeftY := '0';
  315.         uiBottomRightX := '0.916667';
  316.         uiBottomRightY := '1';
  317.     end else if (radioButton_16_9.Checked) then begin
  318.         aspectratioSelected := '16_9';
  319.         fovTop := '0.75';
  320.         fovLeft := '1.333333';
  321.         uiTopLeftX := '0.125';
  322.         uiTopLeftY := '0';
  323.         uiBottomRightX := '0.875';
  324.         uiBottomRightY := '1';
  325.     end else if (radioButton_15_9.Checked) then begin
  326.         aspectratioSelected := '15_9';
  327.         fovTop := '0.8';
  328.         fovLeft := '1.333333';
  329.         uiTopLeftX := '0.125';
  330.         uiTopLeftY := '0.033333';
  331.         uiBottomRightX := '0.875';
  332.         uiBottomRightY := '0.966667';
  333.     end;
  334.     aspectratio_started := false;
  335.     //MsgBox('resolution is "' + aspectratioSelected + '"', mbInformation, MB_OK);
  336. end;
  337. function aspectratio_CreatePage(PreviousPageId: Integer): Integer;
  338. var
  339.   CustomPage: TWizardPage;
  340. begin
  341.   CustomPage := CreateCustomPage(
  342.     PreviousPageId,
  343.     ExpandConstant('{cm:aspectratio_header}'),
  344.     ExpandConstant('{cm:aspectratio_description}')
  345.   );
  346.  
  347.   Label1 := TLabel.Create(CustomPage);
  348.   with Label1 do
  349.   begin
  350.     Parent := CustomPage.Surface;
  351.     Caption := ExpandConstant('{cm:aspectratio_Label1}');
  352.     Left := ScaleX(0);
  353.     Top := ScaleY(24*0);
  354.     Width := ScaleX(300);
  355.     Height := ScaleY(17);
  356.   end;
  357.      
  358.   radioButton_4_3 := TRadioButton.Create(CustomPage);
  359.   with radioButton_4_3 do
  360.   begin
  361.     Parent := CustomPage.Surface;
  362.     Caption := ExpandConstant('{cm:aspectratio_4_3}');
  363.     Left := ScaleX(16);
  364.     Top := ScaleY(24*1);
  365.     Width := ScaleX(193);
  366.     Height := ScaleY(17);
  367.     TabOrder := 0;
  368.   end;
  369.      
  370.   radioButton_5_4 := TRadioButton.Create(CustomPage);
  371.   with radioButton_5_4 do
  372.   begin
  373.     Parent := CustomPage.Surface;
  374.     Caption := ExpandConstant('{cm:aspectratio_5_4}');
  375.     Left := ScaleX(16);
  376.     Top := ScaleY(24*2);
  377.     Width := ScaleX(193);
  378.     Height := ScaleY(17);
  379.     TabOrder := 1;
  380.   end;
  381.      
  382.   radioButton_16_10 := TRadioButton.Create(CustomPage);
  383.   with radioButton_16_10 do
  384.   begin
  385.     Parent := CustomPage.Surface;
  386.     Caption := ExpandConstant('{cm:aspectratio_16_10}');
  387.     Left := ScaleX(16);
  388.     Top := ScaleY(24*3);
  389.     Width := ScaleX(193);
  390.     Height := ScaleY(17);
  391.     TabOrder := 2;
  392.   end;
  393.      
  394.   radioButton_16_9 := TRadioButton.Create(CustomPage);
  395.   with radioButton_16_9 do
  396.   begin
  397.     Parent := CustomPage.Surface;
  398.     Caption := ExpandConstant('{cm:aspectratio_16_9}');
  399.     Left := ScaleX(16);
  400.     Top := ScaleY(24*4);
  401.     Width := ScaleX(225);
  402.     Height := ScaleY(17);
  403.     Checked := True;
  404.     TabOrder := 3;
  405.     TabStop := True;
  406.   end;
  407.      
  408.   radioButton_15_9 := TRadioButton.Create(CustomPage);
  409.   with radioButton_15_9 do
  410.   begin
  411.     Parent := CustomPage.Surface;
  412.     Caption := ExpandConstant('{cm:aspectratio_15_9}');
  413.     Left := ScaleX(16);
  414.     Top := ScaleY(24*5);
  415.     Width := ScaleX(225);
  416.     Height := ScaleY(17);
  417.     TabOrder := 4;
  418.   end;
  419.  
  420.   with CustomPage do
  421.   begin
  422.     OnNextButtonClick := @aspectratio_NextButtonClick;
  423.   end;
  424.    
  425.   // store your custom page ID to further use in the ShouldSkipPage event
  426.   aspectratioPageID := CustomPage.ID;
  427.     Result := aspectratioPageID;
  428. end;
  429.  
  430. // Custom wizard pages
  431. procedure InitializeWizard();
  432. begin
  433.     aspectratio_CreatePage(wpSelectTasks);
  434.     aspectratio_ProgressPage := CreateOutputProgressPage('OFP Aspect Ratio Fix','Applying OFP Aspect Ratio fix');
  435. end;
  436.  
  437. // Replace value on files
  438. function ReplaceValue(const FileName, TagName, TagValue: string; ReplaceAll: boolean): Boolean;
  439. var
  440.   I: Integer;
  441.   Line: string;
  442.   TagPos: Integer;
  443.   FileLines: TStringList;
  444. begin
  445.   Result := False;
  446.   FileLines := TStringList.Create;
  447.   try
  448.     FileLines.LoadFromFile(FileName);
  449.     for I := 0 to FileLines.Count - 1 do
  450.     begin
  451.       Line := FileLines[I];
  452.       TagPos := Pos(TagName, Line);
  453.       if TagPos > 0 then
  454.       begin
  455.         Result := True;
  456.           if ReplaceAll then begin
  457.                 Delete(Line, TagPos, MaxInt);
  458.                 Line := Line + TagValue;
  459.             end else begin
  460.                 Delete(Line, TagPos + Length(TagName), MaxInt);
  461.                 Line := Line + '=' + TagValue + ';';
  462.             end;
  463.         FileLines[I] := Line;
  464.         FileLines.SaveToFile(FileName);
  465.         Break;
  466.       end;
  467.     end;
  468.   finally
  469.     FileLines.Free;
  470.   end;
  471. end;
  472.  
  473. // Fills the "subDirs" TStrings with the subdirectories of the "directory" directory
  474. procedure GetSubDirectories(const Directory: string; subDirs: TStrings);
  475. var
  476.   FindRec: TFindRec;
  477. begin
  478.   subDirs.Clear;
  479.   if FindFirst(ExpandConstant(Directory + '*'), FindRec) then
  480.   try
  481.     repeat
  482.         if (FindRec.Name <> '.') AND (FindRec.Name <> '..') then
  483.             if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY > 0 then
  484.             subDirs.Add(FindRec.Name);
  485.     until
  486.       not FindNext(FindRec);
  487.   finally
  488.     FindClose(FindRec);
  489.   end;
  490. end;
  491.  
  492. // Manage page change event
  493. procedure CurPageChanged(CurPageID: Integer);
  494. var
  495.   i: Integer;
  496.   subDirsList: TStringList;
  497.   cfgFile: String;
  498. begin
  499.     //MsgBox('Page is "' + IntToStr(CurPageID) + '"', mbInformation, MB_OK);
  500.     if CurPageID = wpFinished then
  501.         begin
  502.         // Apply aspect ratio fix
  503.         // Note that while I apply it after the installation is done, this could have been done after installing the config via an AfterInstall procedure in the bin directory
  504.         if (IsTaskSelected('aspectratio') and not aspectratio_started) then
  505.             begin
  506.             aspectratio_started := true;
  507.             aspectratio_ProgressPage.SetText('Searching for user folders...', '');
  508.             aspectratio_ProgressPage.SetProgress(0, 0);
  509.             aspectratio_ProgressPage.Show;
  510.             // Replace values in each user's UserInfo.cfg
  511.             subDirsList := TStringList.Create;
  512.             try
  513.                 GetSubDirectories(ExpandConstant(InstPath + 'users\'), subDirsList);
  514.                 //MsgBox('subDirs: "' + subDirsList.CommaText + '"', mbInformation, MB_OK);
  515.                 aspectratio_ProgressPage.SetText('Updating UserInfo.cfg values...', '');
  516.                 for i := 0 to subDirsList.Count - 1 do
  517.                 begin
  518.                     aspectratio_ProgressPage.SetProgress(i, 0);
  519.                     cfgFile := ExpandConstant(InstPath + 'users\'+ subDirsList[i] + '\UserInfo.cfg');
  520.                     if FileExists(cfgFile) then
  521.                     begin
  522.                         // Replace values
  523.                         ReplaceValue(cfgFile, 'fovTop', fovTop, false);
  524.                         ReplaceValue(cfgFile, 'fovLeft', fovLeft, false);
  525.                         ReplaceValue(cfgFile, 'uiTopLeftX', uiTopLeftX, false);
  526.                         ReplaceValue(cfgFile, 'uiTopLeftY', uiTopLeftY, false);
  527.                         ReplaceValue(cfgFile, 'uiBottomRightX', uiBottomRightX, false);
  528.                         ReplaceValue(cfgFile, 'uiBottomRightY', uiBottomRightY, false);
  529.                     end;
  530.                 end;
  531.             finally
  532.                 subDirsList.Free;
  533.             end;
  534.             // Copy Aspect_Ratio.hpp
  535.             aspectratio_ProgressPage.SetText('Copying Aspect_Ratio.hpp...', '');
  536.             aspectratio_ProgressPage.SetProgress(20, 0);
  537.             FileCopy(ExpandConstant('{app}\ofpaspectratiofix\Aspect_Ratio.hpp'),ExpandConstant(InstPath + 'Aspect_Ratio.hpp'), false);
  538.             // Apply selected ratio to Aspect_Ratio.hpp
  539.             aspectratio_ProgressPage.SetText('Applying aspect ratio...', '');
  540.             aspectratio_ProgressPage.SetProgress(50, 0);
  541.             ReplaceValue(ExpandConstant(InstPath + 'Aspect_Ratio.hpp'), '#define aspect_ratio_', ExpandConstant('#define aspect_ratio_' + aspectratioSelected), true);
  542.             // Copy fixed WW4 config
  543.             aspectratio_ProgressPage.SetText('Copying fixed WW4 config...', '');
  544.             aspectratio_ProgressPage.SetProgress(80, 0);
  545.             // Choose the correct config: radio or no radio
  546.             if isTaskSelected('enableradio') then begin
  547.                 cfgFile := ExpandConstant('{app}\ofpaspectratiofix\Config_radio.cpp');
  548.             end else begin
  549.                 cfgFile := ExpandConstant('{app}\ofpaspectratiofix\Config_noradio.cpp');
  550.             end;
  551.             FileCopy(ExpandConstant(cfgFile),ExpandConstant(getInstallPath('@ww4mod25\bin\Config.cpp')), false);
  552.             // Copy fixed WW4 resource
  553.             aspectratio_ProgressPage.SetText('Copying fixed WW4 resource...', '');
  554.             aspectratio_ProgressPage.SetProgress(80, 0);
  555.             FileCopy(ExpandConstant('{app}\ofpaspectratiofix\Resource.cpp'),ExpandConstant(getInstallPath('@ww4mod25\bin\Resource.cpp')), false);
  556.            
  557.             aspectratio_ProgressPage.SetProgress(100, 0);
  558.             aspectratio_ProgressPage.Hide;
  559.         end;
  560.     end;
  561. end;
  562.  
  563. // Manage skippable pages
  564. function ShouldSkipPage(PageID: Integer): Boolean;
  565. begin
  566.   Result := False;
  567.   if PageID = aspectratioPageID then
  568.     // Skip the page if aspectratio wasn't checked
  569.     Result := not IsTaskSelected('aspectratio');
  570. end;
  571.  
  572. // Repair or uninstall if the mod was already installed
  573. function ShowOptionsForm: TModalResult;
  574. var
  575.   OptionsForm: TSetupForm;
  576.   RepairButton: TNewButton;
  577.   UninstallButton: TNewButton;
  578. begin
  579.   Result := mrNone;
  580.   OptionsForm := CreateCustomForm;
  581.   try
  582.     OptionsForm.Width := 220;
  583.     OptionsForm.Caption := ExpandConstant('{cm:OptionsFormCaption}');
  584.     OptionsForm.Position := poScreenCenter;
  585.  
  586.     RepairButton := TNewButton.Create(OptionsForm);
  587.     RepairButton.Parent := OptionsForm;
  588.     RepairButton.Left := 8;
  589.     RepairButton.Top := 8;
  590.     RepairButton.Width := OptionsForm.ClientWidth - 16;
  591.     RepairButton.Caption := ExpandConstant('{cm:RepairButtonCaption}');
  592.     RepairButton.ModalResult := mrRepair;
  593.  
  594.     UninstallButton := TNewButton.Create(OptionsForm);
  595.     UninstallButton.Parent := OptionsForm;
  596.     UninstallButton.Left := 8;
  597.     UninstallButton.Top := RepairButton.Top + RepairButton.Height + 8;
  598.     UninstallButton.Width := OptionsForm.ClientWidth - 16;
  599.     UninstallButton.Caption := ExpandConstant('{cm:UninstallButtonCaption}');
  600.     UninstallButton.ModalResult := mrUninstall;
  601.  
  602.     OptionsForm.ClientHeight := RepairButton.Height + UninstallButton.Height + 24;
  603.     Result := OptionsForm.ShowModal;
  604.   finally
  605.     OptionsForm.Free;
  606.   end;
  607. end;
  608.  
  609. function GetUninstallerPath: string;
  610. var
  611.   RegKey: string;
  612. begin
  613.   Result := '';
  614.   RegKey := Format('%s\%s_is1', ['Software\Microsoft\Windows\CurrentVersion\Uninstall',
  615.     '{#emit SetupSetting("AppId")}']);
  616.   if not RegQueryStringValue(HKEY_LOCAL_MACHINE, RegKey, 'UninstallString', Result) then
  617.     RegQueryStringValue(HKEY_CURRENT_USER, RegKey, 'UninstallString', Result);
  618. end;
  619.  
  620. function InitializeSetup: Boolean;
  621. var
  622.   regPath: string;
  623.   UninstPath: string;
  624.   ResultCode: Integer;  
  625. begin
  626.   Result := True;
  627.   // Set default directory based on reg (OFP or CWA). CWA takes precedence over OFP
  628.   if RegQueryStringValue(HKLM, 'SOFTWARE\Codemasters\Operation Flashpoint', 'MAIN', regPath) then
  629.     InstPath := regPath + '\';
  630.   if RegQueryStringValue(HKLM, 'SOFTWARE\bohemia interactive studio\coldwarassault', 'MAIN', regPath) then
  631.     InstPath := regPath + '\';
  632.   if RegQueryStringValue(HKLM, 'SOFTWARE\WOW6432Node\bohemia interactive studio\coldwarassault', 'MAIN', regPath) then
  633.     InstPath := regPath + '\';
  634.  
  635.   // Get Uninstall path
  636.   UninstPath := RemoveQuotes(GetUninstallerPath);
  637.   if UninstPath <> '' then
  638.   begin
  639.     case ShowOptionsForm of
  640.       mrRepair: Result := True;
  641.       mrUninstall:
  642.       begin
  643.         Result := False;
  644.         if not Exec(UninstPath, '', '', SW_SHOW, ewNoWait, ResultCode) then
  645.           MsgBox(FmtMessage(SetupMessage(msgUninstallOpenError), [UninstPath]), mbError, MB_OK);
  646.       end;
  647.     else
  648.       Result := False;
  649.     end;
  650.   end;
  651. end;
Add Comment
Please, Sign In to add comment