Inno Setup - 将 children 组件显示为同级组件并在复选框中显示复选而不是正方形

Inno Setup - Show children component as sibling and show check instead of square in checkbox

我正在尝试让 children 组件显示为同级组件。 我正在为一款游戏制作安装程序,该游戏可以在同一安装文件夹中共存多个版本。

现在我希望能够安装可选的 mods,这需要安装特定版本的游戏(依赖项)。因此,当用户单击 mod 时,将选择所需的游戏,如果取消选择游戏,则所有 mod 都将被取消选择。代码按预期工作并且行为如前所述。有时它会让用户感到有点困惑。例如,如果没有安装 mod,游戏中将显示一个正方形而不是检查,并且 mod 的层次结构是不必要的。

我想达到的目标:

  1. 我想让 game_2 显示 check 而不是 square
  2. game_2\com_mods 成为 game_2 的兄弟姐妹而不是 children。

就我所知,我想没有简单的方法可以达到这种效果。如果我使用 [Code] 部分没有错,可以 mod 验证 UI 但我不知道如何强制使用复选框而不是正方形并删除填充children.

这是我的示例代码:

[Setup]
AppName=Demo
AppVersion=1.0
DefaultDirName=.

[Components]
Name: "game_1";    Description: "Game v1";  Types: full custom; Flags: checkablealone
Name: "game_2";    Description: "Game v2";  Types: full custom; Flags: checkablealone
Name: "game_2\com_mods";    Description: "Game Community Mods"; Types: full custom;  Flags: dontinheritcheck
Name: "game_2\com_modsrdmod1"; Description: "Mod 1"; Flags: exclusive
Name: "game_2\com_modsrdmod1"; Description: "Mod 2"; Flags: exclusive
Name: "game_2\com_modsrdmod1"; Description: "Mod 3"; Flags: exclusive 

我希望有人能帮助我或指出正确的方向以产生预期的效果。

问候和感谢。

如果我没有正确理解你的问题,你需要这样的布局:

[Components]
Name: "game_1";    Description: "Game v1";  Types: full custom
Name: "game_2";    Description: "Game v2";  Types: full custom
Name: "com_mods";    Description: "Game Community Mods"; Types: full custom
Name: "com_modsrdmod1"; Description: "Mod 1"; Flags: exclusive
Name: "com_modsrdmod1"; Description: "Mod 2"; Flags: exclusive
Name: "com_modsrdmod1"; Description: "Mod 3"; Flags: exclusive 

但您想保留当前布局的行为。

然后您必须在 Pascal 脚本中编写行为代码:

[Code]

const
  Game2Index = 1;
  Game2ModsIndex = 2;

var
  Game2Checked: Boolean;

procedure ComponentsListClickCheck(Sender: TObject);
var
  ComponentsList: TNewCheckListBox;
begin
  ComponentsList := WizardForm.ComponentsList;

  { If Game 2 got unchecked }
  if Game2Checked and
     (not ComponentsList.Checked[Game2Index]) then
  begin
    { uncheck the mods }
    ComponentsList.Checked[Game2ModsIndex] := False;
  end; 

  { If Game 2 mods got checked, make sure Game 2 is checked too }
  if ComponentsList.Checked[Game2ModsIndex] and
     (not ComponentsList.Checked[Game2Index]) then
  begin
    ComponentsList.Checked[Game2Index] := True;
  end; 

  Game2Checked := ComponentsList.Checked[Game2Index];
end;

procedure InitializeWizard();
begin
  WizardForm.ComponentsList.OnClickCheck := @ComponentsListClickCheck;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectComponents then
  begin
    { Remember the initial state }
    Game2Checked := WizardForm.ComponentsList.Checked[Game2Index];
  end;
end;

在 Inno Setup 6 中,您可以使用 WizardIsComponentSelected and WizardSelectComponents 而不是使用索引。