From d4bdf59cc4b58b829cff0ffb5a16facf82ebf677 Mon Sep 17 00:00:00 2001 From: Mator Date: Mon, 28 Dec 2015 16:04:24 -0800 Subject: [PATCH] Progress on #75 --- lib/mte/mtePluginSelectionForm.dfm | 28 ++++++++- lib/mte/mtePluginSelectionForm.pas | 92 ++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/lib/mte/mtePluginSelectionForm.dfm b/lib/mte/mtePluginSelectionForm.dfm index d7eba6c..40e6315 100644 --- a/lib/mte/mtePluginSelectionForm.dfm +++ b/lib/mte/mtePluginSelectionForm.dfm @@ -80,6 +80,7 @@ object PluginSelectionForm: TPluginSelectionForm OnClick = btnOKClick end object PluginsPopupMenu: TPopupMenu + OnPopup = PluginsPopupMenuPopup Left = 48 Top = 24 object CheckAllItem: TMenuItem @@ -94,6 +95,31 @@ object PluginSelectionForm: TPluginSelectionForm Caption = 'Toggle all' OnClick = ToggleAllItemClick end + object N1: TMenuItem + Caption = '-' + end + object MastersItem: TMenuItem + Caption = 'Masters' + object CheckMastersItem: TMenuItem + Caption = 'Check masters' + OnClick = CheckMastersItemClick + end + object UncheckMastersItem: TMenuItem + Caption = 'Uncheck masters' + OnClick = UncheckMastersItemClick + end + end + object DependenciesItem: TMenuItem + Caption = 'Dependencies' + object CheckDependenciesItem: TMenuItem + Caption = 'Check dependencies' + OnClick = CheckDependenciesItemClick + end + object UncheckDependenciesItem: TMenuItem + Caption = 'Uncheck dependencies' + OnClick = UncheckDependenciesItemClick + end + end end object StateImages: TImageList Height = 17 @@ -101,7 +127,7 @@ object PluginSelectionForm: TPluginSelectionForm Left = 136 Top = 24 Bitmap = { - 494C0101030034005C0011001100FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 494C010103003400600011001100FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 0000000000003600000028000000440000001100000001002000000000001012 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 diff --git a/lib/mte/mtePluginSelectionForm.pas b/lib/mte/mtePluginSelectionForm.pas index c7b13bb..f596b00 100644 --- a/lib/mte/mtePluginSelectionForm.pas +++ b/lib/mte/mtePluginSelectionForm.pas @@ -25,6 +25,13 @@ TPluginSelectionForm = class(TForm) UncheckAllItem: TMenuItem; ToggleAllItem: TMenuItem; StateImages: TImageList; + MastersItem: TMenuItem; + N1: TMenuItem; + CheckMastersItem: TMenuItem; + UncheckMastersItem: TMenuItem; + CheckDependenciesItem: TMenuItem; + UncheckDependenciesItem: TMenuItem; + DependenciesItem: TMenuItem; procedure LoadFields(aListItem: TPluginListItem; sPlugin: string); procedure UpdateDisabled; procedure FormShow(Sender: TObject); @@ -47,6 +54,11 @@ TPluginSelectionForm = class(TForm) function GetMasterStatus(filename: string): Integer; procedure lvPluginsData(Sender: TObject; Item: TListItem); procedure FormClose(Sender: TObject; var Action: TCloseAction); + procedure CheckMastersItemClick(Sender: TObject); + procedure UncheckMastersItemClick(Sender: TObject); + procedure CheckDependenciesItemClick(Sender: TObject); + procedure UncheckDependenciesItemClick(Sender: TObject); + procedure PluginsPopupMenuPopup(Sender: TObject); private { Private declarations } slMasters, slDependencies, slMissing, slDisabled: TStringList; @@ -539,6 +551,16 @@ procedure TPluginSelectionForm.FormShow(Sender: TObject); lvPlugins.Repaint; end; +procedure TPluginSelectionForm.PluginsPopupMenuPopup(Sender: TObject); +var + bHasMasters, bHasDependencies: Boolean; +begin + bHasMasters := slMasters.Count > 0; + bHasDependencies := slDependencies.Count > 0; + MastersItem.Enabled := bHasMasters; + DependenciesItem.Enabled := bHasDependencies; +end; + procedure TPluginSelectionForm.CheckAllItemClick(Sender: TObject); var i: Integer; @@ -577,4 +599,74 @@ procedure TPluginSelectionForm.ToggleAllItemClick(Sender: TObject); lvPlugins.Repaint; end; +procedure TPluginSelectionForm.CheckMastersItemClick(Sender: TObject); +var + i, index: Integer; +begin + // loop through masters of selected plugins + for i := 0 to Pred(slMasters.Count) do begin + index := slAllPlugins.IndexOf(slMasters[i]); + // if the masters isn't loaded, skip it + if index = -1 then + continue; + // else check it + TPluginListItem(ListItems[index]).StateIndex := cChecked; + end; + + // repaint to show updated checkbox state + UpdateDisabled; + lvPlugins.Repaint; +end; + +procedure TPluginSelectionForm.UncheckMastersItemClick(Sender: TObject); +var + i, index: Integer; +begin + // loop through masters of selected plugins + for i := 0 to Pred(slMasters.Count) do begin + index := slAllPlugins.IndexOf(slMasters[i]); + // if the masters isn't loaded, skip it + if index = -1 then + continue; + // else uncheck it + TPluginListItem(ListItems[index]).StateIndex := cUnChecked; + end; + + // repaint to show updated checkbox state + UpdateDisabled; + lvPlugins.Repaint; +end; + +procedure TPluginSelectionForm.CheckDependenciesItemClick(Sender: TObject); +var + i, index: Integer; +begin + // loop through dependencies of selected plugins + for i := 0 to Pred(slDependencies.Count) do begin + index := slAllPlugins.IndexOf(slDependencies[i]); + // check it + TPluginListItem(ListItems[index]).StateIndex := cChecked; + end; + + // repaint to show updated checkbox state + UpdateDisabled; + lvPlugins.Repaint; +end; + +procedure TPluginSelectionForm.UncheckDependenciesItemClick(Sender: TObject); +var + i, index: Integer; +begin + // loop through dependencies of selected plugins + for i := 0 to Pred(slDependencies.Count) do begin + index := slAllPlugins.IndexOf(slDependencies[i]); + // uncheck it + TPluginListItem(ListItems[index]).StateIndex := cUnChecked; + end; + + // repaint to show updated checkbox state + UpdateDisabled; + lvPlugins.Repaint; +end; + end.