Inno设置 - 显示子组件为兄弟并显示检查,而不是正方形复选框 [英] Inno Setup - Show children component as sibling and show check instead of square in checkbox

查看:548
本文介绍了Inno设置 - 显示子组件为兄弟并显示检查,而不是正方形复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个子组件显示为同级。
我为一个游戏制作一个安装程序,可以有多个版本的游戏共存在同一个安装文件夹中。

I'm trying to have a children component to be shown as sibling. I'm making a installer for a Game which can have multiple versions of the game coexisting in the same installation folder.

现在我想有能力安装可选的mods,需要有一个特定版本的游戏安装(依赖)。所以当用户点击一个mod,所需的游戏被选中,如果游戏被取消选择,所有的mods取消选择。代码按原样工作,其行为如前所述。它只是有点混乱的用户有时。例如,如果没有安装mod,在游戏中显示一个正方形而不是支票,并且不需要mods的层次结构。

Now I want to have the ability to install optional mods which require to have a specific version of the game installed (dependency). So when the user clicks on a mod, the required game gets selected, and if the game is deselected, all the mods get deselected. The code as is is working as expected and behaves as described before. It just gets a bit confusing for the user sometimes. For example if no mod is installed, in the game a square is shown instead of a check, and the hierarchy of the mods is unnecessary.

我想要实现的:


  1. 我想要 game_2 显示支票而不是正方形

  2. game_2\com_mods 设为 game_2 的同级,一个孩子。

  1. I want to have game_2 to show a check instead of a square.
  2. To have game_2\com_mods as sibling of game_2 and not as a children.

这是我到达的地方,我想没有简单的方法有效果。如果我没有错误使用 [Code] 部分可以修改UI,但我不知道如何强制复选框而不是正方形,并删除

This is as far as I have arrived, I guess there is no easy way to have that effect. If I'm not wrong using the [Code] section it is possible to modify the UI but I don't know how to force the checkbox instead of the square and remove the padding of the 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_mods\3rdmod1"; Description: "Mod 1"; Flags: exclusive
Name: "game_2\com_mods\3rdmod1"; Description: "Mod 2"; Flags: exclusive
Name: "game_2\com_mods\3rdmod1"; Description: "Mod 3"; Flags: exclusive 

我希望有人能帮助我或指出正确的方向, 。

I hope somebody can help me or point me in the right direction to produce the desired effect.

问候和谢谢。

推荐答案

,您需要此布局:

[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_mods\3rdmod1"; Description: "Mod 1"; Flags: exclusive
Name: "com_mods\3rdmod1"; Description: "Mod 2"; Flags: exclusive
Name: "com_mods\3rdmod1"; Description: "Mod 3"; Flags: exclusive 

但是你想保持当前布局的行为。

But you want to keep the behavior of your current layout.

然后你必须在Pascal Scripting中编写行为:

Then you have to code the behavior in Pascal Scripting:

[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设置 - 显示子组件为兄弟并显示检查,而不是正方形复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆