mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-08 14:48:47 -04:00
Commands gui now has extra permissions too
This commit is contained in:
parent
b3c9a2895a
commit
25849a4a84
@ -96,9 +96,10 @@ namespace MCGalaxy.Gui {
|
||||
}
|
||||
}
|
||||
|
||||
internal static void FillRanks(ComboBox[] boxes) {
|
||||
internal static void FillRanks(ComboBox[] boxes, bool removeRank = true) {
|
||||
for (int i = 0; i < boxes.Length; i++) {
|
||||
boxes[i].Items.AddRange(RankNames);
|
||||
if (!removeRank) continue;
|
||||
boxes[i].Items.Add("(remove rank)");
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ namespace MCGalaxy.Gui {
|
||||
|
||||
bool blockSupressEvents = true;
|
||||
ComboBox[] blockAllowBoxes, blockDisallowBoxes;
|
||||
byte blockID;
|
||||
|
||||
// need to keep a list of changed block perms, because we don't want
|
||||
// to modify the server's live permissions if user clicks 'discard'
|
||||
BlockPerms blockPermsOrig, blockPerms;
|
||||
List<BlockPerms> blockPermsChanged = new List<BlockPerms>();
|
||||
BlockProps[] blockPropsChanged = new BlockProps[256];
|
||||
byte blockID;
|
||||
|
||||
BlockProps[] blockPropsChanged = new BlockProps[256];
|
||||
|
||||
void LoadBlocks() {
|
||||
blk_list.Items.Clear();
|
||||
@ -97,9 +97,10 @@ namespace MCGalaxy.Gui {
|
||||
blk_cbWater.Checked = props.WaterKills;
|
||||
|
||||
blockSupressEvents = true;
|
||||
GuiPerms.SetDefaultIndex(blk_cmbMin, blockPermsOrig.MinRank);
|
||||
GuiPerms.SetSpecificPerms(blockPermsOrig.Allowed, blockAllowBoxes);
|
||||
GuiPerms.SetSpecificPerms(blockPermsOrig.Disallowed, blockDisallowBoxes);
|
||||
BlockPerms perms = blockPerms != null ? blockPerms : blockPermsOrig;
|
||||
GuiPerms.SetDefaultIndex(blk_cmbMin, perms.MinRank);
|
||||
GuiPerms.SetSpecificPerms(perms.Allowed, blockAllowBoxes);
|
||||
GuiPerms.SetSpecificPerms(perms.Disallowed, blockDisallowBoxes);
|
||||
blockSupressEvents = false;
|
||||
}
|
||||
|
||||
|
@ -22,13 +22,16 @@ namespace MCGalaxy.Gui {
|
||||
public partial class PropertyWindow : Form {
|
||||
|
||||
bool commandSupressEvents = true;
|
||||
ComboBox[] commandAllowBoxes, commandDisallowBoxes;
|
||||
ComboBox[] commandAllowBoxes, commandDisallowBoxes, commandExtraBoxes;
|
||||
Label[] commandExtraLabels;
|
||||
string commandName;
|
||||
|
||||
// need to keep a list of changed command perms, because we don't want
|
||||
// to modify the server's live permissions if user clicks 'discard'
|
||||
CommandPerms commandPermsOrig, commandPerms;
|
||||
List<CommandExtraPerms> extraPermsList;
|
||||
List<CommandPerms> commandPermsChanged = new List<CommandPerms>();
|
||||
List<CommandExtraPerms> commandExtraPermsChanged = new List<CommandExtraPerms>();
|
||||
string commandName;
|
||||
|
||||
void LoadCommands() {
|
||||
cmd_list.Items.Clear();
|
||||
@ -49,14 +52,20 @@ namespace MCGalaxy.Gui {
|
||||
foreach (CommandPerms changed in commandPermsChanged) {
|
||||
CommandPerms.Set(changed.CmdName, changed.MinRank,
|
||||
changed.Allowed, changed.Disallowed);
|
||||
}
|
||||
foreach (CommandExtraPerms changed in commandExtraPermsChanged) {
|
||||
CommandExtraPerms orig = CommandExtraPerms.Find(changed.CmdName, changed.Number);
|
||||
orig.MinRank = changed.MinRank;
|
||||
}
|
||||
|
||||
CommandExtraPerms.Save();
|
||||
CommandPerms.Save();
|
||||
CommandPerms.Load();
|
||||
LoadCommands();
|
||||
}
|
||||
|
||||
bool CommandsChanged() {
|
||||
return commandPermsChanged.Count > 0;
|
||||
return commandExtraPermsChanged.Count > 0 || commandPermsChanged.Count > 0;
|
||||
}
|
||||
|
||||
|
||||
@ -67,9 +76,11 @@ namespace MCGalaxy.Gui {
|
||||
CommandInitSpecificArrays();
|
||||
|
||||
commandSupressEvents = true;
|
||||
GuiPerms.SetDefaultIndex(cmd_cmbMin, commandPermsOrig.MinRank);
|
||||
GuiPerms.SetSpecificPerms(commandPermsOrig.Allowed, commandAllowBoxes);
|
||||
GuiPerms.SetSpecificPerms(commandPermsOrig.Disallowed, commandDisallowBoxes);
|
||||
CommandPerms perms = commandPerms != null ? commandPerms : commandPermsOrig;
|
||||
GuiPerms.SetDefaultIndex(cmd_cmbMin, perms.MinRank);
|
||||
GuiPerms.SetSpecificPerms(perms.Allowed, commandAllowBoxes);
|
||||
GuiPerms.SetSpecificPerms(perms.Disallowed, commandDisallowBoxes);
|
||||
CommandInitExtraPerms();
|
||||
commandSupressEvents = false;
|
||||
}
|
||||
|
||||
@ -77,8 +88,14 @@ namespace MCGalaxy.Gui {
|
||||
if (commandAllowBoxes != null) return;
|
||||
commandAllowBoxes = new ComboBox[] { cmd_cmbAlw1, cmd_cmbAlw2, cmd_cmbAlw3 };
|
||||
commandDisallowBoxes = new ComboBox[] { cmd_cmbDis1, cmd_cmbDis2, cmd_cmbDis3 };
|
||||
commandExtraBoxes = new ComboBox[] { cmd_cmbExtra1, cmd_cmbExtra2, cmd_cmbExtra3,
|
||||
cmd_cmbExtra4, cmd_cmbExtra5, cmd_cmbExtra6, cmd_cmbExtra7 };
|
||||
commandExtraLabels = new Label[] { cmd_lblExtra1, cmd_lblExtra2, cmd_lblExtra3,
|
||||
cmd_lblExtra4, cmd_lblExtra5, cmd_lblExtra6, cmd_lblExtra7 };
|
||||
|
||||
GuiPerms.FillRanks(commandAllowBoxes);
|
||||
GuiPerms.FillRanks(commandDisallowBoxes);
|
||||
GuiPerms.FillRanks(commandExtraBoxes, false);
|
||||
}
|
||||
|
||||
void CommandGetOrAddPermsChanged() {
|
||||
@ -133,5 +150,50 @@ namespace MCGalaxy.Gui {
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CommandInitExtraPerms() {
|
||||
extraPermsList = CommandExtraPerms.FindAll(commandName);
|
||||
for (int i = 0; i < commandExtraBoxes.Length; i++) {
|
||||
commandExtraBoxes[i].Visible = false;
|
||||
commandExtraLabels[i].Visible = false;
|
||||
}
|
||||
|
||||
int height = 12;
|
||||
for (int i = 0; i < extraPermsList.Count; i++) {
|
||||
CommandExtraPerms perms = LookupExtraPerms(extraPermsList[i].CmdName, extraPermsList[i].Number);
|
||||
if (perms == null) perms = extraPermsList[i];
|
||||
|
||||
GuiPerms.SetDefaultIndex(commandExtraBoxes[i], perms.MinRank);
|
||||
commandExtraBoxes[i].Visible = true;
|
||||
commandExtraLabels[i].Text = perms.Description;
|
||||
commandExtraLabels[i].Visible = true;
|
||||
height = commandExtraBoxes[i].Bottom + 12;
|
||||
}
|
||||
cmd_grpExtra.Visible = extraPermsList.Count > 0;
|
||||
cmd_grpExtra.Height = height;
|
||||
}
|
||||
|
||||
CommandExtraPerms LookupExtraPerms(string cmdName, int number) {
|
||||
return commandExtraPermsChanged.Find(
|
||||
p => p.CmdName == cmdName && p.Number == number);
|
||||
}
|
||||
|
||||
void cmd_cmbExtra_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
ComboBox box = (ComboBox)sender;
|
||||
if (commandSupressEvents) return;
|
||||
int idx = box.SelectedIndex;
|
||||
if (idx == -1) return;
|
||||
|
||||
int boxIdx = Array.IndexOf<ComboBox>(commandExtraBoxes, box);
|
||||
CommandExtraPerms orig = extraPermsList[boxIdx];
|
||||
CommandExtraPerms copy = LookupExtraPerms(orig.CmdName, orig.Number);
|
||||
|
||||
if (copy == null) {
|
||||
copy = orig.Copy();
|
||||
commandExtraPermsChanged.Add(copy);
|
||||
}
|
||||
copy.MinRank = GuiPerms.RankPerms[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
173
GUI/PropertyWindow/PropertyWindow.Designer.cs
generated
173
GUI/PropertyWindow/PropertyWindow.Designer.cs
generated
@ -367,6 +367,20 @@ namespace MCGalaxy.Gui
|
||||
this.cmd_lblDisallow = new System.Windows.Forms.Label();
|
||||
this.cmd_lblAllow = new System.Windows.Forms.Label();
|
||||
this.cmd_grpExtra = new System.Windows.Forms.GroupBox();
|
||||
this.cmd_cmbExtra1 = new System.Windows.Forms.ComboBox();
|
||||
this.cmd_lblExtra1 = new System.Windows.Forms.Label();
|
||||
this.cmd_cmbExtra2 = new System.Windows.Forms.ComboBox();
|
||||
this.cmd_lblExtra2 = new System.Windows.Forms.Label();
|
||||
this.cmd_cmbExtra3 = new System.Windows.Forms.ComboBox();
|
||||
this.cmd_lblExtra3 = new System.Windows.Forms.Label();
|
||||
this.cmd_cmbExtra4 = new System.Windows.Forms.ComboBox();
|
||||
this.cmd_lblExtra4 = new System.Windows.Forms.Label();
|
||||
this.cmd_cmbExtra5 = new System.Windows.Forms.ComboBox();
|
||||
this.cmd_lblExtra5 = new System.Windows.Forms.Label();
|
||||
this.cmd_cmbExtra6 = new System.Windows.Forms.ComboBox();
|
||||
this.cmd_lblExtra6 = new System.Windows.Forms.Label();
|
||||
this.cmd_cmbExtra7 = new System.Windows.Forms.ComboBox();
|
||||
this.cmd_lblExtra7 = new System.Windows.Forms.Label();
|
||||
this.tabChat.SuspendLayout();
|
||||
this.chat_grpTab.SuspendLayout();
|
||||
this.chat_grpMessages.SuspendLayout();
|
||||
@ -3833,7 +3847,6 @@ namespace MCGalaxy.Gui
|
||||
this.pageCommands.Size = new System.Drawing.Size(498, 521);
|
||||
this.pageCommands.TabIndex = 2;
|
||||
this.pageCommands.Text = "Commands";
|
||||
this.toolTip.SetToolTip(this.pageCommands, "Which ranks can use which commands.");
|
||||
//
|
||||
// cmd_btnHelp
|
||||
//
|
||||
@ -3975,13 +3988,153 @@ namespace MCGalaxy.Gui
|
||||
//
|
||||
// cmd_grpExtra
|
||||
//
|
||||
this.cmd_grpExtra.Location = new System.Drawing.Point(133, 106);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_cmbExtra7);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_lblExtra7);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_cmbExtra6);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_lblExtra6);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_cmbExtra5);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_lblExtra5);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_cmbExtra4);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_lblExtra4);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_cmbExtra3);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_lblExtra3);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_cmbExtra2);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_lblExtra2);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_cmbExtra1);
|
||||
this.cmd_grpExtra.Controls.Add(this.cmd_lblExtra1);
|
||||
this.cmd_grpExtra.Location = new System.Drawing.Point(133, 105);
|
||||
this.cmd_grpExtra.Name = "cmd_grpExtra";
|
||||
this.cmd_grpExtra.Size = new System.Drawing.Size(360, 258);
|
||||
this.cmd_grpExtra.Size = new System.Drawing.Size(360, 205);
|
||||
this.cmd_grpExtra.TabIndex = 28;
|
||||
this.cmd_grpExtra.TabStop = false;
|
||||
this.cmd_grpExtra.Text = "Extra permissions";
|
||||
//
|
||||
// cmd_cmbExtra1
|
||||
//
|
||||
this.cmd_cmbExtra1.FormattingEnabled = true;
|
||||
this.cmd_cmbExtra1.Location = new System.Drawing.Point(10, 17);
|
||||
this.cmd_cmbExtra1.Name = "cmd_cmbExtra1";
|
||||
this.cmd_cmbExtra1.Size = new System.Drawing.Size(81, 21);
|
||||
this.cmd_cmbExtra1.TabIndex = 30;
|
||||
this.cmd_cmbExtra1.SelectedIndexChanged += new System.EventHandler(this.cmd_cmbExtra_SelectedIndexChanged);
|
||||
//
|
||||
// cmd_lblExtra1
|
||||
//
|
||||
this.cmd_lblExtra1.AutoSize = true;
|
||||
this.cmd_lblExtra1.Location = new System.Drawing.Point(91, 20);
|
||||
this.cmd_lblExtra1.Name = "cmd_lblExtra1";
|
||||
this.cmd_lblExtra1.Size = new System.Drawing.Size(12, 13);
|
||||
this.cmd_lblExtra1.TabIndex = 29;
|
||||
this.cmd_lblExtra1.Text = "+";
|
||||
//
|
||||
// cmd_cmbExtra2
|
||||
//
|
||||
this.cmd_cmbExtra2.FormattingEnabled = true;
|
||||
this.cmd_cmbExtra2.Location = new System.Drawing.Point(10, 43);
|
||||
this.cmd_cmbExtra2.Name = "cmd_cmbExtra2";
|
||||
this.cmd_cmbExtra2.Size = new System.Drawing.Size(81, 21);
|
||||
this.cmd_cmbExtra2.TabIndex = 32;
|
||||
this.cmd_cmbExtra2.SelectedIndexChanged += new System.EventHandler(this.cmd_cmbExtra_SelectedIndexChanged);
|
||||
//
|
||||
// cmd_lblExtra2
|
||||
//
|
||||
this.cmd_lblExtra2.AutoSize = true;
|
||||
this.cmd_lblExtra2.Location = new System.Drawing.Point(91, 46);
|
||||
this.cmd_lblExtra2.Name = "cmd_lblExtra2";
|
||||
this.cmd_lblExtra2.Size = new System.Drawing.Size(12, 13);
|
||||
this.cmd_lblExtra2.TabIndex = 31;
|
||||
this.cmd_lblExtra2.Text = "+";
|
||||
//
|
||||
// cmd_cmbExtra3
|
||||
//
|
||||
this.cmd_cmbExtra3.FormattingEnabled = true;
|
||||
this.cmd_cmbExtra3.Location = new System.Drawing.Point(10, 69);
|
||||
this.cmd_cmbExtra3.Name = "cmd_cmbExtra3";
|
||||
this.cmd_cmbExtra3.Size = new System.Drawing.Size(81, 21);
|
||||
this.cmd_cmbExtra3.TabIndex = 34;
|
||||
this.cmd_cmbExtra3.SelectedIndexChanged += new System.EventHandler(this.cmd_cmbExtra_SelectedIndexChanged);
|
||||
//
|
||||
// cmd_lblExtra3
|
||||
//
|
||||
this.cmd_lblExtra3.AutoSize = true;
|
||||
this.cmd_lblExtra3.Location = new System.Drawing.Point(91, 72);
|
||||
this.cmd_lblExtra3.Name = "cmd_lblExtra3";
|
||||
this.cmd_lblExtra3.Size = new System.Drawing.Size(12, 13);
|
||||
this.cmd_lblExtra3.TabIndex = 33;
|
||||
this.cmd_lblExtra3.Text = "+";
|
||||
//
|
||||
// cmd_cmbExtra4
|
||||
//
|
||||
this.cmd_cmbExtra4.FormattingEnabled = true;
|
||||
this.cmd_cmbExtra4.Location = new System.Drawing.Point(10, 95);
|
||||
this.cmd_cmbExtra4.Name = "cmd_cmbExtra4";
|
||||
this.cmd_cmbExtra4.Size = new System.Drawing.Size(81, 21);
|
||||
this.cmd_cmbExtra4.TabIndex = 36;
|
||||
this.cmd_cmbExtra4.SelectedIndexChanged += new System.EventHandler(this.cmd_cmbExtra_SelectedIndexChanged);
|
||||
//
|
||||
// cmd_lblExtra4
|
||||
//
|
||||
this.cmd_lblExtra4.AutoSize = true;
|
||||
this.cmd_lblExtra4.Location = new System.Drawing.Point(91, 98);
|
||||
this.cmd_lblExtra4.Name = "cmd_lblExtra4";
|
||||
this.cmd_lblExtra4.Size = new System.Drawing.Size(12, 13);
|
||||
this.cmd_lblExtra4.TabIndex = 35;
|
||||
this.cmd_lblExtra4.Text = "+";
|
||||
//
|
||||
// cmd_cmbExtra5
|
||||
//
|
||||
this.cmd_cmbExtra5.FormattingEnabled = true;
|
||||
this.cmd_cmbExtra5.Location = new System.Drawing.Point(10, 121);
|
||||
this.cmd_cmbExtra5.Name = "cmd_cmbExtra5";
|
||||
this.cmd_cmbExtra5.Size = new System.Drawing.Size(81, 21);
|
||||
this.cmd_cmbExtra5.TabIndex = 38;
|
||||
this.cmd_cmbExtra5.SelectedIndexChanged += new System.EventHandler(this.cmd_cmbExtra_SelectedIndexChanged);
|
||||
//
|
||||
// cmd_lblExtra5
|
||||
//
|
||||
this.cmd_lblExtra5.AutoSize = true;
|
||||
this.cmd_lblExtra5.Location = new System.Drawing.Point(91, 124);
|
||||
this.cmd_lblExtra5.Name = "cmd_lblExtra5";
|
||||
this.cmd_lblExtra5.Size = new System.Drawing.Size(12, 13);
|
||||
this.cmd_lblExtra5.TabIndex = 37;
|
||||
this.cmd_lblExtra5.Text = "+";
|
||||
//
|
||||
// cmd_cmbExtra6
|
||||
//
|
||||
this.cmd_cmbExtra6.FormattingEnabled = true;
|
||||
this.cmd_cmbExtra6.Location = new System.Drawing.Point(10, 147);
|
||||
this.cmd_cmbExtra6.Name = "cmd_cmbExtra6";
|
||||
this.cmd_cmbExtra6.Size = new System.Drawing.Size(81, 21);
|
||||
this.cmd_cmbExtra6.TabIndex = 40;
|
||||
this.cmd_cmbExtra6.SelectedIndexChanged += new System.EventHandler(this.cmd_cmbExtra_SelectedIndexChanged);
|
||||
//
|
||||
// cmd_lblExtra6
|
||||
//
|
||||
this.cmd_lblExtra6.AutoSize = true;
|
||||
this.cmd_lblExtra6.Location = new System.Drawing.Point(91, 150);
|
||||
this.cmd_lblExtra6.Name = "cmd_lblExtra6";
|
||||
this.cmd_lblExtra6.Size = new System.Drawing.Size(12, 13);
|
||||
this.cmd_lblExtra6.TabIndex = 39;
|
||||
this.cmd_lblExtra6.Text = "+";
|
||||
//
|
||||
// cmd_cmbExtra7
|
||||
//
|
||||
this.cmd_cmbExtra7.FormattingEnabled = true;
|
||||
this.cmd_cmbExtra7.Location = new System.Drawing.Point(10, 173);
|
||||
this.cmd_cmbExtra7.Name = "cmd_cmbExtra7";
|
||||
this.cmd_cmbExtra7.Size = new System.Drawing.Size(81, 21);
|
||||
this.cmd_cmbExtra7.TabIndex = 42;
|
||||
this.cmd_cmbExtra7.SelectedIndexChanged += new System.EventHandler(this.cmd_cmbExtra_SelectedIndexChanged);
|
||||
//
|
||||
// cmd_lblExtra7
|
||||
//
|
||||
this.cmd_lblExtra7.AutoSize = true;
|
||||
this.cmd_lblExtra7.Location = new System.Drawing.Point(91, 176);
|
||||
this.cmd_lblExtra7.Name = "cmd_lblExtra7";
|
||||
this.cmd_lblExtra7.Size = new System.Drawing.Size(12, 13);
|
||||
this.cmd_lblExtra7.TabIndex = 41;
|
||||
this.cmd_lblExtra7.Text = "+";
|
||||
//
|
||||
// PropertyWindow
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -4110,6 +4263,20 @@ namespace MCGalaxy.Gui
|
||||
this.cmd_grpPermissions.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
private System.Windows.Forms.Label cmd_lblExtra1;
|
||||
private System.Windows.Forms.ComboBox cmd_cmbExtra1;
|
||||
private System.Windows.Forms.Label cmd_lblExtra2;
|
||||
private System.Windows.Forms.ComboBox cmd_cmbExtra2;
|
||||
private System.Windows.Forms.Label cmd_lblExtra3;
|
||||
private System.Windows.Forms.ComboBox cmd_cmbExtra3;
|
||||
private System.Windows.Forms.Label cmd_lblExtra4;
|
||||
private System.Windows.Forms.ComboBox cmd_cmbExtra4;
|
||||
private System.Windows.Forms.Label cmd_lblExtra5;
|
||||
private System.Windows.Forms.ComboBox cmd_cmbExtra5;
|
||||
private System.Windows.Forms.Label cmd_lblExtra6;
|
||||
private System.Windows.Forms.ComboBox cmd_cmbExtra6;
|
||||
private System.Windows.Forms.Label cmd_lblExtra7;
|
||||
private System.Windows.Forms.ComboBox cmd_cmbExtra7;
|
||||
private System.Windows.Forms.GroupBox cmd_grpExtra;
|
||||
private System.Windows.Forms.ListBox cmd_list;
|
||||
private System.Windows.Forms.Button cmd_btnHelp;
|
||||
|
@ -35,7 +35,18 @@ namespace MCGalaxy.Commands {
|
||||
public string Description = "";
|
||||
|
||||
/// <summary> The number / identifier of this extra permission. </summary>
|
||||
public int Number;
|
||||
public int Number;
|
||||
|
||||
|
||||
/// <summary> Creates a copy of this instance. </summary>
|
||||
public CommandExtraPerms Copy() {
|
||||
CommandExtraPerms perms = new CommandExtraPerms();
|
||||
perms.CmdName = CmdName;
|
||||
perms.MinRank = MinRank;
|
||||
perms.Description = Description;
|
||||
perms.Number = Number;
|
||||
return perms;
|
||||
}
|
||||
|
||||
static List<CommandExtraPerms> list = new List<CommandExtraPerms>();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user