Stage 2 of blocks gui rewrite: can remove specific allow/disallow perms now

This commit is contained in:
UnknownShadow200 2017-05-27 14:24:57 +10:00
parent 0dc366c44a
commit 75f7764dae
2 changed files with 24 additions and 14 deletions

View File

@ -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<LevelPermission> perms = blockPerms.Allowed;
ComboBox[] boxes = blockAllowBoxes;
@ -98,6 +101,20 @@ namespace MCGalaxy.Gui {
boxIdx = Array.IndexOf<ComboBox>(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<LevelPermission> perms, int idx) {
if (boxIdx < perms.Count) {
perms[boxIdx] = GuiPerms.RankPerms[idx];
} else {

View File

@ -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");