View Single Post
  #11  
Old 05-03-2024, 11:34
Fak Eid Fak Eid is offline
Registered User
 
Join Date: Jun 2023
Location: Mars
Posts: 147
Thanks: 98
Thanked 152 Times in 54 Posts
Fak Eid is on a distinguished road
Common Code to extract Data/Component Files

Declare a global variable DiskSkip in the top
Code:
var
DiskSkip: Boolean;
Updated changes here:
Code:
procedure CurStepChanged(CurStep: TSetupStep);
var
  i: Integer;
begin
  DiskSkip:= False;
  if CurStep = ssInstall then begin
    ISArcExCancel := 0;
    ISArcExDiskCount := 0;
    ISArcDiskAddingSuccess := False;
    ISArcExError := True;

    #include "Game/UnpackTools_Init.iss"
    { - ADDING DISKS: BEGIN -}
    repeat
      {< Main Archives >}
      #ifdef Data1
        VerifyFileExist('Data-01.bin');
        if DiskSkip then break;
      #endif
      #ifdef Data2
        VerifyFileExist('Data-02.bin');
        if DiskSkip then break;
      #endif

      {< Components >}
      #ifdef Component1
        if Checkbox[8].ISChecked then
        VerifyFileExist('selective-english.bin');
      #endif
      #ifdef Component2
        if Checkbox[9].ISChecked then
        VerifyFileExist('selective-bonus.bin');
      #endif
      until true;
    { - ADDING DISKS: END -}

      ISArcExStop;
      if ISArcExError then
        ShowMessage('Installation was interrupted', 'Either the installation has been cancelled by the user,' +#13+ 'or the files are corrupted.');
      end else if not (ISArcDiskAddingSuccess) and (DiskSkip) then
        ShowMessage('Installation is corrupted', 'Required disks could not be located.');

Common procedure to handle all Data files
Code:
procedure VerifyFileExist(FilePath: WideString);
var
  sPath, sFile: WideString;
  sExt: String;
begin
  sPAth := AddBackslash(ExpandConstant('{src}'));
  if FileExists(sPAth + FilePath) then begin
    ISArcDiskAddingSuccess:= ISArcExAddDisks(sPAth + FilePath, '{#DiskPassword}', ExpandConstant('{app}'));
    if not ISArcDiskAddingSuccess then begin
      DiskSkip:= True;
      Exit;
    end;
    ISArcExDiskCount := ISArcExDiskCount + 1;
  end else
    begin
    ShowMessage('Setup Needs the Next Disk', 'Please browse Disk: [ ' + FilePath +  ' ] after closing this prompt'#13#10'If this disk can be found in another folder, browse to the correct path.');
    sExt:= ExtractFileExt(FilePath); StringChange(sExt, '.', '');
    if OpenFileModern(FMXForm.HandleHWND, sExt, FilePath,  sPAth, 'Please specify the location of the next disk', sFile) then
    begin
      sPAth := ExtractFilePath(sFile);
      ISArcDiskAddingSuccess:= ISArcExAddDisks(sPAth + FilePath, '{#DiskPassword}', ExpandConstant('{app}'));
      if not ISArcDiskAddingSuccess then begin
        DiskSkip:= True;
        Exit;
      end;
      ISArcExDiskCount := ISArcExDiskCount + 1;
    end else begin
      ISArcDiskAddingSuccess := False;
      DiskSkip:= True;
      Exit;
    end;
  end;
end;
Reply With Quote
The Following 4 Users Say Thank You to Fak Eid For This Useful Post:
audiofeel (05-03-2024), Behnam2018 (05-03-2024), BLACKFIRE69 (05-03-2024), ScOOt3r (05-03-2024)