Advertisement
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 Patch"
- #define MyAppVersion "1.0.3.1"
- #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 Patch v1.0.3.1 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 patch 1031\EXTinstallerimg1.bmp
- WizardSmallImageFile=userdocs:Installer WW4_EXT patch 1031\EXTinstallersmallimg1.bmp
- DisableReadyPage=True
- Uninstallable=True
- CreateUninstallRegKey=false
- UpdateUninstallLogAppName=false
- [Messages]
- WelcomeLabel2=This program will install the v1.0.3.1 patch for WW4 Extended.
- [CustomMessages]
- 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: "aspectratio"; Description: "Apply aspect ratio fix (with new tank layout position)"; GroupDescription: "Widescreen resolution compatibility for WW4:"; Check: dirExistsCheck ('@ww4mod25');
- Name: "cloudlets"; Description: "Use performance friendly dust and smoke particles"; GroupDescription: "You can use the WGL cloudlets definitions to increase performance:"; Check: dirExistsCheck ('@ww4mod25');
- 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');
- [Files]
- Source: "ofpaspectratiofix\*"; DestDir: "{app}\ofpaspectratiofix"; Flags: ignoreversion createallsubdirs recursesubdirs deleteafterinstall; Check: dirExistsCheck ('@ww4mod25');
- Source: "WW4 cloudlets\WW4_cloudlets.hpp"; DestDir: "{code:getInstallPath|@ww4mod25\bin}"; DestName: "cloudlets.hpp"; Flags: ignoreversion; Check: dirExistsCheck ('@ww4mod25');
- Source: "WW4 cloudlets\WGL_cloudlets.hpp"; DestDir: "{code:getInstallPath|@ww4mod25\bin}"; DestName: "cloudlets.hpp"; Flags: ignoreversion; Tasks: cloudlets; Check: dirExistsCheck ('@ww4mod25');
- Source: "WW4_EXT\addons\*"; DestDir: "{app}\addons"; Flags: ignoreversion createallsubdirs recursesubdirs; AfterInstall: copyOFPinfcfg
- Source: "WW4_EXT\_docs\*"; DestDir: "{app}\_docs"; Flags: ignoreversion createallsubdirs recursesubdirs;
- Source: "v196_patch\ww4ext_inf_cfg.pbo.OFP"; DestDir: "{app}"; Flags: ignoreversion dontcopy
- Source: "WW4_EXT\_docs\WW4Extended-Changelog.pdf"; DestDir: "{app}\_docs"; Flags: ignoreversion isreadme;
- Source: "WW4_EXT_VEH\addons\*"; DestDir: "{code:getInstallPath|WW4_EXT_VEH\addons}"; Flags: ignoreversion createallsubdirs recursesubdirs; Check: dirExistsCheck ('WW4_EXT_VEH');
- [Code]
- 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;
- // Check if dir exists in the OFP/CWA root directory
- function dirExistsCheck(dir: String): Boolean;
- begin
- Result := false;
- if DirExists(getInstallPath(dir)) then begin
- Result := true;
- end;
- 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;
- 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 + '\';
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement