INIEx

INIEx 1.0

Нет прав для скачивания

audiofeel

Ветеран
audiofeel добавил(а) новый ресурс:

INIEx - INIEx - утилита для чтения настроек из INI-файлов

INIEx - утилита для чтения настроек из INI-файлов. Её главная особенность заключается в том, что она позволяет использовать содержимое INI для автоматического формирования частей скрипта Inno Setup ещё на этапе компиляции.

Например, представим, что у нас есть установщик с дополнительными компонентами, которые пользователь может выбирать перед установкой.

В обычном случае для каждого нового компонента пришлось бы добавлять соответствующий чекбокс в скрипт, прописывать...

Узнать больше об этом ресурсе...
 
Тест в архиве Release
code_language.pascal:
#define ReadINIEx(Func, Params) \
  Local[0] = AddBackSlash(GetEnv("TEMP")) + "ini_out.txt", \
  Exec( \
    AddBackSlash(SourcePath) + "Plugin\INIEx\INIEx.exe", \
    Func + " " + Params + " /o=""" + Local[0] + """ """ + AddBackSlash(SourcePath) + "OpenSetup.ini""", \
    "", 1, SW_HIDE \
  ), \
  ExecAndGetFirstLine("cmd.exe", "/C type """ + Local[0] + """")

#define AccentClr ReadINIEx('ReadString', '/Sec=Setup /Key=AccentColor')
#define GameSize Int(ReadINIEx('CalcTotalDiskSizeByte', '/MainSec=Datas /Key=Size'))
#define Password ReadINIEx('ReadString', '/Sec=Setup /Key=Password')

#define i 0
#define MAX_ICONS Int(ReadINIEx('GetSubSectionsCount', '/MainSec=Execs /RootOnly=true'))
#define MAX_REDIST Int(ReadINIEx('GetSubSectionsCount', '/MainSec=Redists /RootOnly=true'))
#define MAX_COMPO Int(ReadINIEx('GetSubSectionsCount', '/MainSec=Compos /RootOnly=true'))
#define MAX_DISKS Int(ReadINIEx('GetSubSectionsCount', '/MainSec=Datas /RootOnly=true'))

[Setup]
AppId={#ReadINIEx('ReadString', '/Sec=Setup /Key=Path')}
AppName={#ReadINIEx('ReadString', '/Sec=Game /Key=Name')}
AppVersion={#ReadINIEx('ReadString', '/Sec=Game /Key=Version')}
AppPublisher={#ReadINIEx('ReadString', '/Sec=Game /Key=Publisher')}
DefaultDirName={sd}\{#ReadINIEx('ReadString', '/Sec=Setup /Key=Path')}
DefaultGroupName={#ReadINIEx('ReadString', '/Sec=Setup /Key=Path')}
DirExistsWarning=False
DisableProgramGroupPage=True
DisableReadyPage=True
DisableWelcomePage=False
OutputBaseFilename=OpenSetup
UsePreviousAppDir=False
UninstallFilesDir={app}\Uninstall
UninstallDisplayName={#SetupSetting('AppName')}
UninstallDisplayIcon={uninstallexe}
ShowLanguageDialog=False
SetupIconFile=setup.ico
WizardStyle=modern dark

#include "Messages.iss"

[Files]
Source: "Modules\FMXBridge_x86.dll"; DestName: "FMXBridge.dll"; Flags: dontcopy
Source: "Files\*"; Flags: dontcopy recursesubdirs
Source: "Modules\ISArcEx.dll"; Flags: dontcopy
#include "Script_ToolsList.iss"

#if MAX_ICONS > 0
[Icons]
#sub InitIcons
  #define IcnSubSec ReadINIEx('GetSubSection', '/MainSec=Execs /Idx=' + Str(i) + ' /RootOnly=true')
  #if IcnSubSec != ""
    #define IcnName ReadINIEx('ReadSubString', '/MainSec=Execs /SubSec=' + IcnSubSec + ' /Key=Name')
    #define IcnExe ReadINIEx('ReadSubString', '/MainSec=Execs /SubSec=' + IcnSubSec + ' /Key=Exe')
    #define IcnIcon ReadINIEx('ReadSubString', '/MainSec=Execs /SubSec=' + IcnSubSec + ' /Key=Icon')
    #define IcnArgs ReadINIEx('ReadSubString', '/MainSec=Execs /SubSec=' + IcnSubSec + ' /Key=Args')
    #define IcnWorkDir ReadINIEx('ReadSubString', '/MainSec=Execs /SubSec=' + IcnSubSec + ' /Key=WorkDir')
Name: "{autodesktop}\{#IcnName}"; Filename: "{#IcnWorkDir}\{#IcnExe}"; IconFilename: "{#IcnWorkDir}\{#IcnIcon}"; Parameters: {#IcnArgs}; WorkingDir: "{#IcnWorkDir}"; Flags: createonlyiffileexists; Check: CreateDesktopIcons
Name: "{group}\{#IcnName}"; Filename: "{#IcnWorkDir}\{#IcnExe}"; IconFilename: "{#IcnWorkDir}\{#IcnIcon}"; Parameters: {#IcnArgs}; WorkingDir: "{#IcnWorkDir}"; Flags: createonlyiffileexists; Check: CreateGroupIcons
Name: "{group}\Uninstall {#IcnName}"; Filename: "{uninstallexe}"; IconFilename: "{uninstallexe}"; Parameters: ""; WorkingDir: "{app}\Uninstall"; Flags: createonlyiffileexists; Check: CreateGroupIcons
  #endif
#endsub
#for {i = 0; i < MAX_ICONS; i++} InitIcons
#endif

[UninstallDelete]
Name: {app}; Type: FilesAndOrDirs

[Code]
#include "Modules\FMXBridgeHandle.iss"
#include "Modules\ISArcEx.iss"

type
  TMyData = record
    Title, FileName, Args: String;
    Size: Integer;
  end;

var
  FMXForm: FForm;

  ISArcDiskAddingSuccess: Boolean;
  ISArcExError: Boolean;
  ISArcExCancel: Integer;
  ISArcExDiskCount: Integer;

  DiskUsage: FDiskUsage;
  CompoSize: Integer;

  FormLayer: FLayout;
  FormShadow: FRectangle;
  TitleBar: FWinTitleBar;
  TitleLine: FLine;

  Page1: FLayout;
  Page1Img: FRectangle;
  Page1ImgShadow: FShadowEffect;
  Page1Line: FLabel;
  Page1Lbl: array [1..4] of FLabel;
  Page1SizeInfo: FButton;
  NextBtn: FButton;

  Page2: FLayout;
  Page2Lbl: array [1..10] of FLabel;
  Page2Line: array [1..3] of FLabel;
  Page2Edit: FEdit;
  DirBrowseBtn: FButton;
  Page2SizeInfo: FButton;
  InstallBtn: FButton;
  CheckboxTree: FCheckboxTree;
#if MAX_ICONS > 0
  SectionIcons: NativeInt;
  DesktopIconCheckBox: NativeInt;
  GroupIconCheckBox: NativeInt;
#endif
#if MAX_REDIST > 0
  SectionRedist: NativeInt;
  RedistCheckBox: array [1..{#MAX_REDIST}] of NativeInt;
  RedistData: array [1..{#MAX_REDIST}] of TMyData;
#endif
#if MAX_COMPO > 0
  SectionCompo: NativeInt;
  CompoCheckBox: array [1..{#MAX_COMPO}] of NativeInt;
  CompoData: array [1..{#MAX_COMPO}] of TMyData;
#endif

  Page3: FLayout;
  Page3Line: FLabel;
  Page3Lbl: array [1..5] of FLabel;
  ProgressBar: FProgressBar;

  Page4: FLayout;
  Page4Line: FLabel;
  Page4Lbl: array [1..5] of FLabel;
  PlayBtn: FButton;
  FinishBtn: FButton;

  MsgForm: FMsgForm;
  MsgFormLayer: FLayout;
  MsgFormTitleBar: FWinTitleBar;
  MsgFormLine: FRectangle;
  MsgFormTitleLbl: FLabel;
  MsgFormSubTitleLbl: FLabel;
  MsgFormBtn: FButton;

  ExitForm: FMsgForm;
  ExitFormLayer: FLayout;
  ExitFormTitleBar: FWinTitleBar;
  ExitFormLine: FRectangle;
  ExitFormTitleLbl: FLabel;
  ExitFormSubTitleLbl: FLabel;
  ExitFormYesBtn: FButton;
  ExitFormNoBtn: FButton;

procedure FMXInit;
var
  i: Integer;
begin
  FMXForm:= InitFormHandle;
  DiskUsage:= InitDiskUsage;
  FormLayer:= InitLayoutHandle;
  FormShadow:= InitRectangleHandle;
  TitleBar:= InitWinTitleBarHandle;
  TitleLine:= InitLineHandle;

  Page1:= InitLayoutHandle;
  Page1Img:= InitRectangleHandle;
  Page1ImgShadow:= InitShadowEffect;
  Page1Line:= InitLabelHandle;
  for i:= 1 to 4 do Page1Lbl[i]:= InitLabelHandle;
  Page1SizeInfo:= InitButtonHandle;
  NextBtn:= InitButtonHandle;

  Page2:= InitLayoutHandle;
  for i:= 1 to 10 do Page2Lbl[i]:= InitLabelHandle;
  for i:= 1 to 3 do Page2Line[i]:= InitLabelHandle;
  Page2Edit:= InitEditHandle;
  DirBrowseBtn:= InitButtonHandle;
  Page2SizeInfo:= InitButtonHandle;
  InstallBtn:= InitButtonHandle;
  CheckboxTree:= InitCheckBoxTree;

  Page3:= InitLayoutHandle;
  Page3Line:= InitLabelHandle;
  for i:= 1 to 5 do Page3Lbl[i]:= InitLabelHandle;
  ProgressBar:= InitProgressBarHandle;

  Page4:= InitLayoutHandle;
  Page4Line:= InitLabelHandle;
  for i:= 1 to 5 do Page4Lbl[i]:= InitLabelHandle;
  PlayBtn:= InitButtonHandle;
  FinishBtn:= InitButtonHandle;

  MsgForm:= InitMsgFormHandle;
  MsgFormLayer:= InitLayoutHandle;
  MsgFormTitleBar:= InitWinTitleBarHandle;
  MsgFormLine:= InitRectangleHandle;
  MsgFormTitleLbl:= InitLabelHandle;
  MsgFormSubTitleLbl:= InitLabelHandle;
  MsgFormBtn:= InitButtonHandle;

  ExitForm:= InitMsgFormHandle;
  ExitFormLayer:= InitLayoutHandle;
  ExitFormTitleBar:= InitWinTitleBarHandle;
  ExitFormLine:= InitRectangleHandle;
  ExitFormTitleLbl:= InitLabelHandle;
  ExitFormSubTitleLbl:= InitLabelHandle;
  ExitFormYesBtn:= InitButtonHandle;
  ExitFormNoBtn:= InitButtonHandle;
end;

function InitializeSetup: Boolean;
begin
  FMXInit;

  Result:= True;
end;

procedure DeinitializeSetup();
begin
  FMXBridgeShutDown;
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  Confirm:= False;
end;

#if MAX_ICONS > 0
function CreateDesktopIcons: Boolean;
begin
  Result:= CheckboxTree.CheckboxGetChecked(DesktopIconCheckBox);
end;

function CreateGroupIcons: Boolean;
begin
  Result:= CheckboxTree.CheckboxGetChecked(GroupIconCheckBox);
end;
#endif

function ProgressCallback(ProgressInfo: TISArcExProgressInfo): LongWord;
begin
  ProgressBar.Value(ProgressInfo.OverallProgressPct);
  Page3Lbl[2].Text(MinimizePathName(ExpandConstant('{app}\') + ProgressInfo.CurrentFileName, WizardForm.FileNameLabel.Font, WizardForm.FileNameLabel.Width));
  Page3Lbl[3].Text(CustomMessage('Page3Lbl3') + ' ' + ProgressInfo.RemainingTime);
  Page3Lbl[4].Text(CustomMessage('Page3Lbl4') + ' ' + ProgressInfo.ElapsedTime);
  Page3Lbl[5].Text(IntToStr(ProgressInfo.OverallProgressPct div 10) + '%');
  Page4Lbl[4].Text(CustomMessage('Page4Lbl4') + ' ' + ProgressInfo.ElapsedTime);

  Result:= ISArcExCancel;
end;

procedure ShowMsgForm(const Title, SubTitle: WideString);
begin
  MsgFormTitleLbl.Text(Title);
  MsgFormSubTitleLbl.Text(SubTitle);
  MsgForm.Show;
end;

function NextButtonClick(CurPage: Integer): Boolean;
begin
  Result:= True;

  if CurPage = wpSelectDir then
    if Round(DiskUsage.FreeSpace) < Round(CompoSize) then
    begin
      Result:= False;
      ShowMsgForm(CustomMessage('MsgSpaceErr1'), CustomMessage('MsgSpaceErr2'));
    end;
end;

procedure CalcSize(Sender: TObject);
var
  GameSize, NeedSize, i: Integer;
begin
  GameSize:= {#GameSize};
  NeedSize:= {#ReadINIEx('ReadString', '/Sec=Setup /Key=NeedSize')};

#if MAX_COMPO > 0
  for i:= 1 to GetArrayLength(CompoData) do
    if CheckboxTree.CheckBoxGetChecked(CompoCheckBox[i]) then
      GameSize:= GameSize + CompoData[i].Size;
#endif

  CompoSize:= GameSize;
  DiskUsage.SetDir(WizardForm.DirEdit.Text);
  Page2SizeInfo.Text(FmtMessage(CustomMessage('Page2SizeInfo'), [MbOrTb(DiskUsage.TotalSpace, 0, CustomMessage('sMb'), CustomMessage('sGb'), CustomMessage('sTb')),
                                                                 MbOrTb(DiskUsage.FreeSpace, 0, CustomMessage('sMb'), CustomMessage('sGb'), CustomMessage('sTb')),
                                                                 MbOrTb(CompoSize + NeedSize, 0, CustomMessage('sMb'), CustomMessage('sGb'), CustomMessage('sTb')),
                                                                 MbOrTb(CompoSize, 0, CustomMessage('sMb'), CustomMessage('sGb'), CustomMessage('sTb'))]));
end;

procedure Page2EditOnTyping(Sender: TObject);
begin
  WizardForm.DirEdit.Text:= Page2Edit.GetText;
  CalcSize(nil);
end;

procedure DirEditOnChange(Sender: TObject);
begin
  Page2Edit.Text(WizardForm.DirEdit.Text);
  CalcSize(nil);
end;

procedure CommonOnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  case Sender of

    TObject(TitleBar.GetObjectMinBtn):
      FMXForm.Minimize;

    TObject(TitleBar.GetObjectExitBtn):
    begin
      case WizardForm.CurPageID of
        wpWelcome,
        wpSelectDir:
          ExitForm.Show;

        wpInstalling:
        begin
          ISArcExSuspendProc;
          ExitForm.Show;
        end;

        wpFinished:
          WizardForm.NextButton.OnClick(Sender);
      end;
    end;

    TObject(ExitFormYesBtn.GetObject):
    begin
      if ISArcExIsSuspended then
      begin
        ISArcExCancel:= 1;
        ISArcExResumeProc;
        ExitForm.Close;
      end else
      WizardForm.CancelButton.OnClick(Sender);
    end;

    TObject(ExitFormNoBtn.GetObject):
    begin
      if ISArcExIsSuspended then
      begin
        ISArcExCancel:= 0;
        ISArcExResumeProc;
      end;
      ExitForm.Close;
    end;

    TObject(NextBtn.GetObject):
      WizardForm.NextButton.OnClick(Sender);

    TObject(DirBrowseBtn.GetObject):
      WizardForm.DirBrowseButton.OnClick(Sender);

    TObject(InstallBtn.GetObject):
      WizardForm.NextButton.OnClick(Sender);

    TObject(MsgFormBtn.GetObject):
      MsgForm.Close;

    TObject(PlayBtn.GetObject):
    begin
      if not ISArcExError then
        Exec(ExpandConstant('{app}\{#ReadINIEx('ReadString', '/Sec=Setup /Key=PlayExe')}'), '', '', SW_SHOW, ewNoWait, ErrorCode);
      WizardForm.NextButton.OnClick(Sender);
    end;

    TObject(FinishBtn.GetObject):
    begin
      if ISArcExError then
        ShellExec('open', '{#ReadINIEx('ReadString', '/Sec=Setup /Key=HelpLink')}', '', '', SW_SHOW, ewNoWait, ErrorCode)
      else
        WizardForm.NextButton.OnClick(Sender);
    end;

  end;
end;

procedure FMXDesigning;
var
  WS: WideString;
begin
  FMXForm.FCreateBlankForm(WizardForm.Handle, 0, ExtractAndLoad('fon.jpg'), True);
  FMXForm.LoadStyleFromFile(ExtractAndLoad('style.style'), {#AccentClr});
  FMXForm.SetContextMenuLanguage(ActiveLanguage);

  FormLayer.FCreate(FMXForm.Handle);
  FormLayer.Align(Client);

  FormShadow.FCreate(FormLayer.Handle);
  FormShadow.Align(Contents);
  FormShadow.FillGradient($FF161A20, $B0161A20, gsLinear);
  FormShadow.FillGradientPosition(0, 0.5, 1, 0.5);

  TitleBar.FCreate(FormLayer.Handle, True);
  TitleBar.Title(CustomMessage('TitleBar'));
  TitleBar.TitleFontSetting('Segoe UI Variable Small', 12, $FFA9A9A9);
  TitleBar.ExitBtnOnClick(@CommonOnClick);
  TitleBar.MinBtnOnClick(@CommonOnClick);
  FMXForm.AddMouseDownControls(TitleBar.Handle);

  TitleLine.FCreate(FormLayer.Handle);
  TitleLine.Align(Top);
  TitleLine.Height(1);
  TitleLine.StrokeColor($FF6C6C6C);
  TitleLine.StrokeSetting(1, scFlat, sdSolid, sjMiter);

  Page1.FCreate(FormLayer.Handle);
  Page1.Align(Client);

  Page1Img.FCreate(Page1.Handle);
  Page1Img.SetBounds(70, 42, 172, 258);
  Page1Img.FillPicture(ExtractAndLoad('cover.jpg'), wmTileStretch);
  Page1Img.CornerStyle(6, 6, [tcTopLeft, tcTopRight, tcBottomLeft, tcBottomRight], ctRound);

  Page1ImgShadow.FCreate(Page1Img.Handle);
  Page1ImgShadow.Distance(0);
  Page1ImgShadow.ShadowColor($FF000000);
  Page1ImgShadow.Opacity(0.9);
  Page1ImgShadow.Softness(0.3);

  Page1Line.FCreate(Page1.Handle);
  Page1Line.Position(288, 50);
  Page1Line.StyleLookup('line');

  Page1Lbl[1].FCreate(Page1.Handle);
  Page1Lbl[1].SetBounds(288, 63, 460, 30);
  Page1Lbl[1].Text('{#SetupSetting('AppName')}');
  Page1Lbl[1].FontSetting('Segoe UI Variable Display', 20, $FFFFFFFF);
  Page1Lbl[1].TextSetting(False, txLeading, txLeading);

  ReadAllText(ExtractAndLoad('info.txt'), WS);

  Page1Lbl[2].FCreate(Page1.Handle);
  Page1Lbl[2].SetBounds(288, 104, 428, 94);
  Page1Lbl[2].Text(WS);
  Page1Lbl[2].FontSetting('Segoe UI Variable Small', 11, $FFA9A9A9);
  Page1Lbl[2].TextSetting(True, txLeading, txLeading);

  Page1Lbl[3].FCreate(Page1.Handle);
  Page1Lbl[3].SetBounds(288, 222, 460, 20);
  Page1Lbl[3].Text('{#ReadINIEx('ReadString', '/Sec=Game /Key=Genre')}');
  Page1Lbl[3].FontSetting('Segoe UI Variable Small', 11, $FFFFFFFF);
  Page1Lbl[3].TextSetting(False, txLeading, txLeading);

  Page1SizeInfo.FCreate(Page1.Handle);
  Page1SizeInfo.SetBounds(484, 264, 63, 36);
  Page1SizeInfo.Text(MbOrTb({#GameSize}, 0, CustomMessage('sMB'), CustomMessage('sGB'), CustomMessage('sTB')));
  Page1SizeInfo.StyleLookup('btn_cust');
  Page1SizeInfo.HitTest(False);

  Page1Lbl[4].FCreate(Page1.Handle);
  Page1Lbl[4].SetBounds(484, 303, 63, 16);
  Page1Lbl[4].Text(CustomMessage('Page1Lbl4'));
  Page1Lbl[4].FontSetting('Segoe UI Variable Small', 9, $FF9E9E9E);
  Page1Lbl[4].TextSetting(False, txCenter, txLeading);

  NextBtn.FCreate(Page1.Handle);
  NextBtn.SetBounds(288, 264, 180, 36);
  NextBtn.Text(CustomMessage('NextBtn'));
  NextBtn.OnClick(@CommonOnClick);

  Page2.FCreate(FormLayer.Handle);
  Page2.Align(Client);
  Page2.Opacity(0);
  Page2.Enabled(False);

  Page2Lbl[1].FCreate(Page2.Handle);
  Page2Lbl[1].SetBounds(70, 36, 440, 35);
  Page2Lbl[1].Text(CustomMessage('Page2Lbl1'));
  Page2Lbl[1].FontSetting('Segoe UI Variable Display', 20, $FFFFFFFF);
  Page2Lbl[1].TextSetting(False, txLeading, txLeading);

  Page2Lbl[2].FCreate(Page2.Handle);
  Page2Lbl[2].SetBounds(70, 74, 98, 20);
  Page2Lbl[2].Text(CustomMessage('Page2Lbl2'));
  Page2Lbl[2].FontSetting('Segoe UI Variable Small', 11, $FFFFFFFF);
  Page2Lbl[2].TextSetting(False, txLeading, txLeading);

  Page2Lbl[3].FCreate(Page2.Handle);
  Page2Lbl[3].SetBounds(70, 140, 440, 20);
  Page2Lbl[3].Text(CustomMessage('Page2Lbl3'));
  Page2Lbl[3].FontSetting('Segoe UI Variable Small', 11, $FFFFFFFF);
  Page2Lbl[3].TextSetting(False, txLeading, txLeading);

  Page2Lbl[4].FCreate(Page2.Handle);
  Page2Lbl[4].SetBounds(529, 140, 110, 20);
  Page2Lbl[4].Text(CustomMessage('Page2Lbl4'));
  Page2Lbl[4].FontSetting('Segoe UI Variable Small', 11, $FFFFFFFF);
  Page2Lbl[4].TextSetting(False, txLeading, txLeading);

  Page2Line[1].FCreate(Page2.Handle);
  Page2Line[1].Position(170, 82);
  Page2Line[1].StyleLookup('line');

  Page2Line[2].FCreate(Page2.Handle);
  Page2Line[2].Position(170, 148);
  Page2Line[2].StyleLookup('line');

  Page2Line[3].FCreate(Page2.Handle);
  Page2Line[3].Position(640, 148);
  Page2Line[3].StyleLookup('line');

  Page2Edit.FCreate(Page2.Handle);
  Page2Edit.SetBounds(70, 95, 444, 36);
  Page2Edit.Text(WizardForm.DirEdit.Text);
  Page2Edit.FontSetting('Segoe UI Variable Small', 11, $FF6C6C6C);
  Page2Edit.OnTyping(@Page2EditOnTyping);

  DirBrowseBtn.FCreate(Page2.Handle);
  DirBrowseBtn.SetBounds(529, 95, 180, 36);
  DirBrowseBtn.Text(CustomMessage('DirBrowseBtn'));
  DirBrowseBtn.OnClick(@CommonOnClick);

  Page2SizeInfo.FCreate(Page2.Handle);
  Page2SizeInfo.SetBounds(529, 161, 180, 93);
  Page2SizeInfo.Text('');
  Page2SizeInfo.FontSetting('Segoe UI Variable Small', 11, $FFA9A9A9);
  Page2SizeInfo.TextSetting(False, txLeading, txCenter);
  Page2SizeInfo.HitTest(False);
  Page2SizeInfo.StyleLookup('info_rect');

  InstallBtn.FCreate(Page2.Handle);
  InstallBtn.SetBounds(529, 264, 180, 36);
  InstallBtn.Text(CustomMessage('InstallBtn'));
  InstallBtn.OnClick(@CommonOnClick);

  CheckboxTree.FCreate(Page2.Handle);
  CheckboxTree.SetBounds(70, 161, 444, 139);
  CheckboxTree.ScrollAnimation(True);
  CheckboxTree.ItemHeight(20);

#if MAX_ICONS > 0
  SectionIcons:= CheckboxTree.AddEmptySection(NativeInt(CheckboxTree.Handle), CustomMessage('SectionIcons'));
  CheckboxTree.SectionFontSetting(SectionIcons, 'Segoe UI Variable Small', 11, $FFFFFFFF);

  DesktopIconCheckBox:= CheckboxTree.AddCheckBox(SectionIcons, 10, 1, 380, CustomMessage('DesktopIconCheckBox'));
  CheckBoxTree.CheckBoxSetChecked(DesktopIconCheckBox, True);
  CheckboxTree.CheckBoxFontSetting(DesktopIconCheckBox, 'Segoe UI Variable Small', 11, $FFFFFFFF);

  GroupIconCheckBox:= CheckboxTree.AddCheckBox(SectionIcons, 10, 1, 380, CustomMessage('GroupIconCheckBox'));
  CheckBoxTree.CheckBoxSetChecked(GroupIconCheckBox, True);
  CheckboxTree.CheckBoxFontSetting(GroupIconCheckBox, 'Segoe UI Variable Small', 11, $FFFFFFFF);
#endif

#if MAX_REDIST > 0
  SectionRedist:= CheckboxTree.AddEmptySection(NativeInt(CheckboxTree.Handle), CustomMessage('SectionRedist'));
  CheckboxTree.SectionFontSetting(SectionRedist, 'Segoe UI Variable Small', 11, $FFFFFFFF);
#sub InitRedists
  #define SubSec ReadInIEx('GetSubSection', '/MainSec=Redists /Idx=' + Str(i) + ' /RootOnly=true')
  #if SubSec != ""
  RedistData[{#i} + 1].Title:= '{#ReadInIEx('ReadSubString', '/MainSec=Redists /SubSec=' + SubSec + ' /Key=Name')}';
  RedistData[{#i} + 1].FileName:= ExpandConstant('{#ReadInIEx('ReadSubString', '/MainSec=Redists /SubSec=' + SubSec + ' /Key=File')}');
  RedistData[{#i} + 1].Args:= '{#ReadInIEx('ReadSubString', '/MainSec=Redists /SubSec=' + SubSec + ' /Key=Args')}';

  RedistCheckBox[{#i} + 1]:= CheckboxTree.AddCheckBox(SectionRedist, 10, 1, 380, RedistData[{#i} + 1].Title);
  CheckboxTree.CheckBoxFontSetting(RedistCheckBox[{#i} + 1], 'Segoe UI Variable Small', 11, $FFFFFFFF);
  #endif
#endsub
#for {i = 0; i < MAX_REDIST; i++} InitRedists
#endif

#if MAX_COMPO > 0
  SectionCompo:= CheckboxTree.AddEmptySection(NativeInt(CheckboxTree.Handle), CustomMessage('SectionCompo'));
  CheckboxTree.SectionFontSetting(SectionCompo, 'Segoe UI Variable Small', 11, $FFFFFFFF);
#sub InitCompos
  #define CompoSubSec ReadInIEx('GetSubSection', '/MainSec=Compos /Idx=' + Str(i) + ' /RootOnly=true')
  #if CompoSubSec != ""
  CompoData[{#i} + 1].Title:= '{#ReadInIEx('ReadSubString', '/MainSec=Compos /SubSec=' + CompoSubSec + ' /Key=Name')}';
  CompoData[{#i} + 1].FileName:= ExpandConstant('{#ReadInIEx('ReadSubString', '/MainSec=Compos /SubSec=' + CompoSubSec + ' /Key=File')}');
  CompoData[{#i} + 1].Size:= {#ReadInIEx('ReadSubString', '/MainSec=Compos /SubSec=' + CompoSubSec + ' /Key=Size')};

  CompoCheckBox[{#i} + 1]:= CheckboxTree.AddCheckBox(SectionCompo, 10, 1, 380, CompoData[{#i} + 1].Title + ' | ' + MbOrTb(CompoData[{#i} + 1].Size, 0, CustomMessage('sMb'), CustomMessage('sGb'), CustomMessage('sTb')));
  CheckboxTree.CheckBoxFontSetting(CompoCheckBox[{#i} + 1], 'Segoe UI Variable Small', 11, $FFFFFFFF);
  CheckboxTree.ItemOnChange(CompoCheckBox[{#i} + 1], @CalcSize);
  #endif
#endsub
#for {i = 0; i < MAX_COMPO; i++} InitCompos
#endif

  Page3.FCreate(FormLayer.Handle);
  Page3.Align(Client);
  Page3.Opacity(0);
  Page3.Enabled(False);

  Page3Line.FCreate(Page3.Handle);
  Page3Line.Position(70, 42);
  Page3Line.StyleLookup('line');

  Page3Lbl[1].FCreate(Page3.Handle);
  Page3Lbl[1].SetBounds(70, 55, 640, 30);
  Page3Lbl[1].Text(CustomMessage('Page3Lbl1'));
  Page3Lbl[1].FontSetting('Segoe UI Variable Display', 20, $FFFFFFFF);
  Page3Lbl[1].TextSetting(False, txLeading, txLeading);

  Page3Lbl[2].FCreate(Page3.Handle);
  Page3Lbl[2].SetBounds(70, 96, 640, 20);
  Page3Lbl[2].Text('***');
  Page3Lbl[2].FontSetting('Segoe UI Variable Small', 11, $FFA9A9A9);
  Page3Lbl[2].TextSetting(False, txLeading, txLeading);

  Page3Lbl[3].FCreate(Page3.Handle);
  Page3Lbl[3].SetBounds(70, 111, 640, 20);
  Page3Lbl[3].Text(CustomMessage('Page3Lbl3'));
  Page3Lbl[3].FontSetting('Segoe UI Variable Small', 11, $FFA9A9A9);
  Page3Lbl[3].TextSetting(False, txLeading, txLeading);

  Page3Lbl[4].FCreate(Page3.Handle);
  Page3Lbl[4].SetBounds(70, 126, 640, 20);
  Page3Lbl[4].Text(CustomMessage('Page3Lbl4'));
  Page3Lbl[4].FontSetting('Segoe UI Variable Small', 11, $FFA9A9A9);
  Page3Lbl[4].TextSetting(False, txLeading, txLeading);

  ProgressBar.FCreate(Page3.Handle);
  ProgressBar.SetBounds(70, 159, 640, 36);
  ProgressBar.Max(1000);

  Page3Lbl[5].FCreate(ProgressBar.Handle);
  Page3Lbl[5].Align(Center);
  Page3Lbl[5].AutoSize(True);
  Page3Lbl[5].Text('00%');
  Page3Lbl[5].FontSetting('Segoe UI Variable Small', 11, $FFFFFFFF);
  Page3Lbl[5].TextSetting(False, txCenter, txCenter);

  Page4.FCreate(FormLayer.Handle);
  Page4.Align(Client);
  Page4.Opacity(0);
  Page4.Enabled(False);

  Page4Line.FCreate(Page4.Handle);
  Page4Line.Position(70, 42);
  Page4Line.StyleLookup('line');

  Page4Lbl[1].FCreate(Page4.Handle);
  Page4Lbl[1].SetBounds(70, 55, 635, 30);
  Page4Lbl[1].Text('{#SetupSetting('AppName')}');
  Page4Lbl[1].FontSetting('Segoe UI Variable Display', 20, $FFFFFFFF);
  Page4Lbl[1].TextSetting(False, txLeading, txLeading);

  Page4Lbl[2].FCreate(Page4.Handle);
  Page4Lbl[2].SetBounds(70, 96, 635, 20);
  Page4Lbl[2].Text(CustomMessage('Page4Lbl2'));
  Page4Lbl[2].FontSetting('Segoe UI Variable Small', 11, {#AccentClr});
  Page4Lbl[2].TextSetting(False, txLeading, txLeading);

  Page4Lbl[3].FCreate(Page4.Handle);
  Page4Lbl[3].SetBounds(70, 111, 635, 20);
  Page4Lbl[3].Text(CustomMessage('Page4Lbl3'));
  Page4Lbl[3].FontSetting('Segoe UI Variable Small', 11, $FFFFFFFF);
  Page4Lbl[3].TextSetting(True, txLeading, txLeading);

  Page4Lbl[4].FCreate(Page4.Handle);
  Page4Lbl[4].SetBounds(70, 186, 635, 20);
  Page4Lbl[4].Text(CustomMessage('Page4Lbl4'));
  Page4Lbl[4].FontSetting('Segoe UI Variable Small', 11, $FFFFFFFF);
  Page4Lbl[4].TextSetting(False, txLeading, txLeading);

  PlayBtn.FCreate(Page4.Handle);
  PlayBtn.SetBounds(70, 264, 180, 36);
  PlayBtn.Text(CustomMessage('PlayBtn'));
  PlayBtn.OnClick(@CommonOnClick);

  FinishBtn.FCreate(Page4.Handle);
  FinishBtn.SetBounds(267, 264, 106, 36);
  FinishBtn.Text(CustomMessage('ExitBtn'));
  FinishBtn.StyleLookup('btn_cust');
  FinishBtn.OnClick(@CommonOnClick);

  Page4Lbl[5].FCreate(Page4.Handle);
  Page4Lbl[5].SetBounds(267, 304, 106, 16);
  Page4Lbl[5].Text(CustomMessage('Page4Lbl5'));
  Page4Lbl[5].FontSetting('Segoe UI Variable Small', 9, $FFA9A9A9);
  Page4Lbl[5].TextSetting(False, txCenter, txLeading);

  MsgForm.FCreateBlankForm(FMXForm.HandleHWND, $FF161A20, '', True);
  MsgForm.Height(180);
  MsgForm.Width(364);

  MsgFormLayer.FCreate(MsgForm.Handle);
  MsgFormLayer.Align(Client);

  MsgFormTitleBar.FCreate(MsgFormLayer.Handle, True);
  MsgFormTitleBar.IconVisible(False);
  MsgFormTitleBar.TitleVisible(False);
  MsgFormTitleBar.MinBtnVisible(False);
  MsgFormTitleBar.ExitBtnEnabled(False);
  MsgForm.AddMouseDownControls(MsgFormTitleBar.Handle);

  MsgFormTitleLbl.FCreate(MsgFormLayer.Handle);
  MsgFormTitleLbl.SetBounds(30, 22, 300, 22);
  MsgFormTitleLbl.Text('');
  MsgFormTitleLbl.FontSetting('Segoe UI Variable Text', 16, $FFFFFFFF);
  MsgFormTitleLbl.TextSetting(False, txLeading, txLeading);

  MsgFormSubTitleLbl.FCreate(MsgFormLayer.Handle);
  MsgFormSubTitleLbl.SetBounds(30, 55, 300, 50);
  MsgFormSubTitleLbl.Text('');
  MsgFormSubTitleLbl.FontSetting('Segoe UI Variable Small', 11, $FFA9A9A9);
  MsgFormSubTitleLbl.TextSetting(True, txLeading, txCenter);

  MsgFormLine.FCreate(MsgFormLayer.Handle);
  MsgFormLine.SetBounds(1, 122, 362, 1);
  MsgFormLine.FillColor($80777777);

  MsgFormBtn.FCreate(MsgFormLayer.Handle);
  MsgFormBtn.SetBounds(142, 138, 80, 26);
  MsgFormBtn.Text(CustomMessage('MsgFormBtn'));
  MsgFormBtn.OnClick(@CommonOnClick);

  ExitForm.FCreateBlankForm(FMXForm.HandleHWND, $FF161A20, '', True);
  ExitForm.Height(180);
  ExitForm.Width(364);

  ExitFormLayer.FCreate(ExitForm.Handle);
  ExitFormLayer.Align(Client);

  ExitFormTitleBar.FCreate(ExitFormLayer.Handle, True);
  ExitFormTitleBar.IconVisible(False);
  ExitFormTitleBar.TitleVisible(False);
  ExitFormTitleBar.MinBtnVisible(False);
  ExitFormTitleBar.ExitBtnEnabled(False);
  ExitForm.AddMouseDownControls(ExitFormTitleBar.Handle);

  ExitFormTitleLbl.FCreate(ExitFormLayer.Handle);
  ExitFormTitleLbl.SetBounds(30, 22, 300, 22);
  ExitFormTitleLbl.Text(CustomMessage('ExitFormTitleLbl'));
  ExitFormTitleLbl.FontSetting('Segoe UI Variable Text', 16, $FFFFFFFF);
  ExitFormTitleLbl.TextSetting(False, txLeading, txLeading);

  ExitFormSubTitleLbl.FCreate(ExitFormLayer.Handle);
  ExitFormSubTitleLbl.SetBounds(30, 55, 300, 50);
  ExitFormSubTitleLbl.Text(CustomMessage('ExitFormSubTitleLbl'));
  ExitFormSubTitleLbl.FontSetting('Segoe UI Variable Small', 11, $FFA9A9A9);
  ExitFormSubTitleLbl.TextSetting(True, txLeading, txCenter);

  ExitFormLine.FCreate(ExitFormLayer.Handle);
  ExitFormLine.SetBounds(1, 122, 362, 1);
  ExitFormLine.FillColor($80777777);

  ExitFormYesBtn.FCreate(ExitFormLayer.Handle);
  ExitFormYesBtn.SetBounds(160, 138, 80, 26);
  ExitFormYesBtn.Text(CustomMessage('ExitFormYesBtn'));
  ExitFormYesBtn.OnClick(@CommonOnClick);

  ExitFormNoBtn.FCreate(ExitFormLayer.Handle);
  ExitFormNoBtn.SetBounds(256, 138, 80, 26);
  ExitFormNoBtn.Text(CustomMessage('ExitFormNoBtn'));
  ExitFormNoBtn.StyleLookup('btn_cust');
  ExitFormNoBtn.OnClick(@CommonOnClick);
end;

procedure InitializeWizard();
begin
  EmptyWizardForm(780, 390);

  FMXDesigning;
  FMXForm.Show;

  WizardForm.DirEdit.OnChange:= @DirEditOnChange;
end;

procedure HideInterface;
var
  i: Integer;
begin
  Page1.Opacity(0);
  Page2.Opacity(0);
  Page3.Opacity(0);
  Page4.Opacity(0);
  Page1.Enabled(False);
  Page2.Enabled(False);
  Page3.Enabled(False);
  Page4.Enabled(False);

#if MAX_REDIST > 0
  for i:= 1 to GetArrayLength(RedistData) do
  if not FileExists(RedistData[i].FileName) then
  begin
    CheckBoxTree.CheckBoxSetChecked(RedistCheckBox[i], False);
    CheckBoxTree.CheckBoxEnable(RedistCheckBox[i], False);
  end;
#endif
#if MAX_COMPO > 0
  for i:= 1 to GetArrayLength(CompoData) do
  if not FileExists(CompoData[i].FileName) then
  begin
    CheckBoxTree.CheckBoxSetChecked(CompoCheckBox[i], False);
    CheckBoxTree.CheckBoxEnable(CompoCheckBox[i], False);
  end;
#endif
end;

procedure ShowInterface(CurPageID: integer);
begin
  case CurPageID of
    wpWelcome:
    begin
      Page1.Enabled(True);
      Page1.Opacity(1);
    end;

    wpSelectDir:
    begin
      CalcSize(nil);
      Page2.Enabled(True);
      FMXAnimateFloat(Page2.Handle, 'Opacity', 1, 0.2, 0, atInOut, itLinear);
    end;

    wpInstalling:
    begin
      Page3.Enabled(True);
      FMXAnimateFloat(Page3.Handle, 'Opacity', 1, 0.2, 0, atInOut, itLinear);
    end;

    wpFinished:
    begin
      Page4.Enabled(True);
      FMXAnimateFloat(Page4.Handle, 'Opacity', 1, 0.2, 0, atInOut, itLinear);

      if ISArcExError then
      begin
        PlayBtn.Text(CustomMessage('ExitBtn'));
        FinishBtn.Text(CustomMessage('HelpBtn'));
        Page4Lbl[2].Color($FFFF0000);
        Page4Lbl[2].Text(CustomMessage('Page4Lbl2ERR'));
        Page4Lbl[3].Text(CustomMessage('Page4Lbl3ERR'));
        Page4Lbl[5].Text(CustomMessage('Page4Lbl5ERR'));
      end;
    end;

  end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  HideInterface;
  ShowInterface(CurPageID);
end;

procedure CurStepChanged(CurStep : TSetupStep);
var
  i, ErrorCode: Integer;
  CompoFailed: Boolean;
begin
  if CurStep = ssInstall then
  begin
    ISArcExCancel:= 0;
    ISArcExDiskCount:= 0;
    ISArcDiskAddingSuccess:= False;
    ISArcExError:= True;
    CompoFailed:= False;
    #include "Script_ToolsList_Init.iss"
    ISArcExChangeLanguage(ActiveLanguage);

    repeat
    #if MAX_DISKS > 0
    #sub InitDataFiles
      #define DataSubSec ReadINIEx('GetSubSection', '/MainSec=Datas /Idx=' + Str(i) + ' /RootOnly=true')
      #if DataSubSec != ""
        #define DataFile ReadINIEx('ReadSubString', '/MainSec=Datas /SubSec=' + DataSubSec + ' /Key=File')
        if FileExists(ExpandConstant('{#DataFile}')) then
        begin
          ISArcDiskAddingSuccess:= ISArcExAddDisks(ExpandConstant('{#DataFile}'), '{#Password}', ExpandConstant('{app}'));
          if not ISArcDiskAddingSuccess then
            Break;
          ISArcExDiskCount:= ISArcExDiskCount + 1;
        end;
        #endif
      #endsub
    #for {i = 0; i < MAX_DISKS; i++} InitDataFiles
    #endif

    #if MAX_COMPO > 0
      for i:= 1 to GetArrayLength(CompoData) do
      begin
        if CheckBoxTree.CheckBoxGetChecked(CompoCheckBox[i]) then
        begin
          ISArcDiskAddingSuccess:= ISArcExAddDisks(CompoData[i].FileName, '{#Password}', ExpandConstant('{app}'));
          if not ISArcDiskAddingSuccess then
          begin
            CompoFailed:= True;
            Break;
          end;
          ISArcExDiskCount:= ISArcExDiskCount + 1;
        end;
      end;
      if CompoFailed then
        Break;
    #endif
    until true;

    if (ISArcDiskAddingSuccess) and ISArcExInit(2, @ProgressCallback) then
    begin
      ISArcExCallbackInterval(1);
      repeat
        for i:= 1 to ISArcExDiskCount do
        begin
          ISArcExError:= not ISArcExExtract(i, ExpandConstant('{tmp}\arc.ini'), ExpandConstant('{app}'));
          if ISArcExError then
            break;
        end;
      until true;
      ISArcExStop;
    end;

  end;

  if (CurStep = ssPostInstall) and ISArcExError then
  begin
    Page3Lbl[2].Text(CustomMessage('Page3Lbl2ERR'));
    ISArcExRun(ExpandConstant('{uninstallexe}'), '/VERYSILENT', False);
  end else
  if (CurStep = ssPostInstall) and (not ISArcExError) then
  begin
  #if MAX_REDIST > 0
    for i:= 1 to GetArrayLength(RedistData) do
    if CheckBoxTree.CheckBoxGetChecked(RedistCheckBox[i]) then
    begin
      Page3Lbl[2].Text(CustomMessage('Page3Lbl2R') + ' ' + RedistData[i].Title);
      Exec(RedistData[i].FileName, RedistData[i].Args, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
    end;
  #endif

    RegWriteDWordValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#StringChange(SetupSetting("AppId"), "{{", "{")}_is1', 'EstimatedSize', CompoSize * 1024);
  end;
end;
 

Вложения

Назад
Сверху