Advertisement
kenoxite

WW4_EXT_patch_v1031_installer.iss

Jun 13th, 2015
55
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 Patch"
  5. #define MyAppVersion "1.0.3.1"
  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 Patch v1.0.3.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. WizardImageFile=userdocs:Installer WW4_EXT patch 1031\EXTinstallerimg1.bmp
  35. WizardSmallImageFile=userdocs:Installer WW4_EXT patch 1031\EXTinstallersmallimg1.bmp
  36. DisableReadyPage=True
  37. Uninstallable=True
  38. CreateUninstallRegKey=false
  39. UpdateUninstallLogAppName=false
  40.  
  41. [Messages]
  42. WelcomeLabel2=This program will install the v1.0.3.1 patch for WW4 Extended.
  43.  
  44. [CustomMessages]
  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: "aspectratio"; Description: "Apply aspect ratio fix (with new tank layout position)"; GroupDescription: "Widescreen resolution compatibility for WW4:"; Check: dirExistsCheck ('@ww4mod25');
  84. Name: "cloudlets"; Description: "Use performance friendly dust and smoke particles"; GroupDescription: "You can use the WGL cloudlets definitions to increase performance:"; Check: dirExistsCheck ('@ww4mod25');
  85. 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; Check: dirExistsCheck ('@ww4mod25');
  86.  
  87. [Files]
  88. Source: "ofpaspectratiofix\*"; DestDir: "{app}\ofpaspectratiofix"; Flags: ignoreversion createallsubdirs recursesubdirs deleteafterinstall; Check: dirExistsCheck ('@ww4mod25');
  89. Source: "WW4 cloudlets\WW4_cloudlets.hpp"; DestDir: "{code:getInstallPath|@ww4mod25\bin}"; DestName: "cloudlets.hpp"; Flags: ignoreversion; Check: dirExistsCheck ('@ww4mod25');
  90. Source: "WW4 cloudlets\WGL_cloudlets.hpp"; DestDir: "{code:getInstallPath|@ww4mod25\bin}"; DestName: "cloudlets.hpp"; Flags: ignoreversion; Tasks: cloudlets; Check: dirExistsCheck ('@ww4mod25');
  91. Source: "WW4_EXT\addons\*"; DestDir: "{app}\addons"; Flags: ignoreversion createallsubdirs recursesubdirs; AfterInstall: copyOFPinfcfg
  92. Source: "WW4_EXT\_docs\*"; DestDir: "{app}\_docs"; Flags: ignoreversion createallsubdirs recursesubdirs;
  93. Source: "v196_patch\ww4ext_inf_cfg.pbo.OFP"; DestDir: "{app}"; Flags: ignoreversion dontcopy
  94. Source: "WW4_EXT\_docs\WW4Extended-Changelog.pdf"; DestDir: "{app}\_docs"; Flags: ignoreversion isreadme;
  95. Source: "WW4_EXT_VEH\addons\*"; DestDir: "{code:getInstallPath|WW4_EXT_VEH\addons}"; Flags: ignoreversion createallsubdirs recursesubdirs; Check: dirExistsCheck ('WW4_EXT_VEH');
  96.  
  97. [Code]  
  98. var
  99.  InstPath: string;
  100.  aspectratioPageID: Integer;
  101.  Label1: TLabel;
  102.  radioButton_4_3: TRadioButton;
  103.  radioButton_5_4: TRadioButton;
  104.  radioButton_16_10: TRadioButton;
  105.  radioButton_16_9: TRadioButton;
  106.  radioButton_15_9: TRadioButton;
  107.  aspectratio_ProgressPage: TOutputProgressWizardPage;
  108.  aspectratio_started: Boolean;
  109.  aspectratioSelected: String;
  110.  fovTop: String;
  111.  fovLeft: String;
  112.  uiTopLeftX: String;
  113.  uiTopLeftY: String;
  114.  uiBottomRightX: String;
  115.  uiBottomRightY: String;
  116.  isSteam: boolean;
  117.  
  118. // Generate mod list based on the installed components
  119. function getLaunchedMods(Default: String): String;
  120. begin
  121.     Result := '-nosplash -mod=@ww4mod25;WW4_EXT';
  122.     if IsComponentSelected('main\vehicles') then
  123.         Result := Result + ';WW4_EXT_VEH';
  124.     if IsComponentSelected('main\vehicles\coldwar') then
  125.         Result := Result + ';WW4EXT_CW';
  126.     if IsComponentSelected('main\vehicles\coldwar\arctic') then
  127.         Result := Result + ';WW4EXT_ARCTIC';
  128. end;
  129.  
  130. // Check if the selected installation directory has a CWA or OFP game
  131. function isCWA: Boolean;
  132. begin
  133.     Result := false;
  134.     if FileExists(ExpandConstant(InstPath+'coldwarassault.exe')) then
  135.         Result := true;
  136. end;
  137.  
  138. // Generates an installation path based on the one selected by the user
  139. function getInstallPath(Append: String): String;
  140. begin
  141.     Result := InstPath + Append;
  142. end;
  143.  
  144. // Check if dir exists in the OFP/CWA root directory
  145. function dirExistsCheck(dir: String): Boolean;
  146. begin
  147.     Result := false;
  148.     if DirExists(getInstallPath(dir)) then begin
  149.         Result := true;
  150.     end;
  151. end;
  152.  
  153. // Generates a path to the game based on if it's an OFP or CWA installation and the directory selected by the user
  154. function getGamePath(Default: String): String;
  155. begin
  156.     if isCWA then begin
  157.         Result := InstPath + 'coldwarassault.exe';
  158.     end else begin
  159.         Result := InstPath + 'FLASHPOINTRESISTANCE.exe';
  160.     end;
  161. end;
  162.  
  163. // Get Steam path
  164. function getSteamPath(Default: String): String;
  165. begin
  166.     Result := '';
  167.     if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam') then
  168.         RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam','InstallPath', Result);
  169. end;
  170.  
  171. // Check if the selected installation directory belongs to Steam
  172. function isSteamGame: Boolean;
  173. var steamPath: string;
  174. begin
  175.     Result := false;
  176.     if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam') then begin
  177.         steamPath := getSteamPath('');
  178.         if InstPath = (steamPath + '\steamapps\common\ARMA Cold War Assault\') then begin
  179.             Result := true;
  180.         end;
  181.     end;
  182. end;
  183.  
  184. // Get Steam game path
  185. function getGamePathSteam(Default: String): String;
  186. begin
  187.     Result := getSteamPath('') + '\Steam.exe';
  188. end;
  189.  
  190. // Return the result of the Steam check
  191. // This seems a bit convoluted (lots of similar checks), but Inno doesn't seem to create the shortcuts otherwise
  192. function returnSteamCheck: Boolean;
  193. begin
  194.     Result := isSteam;
  195. end;
  196.  
  197. // Copy OFP compatible inf_cfg.pbo if not CWA
  198. procedure copyOFPinfcfg();
  199. begin
  200.     if not isCWA then begin
  201.         RenameFile(ExpandConstant('{app}\addons\ww4ext_inf_cfg.pbo'),ExpandConstant('{app}\addons\ww4ext_inf_cfg.pbo.CWA'));
  202.         ExtractTemporaryFile('ww4ext_inf_cfg.pbo.OFP');
  203.         FileCopy(ExpandConstant('{tmp}\ww4ext_inf_cfg.pbo.OFP'),ExpandConstant('{app}\addons\ww4ext_inf_cfg.pbo'), false);
  204.     end;
  205. end;
  206.  
  207. // Manage next button click event
  208. function NextButtonClick(CurPageID: Integer): Boolean;
  209. begin
  210.   Result := True;
  211.     //MsgBox('Page is "' + IntToStr(CurPageID) + '"', mbInformation, MB_OK);
  212.     // Generate a new default install dir based on the installed games
  213.     if CurPageID = 1 then begin
  214.         WizardForm.DirEdit.Text := InstPath + '{#modDir}';
  215.     end;
  216.     // Warning if WW4 isn't installed and user doesn't want to install it
  217.     if CurPageID = wpSelectComponents then begin
  218.         if not DirExists(ExpandConstant(getInstallPath('@ww4mod25'))) and not isComponentSelected('base') then begin
  219.             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);
  220.         end;
  221.     end;
  222.     if CurPageID = wpSelectProgramGroup then begin
  223.         isSteam := isSteamGame;
  224.     end;
  225. end;
  226.  
  227. // Aspect Ratio wizard page
  228. function aspectratio_NextButtonClick(CustomPage: TWizardPage): Boolean;
  229. begin
  230.   Result := True;
  231.     if (radioButton_4_3.Checked) then begin
  232.         aspectratioSelected := '4_3';
  233.         fovTop := '0.75';
  234.         fovLeft := '1';
  235.         uiTopLeftX := '0';
  236.         uiTopLeftY := '0';
  237.         uiBottomRightX := '1';
  238.         uiBottomRightY := '1';
  239.     end else if (radioButton_5_4.Checked) then begin
  240.         aspectratioSelected := '5_4';
  241.         fovTop := '0.8';
  242.         fovLeft := '1';
  243.         uiTopLeftX := '0';
  244.         uiTopLeftY := '0.033333';
  245.         uiBottomRightX := '1';
  246.         uiBottomRightY := '0.966667';
  247.     end else if (radioButton_16_10.Checked) then begin
  248.         aspectratioSelected := '16_10';
  249.         fovTop := '0.75';
  250.         fovLeft := '1.2';
  251.         uiTopLeftX := '0.083333';
  252.         uiTopLeftY := '0';
  253.         uiBottomRightX := '0.916667';
  254.         uiBottomRightY := '1';
  255.     end else if (radioButton_16_9.Checked) then begin
  256.         aspectratioSelected := '16_9';
  257.         fovTop := '0.75';
  258.         fovLeft := '1.333333';
  259.         uiTopLeftX := '0.125';
  260.         uiTopLeftY := '0';
  261.         uiBottomRightX := '0.875';
  262.         uiBottomRightY := '1';
  263.     end else if (radioButton_15_9.Checked) then begin
  264.         aspectratioSelected := '15_9';
  265.         fovTop := '0.8';
  266.         fovLeft := '1.333333';
  267.         uiTopLeftX := '0.125';
  268.         uiTopLeftY := '0.033333';
  269.         uiBottomRightX := '0.875';
  270.         uiBottomRightY := '0.966667';
  271.     end;
  272.     aspectratio_started := false;
  273.     //MsgBox('resolution is "' + aspectratioSelected + '"', mbInformation, MB_OK);
  274. end;
  275. function aspectratio_CreatePage(PreviousPageId: Integer): Integer;
  276. var
  277.   CustomPage: TWizardPage;
  278. begin
  279.   CustomPage := CreateCustomPage(
  280.     PreviousPageId,
  281.     ExpandConstant('{cm:aspectratio_header}'),
  282.     ExpandConstant('{cm:aspectratio_description}')
  283.   );
  284.  
  285.   Label1 := TLabel.Create(CustomPage);
  286.   with Label1 do
  287.   begin
  288.     Parent := CustomPage.Surface;
  289.     Caption := ExpandConstant('{cm:aspectratio_Label1}');
  290.     Left := ScaleX(0);
  291.     Top := ScaleY(24*0);
  292.     Width := ScaleX(300);
  293.     Height := ScaleY(17);
  294.   end;
  295.      
  296.   radioButton_4_3 := TRadioButton.Create(CustomPage);
  297.   with radioButton_4_3 do
  298.   begin
  299.     Parent := CustomPage.Surface;
  300.     Caption := ExpandConstant('{cm:aspectratio_4_3}');
  301.     Left := ScaleX(16);
  302.     Top := ScaleY(24*1);
  303.     Width := ScaleX(193);
  304.     Height := ScaleY(17);
  305.     TabOrder := 0;
  306.   end;
  307.      
  308.   radioButton_5_4 := TRadioButton.Create(CustomPage);
  309.   with radioButton_5_4 do
  310.   begin
  311.     Parent := CustomPage.Surface;
  312.     Caption := ExpandConstant('{cm:aspectratio_5_4}');
  313.     Left := ScaleX(16);
  314.     Top := ScaleY(24*2);
  315.     Width := ScaleX(193);
  316.     Height := ScaleY(17);
  317.     TabOrder := 1;
  318.   end;
  319.      
  320.   radioButton_16_10 := TRadioButton.Create(CustomPage);
  321.   with radioButton_16_10 do
  322.   begin
  323.     Parent := CustomPage.Surface;
  324.     Caption := ExpandConstant('{cm:aspectratio_16_10}');
  325.     Left := ScaleX(16);
  326.     Top := ScaleY(24*3);
  327.     Width := ScaleX(193);
  328.     Height := ScaleY(17);
  329.     TabOrder := 2;
  330.   end;
  331.      
  332.   radioButton_16_9 := TRadioButton.Create(CustomPage);
  333.   with radioButton_16_9 do
  334.   begin
  335.     Parent := CustomPage.Surface;
  336.     Caption := ExpandConstant('{cm:aspectratio_16_9}');
  337.     Left := ScaleX(16);
  338.     Top := ScaleY(24*4);
  339.     Width := ScaleX(225);
  340.     Height := ScaleY(17);
  341.     Checked := True;
  342.     TabOrder := 3;
  343.     TabStop := True;
  344.   end;
  345.      
  346.   radioButton_15_9 := TRadioButton.Create(CustomPage);
  347.   with radioButton_15_9 do
  348.   begin
  349.     Parent := CustomPage.Surface;
  350.     Caption := ExpandConstant('{cm:aspectratio_15_9}');
  351.     Left := ScaleX(16);
  352.     Top := ScaleY(24*5);
  353.     Width := ScaleX(225);
  354.     Height := ScaleY(17);
  355.     TabOrder := 4;
  356.   end;
  357.  
  358.   with CustomPage do
  359.   begin
  360.     OnNextButtonClick := @aspectratio_NextButtonClick;
  361.   end;
  362.    
  363.   // store your custom page ID to further use in the ShouldSkipPage event
  364.   aspectratioPageID := CustomPage.ID;
  365.     Result := aspectratioPageID;
  366. end;
  367.  
  368. // Custom wizard pages
  369. procedure InitializeWizard();
  370. begin
  371.     aspectratio_CreatePage(wpSelectTasks);
  372.     aspectratio_ProgressPage := CreateOutputProgressPage('OFP Aspect Ratio Fix','Applying OFP Aspect Ratio fix');
  373. end;
  374.  
  375. // Replace value on files
  376. function ReplaceValue(const FileName, TagName, TagValue: string; ReplaceAll: boolean): Boolean;
  377. var
  378.   I: Integer;
  379.   Line: string;
  380.   TagPos: Integer;
  381.   FileLines: TStringList;
  382. begin
  383.   Result := False;
  384.   FileLines := TStringList.Create;
  385.   try
  386.     FileLines.LoadFromFile(FileName);
  387.     for I := 0 to FileLines.Count - 1 do
  388.     begin
  389.       Line := FileLines[I];
  390.       TagPos := Pos(TagName, Line);
  391.       if TagPos > 0 then
  392.       begin
  393.         Result := True;
  394.           if ReplaceAll then begin
  395.                 Delete(Line, TagPos, MaxInt);
  396.                 Line := Line + TagValue;
  397.             end else begin
  398.                 Delete(Line, TagPos + Length(TagName), MaxInt);
  399.                 Line := Line + '=' + TagValue + ';';
  400.             end;
  401.         FileLines[I] := Line;
  402.         FileLines.SaveToFile(FileName);
  403.         Break;
  404.       end;
  405.     end;
  406.   finally
  407.     FileLines.Free;
  408.   end;
  409. end;
  410.  
  411. // Fills the "subDirs" TStrings with the subdirectories of the "directory" directory
  412. procedure GetSubDirectories(const Directory: string; subDirs: TStrings);
  413. var
  414.   FindRec: TFindRec;
  415. begin
  416.   subDirs.Clear;
  417.   if FindFirst(ExpandConstant(Directory + '*'), FindRec) then
  418.   try
  419.     repeat
  420.         if (FindRec.Name <> '.') AND (FindRec.Name <> '..') then
  421.             if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY > 0 then
  422.             subDirs.Add(FindRec.Name);
  423.     until
  424.       not FindNext(FindRec);
  425.   finally
  426.     FindClose(FindRec);
  427.   end;
  428. end;
  429.  
  430. // Manage page change event
  431. procedure CurPageChanged(CurPageID: Integer);
  432. var
  433.   i: Integer;
  434.   subDirsList: TStringList;
  435.   cfgFile: String;
  436. begin
  437.     //MsgBox('Page is "' + IntToStr(CurPageID) + '"', mbInformation, MB_OK);
  438.     if CurPageID = wpFinished then
  439.         begin
  440.         // Apply aspect ratio fix
  441.         // 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
  442.         if (IsTaskSelected('aspectratio') and not aspectratio_started) then
  443.             begin
  444.             aspectratio_started := true;
  445.             aspectratio_ProgressPage.SetText('Searching for user folders...', '');
  446.             aspectratio_ProgressPage.SetProgress(0, 0);
  447.             aspectratio_ProgressPage.Show;
  448.             // Replace values in each user's UserInfo.cfg
  449.             subDirsList := TStringList.Create;
  450.             try
  451.                 GetSubDirectories(ExpandConstant(InstPath + 'users\'), subDirsList);
  452.                 //MsgBox('subDirs: "' + subDirsList.CommaText + '"', mbInformation, MB_OK);
  453.                 aspectratio_ProgressPage.SetText('Updating UserInfo.cfg values...', '');
  454.                 for i := 0 to subDirsList.Count - 1 do
  455.                 begin
  456.                     aspectratio_ProgressPage.SetProgress(i, 0);
  457.                     cfgFile := ExpandConstant(InstPath + 'users\'+ subDirsList[i] + '\UserInfo.cfg');
  458.                     if FileExists(cfgFile) then
  459.                     begin
  460.                         // Replace values
  461.                         ReplaceValue(cfgFile, 'fovTop', fovTop, false);
  462.                         ReplaceValue(cfgFile, 'fovLeft', fovLeft, false);
  463.                         ReplaceValue(cfgFile, 'uiTopLeftX', uiTopLeftX, false);
  464.                         ReplaceValue(cfgFile, 'uiTopLeftY', uiTopLeftY, false);
  465.                         ReplaceValue(cfgFile, 'uiBottomRightX', uiBottomRightX, false);
  466.                         ReplaceValue(cfgFile, 'uiBottomRightY', uiBottomRightY, false);
  467.                     end;
  468.                 end;
  469.             finally
  470.                 subDirsList.Free;
  471.             end;
  472.             // Copy Aspect_Ratio.hpp
  473.             aspectratio_ProgressPage.SetText('Copying Aspect_Ratio.hpp...', '');
  474.             aspectratio_ProgressPage.SetProgress(20, 0);
  475.             FileCopy(ExpandConstant('{app}\ofpaspectratiofix\Aspect_Ratio.hpp'),ExpandConstant(InstPath + 'Aspect_Ratio.hpp'), false);
  476.             // Apply selected ratio to Aspect_Ratio.hpp
  477.             aspectratio_ProgressPage.SetText('Applying aspect ratio...', '');
  478.             aspectratio_ProgressPage.SetProgress(50, 0);
  479.             ReplaceValue(ExpandConstant(InstPath + 'Aspect_Ratio.hpp'), '#define aspect_ratio_', ExpandConstant('#define aspect_ratio_' + aspectratioSelected), true);
  480.             // Copy fixed WW4 config
  481.             aspectratio_ProgressPage.SetText('Copying fixed WW4 config...', '');
  482.             aspectratio_ProgressPage.SetProgress(80, 0);
  483.             // Choose the correct config: radio or no radio
  484.             if isTaskSelected('enableradio') then begin
  485.                 cfgFile := ExpandConstant('{app}\ofpaspectratiofix\Config_radio.cpp');
  486.             end else begin
  487.                 cfgFile := ExpandConstant('{app}\ofpaspectratiofix\Config_noradio.cpp');
  488.             end;
  489.             FileCopy(ExpandConstant(cfgFile),ExpandConstant(getInstallPath('@ww4mod25\bin\Config.cpp')), false);
  490.             // Copy fixed WW4 resource
  491.             aspectratio_ProgressPage.SetText('Copying fixed WW4 resource...', '');
  492.             aspectratio_ProgressPage.SetProgress(80, 0);
  493.             FileCopy(ExpandConstant('{app}\ofpaspectratiofix\Resource.cpp'),ExpandConstant(getInstallPath('@ww4mod25\bin\Resource.cpp')), false);
  494.            
  495.             aspectratio_ProgressPage.SetProgress(100, 0);
  496.             aspectratio_ProgressPage.Hide;
  497.         end;
  498.     end;
  499. end;
  500.  
  501. // Manage skippable pages
  502. function ShouldSkipPage(PageID: Integer): Boolean;
  503. begin
  504.   Result := False;
  505.   if PageID = aspectratioPageID then
  506.     // Skip the page if aspectratio wasn't checked
  507.     Result := not IsTaskSelected('aspectratio');
  508. end;
  509.  
  510. function InitializeSetup: Boolean;
  511. var
  512.   regPath: string;
  513.   UninstPath: string;
  514.   ResultCode: Integer;  
  515. begin
  516.   Result := True;
  517.   // Set default directory based on reg (OFP or CWA). CWA takes precedence over OFP
  518.   if RegQueryStringValue(HKLM, 'SOFTWARE\Codemasters\Operation Flashpoint', 'MAIN', regPath) then
  519.     InstPath := regPath + '\';
  520.   if RegQueryStringValue(HKLM, 'SOFTWARE\bohemia interactive studio\coldwarassault', 'MAIN', regPath) then
  521.     InstPath := regPath + '\';
  522.   if RegQueryStringValue(HKLM, 'SOFTWARE\WOW6432Node\bohemia interactive studio\coldwarassault', 'MAIN', regPath) then
  523.     InstPath := regPath + '\';
  524. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement