2015-09-21 22 views
1

我試圖讓兒童組件顯示爲兄弟。 我正在做一個遊戲的安裝程序,它可以有多個版本的遊戲共存於同一個安裝文件夾中。Inno Setup - 將兒童組件顯示爲兄弟,並在複選框中顯示支票而不是方形

現在我希望能夠安裝需要安裝遊戲特定版本(依賴項)的可選mod。所以當用戶點擊一個mod時,所需的遊戲被選中,如果遊戲被取消選中,所有的mod都被取消選擇。代碼原樣按預期工作,並按照前面所述的方式運行。它有時候會讓用戶感到困惑。例如,如果沒有安裝mod,則在遊戲中顯示一個方塊而不是檢查,並且mods的層次結構是不必要的。

我想達到的目標:

  1. 我想有game_2表現出檢查代替
  2. 要有game_2\com_mods作爲game_2的兄弟姐妹,而不是孩子。

這是就我到達,我想有沒有簡單的方法來產生這種效果。如果我沒有錯,使用[Code]部分可以修改UI,但我不知道如何強制複選框而不是正方形,並刪除孩子的填充。

這裏是我的示例代碼:

[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 

我希望有人能幫助我,或點我在正確的方向產生預期的效果。

問候和感謝。

回答

4

如果我正確理解你的問題,你想這個佈局:

[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 

enter image description here

但你要保持你的當前佈局的行爲。

然後,你必須代碼帕斯卡爾腳本行爲:

[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; 
+0

這就是我一直在尋找。萬分感謝。這只是完美的工作。感謝代碼中的評論,我是Inno Setup中Pascal腳本的新手,所以它幫助我瞭解發生了什麼。 –