From adb2201fe40dc1e3706b08f9a2d303d9f202d2e7 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 29 May 2017 13:40:48 +1000 Subject: [PATCH] Minor code cleanup, move CustomCommands to a popup --- GUI/Popups/CustomCommands.Designer.cs | 193 ++++++++++++++++++++ GUI/Popups/CustomCommands.cs | 25 +++ GUI/{ => Popups}/PortTools.Designer.cs | 0 GUI/{ => Popups}/PortTools.cs | 0 GUI/{ => Popups}/PortTools.resx | 0 GUI/PropertyWindow/PropertyWindow.Blocks.cs | 45 +++-- GUI/Starter.csproj | 68 +++---- 7 files changed, 264 insertions(+), 67 deletions(-) create mode 100644 GUI/Popups/CustomCommands.Designer.cs create mode 100644 GUI/Popups/CustomCommands.cs rename GUI/{ => Popups}/PortTools.Designer.cs (100%) rename GUI/{ => Popups}/PortTools.cs (100%) rename GUI/{ => Popups}/PortTools.resx (100%) diff --git a/GUI/Popups/CustomCommands.Designer.cs b/GUI/Popups/CustomCommands.Designer.cs new file mode 100644 index 000000000..934f1cebf --- /dev/null +++ b/GUI/Popups/CustomCommands.Designer.cs @@ -0,0 +1,193 @@ +namespace MCGalaxy.Gui.Popups { + partial class CustomCommands { + /// + /// Designer variable used to keep track of non-visual components. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Disposes resources used by the form. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + /// + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// + private void InitializeComponent() { + this.cus_lblLoaded = new System.Windows.Forms.Label(); + this.cus_lstLoaded = new System.Windows.Forms.ListBox(); + this.cus_grpCreate = new System.Windows.Forms.GroupBox(); + this.cus_radPanel = new System.Windows.Forms.Panel(); + this.cus_radVB = new System.Windows.Forms.RadioButton(); + this.cus_radCS = new System.Windows.Forms.RadioButton(); + this.cus_btnCreate = new System.Windows.Forms.Button(); + this.cus_txtCmdName = new System.Windows.Forms.TextBox(); + this.cus_lblTxtName = new System.Windows.Forms.Label(); + this.cus_btnLoad = new System.Windows.Forms.Button(); + this.cus_btnUnload = new System.Windows.Forms.Button(); + this.cus_grpCreate.SuspendLayout(); + this.cus_radPanel.SuspendLayout(); + this.SuspendLayout(); + // + // cus_lblLoaded + // + this.cus_lblLoaded.AutoSize = true; + this.cus_lblLoaded.Location = new System.Drawing.Point(13, 129); + this.cus_lblLoaded.Name = "cus_lblLoaded"; + this.cus_lblLoaded.Size = new System.Drawing.Size(134, 13); + this.cus_lblLoaded.TabIndex = 45; + this.cus_lblLoaded.Text = "Loaded custom commands"; + // + // cus_lstLoaded + // + this.cus_lstLoaded.FormattingEnabled = true; + this.cus_lstLoaded.Location = new System.Drawing.Point(13, 145); + this.cus_lstLoaded.Name = "cus_lstLoaded"; + this.cus_lstLoaded.Size = new System.Drawing.Size(458, 303); + this.cus_lstLoaded.TabIndex = 44; + // + // cus_grpCreate + // + this.cus_grpCreate.Controls.Add(this.cus_radPanel); + this.cus_grpCreate.Controls.Add(this.cus_btnCreate); + this.cus_grpCreate.Controls.Add(this.cus_txtCmdName); + this.cus_grpCreate.Controls.Add(this.cus_lblTxtName); + this.cus_grpCreate.Location = new System.Drawing.Point(12, 12); + this.cus_grpCreate.Name = "cus_grpCreate"; + this.cus_grpCreate.Size = new System.Drawing.Size(459, 100); + this.cus_grpCreate.TabIndex = 43; + this.cus_grpCreate.TabStop = false; + this.cus_grpCreate.Text = "Create command"; + // + // cus_radPanel + // + this.cus_radPanel.Controls.Add(this.cus_radVB); + this.cus_radPanel.Controls.Add(this.cus_radCS); + this.cus_radPanel.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cus_radPanel.Location = new System.Drawing.Point(13, 58); + this.cus_radPanel.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); + this.cus_radPanel.Name = "cus_radPanel"; + this.cus_radPanel.Size = new System.Drawing.Size(84, 29); + this.cus_radPanel.TabIndex = 37; + // + // cus_radVB + // + this.cus_radVB.AutoSize = true; + this.cus_radVB.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cus_radVB.Location = new System.Drawing.Point(41, 6); + this.cus_radVB.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); + this.cus_radVB.Name = "cus_radVB"; + this.cus_radVB.Size = new System.Drawing.Size(36, 16); + this.cus_radVB.TabIndex = 27; + this.cus_radVB.Text = "VB"; + this.cus_radVB.UseVisualStyleBackColor = true; + // + // cus_radCS + // + this.cus_radCS.AutoSize = true; + this.cus_radCS.Checked = true; + this.cus_radCS.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cus_radCS.Location = new System.Drawing.Point(2, 6); + this.cus_radCS.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); + this.cus_radCS.Name = "cus_radCS"; + this.cus_radCS.Size = new System.Drawing.Size(35, 16); + this.cus_radCS.TabIndex = 0; + this.cus_radCS.TabStop = true; + this.cus_radCS.Text = "C#"; + this.cus_radCS.UseVisualStyleBackColor = true; + // + // cus_btnCreate + // + this.cus_btnCreate.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cus_btnCreate.Location = new System.Drawing.Point(374, 71); + this.cus_btnCreate.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); + this.cus_btnCreate.Name = "cus_btnCreate"; + this.cus_btnCreate.Size = new System.Drawing.Size(80, 23); + this.cus_btnCreate.TabIndex = 29; + this.cus_btnCreate.Text = "Create command"; + this.cus_btnCreate.UseVisualStyleBackColor = true; + // + // cus_txtCmdName + // + this.cus_txtCmdName.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cus_txtCmdName.Location = new System.Drawing.Point(93, 20); + this.cus_txtCmdName.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); + this.cus_txtCmdName.Name = "cus_txtCmdName"; + this.cus_txtCmdName.Size = new System.Drawing.Size(355, 18); + this.cus_txtCmdName.TabIndex = 27; + // + // cus_lblTxtName + // + this.cus_lblTxtName.AutoSize = true; + this.cus_lblTxtName.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cus_lblTxtName.Location = new System.Drawing.Point(11, 23); + this.cus_lblTxtName.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.cus_lblTxtName.Name = "cus_lblTxtName"; + this.cus_lblTxtName.Size = new System.Drawing.Size(78, 12); + this.cus_lblTxtName.TabIndex = 28; + this.cus_lblTxtName.Text = "Command Name:"; + // + // cus_btnLoad + // + this.cus_btnLoad.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cus_btnLoad.Location = new System.Drawing.Point(13, 454); + this.cus_btnLoad.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); + this.cus_btnLoad.Name = "cus_btnLoad"; + this.cus_btnLoad.Size = new System.Drawing.Size(80, 23); + this.cus_btnLoad.TabIndex = 41; + this.cus_btnLoad.Text = "Load"; + this.cus_btnLoad.UseVisualStyleBackColor = true; + // + // cus_btnUnload + // + this.cus_btnUnload.Enabled = false; + this.cus_btnUnload.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cus_btnUnload.Location = new System.Drawing.Point(391, 454); + this.cus_btnUnload.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); + this.cus_btnUnload.Name = "cus_btnUnload"; + this.cus_btnUnload.Size = new System.Drawing.Size(80, 23); + this.cus_btnUnload.TabIndex = 42; + this.cus_btnUnload.Text = "Unload"; + this.cus_btnUnload.UseVisualStyleBackColor = true; + // + // CustomCommands + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(484, 479); + this.Controls.Add(this.cus_lblLoaded); + this.Controls.Add(this.cus_lstLoaded); + this.Controls.Add(this.cus_grpCreate); + this.Controls.Add(this.cus_btnLoad); + this.Controls.Add(this.cus_btnUnload); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "CustomCommands"; + this.Text = "Custom commands"; + this.cus_grpCreate.ResumeLayout(false); + this.cus_grpCreate.PerformLayout(); + this.cus_radPanel.ResumeLayout(false); + this.cus_radPanel.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + } + private System.Windows.Forms.Button cus_btnUnload; + private System.Windows.Forms.Button cus_btnLoad; + private System.Windows.Forms.Label cus_lblTxtName; + private System.Windows.Forms.TextBox cus_txtCmdName; + private System.Windows.Forms.Button cus_btnCreate; + private System.Windows.Forms.RadioButton cus_radCS; + private System.Windows.Forms.RadioButton cus_radVB; + private System.Windows.Forms.Panel cus_radPanel; + private System.Windows.Forms.GroupBox cus_grpCreate; + private System.Windows.Forms.ListBox cus_lstLoaded; + private System.Windows.Forms.Label cus_lblLoaded; + } +} diff --git a/GUI/Popups/CustomCommands.cs b/GUI/Popups/CustomCommands.cs new file mode 100644 index 000000000..277281d9c --- /dev/null +++ b/GUI/Popups/CustomCommands.cs @@ -0,0 +1,25 @@ +/* +Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy) +Dual-licensed under the Educational Community License, Version 2.0 and +the GNU General Public License, Version 3 (the "Licenses"); you may +not use this file except in compliance with the Licenses. You may +obtain a copy of the Licenses at +http://www.opensource.org/licenses/ecl2.php +http://www.gnu.org/licenses/gpl-3.0.html +Unless required by applicable law or agreed to in writing, +software distributed under the Licenses are distributed on an "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +or implied. See the Licenses for the specific language governing +permissions and limitations under the Licenses. + */ +using System; +using System.Windows.Forms; + +namespace MCGalaxy.Gui.Popups { + public partial class CustomCommands : Form { + + public CustomCommands() { + InitializeComponent(); + } + } +} diff --git a/GUI/PortTools.Designer.cs b/GUI/Popups/PortTools.Designer.cs similarity index 100% rename from GUI/PortTools.Designer.cs rename to GUI/Popups/PortTools.Designer.cs diff --git a/GUI/PortTools.cs b/GUI/Popups/PortTools.cs similarity index 100% rename from GUI/PortTools.cs rename to GUI/Popups/PortTools.cs diff --git a/GUI/PortTools.resx b/GUI/Popups/PortTools.resx similarity index 100% rename from GUI/PortTools.resx rename to GUI/Popups/PortTools.resx diff --git a/GUI/PropertyWindow/PropertyWindow.Blocks.cs b/GUI/PropertyWindow/PropertyWindow.Blocks.cs index 3163b2fa9..77d4b2fac 100644 --- a/GUI/PropertyWindow/PropertyWindow.Blocks.cs +++ b/GUI/PropertyWindow/PropertyWindow.Blocks.cs @@ -1,16 +1,19 @@ /* -Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy) -Dual-licensed under the Educational Community License, Version 2.0 and -the GNU General Public License, Version 3 (the "Licenses"); you may -not use this file except in compliance with the Licenses. You may -obtain a copy of the Licenses at -http://www.opensource.org/licenses/ecl2.php -http://www.gnu.org/licenses/gpl-3.0.html -Unless required by applicable law or agreed to in writing, -software distributed under the Licenses are distributed on an "AS IS" -BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -or implied. See the Licenses for the specific language governing -permissions and limitations under the Licenses. + Copyright 2015 MCGalaxy + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. */ using System; using System.Collections.Generic; @@ -30,17 +33,15 @@ namespace MCGalaxy.Gui { byte blockID; - public void LoadBlocks() { + void LoadBlocks() { blk_list.Items.Clear(); blockPermsChanged.Clear(); for (int i = 0; i < Block.Props.Length; i++) { blockPropsChanged[i] = Block.Props[i]; blockPropsChanged[i].Changed = false; - } - - foreach (BlockPerms perms in BlockPerms.List) { - if (Block.Name(perms.BlockID) != "unknown") { - blk_list.Items.Add(Block.Name(perms.BlockID)); + + if (Block.Props[i].Name != "unknown") { + blk_list.Items.Add(Block.Props[i].Name); } } @@ -48,7 +49,7 @@ namespace MCGalaxy.Gui { blk_list.SelectedIndex = 0; } - public void SaveBlocks() { + void SaveBlocks() { if (!BlocksChanged()) { LoadBlocks(); return; } for (int i = 0; i < blockPropsChanged.Length; i++) { @@ -70,8 +71,7 @@ namespace MCGalaxy.Gui { bool BlocksChanged() { for (int i = 0; i < blockPropsChanged.Length; i++) { - if (!blockPropsChanged[i].Changed) continue; - return true; + if (blockPropsChanged[i].Changed) return true; } return blockPermsChanged.Count > 0; } @@ -82,8 +82,7 @@ namespace MCGalaxy.Gui { blockPermsOrig = BlockPerms.List[blockID]; blockPerms = blockPermsChanged.Find(p => p.BlockID == blockID); BlockInitSpecificArrays(); - - // TODO: actually save & set these + BlockProps props = blockPropsChanged[blockID]; blk_cbMsgBlock.Checked = props.IsMessageBlock; blk_cbPortal.Checked = props.IsPortal; diff --git a/GUI/Starter.csproj b/GUI/Starter.csproj index 6801651e1..c4ace3f02 100644 --- a/GUI/Starter.csproj +++ b/GUI/Starter.csproj @@ -53,16 +53,20 @@ + + + CustomCommands.cs + + + Form + + + PortTools.cs + - - PropertyWindow.cs - - - PropertyWindow.cs - - - PropertyWindow.cs - + + + Form @@ -70,24 +74,13 @@ PropertyWindow.cs - PropertyWindow.cs Form - - PropertyWindow.cs - - - PropertyWindow.cs - - - PropertyWindow.cs - - - PropertyWindow.cs - - - PropertyWindow.cs - + + + + + @@ -109,12 +102,6 @@ EconomyWindow.cs - - Form - - - PortTools.cs - Form @@ -128,22 +115,14 @@ Window.cs - - Window.cs - - - Window.cs - - - Window.cs - - - Window.cs - + + + + EconomyWindow.cs - + PortTools.cs @@ -165,6 +144,7 @@ +