Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Script generated by the Inno Script Studio Wizard.
- ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
- #define MyAppName "WW4 Extended"
- #define MyAppVersion "1.0.3"
- #define MyAppPublisher "kenoxite"
- #define MyAppURL "http://forums.bistudio.com/showthread.php?154829"
- #define MyGroupName "OFP & CWA mods/WW4 Extended"
- #define modDir "WW4_EXT"
- [Setup]
- ; NOTE: The value of AppId uniquely identifies this application.
- ; Do not use the same AppId value in installers for other applications.
- ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
- AppId=E97A55E2-8D25-4BD9-A863-AC726887B9C3
- AppName={#MyAppName}
- AppVersion={#MyAppVersion}
- ;AppVerName={#MyAppName} {#MyAppVersion}
- AppPublisher={#MyAppPublisher}
- AppPublisherURL={#MyAppURL}
- AppSupportURL={#MyAppURL}
- AppUpdatesURL={#MyAppURL}
- DefaultDirName={#modDir}
- OutputBaseFilename=WW4 Extended v1.0.3 Setup
- SolidCompression=yes
- OutputDir=C:\Users\Usuario\Documents
- DisableDirPage=auto
- DisableReadyMemo=True
- UsePreviousGroup=False
- AllowNoIcons=True
- AlwaysUsePersonalGroup=True
- DefaultGroupName={#MyGroupName}
- DisableWelcomePage=false
- WizardImageFile=userdocs:Installer_WW4_EXT\EXTinstallerimg1.bmp
- WizardSmallImageFile=userdocs:Installer_WW4_EXT\EXTinstallersmallimg1.bmp
- DisableReadyPage=True
- [Messages]
- 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.
- [CustomMessages]
- OptionsFormCaption=WW4 Extended installed already...
- RepairButtonCaption=Repair
- UninstallButtonCaption=Uninstall
- aspectratio_header=OFP Aspect Ratio Fix for WW4 mod
- aspectratio_description=Here you can make WW4 mod compatible with widescreen resolutions
- aspectratio_Label1=Select your screen's aspect ratio:
- aspectratio_4_3=4:3
- aspectratio_5_4=5:4
- aspectratio_16_10=16:10
- aspectratio_16_9=16:9
- aspectratio_15_9=15:9
- [Languages]
- Name: "english"; MessagesFile: "compiler:Default.isl"
- Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
- Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
- Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
- Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
- Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
- Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
- Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
- Name: "french"; MessagesFile: "compiler:Languages\French.isl"
- Name: "german"; MessagesFile: "compiler:Languages\German.isl"
- Name: "greek"; MessagesFile: "compiler:Languages\Greek.isl"
- Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
- Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
- Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
- Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
- Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
- Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
- Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
- Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
- Name: "scottishgaelic"; MessagesFile: "compiler:Languages\ScottishGaelic.isl"
- Name: "serbiancyrillic"; MessagesFile: "compiler:Languages\SerbianCyrillic.isl"
- Name: "serbianlatin"; MessagesFile: "compiler:Languages\SerbianLatin.isl"
- Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
- Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
- Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
- Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
- [Tasks]
- Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
- Name: "lowcontrast"; Description: "Install low contrast materials"; GroupDescription: "The low contrast version is more visually compatible with dynamically spawned units:"; Flags: unchecked
- Name: "aspectratio"; Description: "Apply aspect ratio fix"; GroupDescription: "Widescreen resolution compatibility for WW4:"; Components: base
- Name: "cloudlets"; Description: "Use performance friendly cloudlets"; GroupDescription: "You can use the WGL cloudlets definitions to increase performance:"; Components: base
- 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
- [Icons]
- Name: "{userdesktop}\WW4 Extended"; Filename: "{code:getGamePath}"; IconFilename: "{app}\ww4ext.ico"; IconIndex: 0; Parameters: "{code:getLaunchedMods}"; Tasks: desktopicon
- Name: "{userdesktop}\WW4 Extended (Steam)"; Filename: "{code:getGamePathSteam}"; IconFilename: "{app}\ww4ext.ico"; IconIndex: 0; Parameters: "-applaunch 65790 {code:getLaunchedMods}"; Check: returnSteamCheck; Tasks: desktopicon
- Name: "{group}\Play WW4 Extended"; Filename: "{code:getGamePath}"; IconFilename: "{app}\ww4ext.ico"; IconIndex: 0; Parameters: "{code:getLaunchedMods}"; Components: main
- Name: "{group}\Play WW4 Extended (Steam)"; Filename: "{code:getGamePathSteam}"; IconFilename: "{app}\ww4ext.ico"; Parameters: "-applaunch 65790 {code:getLaunchedMods}"; Components: main; Check: returnSteamCheck
- Name: "{group}\Play WW4"; Filename: "{code:getGamePath}"; Parameters: "-nosplash -mod=@ww4mod25"; Components: main
- Name: "{group}\Play WW4 (Steam)"; Filename: "{code:getGamePathSteam}"; IconFilename: "{app}\ww4ext.ico"; Parameters: "-applaunch 65790 -nosplash -mod=@ww4mod25"; Components: main; Check: returnSteamCheck
- Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
- Name: "{group}\Documentation\View Main Readme"; Filename: "{app}\_docs\WW4Extendedv1.0.3-Readme.pdf"; Components: main
- Name: "{group}\Documentation\View Extra Features Manual"; Filename: "{app}\_docs\WW4Extended-ExtraFeaturesManual.pdf"; Components: main
- Name: "{group}\Documentation\View Flags Manual"; Filename: "{app}\_docs\WW4Extended-Flags.pdf"; Components: main
- Name: "{group}\Documentation\View Music track classes"; Filename: "{app}\_docs\WW4 EXT music.txt"; Components: main
- Name: "{group}\Documentation\View Main Credits"; Filename: "{app}\_docs\WW4Extended-Credits.pdf"; Components: main
- Name: "{group}\Documentation\View Main Changelog"; Filename: "{app}\_docs\WW4Extended-Changelog.pdf"; Components: main
- Name: "{group}\Documentation\View Cold War Readme"; Filename: "{code:getInstallPath|WW4EXT_CW\_docs\WW4ExtendedColdWarv1.0-Readme.pdf}"; Components: main\vehicles\coldwar
- Name: "{group}\Documentation\View Arctic Readme"; Filename: "{code:getInstallPath|WW4EXT_ARCTIC\_docs\WW4ExtendedArcticv1.2-Readme.pdf}"; Components: main\vehicles\coldwar\arctic
- [Files]
- Source: "WW4_251\@ww4mod25\*"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: base
- Source: "WW4 cloudlets\WW4_cloudlets.hpp"; DestDir: "{code:getInstallPath|@ww4mod25\bin}"; DestName: "cloudlets.hpp"; Flags: ignoreversion; Components: base
- Source: "WW4 cloudlets\WGL_cloudlets.hpp"; DestDir: "{code:getInstallPath|@ww4mod25\bin}"; DestName: "cloudlets.hpp"; Flags: ignoreversion; Components: base; Tasks: cloudlets
- Source: "WW4_251\Bonus\*"; DestDir: "{code:getInstallPath|@ww4mod25\Bonus}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: base
- Source: "WW4_251\DMA_FlashUpdate.txt"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion; Components: base
- Source: "WW4_251\Gamelogics.txt"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion; Components: base
- Source: "WW4_251\READmePatch.txt"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion; Components: base
- Source: "WW4_251\Readme-WW4modpack25.txt"; DestDir: "{code:getInstallPath|@ww4mod25}"; Flags: ignoreversion isreadme; Components: base
- Source: "ofpaspectratiofix\*"; DestDir: "{app}\ofpaspectratiofix"; Flags: ignoreversion createallsubdirs recursesubdirs deleteafterinstall; Components: base
- Source: "WW4_EXT\addons\*"; DestDir: "{app}\addons"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main; AfterInstall: copyOFPinfcfg
- Source: "v196_patch\ww4ext_inf_cfg.pbo.OFP"; DestDir: "{app}"; Flags: ignoreversion dontcopy; Components: main
- Source: "low contrast materials\*"; DestDir: "{app}\low contrast materials"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main
- Source: "high contrast materials\*"; DestDir: "{app}\high contrast materials"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main
- Source: "low contrast materials\ofp_matdef_core.pbo"; DestDir: "{app}\addons"; Flags: ignoreversion; Components: main; Tasks: lowcontrast
- Source: "WW4_EXT\ww4ext.ico"; DestDir: "{app}"; Flags: ignoreversion; Components: main
- Source: "WW4_EXT\_docs\*"; DestDir: "{app}\_docs"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main
- Source: "WW4_EXT\_docs\WW4Extendedv1.0.3-Readme.pdf"; DestDir: "{app}\_docs"; Flags: ignoreversion isreadme; Components: main
- 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
- Source: "WW4_EXT\_missions\_Missions\ww4ext_TakeTheRedCar_v11.WW4_DesertAbel2.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended}"; Flags: ignoreversion; Components: main\vehicles
- Source: "WW4_EXT\_missions\_Missions\ww4ext_montignacassault_v13.Eden.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended}"; Flags: ignoreversion; Components: main\vehicles
- Source: "WW4_EXT\_missions\_Missions\badexfil_v11.WW4_DesertAbel2.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended}"; Flags: ignoreversion; Components: main\vehicles
- Source: "WW4_EXT\_missions\_Missions\_ww4ext_nationalAssault_v11.WW4_DesertAbel2.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended}"; Flags: ignoreversion; Components: main\vehicles
- Source: "WW4_EXT_VEH\addons\*"; DestDir: "{code:getInstallPath|WW4_EXT_VEH\addons}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles
- Source: "WW4EXT_CW\addons\*"; DestDir: "{code:getInstallPath|WW4EXT_CW\addons}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar
- Source: "WW4EXT_CW\_docs\*"; DestDir: "{code:getInstallPath|WW4EXT_CW\_docs}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar
- Source: "WW4EXT_CW\_docs\WW4ExtendedColdWarv1.0-Readme.pdf"; DestDir: "{code:getInstallPath|WW4EXT_CW\_docs}"; Flags: ignoreversion isreadme; Components: main\vehicles\coldwar
- Source: "WW4EXT_CW\_missions\WW4EXT_Battlefields_v1.Eden.pbo"; DestDir: "{code:getInstallPath|Missions\WW4 Extended - Cold War}"; Flags: ignoreversion; Components: main\vehicles\coldwar
- Source: "WW4EXT_ARCTIC\addons\*"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar\arctic
- Source: "WW4EXT_ARCTIC\_docs\*"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\_docs}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar\arctic
- Source: "WW4EXT_ARCTIC\_docs\WW4ExtendedArcticv1.2-Readme.pdf"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\_docs}"; Flags: ignoreversion isreadme; Components: main\vehicles\coldwar\arctic
- 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
- 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
- Source: "WinterNogojev11\Readme-Winter Nogojev.txt"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\_docs}"; Flags: ignoreversion isreadme; Components: main\vehicles\coldwar\arctic
- Source: "WinterNogojev11\kegnoecain_snow.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
- Source: "WinterNogojev11\KEGepack_snow.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
- Source: "WinterNogojev11\KEGnoecainS_anim\*"; DestDir: "{code:getInstallPath|AddOns\KEGnoecainS_anim}"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: main\vehicles\coldwar\arctic
- Source: "WinterNogojev11\KEGak103.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
- Source: "WinterNogojev11\KEGak107.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
- Source: "WinterNogojev11\KEGmakarov.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
- Source: "WinterNogojev11\KEGrpg7.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
- Source: "WinterNogojev11\KEGrpk47.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
- Source: "WinterNogojev11\KEGrpk74.pbo"; DestDir: "{code:getInstallPath|WW4EXT_ARCTIC\addons}"; Flags: ignoreversion; Components: main\vehicles\coldwar\arctic
- [Components]
- Name: "base"; Description: "WW4 mod 2.5.1"; Types: full custom compact; Flags: checkablealone
- Name: "main"; Description: "WW4 Extended Core (Infantry units)"; Types: full custom compact; Flags: fixed checkablealone dontinheritcheck
- Name: "main\vehicles"; Description: "WW4 Extended Vehicles"; Types: full custom; Flags: checkablealone
- Name: "main\vehicles\coldwar"; Description: "Cold War vehicles and infantry units"; Types: full custom; Flags: dontinheritcheck checkablealone
- Name: "main\vehicles\coldwar\arctic"; Description: "Arctic vehicles and infantry units (includes Kegetys' Winter Nogojev)"; Types: full custom; Flags: dontinheritcheck checkablealone
- [Run]
- Filename: {code:getGamePath}; Parameters: {code:getLaunchedMods}; Flags: nowait postinstall skipifsilent unchecked; Description: "Launch WW4 Extended"
- [UninstallDelete]
- Type: files; Name: "{app}\addons\ww4ext_inf_cfg.pbo.CWA"
- Type: dirifempty; Name: "{app}\*"
- [Code]
- const
- mrRepair = 100;
- mrUninstall = 101;
- var
- InstPath: string;
- aspectratioPageID: Integer;
- Label1: TLabel;
- radioButton_4_3: TRadioButton;
- radioButton_5_4: TRadioButton;
- radioButton_16_10: TRadioButton;
- radioButton_16_9: TRadioButton;
- radioButton_15_9: TRadioButton;
- aspectratio_ProgressPage: TOutputProgressWizardPage;
- aspectratio_started: Boolean;
- aspectratioSelected: String;
- fovTop: String;
- fovLeft: String;
- uiTopLeftX: String;
- uiTopLeftY: String;
- uiBottomRightX: String;
- uiBottomRightY: String;
- isSteam: boolean;
- // Generate mod list based on the installed components
- function getLaunchedMods(Default: String): String;
- begin
- Result := '-nosplash -mod=@ww4mod25;WW4_EXT';
- if IsComponentSelected('main\vehicles') then
- Result := Result + ';WW4_EXT_VEH';
- if IsComponentSelected('main\vehicles\coldwar') then
- Result := Result + ';WW4EXT_CW';
- if IsComponentSelected('main\vehicles\coldwar\arctic') then
- Result := Result + ';WW4EXT_ARCTIC';
- end;
- // Check if the selected installation directory has a CWA or OFP game
- function isCWA: Boolean;
- begin
- Result := false;
- if FileExists(ExpandConstant(InstPath+'coldwarassault.exe')) then
- Result := true;
- end;
- // Generates an installation path based on the one selected by the user
- function getInstallPath(Append: String): String;
- begin
- Result := InstPath + Append;
- end;
- // Generates a path to the game based on if it's an OFP or CWA installation and the directory selected by the user
- function getGamePath(Default: String): String;
- begin
- if isCWA then begin
- Result := InstPath + 'coldwarassault.exe';
- end else begin
- Result := InstPath + 'FLASHPOINTRESISTANCE.exe';
- end;
- end;
- // Get Steam path
- function getSteamPath(Default: String): String;
- begin
- Result := '';
- if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam') then
- RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam','InstallPath', Result);
- end;
- // Check if the selected installation directory belongs to Steam
- function isSteamGame: Boolean;
- var steamPath: string;
- begin
- Result := false;
- if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Valve\Steam') then begin
- steamPath := getSteamPath('');
- if InstPath = (steamPath + '\steamapps\common\ARMA Cold War Assault\') then begin
- Result := true;
- end;
- end;
- end;
- // Get Steam game path
- function getGamePathSteam(Default: String): String;
- begin
- Result := getSteamPath('') + '\Steam.exe';
- end;
- // Return the result of the Steam check
- // This seems a bit convoluted (lots of similar checks), but Inno doesn't seem to create the shortcuts otherwise
- function returnSteamCheck: Boolean;
- begin
- Result := isSteam;
- end;
- // Copy OFP compatible inf_cfg.pbo if not CWA
- procedure copyOFPinfcfg();
- begin
- if not isCWA then begin
- RenameFile(ExpandConstant('{app}\addons\ww4ext_inf_cfg.pbo'),ExpandConstant('{app}\addons\ww4ext_inf_cfg.pbo.CWA'));
- ExtractTemporaryFile('ww4ext_inf_cfg.pbo.OFP');
- FileCopy(ExpandConstant('{tmp}\ww4ext_inf_cfg.pbo.OFP'),ExpandConstant('{app}\addons\ww4ext_inf_cfg.pbo'), false);
- end;
- end;
- // Manage next button click event
- function NextButtonClick(CurPageID: Integer): Boolean;
- begin
- Result := True;
- //MsgBox('Page is "' + IntToStr(CurPageID) + '"', mbInformation, MB_OK);
- // Generate a new default install dir based on the installed games
- if CurPageID = 1 then begin
- WizardForm.DirEdit.Text := InstPath + '{#modDir}';
- end;
- // Warning if WW4 isn't installed and user doesn't want to install it
- if CurPageID = wpSelectComponents then begin
- if not DirExists(ExpandConstant(getInstallPath('@ww4mod25'))) and not isComponentSelected('base') then begin
- 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);
- end;
- end;
- if CurPageID = wpSelectProgramGroup then begin
- isSteam := isSteamGame;
- end;
- end;
- // Aspect Ratio wizard page
- function aspectratio_NextButtonClick(CustomPage: TWizardPage): Boolean;
- begin
- Result := True;
- if (radioButton_4_3.Checked) then begin
- aspectratioSelected := '4_3';
- fovTop := '0.75';
- fovLeft := '1';
- uiTopLeftX := '0';
- uiTopLeftY := '0';
- uiBottomRightX := '1';
- uiBottomRightY := '1';
- end else if (radioButton_5_4.Checked) then begin
- aspectratioSelected := '5_4';
- fovTop := '0.8';
- fovLeft := '1';
- uiTopLeftX := '0';
- uiTopLeftY := '0.033333';
- uiBottomRightX := '1';
- uiBottomRightY := '0.966667';
- end else if (radioButton_16_10.Checked) then begin
- aspectratioSelected := '16_10';
- fovTop := '0.75';
- fovLeft := '1.2';
- uiTopLeftX := '0.083333';
- uiTopLeftY := '0';
- uiBottomRightX := '0.916667';
- uiBottomRightY := '1';
- end else if (radioButton_16_9.Checked) then begin
- aspectratioSelected := '16_9';
- fovTop := '0.75';
- fovLeft := '1.333333';
- uiTopLeftX := '0.125';
- uiTopLeftY := '0';
- uiBottomRightX := '0.875';
- uiBottomRightY := '1';
- end else if (radioButton_15_9.Checked) then begin
- aspectratioSelected := '15_9';
- fovTop := '0.8';
- fovLeft := '1.333333';
- uiTopLeftX := '0.125';
- uiTopLeftY := '0.033333';
- uiBottomRightX := '0.875';
- uiBottomRightY := '0.966667';
- end;
- aspectratio_started := false;
- //MsgBox('resolution is "' + aspectratioSelected + '"', mbInformation, MB_OK);
- end;
- function aspectratio_CreatePage(PreviousPageId: Integer): Integer;
- var
- CustomPage: TWizardPage;
- begin
- CustomPage := CreateCustomPage(
- PreviousPageId,
- ExpandConstant('{cm:aspectratio_header}'),
- ExpandConstant('{cm:aspectratio_description}')
- );
- Label1 := TLabel.Create(CustomPage);
- with Label1 do
- begin
- Parent := CustomPage.Surface;
- Caption := ExpandConstant('{cm:aspectratio_Label1}');
- Left := ScaleX(0);
- Top := ScaleY(24*0);
- Width := ScaleX(300);
- Height := ScaleY(17);
- end;
- radioButton_4_3 := TRadioButton.Create(CustomPage);
- with radioButton_4_3 do
- begin
- Parent := CustomPage.Surface;
- Caption := ExpandConstant('{cm:aspectratio_4_3}');
- Left := ScaleX(16);
- Top := ScaleY(24*1);
- Width := ScaleX(193);
- Height := ScaleY(17);
- TabOrder := 0;
- end;
- radioButton_5_4 := TRadioButton.Create(CustomPage);
- with radioButton_5_4 do
- begin
- Parent := CustomPage.Surface;
- Caption := ExpandConstant('{cm:aspectratio_5_4}');
- Left := ScaleX(16);
- Top := ScaleY(24*2);
- Width := ScaleX(193);
- Height := ScaleY(17);
- TabOrder := 1;
- end;
- radioButton_16_10 := TRadioButton.Create(CustomPage);
- with radioButton_16_10 do
- begin
- Parent := CustomPage.Surface;
- Caption := ExpandConstant('{cm:aspectratio_16_10}');
- Left := ScaleX(16);
- Top := ScaleY(24*3);
- Width := ScaleX(193);
- Height := ScaleY(17);
- TabOrder := 2;
- end;
- radioButton_16_9 := TRadioButton.Create(CustomPage);
- with radioButton_16_9 do
- begin
- Parent := CustomPage.Surface;
- Caption := ExpandConstant('{cm:aspectratio_16_9}');
- Left := ScaleX(16);
- Top := ScaleY(24*4);
- Width := ScaleX(225);
- Height := ScaleY(17);
- Checked := True;
- TabOrder := 3;
- TabStop := True;
- end;
- radioButton_15_9 := TRadioButton.Create(CustomPage);
- with radioButton_15_9 do
- begin
- Parent := CustomPage.Surface;
- Caption := ExpandConstant('{cm:aspectratio_15_9}');
- Left := ScaleX(16);
- Top := ScaleY(24*5);
- Width := ScaleX(225);
- Height := ScaleY(17);
- TabOrder := 4;
- end;
- with CustomPage do
- begin
- OnNextButtonClick := @aspectratio_NextButtonClick;
- end;
- // store your custom page ID to further use in the ShouldSkipPage event
- aspectratioPageID := CustomPage.ID;
- Result := aspectratioPageID;
- end;
- // Custom wizard pages
- procedure InitializeWizard();
- begin
- aspectratio_CreatePage(wpSelectTasks);
- aspectratio_ProgressPage := CreateOutputProgressPage('OFP Aspect Ratio Fix','Applying OFP Aspect Ratio fix');
- end;
- // Replace value on files
- function ReplaceValue(const FileName, TagName, TagValue: string; ReplaceAll: boolean): Boolean;
- var
- I: Integer;
- Line: string;
- TagPos: Integer;
- FileLines: TStringList;
- begin
- Result := False;
- FileLines := TStringList.Create;
- try
- FileLines.LoadFromFile(FileName);
- for I := 0 to FileLines.Count - 1 do
- begin
- Line := FileLines[I];
- TagPos := Pos(TagName, Line);
- if TagPos > 0 then
- begin
- Result := True;
- if ReplaceAll then begin
- Delete(Line, TagPos, MaxInt);
- Line := Line + TagValue;
- end else begin
- Delete(Line, TagPos + Length(TagName), MaxInt);
- Line := Line + '=' + TagValue + ';';
- end;
- FileLines[I] := Line;
- FileLines.SaveToFile(FileName);
- Break;
- end;
- end;
- finally
- FileLines.Free;
- end;
- end;
- // Fills the "subDirs" TStrings with the subdirectories of the "directory" directory
- procedure GetSubDirectories(const Directory: string; subDirs: TStrings);
- var
- FindRec: TFindRec;
- begin
- subDirs.Clear;
- if FindFirst(ExpandConstant(Directory + '*'), FindRec) then
- try
- repeat
- if (FindRec.Name <> '.') AND (FindRec.Name <> '..') then
- if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY > 0 then
- subDirs.Add(FindRec.Name);
- until
- not FindNext(FindRec);
- finally
- FindClose(FindRec);
- end;
- end;
- // Manage page change event
- procedure CurPageChanged(CurPageID: Integer);
- var
- i: Integer;
- subDirsList: TStringList;
- cfgFile: String;
- begin
- //MsgBox('Page is "' + IntToStr(CurPageID) + '"', mbInformation, MB_OK);
- if CurPageID = wpFinished then
- begin
- // Apply aspect ratio fix
- // 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
- if (IsTaskSelected('aspectratio') and not aspectratio_started) then
- begin
- aspectratio_started := true;
- aspectratio_ProgressPage.SetText('Searching for user folders...', '');
- aspectratio_ProgressPage.SetProgress(0, 0);
- aspectratio_ProgressPage.Show;
- // Replace values in each user's UserInfo.cfg
- subDirsList := TStringList.Create;
- try
- GetSubDirectories(ExpandConstant(InstPath + 'users\'), subDirsList);
- //MsgBox('subDirs: "' + subDirsList.CommaText + '"', mbInformation, MB_OK);
- aspectratio_ProgressPage.SetText('Updating UserInfo.cfg values...', '');
- for i := 0 to subDirsList.Count - 1 do
- begin
- aspectratio_ProgressPage.SetProgress(i, 0);
- cfgFile := ExpandConstant(InstPath + 'users\'+ subDirsList[i] + '\UserInfo.cfg');
- if FileExists(cfgFile) then
- begin
- // Replace values
- ReplaceValue(cfgFile, 'fovTop', fovTop, false);
- ReplaceValue(cfgFile, 'fovLeft', fovLeft, false);
- ReplaceValue(cfgFile, 'uiTopLeftX', uiTopLeftX, false);
- ReplaceValue(cfgFile, 'uiTopLeftY', uiTopLeftY, false);
- ReplaceValue(cfgFile, 'uiBottomRightX', uiBottomRightX, false);
- ReplaceValue(cfgFile, 'uiBottomRightY', uiBottomRightY, false);
- end;
- end;
- finally
- subDirsList.Free;
- end;
- // Copy Aspect_Ratio.hpp
- aspectratio_ProgressPage.SetText('Copying Aspect_Ratio.hpp...', '');
- aspectratio_ProgressPage.SetProgress(20, 0);
- FileCopy(ExpandConstant('{app}\ofpaspectratiofix\Aspect_Ratio.hpp'),ExpandConstant(InstPath + 'Aspect_Ratio.hpp'), false);
- // Apply selected ratio to Aspect_Ratio.hpp
- aspectratio_ProgressPage.SetText('Applying aspect ratio...', '');
- aspectratio_ProgressPage.SetProgress(50, 0);
- ReplaceValue(ExpandConstant(InstPath + 'Aspect_Ratio.hpp'), '#define aspect_ratio_', ExpandConstant('#define aspect_ratio_' + aspectratioSelected), true);
- // Copy fixed WW4 config
- aspectratio_ProgressPage.SetText('Copying fixed WW4 config...', '');
- aspectratio_ProgressPage.SetProgress(80, 0);
- // Choose the correct config: radio or no radio
- if isTaskSelected('enableradio') then begin
- cfgFile := ExpandConstant('{app}\ofpaspectratiofix\Config_radio.cpp');
- end else begin
- cfgFile := ExpandConstant('{app}\ofpaspectratiofix\Config_noradio.cpp');
- end;
- FileCopy(ExpandConstant(cfgFile),ExpandConstant(getInstallPath('@ww4mod25\bin\Config.cpp')), false);
- // Copy fixed WW4 resource
- aspectratio_ProgressPage.SetText('Copying fixed WW4 resource...', '');
- aspectratio_ProgressPage.SetProgress(80, 0);
- FileCopy(ExpandConstant('{app}\ofpaspectratiofix\Resource.cpp'),ExpandConstant(getInstallPath('@ww4mod25\bin\Resource.cpp')), false);
- aspectratio_ProgressPage.SetProgress(100, 0);
- aspectratio_ProgressPage.Hide;
- end;
- end;
- end;
- // Manage skippable pages
- function ShouldSkipPage(PageID: Integer): Boolean;
- begin
- Result := False;
- if PageID = aspectratioPageID then
- // Skip the page if aspectratio wasn't checked
- Result := not IsTaskSelected('aspectratio');
- end;
- // Repair or uninstall if the mod was already installed
- function ShowOptionsForm: TModalResult;
- var
- OptionsForm: TSetupForm;
- RepairButton: TNewButton;
- UninstallButton: TNewButton;
- begin
- Result := mrNone;
- OptionsForm := CreateCustomForm;
- try
- OptionsForm.Width := 220;
- OptionsForm.Caption := ExpandConstant('{cm:OptionsFormCaption}');
- OptionsForm.Position := poScreenCenter;
- RepairButton := TNewButton.Create(OptionsForm);
- RepairButton.Parent := OptionsForm;
- RepairButton.Left := 8;
- RepairButton.Top := 8;
- RepairButton.Width := OptionsForm.ClientWidth - 16;
- RepairButton.Caption := ExpandConstant('{cm:RepairButtonCaption}');
- RepairButton.ModalResult := mrRepair;
- UninstallButton := TNewButton.Create(OptionsForm);
- UninstallButton.Parent := OptionsForm;
- UninstallButton.Left := 8;
- UninstallButton.Top := RepairButton.Top + RepairButton.Height + 8;
- UninstallButton.Width := OptionsForm.ClientWidth - 16;
- UninstallButton.Caption := ExpandConstant('{cm:UninstallButtonCaption}');
- UninstallButton.ModalResult := mrUninstall;
- OptionsForm.ClientHeight := RepairButton.Height + UninstallButton.Height + 24;
- Result := OptionsForm.ShowModal;
- finally
- OptionsForm.Free;
- end;
- end;
- function GetUninstallerPath: string;
- var
- RegKey: string;
- begin
- Result := '';
- RegKey := Format('%s\%s_is1', ['Software\Microsoft\Windows\CurrentVersion\Uninstall',
- '{#emit SetupSetting("AppId")}']);
- if not RegQueryStringValue(HKEY_LOCAL_MACHINE, RegKey, 'UninstallString', Result) then
- RegQueryStringValue(HKEY_CURRENT_USER, RegKey, 'UninstallString', Result);
- end;
- function InitializeSetup: Boolean;
- var
- regPath: string;
- UninstPath: string;
- ResultCode: Integer;
- begin
- Result := True;
- // Set default directory based on reg (OFP or CWA). CWA takes precedence over OFP
- if RegQueryStringValue(HKLM, 'SOFTWARE\Codemasters\Operation Flashpoint', 'MAIN', regPath) then
- InstPath := regPath + '\';
- if RegQueryStringValue(HKLM, 'SOFTWARE\bohemia interactive studio\coldwarassault', 'MAIN', regPath) then
- InstPath := regPath + '\';
- if RegQueryStringValue(HKLM, 'SOFTWARE\WOW6432Node\bohemia interactive studio\coldwarassault', 'MAIN', regPath) then
- InstPath := regPath + '\';
- // Get Uninstall path
- UninstPath := RemoveQuotes(GetUninstallerPath);
- if UninstPath <> '' then
- begin
- case ShowOptionsForm of
- mrRepair: Result := True;
- mrUninstall:
- begin
- Result := False;
- if not Exec(UninstPath, '', '', SW_SHOW, ewNoWait, ResultCode) then
- MsgBox(FmtMessage(SetupMessage(msgUninstallOpenError), [UninstPath]), mbError, MB_OK);
- end;
- else
- Result := False;
- end;
- end;
- end;
Add Comment
Please, Sign In to add comment