From 75f7764dae2cce5e70b9610fae8695d67c7330a2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 27 May 2017 14:24:57 +1000 Subject: [PATCH] Stage 2 of blocks gui rewrite: can remove specific allow/disallow perms now --- GUI/PropertyWindow/PropertyWindow.Blocks.cs | 27 +++++++++++++++++---- GUI/PropertyWindow/PropertyWindow.cs | 11 ++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/GUI/PropertyWindow/PropertyWindow.Blocks.cs b/GUI/PropertyWindow/PropertyWindow.Blocks.cs index 501df3035..cbf67d383 100644 --- a/GUI/PropertyWindow/PropertyWindow.Blocks.cs +++ b/GUI/PropertyWindow/PropertyWindow.Blocks.cs @@ -42,8 +42,10 @@ namespace MCGalaxy.Gui { blockDisallowBoxes = new ComboBox[] { blk_cmbDis1, blk_cmbDis2, blk_cmbDis3 }; for (int i = 0; i < blockAllowBoxes.Length; i++) { - blockAllowBoxes[i].Items.Add("(add rank)"); - blockDisallowBoxes[i].Items.Add("(add rank)"); + blockAllowBoxes[i].Items.AddRange(GuiPerms.RankNames); + blockAllowBoxes[i].Items.Add("(remove rank)"); + blockDisallowBoxes[i].Items.AddRange(GuiPerms.RankNames); + blockDisallowBoxes[i].Items.Add("(remove rank)"); } } @@ -55,6 +57,7 @@ namespace MCGalaxy.Gui { box.Text = ""; box.Enabled = false; box.Visible = false; + box.SelectedIndex = -1; // Show the non-visible specific permissions previously set if (perms.Count > i) { @@ -72,8 +75,8 @@ namespace MCGalaxy.Gui { void BlockSetAddRank(ComboBox box) { box.Visible = true; box.Enabled = true; - box.SelectedIndex = box.Items.Count - 1; - } + box.Text = "(add rank)"; + } void blk_cmbMin_SelectedIndexChanged(object sender, EventArgs e) { @@ -87,7 +90,7 @@ namespace MCGalaxy.Gui { ComboBox box = (ComboBox)sender; if (blockSupressEvents) return; int idx = box.SelectedIndex; - if (idx == box.Items.Count - 1) return; + if (idx == -1) return; List perms = blockPerms.Allowed; ComboBox[] boxes = blockAllowBoxes; @@ -98,6 +101,20 @@ namespace MCGalaxy.Gui { boxIdx = Array.IndexOf(boxes, box); } + if (idx == box.Items.Count - 1) { + if (boxIdx >= perms.Count) return; + perms.RemoveAt(boxIdx); + + blockSupressEvents = true; + BlockSetSpecificPerms(perms, boxes); + blockSupressEvents = false; + } else { + BlockSetSpecific(boxes, boxIdx, perms, idx); + } + } + + void BlockSetSpecific(ComboBox[] boxes, int boxIdx, + List perms, int idx) { if (boxIdx < perms.Count) { perms[boxIdx] = GuiPerms.RankPerms[idx]; } else { diff --git a/GUI/PropertyWindow/PropertyWindow.cs b/GUI/PropertyWindow/PropertyWindow.cs index 35c00c480..8858e070b 100644 --- a/GUI/PropertyWindow/PropertyWindow.cs +++ b/GUI/PropertyWindow/PropertyWindow.cs @@ -53,15 +53,8 @@ namespace MCGalaxy.Gui { rank_cmbAdminChat.Items.AddRange(GuiPerms.RankNames); rank_cmbOsMap.Items.AddRange(GuiPerms.RankNames); sec_cmbVerifyRank.Items.AddRange(GuiPerms.RankNames); - afk_cmbKickPerm.Items.AddRange(GuiPerms.RankNames); - - blk_cmbMin.Items.AddRange(GuiPerms.RankNames); - blk_cmbAlw1.Items.AddRange(GuiPerms.RankNames); - blk_cmbAlw2.Items.AddRange(GuiPerms.RankNames); - blk_cmbAlw3.Items.AddRange(GuiPerms.RankNames); - blk_cmbDis1.Items.AddRange(GuiPerms.RankNames); - blk_cmbDis2.Items.AddRange(GuiPerms.RankNames); - blk_cmbDis3.Items.AddRange(GuiPerms.RankNames); + afk_cmbKickPerm.Items.AddRange(GuiPerms.RankNames); + blk_cmbMin.Items.AddRange(GuiPerms.RankNames); //Load server stuff LoadProp("properties/server.properties");