Skip to content

Commit

Permalink
Progress on #75
Browse files Browse the repository at this point in the history
  • Loading branch information
matortheeternal committed Dec 29, 2015
1 parent a7d52d8 commit d4bdf59
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/mte/mtePluginSelectionForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ object PluginSelectionForm: TPluginSelectionForm
OnClick = btnOKClick
end
object PluginsPopupMenu: TPopupMenu
OnPopup = PluginsPopupMenuPopup
Left = 48
Top = 24
object CheckAllItem: TMenuItem
Expand All @@ -94,14 +95,39 @@ 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
Width = 17
Left = 136
Top = 24
Bitmap = {
494C0101030034005C0011001100FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010103003400600011001100FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000440000001100000001002000000000001012
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down
92 changes: 92 additions & 0 deletions lib/mte/mtePluginSelectionForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.

1 comment on commit d4bdf59

@matortheeternal
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #75

Please sign in to comment.