Bracie @Panczo, poratuj
Dzięki Twym radom utworzyłem wtedy instalatora, i potem własnymi siłami, wspieranymi góglami i dokumentacją rozwinąłem go do poniższej postaci:
- dodałem nowy komponent instalacji
- dodałem podmianę zawartości pliku setup.ini zaraz po tym, jak się zainstaluje
- przerobiłem wizarda aby o ścieżkę do Battletecha pytał się za każdym razem
Niestety, to czego nie wiem, i do czego nie znajduję punktu zaczepienia (znaczy się tyle wiem, że trzeba będzie prawdopodobnie stworzyć własną stronę wizarda instalacyjnego) to takie coś:
na tej stronie gdzie się pyta o ścieżkę do Battletecha chcę poniżej jeszcze mieć prosty element GUI:
[checkBox] Enable advanced mode
<tu może jakiś opis co to takiego ten advanced mode>
i jak checkbox będzie zaznaczony to coś wpisać do setup.ini. Tą część ze wpisem to sam ogarnę.
Jak takie coś uzyskać? CreateInputFilePage()
tym razem pewnie nie wystarczy :/
Aktualny kod
; Script generated by the Inno Script Studio Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[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={{CD963CF4-FE83-434A-B3FA-67BB45338268}
AppName=Mech Designer
AppVersion=0.74
AppPublisher=MasterBLB's Soft
DefaultDirName={sd}\Mech Designer by MasterBLB
DefaultGroupName=Mech Designer by MasterBLB
AllowNoIcons=yes
LicenseFile=C:\Qt\Projects\MechDesigner\Documentation\license.txt
Compression=lzma
SolidCompression=yes
DisableWelcomePage=False
AllowRootDirectory=False
ShowLanguageDialog=yes
AlwaysShowComponentsList=yes
OutputBaseFilename=MechDesigner v{#SetupSetting("AppVersion")} Installer
OutputDir=.\
;if only a mech pack is installed don't create uninstaller
Uninstallable=WizardIsComponentSelected('MechDesigner')
[Types]
Name: "Core"; Description: "Full installation"
Name: "Flashpoint"; Description: "Only Flashpoint mechs data files"
Name: "UrbanWarfare"; Description: "Only Urban Warfare mechs and equipment"
Name: "Custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "MechDesigner"; Description: "Mech Designer core files"; Types: Core Custom
Name: "FlashpointPack"; Description: "Flashpoint mechs pack"; Types: Core Flashpoint Custom
Name: "UrbanWarfarePack"; Description: "Urban Warfare mechs and equipment pack"; Types: Core UrbanWarfare Custom
[Files]
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
;executable, .ini and manual
Source: "..\Release\release\MechDesigner.exe"; DestDir: "{app}"; Components: MechDesigner; Flags: ignoreversion
Source: "..\Data and config files\setup.ini"; DestDir: "{app}"; Components: MechDesigner; Flags: ignoreversion; AfterInstall : AlterSetupINI
Source: "..\Documentation\Mech Designer user's manual.pdf"; DestDir: "{app}"; Components: MechDesigner; Flags: isreadme ignoreversion
;required libraries
Source: "libs\libgcc_s_dw2-1.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "libs\libstdc++-6.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "libs\libwinpthread-1.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "libs\Qt5Core.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "libs\Qt5Gui.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "libs\Qt5Widgets.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "libs\platforms\qwindows.dll"; DestDir: "{app}\platforms"; Components: MechDesigner
Source: "libs\styles\qwindowsvistastyle.dll"; DestDir: "{app}\styles"; Components: MechDesigner
;GUI icons
Source: "..\GUI\AppIcon.ico"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\Actuators.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\Ammo.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\ArmorFront.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\ArmorRear.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\BallisticHardpoint.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\Cbills.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\CloseButton.PNG"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\CockpitMods.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\Computers.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\DockedMode.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\ElectronicWarfare.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\EnergyHardpoint.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\FloatingMode.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\Gyro.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\HeatDissipated.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\HeatGenerated.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\Heatsinks.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\JumpJets.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\MissileHardpoint.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\Slots.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\SupportHardpoint.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\Tonnage.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "..\GUI\Warning.png"; DestDir: "{app}\GUI"; Components: MechDesigner
;Flashpoint mechs data
Source: "Flashpoint mechs\chassisdef_crab__fp_gladiator_BSC-27.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Flashpoint mechs\mechdef_crab__fp_gladiator_BSC-27.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Flashpoint mechs\chassisdef_crab_CRB-27.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Flashpoint mechs\mechdef_crab_CRB-27.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Flashpoint mechs\chassisdef_cyclops_CP-10-Q.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Flashpoint mechs\mechdef_cyclops_CP-10-Q.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Flashpoint mechs\chassisdef_cyclops_CP-10-Z.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Flashpoint mechs\mechdef_cyclops_CP-10-Z.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Flashpoint mechs\chassisdef_hatchetman_HCT-3F.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Flashpoint mechs\mechdef_hatchetman_HCT-3F.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
;Urban Warfare mechs
Source: "Urban Warfare mechs\chassisdef_hatchetman_HCT-3X.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
Source: "Urban Warfare mechs\mechdef_hatchetman_HCT-3X.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
Source: "Urban Warfare mechs\chassisdef_javelin_JVN-10F.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
Source: "Urban Warfare mechs\mechdef_javelin_JVN-10F.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
Source: "Urban Warfare mechs\chassisdef_javelin_JVN-10N.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
Source: "Urban Warfare mechs\mechdef_javelin_JVN-10N.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
Source: "Urban Warfare mechs\chassisdef_raven_RVN-1X.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
Source: "Urban Warfare mechs\mechdef_raven_RVN-1X.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
;Urban Warfare equipment
Source: "Urban Warfare mechs\Gear_Sensor_Prototype_ActiveProbe.json"; DestDir: "{code:battletechDataDir}\upgrades\ElectronicWarfare"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
Source: "Urban Warfare mechs\Gear_Sensor_Prototype_ECM.json"; DestDir: "{code:battletechDataDir}\upgrades\ElectronicWarfare"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
Source: "Urban Warfare mechs\Gear_Sensor_Prototype_EWE.json"; DestDir: "{code:battletechDataDir}\upgrades\ElectronicWarfare"; Flags: uninsneveruninstall confirmoverwrite; Components: UrbanWarfarePack
[Icons]
Name: "{group}\Mech Designer"; Filename: "{app}\MechDesigner.exe"; Components: MechDesigner
Name: "{group}\Mech Designer user's manual"; Filename: "{app}\Mech Designer user's manual.pdf"; Components: MechDesigner
Name: "{group}\{cm:UninstallProgram,Mech Designer}"; Filename: "{uninstallexe}"; Components: MechDesigner
Name: "{commondesktop}\Mech Designer"; Filename: "{app}\MechDesigner.exe"; Tasks: desktopicon; Components: MechDesigner
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Components: MechDesigner
[Run]
Filename: "{app}\MechDesigner.exe"; Description: "{cm:LaunchProgram,Mech Designer}"; Flags: nowait postinstall skipifsilent; Components: MechDesigner
;the code ask for path to battletech.exe in case Flashpoint/Urban Warfare mech pack has been selected, validates it by checking if <battletech.exe>\BattleTech_libs\StreamingAssets\data contains folder Flashpoint
;only if the check is validated it alllows to proceed the instalation
[Code]
var
battletechPage: TInputFileWizardPage;
battletechPageID: Integer;
procedure InitializeWizard();
begin
battletechPage := CreateInputFilePage(wpSelectTasks, 'Additional patch to Battletech.exe is required', '', 'Navigate to and point the Battletech.exe from the latest chosen expansion mech pack');
battletechPage.Add('Path to Battletech.exe', 'battletech.exe|battletech.exe', '.exe');
battletechPageID := battletechPage.ID;
battletechPage.Description := 'To properly install mech packs, and update setup.ini, you need to provide valid path to the most recent expansion chosen on components page';
end;
procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
// Store the selected folder for further reinstall/upgrade
SetPreviousData(PreviousDataKey, 'battletechfile', battletechPage.Values[0]);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if CurPageID = battletechPageID then
begin
if battletechPage.Values[0] = '' then
begin
MsgBox('You have to select the battletech.exe!', mbInformation, MB_OK);
Result := False;
end
else
begin
//check if user selected right directory
if WizardIsComponentSelected('FlashpointPack') or WizardIsComponentSelected('UrbanWarfarePack') then
if not DirExists(ExtractFileDir(battletechPage.Values[0]) + '\BattleTech_Data\StreamingAssets\data\flashpoints') then
begin
msgbox('Wrong path! You have to navigate to proper Battletech main folder!', mbInformation, MB_OK);
Result := false;
end;
end;
end;
end;
//don't show the path selection page if no DLC has been selected
//function ShouldSkipPage(PageID: Integer): Boolean;
//begin
// Result := False;
// if PageID = battletechPageID then Result := not (WizardIsComponentSelected('FlashpointPack') or WizardIsComponentSelected('UrbanWarfarePack'));
//end;
//Return the selected DataDir - it removes battletech.exe from the path, and returns the rest
function battletechDataDir(Param: String): String;
begin
Result := ExtractFileDir(battletechPage.Values[0]) + '\BattleTech_Data\StreamingAssets\data';
end;
//after installation of the setup.ini add line jsonDataPath=<path to data folder>
procedure AlterSetupINI();
var path : String;
var file : TStrings;
begin
path := battletechDataDir('');
if DirExists(path) then
begin
StringChangeEx(path, '\', '/', true);
file := TStringList.Create();
file.LoadFromFile(ExpandConstant('{app}') + '\setup.ini');
file[1] := 'jsonDataPath=' + path;
file.SaveToFile(ExpandConstant('{app}') + '\setup.ini');
end;
end;