diff --git a/Build/Configurations/Includes/Hexen_linedefs.cfg b/Build/Configurations/Includes/Hexen_linedefs.cfg index c2c0dbfd3f43023446868c3282dd1967a84d063f..7d71224532a6e0b26bd65b9e99237b3de8eca94d 100644 --- a/Build/Configurations/Includes/Hexen_linedefs.cfg +++ b/Build/Configurations/Includes/Hexen_linedefs.cfg @@ -1828,6 +1828,8 @@ script arg4 { title = "Key Number"; + type = 11; + enum = "keys"; } } } diff --git a/Build/Configurations/Includes/ZDoom_things.cfg b/Build/Configurations/Includes/ZDoom_things.cfg index 26d1a47b93dde38ab9424e746d8e2af3e69a4fa8..fe2a990a648928ce11d8c15284dfd053fde92b6f 100644 --- a/Build/Configurations/Includes/ZDoom_things.cfg +++ b/Build/Configurations/Includes/ZDoom_things.cfg @@ -473,15 +473,15 @@ zdoom enum { 0 = "0: Hexen default"; - 11 = "11: 15° / second"; - 21 = "21: 30° / second"; - 32 = "32: 45° / second"; - 64 = "64: 90° / second"; - 128 = "128: 180° / second"; - 192 = "192: -90° / second"; - 223 = "223: -45° / second"; - 233 = "233: -30° / second"; - 244 = "244: -15° / second"; + 11 = "11: 15 deg. per second"; + 21 = "21: 30 deg. per second"; + 32 = "32: 45 deg. per second"; + 64 = "64: 90 deg. per second"; + 128 = "128: 180 deg. per second"; + 192 = "192: -90 deg. per second"; + 223 = "223: -45 deg. per second"; + 233 = "233: -30 deg. per second"; + 244 = "244: -15 deg. per second"; } } arg4 @@ -490,7 +490,7 @@ zdoom type = 11; enum { - 0 = "Hexen default"; + 0 = "0: Hexen default"; } } } diff --git a/Help/gzdb/deprecated_plugins.html b/Help/gzdb/deprecated_plugins.html index 217b4439ee8c6f1afb0fd06c9f95060ea732dea4..5ecf54c76bad54e883613a00d91ce46904878ed3 100644 --- a/Help/gzdb/deprecated_plugins.html +++ b/Help/gzdb/deprecated_plugins.html @@ -17,9 +17,11 @@ <div id="gz_title"><h1>List of deprecated plugins</h1></div> <div id="contents"> - <p><strong>The following plugins, which shipped with either Doom Builder 2 or older versions of GZDoom Builder, are no longer required or supported.</strong><br />They can potentially cause problems in the SVN versions of GZDoom Builder 1.14.<br />It is recommended to delete them from the "Plugins" folder.</p> + <p><strong>The following plugins, which shipped with either Doom Builder 2 or older versions of GZDoom Builder, are no longer required or supported.</strong><br /> + They can potentially cause problems in GZDoom Builder 2.3 or newer.<br /> + It is recommended to delete them from the "Plugins" folder.</p> <ul> - <li><strong>GZDoomEditing.dll</strong> - was merged into BuilderModes.dll in GZDB 1.14. Will cause crash during startup in the SVN versions of GZDB 1.14.</li> + <li><strong>GZDoomEditing.dll</strong> - was merged into BuilderModes.dll in GZDB 1.14. Will cause crash during startup in the SVN versions of GZDB 1.14.</li> <li><strong>Statistics.dll</strong> - merged into the core in the SVN versions of GZDB 1.14. Statistics are now shown in any editing mode when not highlighting any map elements.</li> <li><strong>UDMFControls.dll</strong> - plugin's functionality was fully replaced by <a href="../w_linedefedit.html">Edit Linedef</a> and <a href="../w_sectoredit.html">Edit Sector</a> windows in the SVN versions of GZDB 1.14.</li> <li><strong>CopyPasteSectorProps.dll</strong> - merged into BuilderModes.dll in the SVN versions of GZDB 1.14.</li> diff --git a/Source/Core/Builder.csproj b/Source/Core/Builder.csproj index c1587c02755d575fd3d009d54ad0999d33186e74..41cc55a4297cdaf5427422d33a14c9522a44c1c8 100644 --- a/Source/Core/Builder.csproj +++ b/Source/Core/Builder.csproj @@ -690,6 +690,12 @@ <Compile Include="Controls\ActionSpecialHelpButton.Designer.cs"> <DependentUpon>ActionSpecialHelpButton.cs</DependentUpon> </Compile> + <Compile Include="Controls\ArgumentsControl.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Controls\ArgumentsControl.Designer.cs"> + <DependentUpon>ArgumentsControl.cs</DependentUpon> + </Compile> <Compile Include="Controls\ButtonsNumericTextboxDesigner.cs" /> <Compile Include="Controls\CollapsibleSplitContainer.cs"> <SubType>Component</SubType> @@ -981,6 +987,9 @@ <EmbeddedResource Include="Controls\ActionSpecialHelpButton.resx"> <DependentUpon>ActionSpecialHelpButton.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="Controls\ArgumentsControl.resx"> + <DependentUpon>ArgumentsControl.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="Controls\CommentEditor.resx"> <DependentUpon>CommentEditor.cs</DependentUpon> </EmbeddedResource> diff --git a/Source/Core/Controls/ArgumentBox.cs b/Source/Core/Controls/ArgumentBox.cs index b07d3040b0fb326cd6edbb8e3ed009cc97c8a792..0e4522d04dd67df7efcfaa63181c8b64f25eced7 100644 --- a/Source/Core/Controls/ArgumentBox.cs +++ b/Source/Core/Controls/ArgumentBox.cs @@ -226,8 +226,8 @@ namespace CodeImp.DoomBuilder.Controls // Setup layout ArgumentBox_Resize(this, EventArgs.Empty); - // Re-apply value - SetValue(oldvalue); + //mxd. If not mixed values, re-apply the old value + if(!string.IsNullOrEmpty(combobox.Text)) SetValue(oldvalue); } // This sets the value diff --git a/Source/Core/Controls/ArgumentsControl.Designer.cs b/Source/Core/Controls/ArgumentsControl.Designer.cs new file mode 100644 index 0000000000000000000000000000000000000000..900b2e6017e4639523bcdab1232ce70b52c3f03a --- /dev/null +++ b/Source/Core/Controls/ArgumentsControl.Designer.cs @@ -0,0 +1,244 @@ +namespace CodeImp.DoomBuilder.Controls +{ + partial class ArgumentsControl + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + this.splitcontainer = new System.Windows.Forms.SplitContainer(); + this.cbuseargstr = new System.Windows.Forms.CheckBox(); + this.arg0label = new System.Windows.Forms.Label(); + this.arg1label = new System.Windows.Forms.Label(); + this.arg2label = new System.Windows.Forms.Label(); + this.arg3label = new System.Windows.Forms.Label(); + this.arg4label = new System.Windows.Forms.Label(); + this.tooltip = new System.Windows.Forms.ToolTip(this.components); + this.scriptnames = new CodeImp.DoomBuilder.Controls.ColoredComboBox(); + this.scriptnumbers = new CodeImp.DoomBuilder.Controls.ColoredComboBox(); + this.arg0 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); + this.arg1 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); + this.arg2 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); + this.arg3 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); + this.arg4 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); + this.splitcontainer.Panel1.SuspendLayout(); + this.splitcontainer.Panel2.SuspendLayout(); + this.splitcontainer.SuspendLayout(); + this.SuspendLayout(); + // + // splitcontainer + // + this.splitcontainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitcontainer.Location = new System.Drawing.Point(0, 0); + this.splitcontainer.Name = "splitcontainer"; + // + // splitcontainer.Panel1 + // + this.splitcontainer.Panel1.Controls.Add(this.cbuseargstr); + this.splitcontainer.Panel1.Controls.Add(this.scriptnames); + this.splitcontainer.Panel1.Controls.Add(this.scriptnumbers); + this.splitcontainer.Panel1.Controls.Add(this.arg0label); + this.splitcontainer.Panel1.Controls.Add(this.arg1label); + this.splitcontainer.Panel1.Controls.Add(this.arg2label); + this.splitcontainer.Panel1.Controls.Add(this.arg0); + this.splitcontainer.Panel1.Controls.Add(this.arg1); + this.splitcontainer.Panel1.Controls.Add(this.arg2); + // + // splitcontainer.Panel2 + // + this.splitcontainer.Panel2.Controls.Add(this.arg3label); + this.splitcontainer.Panel2.Controls.Add(this.arg4label); + this.splitcontainer.Panel2.Controls.Add(this.arg3); + this.splitcontainer.Panel2.Controls.Add(this.arg4); + this.splitcontainer.Size = new System.Drawing.Size(700, 140); + this.splitcontainer.SplitterDistance = 350; + this.splitcontainer.SplitterWidth = 1; + this.splitcontainer.TabIndex = 0; + this.splitcontainer.TabStop = false; + // + // cbuseargstr + // + this.cbuseargstr.Location = new System.Drawing.Point(3, -5); + this.cbuseargstr.Name = "cbuseargstr"; + this.cbuseargstr.Size = new System.Drawing.Size(63, 40); + this.cbuseargstr.TabIndex = 44; + this.cbuseargstr.Text = "Named script"; + this.cbuseargstr.UseVisualStyleBackColor = true; + this.cbuseargstr.CheckedChanged += new System.EventHandler(this.cbuseargstr_CheckedChanged); + // + // arg0label + // + this.arg0label.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg0label.Location = new System.Drawing.Point(55, 8); + this.arg0label.Name = "arg0label"; + this.arg0label.Size = new System.Drawing.Size(179, 14); + this.arg0label.TabIndex = 33; + this.arg0label.Text = "Argument 1:"; + this.arg0label.TextAlign = System.Drawing.ContentAlignment.TopRight; + this.arg0label.UseMnemonic = false; + // + // arg1label + // + this.arg1label.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg1label.Location = new System.Drawing.Point(55, 33); + this.arg1label.Name = "arg1label"; + this.arg1label.Size = new System.Drawing.Size(179, 14); + this.arg1label.TabIndex = 42; + this.arg1label.Text = "Argument 2:"; + this.arg1label.TextAlign = System.Drawing.ContentAlignment.TopRight; + this.arg1label.UseMnemonic = false; + // + // arg2label + // + this.arg2label.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg2label.Location = new System.Drawing.Point(55, 58); + this.arg2label.Name = "arg2label"; + this.arg2label.Size = new System.Drawing.Size(179, 14); + this.arg2label.TabIndex = 43; + this.arg2label.Text = "Argument 3:"; + this.arg2label.TextAlign = System.Drawing.ContentAlignment.TopRight; + this.arg2label.UseMnemonic = false; + // + // arg3label + // + this.arg3label.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg3label.Location = new System.Drawing.Point(55, 8); + this.arg3label.Name = "arg3label"; + this.arg3label.Size = new System.Drawing.Size(179, 14); + this.arg3label.TabIndex = 44; + this.arg3label.Text = "Argument 4:"; + this.arg3label.TextAlign = System.Drawing.ContentAlignment.TopRight; + this.arg3label.UseMnemonic = false; + // + // arg4label + // + this.arg4label.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg4label.Location = new System.Drawing.Point(55, 33); + this.arg4label.Name = "arg4label"; + this.arg4label.Size = new System.Drawing.Size(179, 14); + this.arg4label.TabIndex = 46; + this.arg4label.Text = "Argument 5:"; + this.arg4label.TextAlign = System.Drawing.ContentAlignment.TopRight; + this.arg4label.UseMnemonic = false; + // + // scriptnames + // + this.scriptnames.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.scriptnames.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.scriptnames.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.scriptnames.BackColor = System.Drawing.Color.Honeydew; + this.scriptnames.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + this.scriptnames.FormattingEnabled = true; + this.scriptnames.Location = new System.Drawing.Point(237, 104); + this.scriptnames.Name = "scriptnames"; + this.scriptnames.Size = new System.Drawing.Size(110, 21); + this.scriptnames.TabIndex = 41; + this.scriptnames.TextChanged += new System.EventHandler(this.scriptnames_TextChanged); + // + // scriptnumbers + // + this.scriptnumbers.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.scriptnumbers.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.scriptnumbers.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.scriptnumbers.BackColor = System.Drawing.Color.LemonChiffon; + this.scriptnumbers.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + this.scriptnumbers.FormattingEnabled = true; + this.scriptnumbers.Location = new System.Drawing.Point(237, 80); + this.scriptnumbers.Name = "scriptnumbers"; + this.scriptnumbers.Size = new System.Drawing.Size(110, 21); + this.scriptnumbers.TabIndex = 40; + this.scriptnumbers.TextChanged += new System.EventHandler(this.scriptnumbers_TextChanged); + // + // arg0 + // + this.arg0.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg0.Location = new System.Drawing.Point(237, 3); + this.arg0.Name = "arg0"; + this.arg0.Size = new System.Drawing.Size(110, 24); + this.arg0.TabIndex = 2; + // + // arg1 + // + this.arg1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg1.Location = new System.Drawing.Point(237, 28); + this.arg1.Name = "arg1"; + this.arg1.Size = new System.Drawing.Size(110, 24); + this.arg1.TabIndex = 34; + // + // arg2 + // + this.arg2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg2.Location = new System.Drawing.Point(237, 53); + this.arg2.Name = "arg2"; + this.arg2.Size = new System.Drawing.Size(110, 24); + this.arg2.TabIndex = 35; + // + // arg3 + // + this.arg3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg3.Location = new System.Drawing.Point(236, 3); + this.arg3.Name = "arg3"; + this.arg3.Size = new System.Drawing.Size(110, 24); + this.arg3.TabIndex = 43; + // + // arg4 + // + this.arg4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.arg4.Location = new System.Drawing.Point(236, 28); + this.arg4.Name = "arg4"; + this.arg4.Size = new System.Drawing.Size(110, 24); + this.arg4.TabIndex = 45; + // + // ArgumentsControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.Controls.Add(this.splitcontainer); + this.Name = "ArgumentsControl"; + this.Size = new System.Drawing.Size(700, 140); + this.splitcontainer.Panel1.ResumeLayout(false); + this.splitcontainer.Panel2.ResumeLayout(false); + this.splitcontainer.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitcontainer; + private ArgumentBox arg0; + private ArgumentBox arg1; + private System.Windows.Forms.Label arg0label; + private ColoredComboBox scriptnumbers; + private System.Windows.Forms.Label arg2label; + private System.Windows.Forms.Label arg1label; + private ColoredComboBox scriptnames; + private System.Windows.Forms.Label arg3label; + private System.Windows.Forms.Label arg4label; + private ArgumentBox arg3; + private ArgumentBox arg4; + private System.Windows.Forms.CheckBox cbuseargstr; + private System.Windows.Forms.ToolTip tooltip; + private ArgumentBox arg2; + } +} diff --git a/Source/Core/Controls/ArgumentsControl.cs b/Source/Core/Controls/ArgumentsControl.cs new file mode 100644 index 0000000000000000000000000000000000000000..b6c91c38abcf3e37f41c069568a6226b854a4243 --- /dev/null +++ b/Source/Core/Controls/ArgumentsControl.cs @@ -0,0 +1,455 @@ +#region ================== Namespaces + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using CodeImp.DoomBuilder.Config; +using CodeImp.DoomBuilder.GZBuilder.Data; +using CodeImp.DoomBuilder.Geometry; +using CodeImp.DoomBuilder.Map; +using CodeImp.DoomBuilder.Types; + +#endregion + +namespace CodeImp.DoomBuilder.Controls +{ + public partial class ArgumentsControl : UserControl + { + #region ================== Native stuff + + [DllImport("user32.dll")] + private static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam); + + private const int WM_SETREDRAW = 11; + + #endregion + + #region ================== Variables + + private string arg0str; + private bool havearg0str; + private int action; + private ArgumentInfo[] arginfo; + + #endregion + + #region ================== Constructor + + public ArgumentsControl() + { + InitializeComponent(); + + // Only when running (this.DesignMode won't do when not this, but one of parent controls is in design mode) + if(LicenseManager.UsageMode != LicenseUsageMode.Designtime) + { + //mxd. Setup script numbers + scriptnumbers.Location = new Point(arg0.Location.X, arg0.Location.Y + 2); + foreach(ScriptItem si in General.Map.NumberedScripts.Values) + scriptnumbers.Items.Add(new ColoredComboBoxItem(si, si.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); + scriptnumbers.DropDownWidth = Tools.GetDropDownWidth(scriptnumbers); + + //mxd. Setup script names + if(General.Map.UDMF) + { + scriptnames.Location = scriptnumbers.Location; + foreach(ScriptItem nsi in General.Map.NamedScripts.Values) + scriptnames.Items.Add(new ColoredComboBoxItem(nsi, nsi.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); + scriptnames.DropDownWidth = Tools.GetDropDownWidth(scriptnames); + } + else + { + scriptnames.Visible = false; + cbuseargstr.Visible = false; + } + } + } + + #endregion + + #region ================== Setup + + public void SetValue(Linedef l, bool first) + { + SetValue(l.Fields, l.Args, first); + } + + public void SetValue(Thing t, bool first) + { + SetValue(t.Fields, t.Args, first); + } + + private void SetValue(UniFields fields, int[] args, bool first) + { + if(first) + { + if(General.Map.UDMF) + { + arg0str = fields.GetValue("arg0str", string.Empty); + havearg0str = !string.IsNullOrEmpty(arg0str); + } + + // Update arguments + arg0.SetValue(args[0]); + arg1.SetValue(args[1]); + arg2.SetValue(args[2]); + arg3.SetValue(args[3]); + arg4.SetValue(args[4]); + } + else + { + if(General.Map.UDMF) + { + if(arg0str != fields.GetValue("arg0str", string.Empty)) + { + havearg0str = true; + arg0str = string.Empty; + } + } + + // Update arguments + if(!string.IsNullOrEmpty(arg0.Text) && args[0] != arg0.GetResult(int.MinValue)) arg0.ClearValue(); + if(!string.IsNullOrEmpty(arg1.Text) && args[1] != arg1.GetResult(int.MinValue)) arg1.ClearValue(); + if(!string.IsNullOrEmpty(arg2.Text) && args[2] != arg2.GetResult(int.MinValue)) arg2.ClearValue(); + if(!string.IsNullOrEmpty(arg3.Text) && args[3] != arg3.GetResult(int.MinValue)) arg3.ClearValue(); + if(!string.IsNullOrEmpty(arg4.Text) && args[4] != arg4.GetResult(int.MinValue)) arg4.ClearValue(); + } + } + + #endregion + + #region ================== Apply + + public void Apply(Linedef l) + { + //mxd. Script name/number handling + if(scriptnumbers.Visible) + { + //apply script number + if(!string.IsNullOrEmpty(scriptnumbers.Text)) + { + if(scriptnumbers.SelectedItem != null) + l.Args[0] = ((ScriptItem)((ColoredComboBoxItem)scriptnumbers.SelectedItem).Value).Index; + else if(!int.TryParse(scriptnumbers.Text.Trim(), out l.Args[0])) + l.Args[0] = 0; + + if(l.Fields.ContainsKey("arg0str")) l.Fields.Remove("arg0str"); + } + } + else if(scriptnames.Visible) + { + // Apply arg0str + if(!string.IsNullOrEmpty(scriptnames.Text)) + l.Fields["arg0str"] = new UniValue(UniversalType.String, scriptnames.Text); + } + else + { + l.Args[0] = arg0.GetResult(l.Args[0]); + if(l.Fields.ContainsKey("arg0str")) l.Fields.Remove("arg0str"); + } + + // Apply the rest of args + l.Args[1] = arg1.GetResult(l.Args[1]); + l.Args[2] = arg2.GetResult(l.Args[2]); + l.Args[3] = arg3.GetResult(l.Args[3]); + l.Args[4] = arg4.GetResult(l.Args[4]); + } + + public void Apply(Thing t) + { + //mxd. Script name/number handling + if(scriptnumbers.Visible) + { + //apply script number + if(!string.IsNullOrEmpty(scriptnumbers.Text)) + { + if(scriptnumbers.SelectedItem != null) + t.Args[0] = ((ScriptItem)((ColoredComboBoxItem)scriptnumbers.SelectedItem).Value).Index; + else if(!int.TryParse(scriptnumbers.Text.Trim(), out t.Args[0])) + t.Args[0] = 0; + + if(t.Fields.ContainsKey("arg0str")) t.Fields.Remove("arg0str"); + } + } + else if(scriptnames.Visible) + { + // Apply arg0str + if(!string.IsNullOrEmpty(scriptnames.Text)) + t.Fields["arg0str"] = new UniValue(UniversalType.String, scriptnames.Text); + } + else + { + t.Args[0] = arg0.GetResult(t.Args[0]); + if(t.Fields.ContainsKey("arg0str")) t.Fields.Remove("arg0str"); + } + + // Apply the rest of args + t.Args[1] = arg1.GetResult(t.Args[1]); + t.Args[2] = arg2.GetResult(t.Args[2]); + t.Args[3] = arg3.GetResult(t.Args[3]); + t.Args[4] = arg4.GetResult(t.Args[4]); + } + + #endregion + + #region ================== Update + + public void UpdateAction(int action, bool setuponly) + { + UpdateAction(action, setuponly, null); + } + + public void UpdateAction(int action, bool setuponly, ThingTypeInfo info) + { + // Update arguments + int showaction = 0; + + // Only when action type is known + if(General.Map.Config.LinedefActions.ContainsKey(action)) showaction = action; + if((showaction == 0) && (info != null)) arginfo = info.Args; + else arginfo = General.Map.Config.LinedefActions[showaction].Args; + + // Don't update action args when thing type is changed + if(info != null && showaction != 0 && this.action == showaction) return; + + // Change the argument descriptions + this.BeginUpdate(); + + UpdateArgument(arg0, arg0label, arginfo[0]); + UpdateArgument(arg1, arg1label, arginfo[1]); + UpdateArgument(arg2, arg2label, arginfo[2]); + UpdateArgument(arg3, arg3label, arginfo[3]); + UpdateArgument(arg4, arg4label, arginfo[4]); + + if(!setuponly) + { + // Apply action's or thing's default arguments + if(showaction != 0 || info != null) + { + arg0.SetDefaultValue(); + arg1.SetDefaultValue(); + arg2.SetDefaultValue(); + arg3.SetDefaultValue(); + arg4.SetDefaultValue(); + } + else //or set them to 0 + { + arg0.SetValue(0); + arg1.SetValue(0); + arg2.SetValue(0); + arg3.SetValue(0); + arg4.SetValue(0); + } + } + + // Store current action + this.action = showaction; + + this.EndUpdate(); + } + + public void UpdateScriptControls() + { + // Update script-specific stuff + if(Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action) != -1) + { + // Update script controls visibility + bool shownamedscripts = (General.Map.UDMF && havearg0str); + cbuseargstr.Visible = General.Map.UDMF; + cbuseargstr.Checked = shownamedscripts; + scriptnames.Visible = shownamedscripts; + scriptnumbers.Visible = !shownamedscripts; + + // Update named script name + if(shownamedscripts) + { + if(General.Map.NamedScripts.ContainsKey(arg0str)) + { + int i = 0; + foreach(ScriptItem item in General.Map.NamedScripts.Values) + { + if(item.Name == arg0str) + { + scriptnames.SelectedIndex = i; + UpdateScriptArguments(item); + break; + } + i++; + } + } + else + { + // Unknown script name + scriptnames.Text = arg0str; + } + } + else + { + // Update numbered script name + int a0 = arg0.GetResult(0); + if(General.Map.NumberedScripts.ContainsKey(a0)) + { + int i = 0; + foreach(ScriptItem item in General.Map.NumberedScripts.Values) + { + if(item.Index == a0) + { + scriptnumbers.SelectedIndex = i; + UpdateScriptArguments(item); + break; + } + + i++; + } + } + else + { + // Unknown script number... + scriptnumbers.Text = a0.ToString(); + } + } + } + else + { + cbuseargstr.Visible = false; + scriptnames.Visible = false; + scriptnumbers.Visible = false; + cbuseargstr.Checked = false; + } + + arg0.Visible = (!scriptnames.Visible && !scriptnumbers.Visible); + } + + private void UpdateArgument(ArgumentBox arg, Label label, ArgumentInfo info) + { + // Update labels + label.Text = info.Title + ":"; + label.Enabled = info.Used; + arg.ForeColor = (label.Enabled ? SystemColors.WindowText : SystemColors.GrayText); + arg.Setup(info); + + // Update tooltip + UpdateToolTip(label, info); + } + + private void UpdateToolTip(Label label, ArgumentInfo info) + { + if(info.Used && !string.IsNullOrEmpty(info.ToolTip)) + { + tooltip.SetToolTip(label, info.ToolTip); + label.Font = new Font(label.Font, FontStyle.Underline); + label.ForeColor = SystemColors.HotTrack; + } + else + { + tooltip.SetToolTip(label, null); + label.Font = new Font(label.Font, FontStyle.Regular); + label.ForeColor = SystemColors.WindowText; + } + } + + private void UpdateScriptArguments(ScriptItem item) + { + Label[] labels = { arg0label, arg1label, arg2label, arg3label, arg4label }; + ArgumentBox[] args = { arg0, arg1, arg2, arg3, arg4 }; + if(item != null) + { + string[] argnames = item.GetArgumentsDescriptions(action); + for(int i = 0; i < labels.Length; i++) + { + if(!string.IsNullOrEmpty(argnames[i])) + { + labels[i].Text = argnames[i] + ":"; + labels[i].Enabled = true; + labels[i].Font = new Font(labels[i].Font, FontStyle.Regular); + labels[i].ForeColor = SystemColors.WindowText; + } + else + { + labels[i].Text = arginfo[i].Title; + labels[i].Enabled = arginfo[i].Used; + UpdateToolTip(labels[i], arginfo[i]); + } + + args[i].ForeColor = (labels[i].Enabled ? SystemColors.WindowText : SystemColors.GrayText); + } + } + else + { + for (int i = 0; i < labels.Length; i++) + { + labels[i].Text = arginfo[i].Title; + labels[i].Enabled = arginfo[i].Used; + UpdateToolTip(labels[i], arginfo[i]); + args[i].ForeColor = (labels[i].Enabled ? SystemColors.WindowText : SystemColors.GrayText); + } + } + } + + #endregion + + #region ================== Redraw control + + private void BeginUpdate() + { + SendMessage(this.Parent.Handle, WM_SETREDRAW, false, 0); + } + + private void EndUpdate() + { + SendMessage(this.Parent.Handle, WM_SETREDRAW, true, 0); + this.Parent.Refresh(); + } + + #endregion + + #region ================== Events + + private void cbuseargstr_CheckedChanged(object sender, EventArgs e) + { + if(!cbuseargstr.Visible) return; + scriptnames.Visible = cbuseargstr.Checked; + scriptnumbers.Visible = !cbuseargstr.Checked; + arg0label.Text = (cbuseargstr.Checked ? "Script Name:" : "Script Number:"); + } + + private void scriptnumbers_TextChanged(object sender, EventArgs e) + { + if(string.IsNullOrEmpty(scriptnumbers.Text)) return; + ScriptItem item = null; + if(scriptnumbers.SelectedIndex != -1) + { + item = ((ScriptItem)((ColoredComboBoxItem)scriptnumbers.SelectedItem).Value); + } + else + { + int scriptindex; + if(int.TryParse(scriptnumbers.Text, out scriptindex) && General.Map.NumberedScripts.ContainsKey(scriptindex)) + item = General.Map.NumberedScripts[scriptindex]; + } + + UpdateScriptArguments(item); + } + + private void scriptnames_TextChanged(object sender, EventArgs e) + { + if(string.IsNullOrEmpty(scriptnames.Text)) return; + ScriptItem item = null; + if(scriptnames.SelectedIndex != -1) + { + item = ((ScriptItem)((ColoredComboBoxItem)scriptnames.SelectedItem).Value); + } + else + { + string scriptname = scriptnames.Text.Trim().ToLowerInvariant(); + if(General.Map.NamedScripts.ContainsKey(scriptname)) + item = General.Map.NamedScripts[scriptname]; + } + + UpdateScriptArguments(item); + } + + #endregion + } +} diff --git a/Source/Core/Controls/ArgumentsControl.resx b/Source/Core/Controls/ArgumentsControl.resx new file mode 100644 index 0000000000000000000000000000000000000000..f991e2b7bc89d9052984b85dac65be4abde7b063 --- /dev/null +++ b/Source/Core/Controls/ArgumentsControl.resx @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> +</root> \ No newline at end of file diff --git a/Source/Core/Controls/CommentEditor.Designer.cs b/Source/Core/Controls/CommentEditor.Designer.cs index 165f05448377f28a1cbb1af3a3a6af6da29acdbe..393b8168f942781acdfd510666821aae46413869 100644 --- a/Source/Core/Controls/CommentEditor.Designer.cs +++ b/Source/Core/Controls/CommentEditor.Designer.cs @@ -34,10 +34,7 @@ this.radioButton4 = new System.Windows.Forms.RadioButton(); this.radioButton5 = new System.Windows.Forms.RadioButton(); this.panel1 = new System.Windows.Forms.Panel(); - this.tip = new System.Windows.Forms.PictureBox(); - this.hintlabel = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.tip)).BeginInit(); this.SuspendLayout(); // // textbox @@ -49,23 +46,25 @@ this.textbox.Multiline = true; this.textbox.Name = "textbox"; this.textbox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textbox.Size = new System.Drawing.Size(481, 239); + this.textbox.Size = new System.Drawing.Size(481, 268); this.textbox.TabIndex = 0; this.textbox.TabStop = false; this.textbox.TextChanged += new System.EventHandler(this.textbox_TextChanged); + this.textbox.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textbox_PreviewKeyDown); this.textbox.Leave += new System.EventHandler(this.textbox_Leave); this.textbox.Enter += new System.EventHandler(this.textbox_Enter); // // clear // - this.clear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.clear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.clear.Image = global::CodeImp.DoomBuilder.Properties.Resources.Clear; this.clear.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.clear.Location = new System.Drawing.Point(394, 274); + this.clear.Location = new System.Drawing.Point(424, 2); this.clear.Name = "clear"; - this.clear.Size = new System.Drawing.Size(90, 23); + this.clear.Size = new System.Drawing.Size(60, 23); this.clear.TabIndex = 1; this.clear.Text = "Clear"; + this.clear.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.clear.UseVisualStyleBackColor = true; this.clear.Click += new System.EventHandler(this.clear_Click); // @@ -152,35 +151,13 @@ this.panel1.Controls.Add(this.radioButton5); this.panel1.Location = new System.Drawing.Point(88, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(396, 23); + this.panel1.Size = new System.Drawing.Size(330, 23); this.panel1.TabIndex = 8; // - // tip - // - this.tip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.tip.Image = global::CodeImp.DoomBuilder.Properties.Resources.Lightbulb; - this.tip.Location = new System.Drawing.Point(3, 277); - this.tip.Name = "tip"; - this.tip.Size = new System.Drawing.Size(16, 16); - this.tip.TabIndex = 9; - this.tip.TabStop = false; - // - // hintlabel - // - this.hintlabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.hintlabel.AutoSize = true; - this.hintlabel.Location = new System.Drawing.Point(21, 279); - this.hintlabel.Name = "hintlabel"; - this.hintlabel.Size = new System.Drawing.Size(170, 13); - this.hintlabel.TabIndex = 10; - this.hintlabel.Text = "Press Ctrl-Enter to add a line break"; - // // CommentEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.hintlabel); - this.Controls.Add(this.tip); this.Controls.Add(this.clear); this.Controls.Add(this.panel1); this.Controls.Add(this.label1); @@ -188,7 +165,6 @@ this.Name = "CommentEditor"; this.Size = new System.Drawing.Size(487, 300); this.panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.tip)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -205,7 +181,5 @@ private System.Windows.Forms.RadioButton radioButton4; private System.Windows.Forms.RadioButton radioButton5; private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.PictureBox tip; - private System.Windows.Forms.Label hintlabel; } } diff --git a/Source/Core/Controls/CommentEditor.cs b/Source/Core/Controls/CommentEditor.cs index fdbbea471d80389847fbaa733092c164631f1b56..9d76822a2dbf4c27efe343e4cb2daf7f0a203ae2 100644 --- a/Source/Core/Controls/CommentEditor.cs +++ b/Source/Core/Controls/CommentEditor.cs @@ -130,6 +130,12 @@ namespace CodeImp.DoomBuilder.Controls commenttype = (int)((Control)sender).Tag; } + // We don't want to close the parent form when user presses Enter while typing the text + private void textbox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + if(e.KeyCode == Keys.Enter) e.IsInputKey = true; + } + #endregion } } diff --git a/Source/Core/Controls/LinedefInfoPanel.cs b/Source/Core/Controls/LinedefInfoPanel.cs index 75c2189c138fee9bdce582e101bc44b0ea96573c..18ded945cffac21e7a858df1f1d9752396edf314 100644 --- a/Source/Core/Controls/LinedefInfoPanel.cs +++ b/Source/Core/Controls/LinedefInfoPanel.cs @@ -21,6 +21,7 @@ using System.Collections.Generic; using System.Drawing; using System.Globalization; using System.Windows.Forms; +using CodeImp.DoomBuilder.GZBuilder.Data; using CodeImp.DoomBuilder.GZBuilder.Tools; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Config; @@ -152,31 +153,60 @@ namespace CodeImp.DoomBuilder.Controls action.Enabled = (act.Index != 0); actionlabel.Enabled = (act.Index != 0); - //mxd - bool hasArg0Str = General.Map.UDMF && Array.IndexOf(GZGeneral.ACS_SPECIALS, l.Action) != -1 && l.Fields.ContainsKey("arg0str"); - - // Arguments - arglbl1.Text = hasArg0Str ? "Script name:" : act.Args[0].Title + ":"; //mxd - arglbl2.Text = act.Args[1].Title + ":"; - arglbl3.Text = act.Args[2].Title + ":"; - arglbl4.Text = act.Args[3].Title + ":"; - arglbl5.Text = act.Args[4].Title + ":"; - arglbl1.Enabled = act.Args[0].Used; - arglbl2.Enabled = act.Args[1].Used; - arglbl3.Enabled = act.Args[2].Used; - arglbl4.Enabled = act.Args[3].Used; - arglbl5.Enabled = act.Args[4].Used; - arg1.Enabled = act.Args[0].Used; - arg2.Enabled = act.Args[1].Used; - arg3.Enabled = act.Args[2].Used; - arg4.Enabled = act.Args[3].Used; - arg5.Enabled = act.Args[4].Used; + //mxd. ACS script argument names + bool isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, l.Action) != -1); + bool isnamedacsscript = (isacsscript && General.Map.UDMF && l.Fields.ContainsKey("arg0str")); + string scriptname = (isnamedacsscript ? l.Fields.GetValue("arg0str", string.Empty) : string.Empty); + ScriptItem scriptitem = null; - //mxd - if (hasArg0Str) - arg1.Text = '"' + l.Fields["arg0str"].Value.ToString() + '"'; - else - SetArgumentText(act.Args[0], arg1, l.Args[0]); + // Named script? + if(isnamedacsscript && General.Map.NamedScripts.ContainsKey(scriptname.ToLowerInvariant())) + { + scriptitem = General.Map.NamedScripts[scriptname.ToLowerInvariant()]; + } + // Script number? + else if(isacsscript && General.Map.NumberedScripts.ContainsKey(l.Args[0])) + { + scriptitem = General.Map.NumberedScripts[l.Args[0]]; + scriptname = scriptitem.Name; + } + + // Apply script args? + Label[] arglabels = new[] { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 }; + Label[] args = new[] { arg1, arg2, arg3, arg4, arg5 }; + + if(scriptitem != null) + { + string[] argnames = scriptitem.GetArgumentsDescriptions(l.Action); + for(int i = 0; i < argnames.Length; i++) + { + if(!string.IsNullOrEmpty(argnames[i])) + { + arglabels[i].Text = argnames[i] + ":"; + arglabels[i].Enabled = true; + args[i].Enabled = true; + } + else + { + arglabels[i].Text = act.Args[i].Title + ":"; + arglabels[i].Enabled = act.Args[i].Used; + args[i].Enabled = act.Args[i].Used; + } + } + } + else + { + for(int i = 0; i < act.Args.Length; i++) + { + arglabels[i].Text = act.Args[i].Title + ":"; + arglabels[i].Enabled = act.Args[i].Used; + args[i].Enabled = act.Args[i].Used; + } + } + + //mxd. Set argument value and label + if(!string.IsNullOrEmpty(scriptname)) arg1.Text = scriptname; + else SetArgumentText(act.Args[0], arg1, l.Args[0]); SetArgumentText(act.Args[1], arg2, l.Args[1]); SetArgumentText(act.Args[2], arg3, l.Args[2]); SetArgumentText(act.Args[3], arg4, l.Args[3]); diff --git a/Source/Core/Controls/ThingInfoPanel.cs b/Source/Core/Controls/ThingInfoPanel.cs index 03b0df405f468c5dbf73afdf4b5816cdbcf20508..c6a39fccc1c5300c4354f0198c8feaf80c1b7cf5 100644 --- a/Source/Core/Controls/ThingInfoPanel.cs +++ b/Source/Core/Controls/ThingInfoPanel.cs @@ -20,6 +20,7 @@ using System; using System.Globalization; using System.Windows.Forms; using CodeImp.DoomBuilder.Data; +using CodeImp.DoomBuilder.GZBuilder.Data; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Config; using CodeImp.DoomBuilder.Types; @@ -32,8 +33,8 @@ namespace CodeImp.DoomBuilder.Controls { internal partial class ThingInfoPanel : UserControl { - private int hexenformatwidth; - private int doomformatwidth; + private readonly int hexenformatwidth; + private readonly int doomformatwidth; // Constructor public ThingInfoPanel() @@ -49,7 +50,6 @@ namespace CodeImp.DoomBuilder.Controls // This shows the info public void ShowInfo(Thing t) { - LinedefActionInfo act = null; string actioninfo; string zinfo; @@ -79,15 +79,10 @@ namespace CodeImp.DoomBuilder.Controls ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type); // Get thing action information - if(General.Map.Config.LinedefActions.ContainsKey(t.Action)) - { - act = General.Map.Config.LinedefActions[t.Action]; - actioninfo = act.ToString(); - } - else if(t.Action == 0) - actioninfo = t.Action + " - None"; - else - actioninfo = t.Action + " - Unknown"; + LinedefActionInfo act = General.Map.Config.LinedefActions[t.Action]; + if(General.Map.Config.LinedefActions.ContainsKey(t.Action)) actioninfo = act.ToString(); + else if(t.Action == 0) actioninfo = t.Action + " - None"; + else actioninfo = t.Action + " - Unknown"; // Determine z info to show t.DetermineSector(); @@ -134,39 +129,64 @@ namespace CodeImp.DoomBuilder.Controls spritename.Text = ""; spritetex.Image = null; } - // Arguments - ArgumentInfo[] arginfo = (((t.Action == 0 || act == null) && ti.Args[0] != null) ? ti.Args : act.Args); //mxd + ArgumentInfo[] arginfo = ((t.Action == 0 && ti.Args[0] != null) ? ti.Args : act.Args); //mxd - //mxd - bool hasArg0Str = General.Map.UDMF && Array.IndexOf(GZGeneral.ACS_SPECIALS, t.Action) != -1 && t.Fields.ContainsKey("arg0str"); - - arglbl1.Text = hasArg0Str ? "Script name:" : arginfo[0].Title + ":"; //mxd - arglbl2.Text = arginfo[1].Title + ":"; - arglbl3.Text = arginfo[2].Title + ":"; - arglbl4.Text = arginfo[3].Title + ":"; - arglbl5.Text = arginfo[4].Title + ":"; - arglbl1.Enabled = arginfo[0].Used; - arglbl2.Enabled = arginfo[1].Used; - arglbl3.Enabled = arginfo[2].Used; - arglbl4.Enabled = arginfo[3].Used; - arglbl5.Enabled = arginfo[4].Used; - arg1.Enabled = arginfo[0].Used; - arg2.Enabled = arginfo[1].Used; - arg3.Enabled = arginfo[2].Used; - arg4.Enabled = arginfo[3].Used; - arg5.Enabled = arginfo[4].Used; + //mxd. ACS script argument names + bool isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, t.Action) != -1); + bool isnamedacsscript = (isacsscript && General.Map.UDMF && t.Fields.ContainsKey("arg0str")); + string scriptname = (isnamedacsscript ? t.Fields.GetValue("arg0str", string.Empty) : string.Empty); + ScriptItem scriptitem = null; - //mxd - if(hasArg0Str) + // Named script? + if(isnamedacsscript && General.Map.NamedScripts.ContainsKey(scriptname.ToLowerInvariant())) { - arg1.Text = '"' + t.Fields["arg0str"].Value.ToString() + '"'; - } - else + scriptitem = General.Map.NamedScripts[scriptname.ToLowerInvariant()]; + } + // Script number? + else if(isacsscript && General.Map.NumberedScripts.ContainsKey(t.Args[0])) { - SetArgumentText(arginfo[0], arg1, t.Args[0]); + scriptitem = General.Map.NumberedScripts[t.Args[0]]; + scriptname = scriptitem.Name; } + + // Apply script args? + Label[] arglabels = new[] { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 }; + Label[] args = new[] { arg1, arg2, arg3, arg4, arg5 }; + + if(scriptitem != null) + { + string[] argnames = scriptitem.GetArgumentsDescriptions(t.Action); + for(int i = 0; i < argnames.Length; i++) + { + if(!string.IsNullOrEmpty(argnames[i])) + { + arglabels[i].Text = argnames[i] + ":"; + arglabels[i].Enabled = true; + args[i].Enabled = true; + } + else + { + arglabels[i].Text = arginfo[i].Title + ":"; + arglabels[i].Enabled = arginfo[i].Used; + args[i].Enabled = arginfo[i].Used; + } + } + } + else + { + for(int i = 0; i < arginfo.Length; i++) + { + arglabels[i].Text = arginfo[i].Title + ":"; + arglabels[i].Enabled = arginfo[i].Used; + args[i].Enabled = arginfo[i].Used; + } + } + + //mxd. Set argument value and label + if(!string.IsNullOrEmpty(scriptname)) arg1.Text = scriptname; + else SetArgumentText(arginfo[0], arg1, t.Args[0]); SetArgumentText(arginfo[1], arg2, t.Args[1]); SetArgumentText(arginfo[2], arg3, t.Args[2]); SetArgumentText(arginfo[3], arg4, t.Args[3]); diff --git a/Source/Core/GZBuilder/Data/ScriptItem.cs b/Source/Core/GZBuilder/Data/ScriptItem.cs index 25a22e417bcb4601ae6e36b3da11252da9177aee..f41afd7fd90fc180ede8bcf8efb9dfddef9d7bd5 100644 --- a/Source/Core/GZBuilder/Data/ScriptItem.cs +++ b/Source/Core/GZBuilder/Data/ScriptItem.cs @@ -1,10 +1,12 @@ using System; +using System.Collections.Generic; namespace CodeImp.DoomBuilder.GZBuilder.Data { internal sealed class ScriptItem : Object { private readonly string name; + private readonly List<string> argnames; private readonly int index; private readonly int cursorposition; private readonly bool isinclude; @@ -14,18 +16,31 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data internal int CursorPosition { get { return cursorposition; } } internal bool IsInclude { get { return isinclude; } } - internal ScriptItem(int index, string name, int cursorPosition, bool isinclude) + internal ScriptItem(string name, int cursorposition, bool isinclude) { this.name = name; - this.index = index; - this.cursorposition = cursorPosition; + this.argnames = new List<string>(); + this.index = int.MinValue; + this.cursorposition = cursorposition; this.isinclude = isinclude; } - internal ScriptItem(int index, string name) + internal ScriptItem(int index, string name, List<string> argnames, int cursorposition, bool isinclude) { this.name = name; + this.argnames = argnames; this.index = index; + this.cursorposition = cursorposition; + this.isinclude = isinclude; + } + + internal ScriptItem(string name, List<string> argnames, int cursorposition, bool isinclude) + { + this.name = name; + this.argnames = argnames; + this.index = int.MinValue; + this.cursorposition = cursorposition; + this.isinclude = isinclude; } internal static int SortByIndex(ScriptItem i1, ScriptItem i2) @@ -58,6 +73,37 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data return -1; } + // God awful, but will do... + internal string[] GetArgumentsDescriptions(int action) + { + string[] result = new[] { index == int.MinValue ? "Script Name" : "Script Number", string.Empty, string.Empty, string.Empty, string.Empty }; + switch (action) + { + case 80: //ACS_Execute (script, map, s_arg1, s_arg2, s_arg3) + case 226: //ACS_ExecuteAlways (script, map, s_arg1, s_arg2, s_arg3) + argnames.CopyTo(0, result, 2, argnames.Count < 3 ? argnames.Count : 3); + break; + + case 83: //ACS_LockedExecute (script, map, s_arg1, s_arg2, lock) + case 85: //ACS_LockedExecuteDoor (script, map, s_arg1, s_arg2, lock) + argnames.CopyTo(0, result, 2, argnames.Count < 2 ? argnames.Count : 2); + break; + + case 84: //ACS_ExecuteWithResult (script, s_arg1, s_arg2, s_arg3, s_arg4) + argnames.CopyTo(0, result, 1, argnames.Count < 4 ? argnames.Count : 4); + break; + + case 81: //ACS_Suspend (script, map) + case 82: //ACS_Terminate (script, map) + return result; + + default: + return new[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + } + + return result; + } + public override string ToString() { return name; diff --git a/Source/Core/GZBuilder/GZDoom/AcsParserSE.cs b/Source/Core/GZBuilder/GZDoom/AcsParserSE.cs index 725208f6565d74be49af4723892b9d3e12dd37bf..945a4cb7593a0efc46b9f31571345f1e50a3c738 100644 --- a/Source/Core/GZBuilder/GZDoom/AcsParserSE.cs +++ b/Source/Core/GZBuilder/GZDoom/AcsParserSE.cs @@ -31,6 +31,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom functions = new List<ScriptItem>(); parsedlumps = new List<string>(); includes = new List<string>(); + specialtokens += "(,)"; } public override bool Parse(Stream stream, string sourcefilename) @@ -76,23 +77,25 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom if (token.IndexOf('"') != -1) { startpos += 1; - //check if we have something like '"mycoolscript"(void)' as a token - if(token.LastIndexOf('"') != token.Length - 1) - token = token.Substring(0, token.LastIndexOf('"')); + string scriptname = StripTokenQuotes(token); - token = StripTokenQuotes(token); - ScriptItem i = new ScriptItem(0, token, startpos, isinclude); - namedscripts.Add(i); + // Try to parse argument names + List<KeyValuePair<string, string>> args = ParseArgs(); + List<string> argnames = new List<string>(); + foreach(KeyValuePair<string, string> group in args) argnames.Add(group.Value); + + // Add to collection + namedscripts.Add(new ScriptItem(scriptname, argnames, startpos, isinclude)); } else //should be numbered script { - //check if we have something like "999(void)" as a token - if (token.Contains("(")) token = token.Substring(0, token.IndexOf("(")); - int n; if (int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out n)) { - //now find opening brace + // Try to parse argument names + List<KeyValuePair<string, string>> args = ParseArgs(); + + // Now find the opening brace do { if(!SkipWhitespace(true)) break; @@ -114,8 +117,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom } name = (name.Length > 0 ? name + " [" + n + "]" : "Script " + n); - ScriptItem i = new ScriptItem(n, name, startpos, isinclude); - numberedscripts.Add(i); + + List<string> argnames = new List<string>(); + foreach(KeyValuePair<string, string> group in args) argnames.Add(group.Value); + + // Add to collection + numberedscripts.Add(new ScriptItem(n, name, argnames, startpos, isinclude)); } } } @@ -129,30 +136,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom SkipWhitespace(true); funcname += " " + ReadToken(); //read function name - //look for opening brace - if (!funcname.Contains("(")) - { - SkipWhitespace(true); - funcname += " " + ReadToken(); - } - else - { - funcname = funcname.Replace("(", " ("); - } - - //look for closing brace - if(!funcname.Contains(")")) - { - do - { - if(!SkipWhitespace(true)) break; - token = ReadToken(); - funcname += " " + token; - } while(!string.IsNullOrEmpty(token) && !token.Contains(")")); - } + // Try to parse argument names + List<KeyValuePair<string, string>> args = ParseArgs(); + List<string> argnames = new List<string>(); + foreach(KeyValuePair<string, string> group in args) argnames.Add(group.Value); - ScriptItem i = new ScriptItem(0, funcname, startpos, isinclude); - functions.Add(i); + // Add to collection + functions.Add(new ScriptItem(funcname, argnames, startpos, isinclude)); } break; @@ -187,5 +177,40 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom } return true; } + + private List<KeyValuePair<string, string>> ParseArgs() //type, name + { + List<KeyValuePair<string, string>> argnames = new List<KeyValuePair<string, string>>(); + SkipWhitespace(true); + string token = ReadToken(); + + // Should be ENTER/OPEN etc. script type + if(token != "(") + { + argnames.Add(new KeyValuePair<string, string>(token.ToUpperInvariant(), string.Empty)); + return argnames; + } + + while(SkipWhitespace(true)) + { + string argtype = ReadToken(); // should be type + if(IsSpecialToken(argtype)) break; + if(argtype.ToUpperInvariant() == "VOID") + { + argnames.Add(new KeyValuePair<string, string>("(void)", string.Empty)); + break; + } + + SkipWhitespace(true); + token = ReadToken(); // should be arg name + argnames.Add(new KeyValuePair<string, string>(argtype, token)); + + SkipWhitespace(true); + token = ReadToken(); // should be comma or ")" + if(token != ",") break; + } + + return argnames; + } } } \ No newline at end of file diff --git a/Source/Core/GZBuilder/GZDoom/DecorateParserSE.cs b/Source/Core/GZBuilder/GZDoom/DecorateParserSE.cs index 7dd3606877e46927caf4726f83342fc133bec2de..afc80a6bfaabd2a3e5956a86e04854386e7d535c 100644 --- a/Source/Core/GZBuilder/GZDoom/DecorateParserSE.cs +++ b/Source/Core/GZBuilder/GZDoom/DecorateParserSE.cs @@ -45,7 +45,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom string name = ""; foreach (string s in definition) name += s + " "; - actors.Add(new ScriptItem(0, name.TrimEnd(), startPos, false)); + actors.Add(new ScriptItem(name.TrimEnd(), startPos, false)); } } } diff --git a/Source/Core/GZBuilder/GZDoom/ModeldefParserSE.cs b/Source/Core/GZBuilder/GZDoom/ModeldefParserSE.cs index 8f7b1744206764ce09debd8da49c511cf9ac086e..e591e45338138276846ad48b1e96a28c28f3aee0 100644 --- a/Source/Core/GZBuilder/GZDoom/ModeldefParserSE.cs +++ b/Source/Core/GZBuilder/GZDoom/ModeldefParserSE.cs @@ -43,7 +43,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom if (token == "{") { - ScriptItem i = new ScriptItem(0, modelName, startPos, false); + ScriptItem i = new ScriptItem(modelName, startPos, false); models.Add(i); } } diff --git a/Source/Core/General/MapManager.cs b/Source/Core/General/MapManager.cs index 72c4ec210fc5500169ee7b5aba439efeb6f6750f..230b6a01032e1cb2a3234c20211bd5d0d65aa5f0 100644 --- a/Source/Core/General/MapManager.cs +++ b/Source/Core/General/MapManager.cs @@ -83,8 +83,8 @@ namespace CodeImp.DoomBuilder private VisualCamera visualcamera; //mxd - private List<ScriptItem> namedScripts; - private List<ScriptItem> numberedScripts; + private Dictionary<string, ScriptItem> namedscripts; + private Dictionary<int, ScriptItem> numberedscripts; private List<string> scriptincludes; // Disposing @@ -122,8 +122,8 @@ namespace CodeImp.DoomBuilder //mxd public bool UDMF { get { return config.FormatInterface == "UniversalMapSetIO"; } } - internal List<ScriptItem> NamedScripts { get { return namedScripts; } } - internal List<ScriptItem> NumberedScripts { get { return numberedScripts; } } + internal Dictionary<string, ScriptItem> NamedScripts { get { return namedscripts; } } + internal Dictionary<int, ScriptItem> NumberedScripts { get { return numberedscripts; } } internal List<string> ScriptIncludes { get { return scriptincludes; } } public ViewMode ViewMode { get { return renderer2d.ViewMode; } } @@ -152,8 +152,8 @@ namespace CodeImp.DoomBuilder errors = new List<CompilerError>(); //mxd - numberedScripts = new List<ScriptItem>(); - namedScripts = new List<ScriptItem>(); + numberedscripts = new Dictionary<int, ScriptItem>(); + namedscripts = new Dictionary<string, ScriptItem>(); scriptincludes = new List<string>(); } @@ -308,8 +308,8 @@ namespace CodeImp.DoomBuilder map.Update(); thingsfilter.Update(); - namedScripts = new List<ScriptItem>(); //mxd - numberedScripts = new List<ScriptItem>(); //mxd + namedscripts = new Dictionary<string, ScriptItem>(); //mxd + numberedscripts = new Dictionary<int, ScriptItem>(); //mxd // Bind any methods General.Actions.BindMethods(this); @@ -1485,6 +1485,8 @@ namespace CodeImp.DoomBuilder scriptwindow.Show(); } } + + if(scriptwindow.WindowState == FormWindowState.Minimized) scriptwindow.WindowState = FormWindowState.Normal; //mxd scriptwindow.Activate(); scriptwindow.Focus(); Cursor.Current = Cursors.Default; @@ -1718,8 +1720,8 @@ namespace CodeImp.DoomBuilder //mxd internal void UpdateScriptNames() { - namedScripts = new List<ScriptItem>(); - numberedScripts = new List<ScriptItem>(); + List<ScriptItem> namedscriptslist = new List<ScriptItem>(); + List<ScriptItem> numberedscriptslist = new List<ScriptItem>(); // Load the script lumps foreach (MapLumpInfo maplumpinfo in config.MapLumps.Values) @@ -1737,16 +1739,31 @@ namespace CodeImp.DoomBuilder parser.Parse(stream, "SCRIPTS", true, false); // Add them to arrays - namedScripts.AddRange(parser.NamedScripts); - numberedScripts.AddRange(parser.NumberedScripts); + namedscriptslist.AddRange(parser.NamedScripts); + numberedscriptslist.AddRange(parser.NumberedScripts); scriptincludes.AddRange(parser.Includes); } } } // Sort script names - namedScripts.Sort(ScriptItem.SortByName); - numberedScripts.Sort(ScriptItem.SortByIndex); + namedscriptslist.Sort(ScriptItem.SortByName); + numberedscriptslist.Sort(ScriptItem.SortByIndex); + + // Add to collections + namedscripts = new Dictionary<string, ScriptItem>(namedscriptslist.Count); + numberedscripts = new Dictionary<int, ScriptItem>(numberedscriptslist.Count); + + foreach (ScriptItem item in namedscriptslist) + { + if(!namedscripts.ContainsKey(item.Name.ToLowerInvariant())) + namedscripts.Add(item.Name.ToLowerInvariant(), item); + } + foreach(ScriptItem item in numberedscriptslist) + { + if(!numberedscripts.ContainsKey(item.Index)) + numberedscripts.Add(item.Index, item); + } } //mxd diff --git a/Source/Core/Windows/LinedefEditForm.Designer.cs b/Source/Core/Windows/LinedefEditForm.Designer.cs index 9a3d9bbc1aa20a7f6c901d78d01cf0ab3fe124bd..106bfc94d70038ae5bf9c5ee9a59a1ab2ae76d58 100644 --- a/Source/Core/Windows/LinedefEditForm.Designer.cs +++ b/Source/Core/Windows/LinedefEditForm.Designer.cs @@ -44,19 +44,8 @@ namespace CodeImp.DoomBuilder.Windows this.cancel = new System.Windows.Forms.Button(); this.apply = new System.Windows.Forms.Button(); this.actiongroup = new System.Windows.Forms.GroupBox(); + this.argscontrol = new CodeImp.DoomBuilder.Controls.ArgumentsControl(); this.actionhelp = new CodeImp.DoomBuilder.Controls.ActionSpecialHelpButton(); - this.argspanel = new System.Windows.Forms.Panel(); - this.scriptNumbers = new CodeImp.DoomBuilder.Controls.ColoredComboBox(); - this.arg2 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg1 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg0 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg3 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg4 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg1label = new System.Windows.Forms.Label(); - this.arg3label = new System.Windows.Forms.Label(); - this.arg2label = new System.Windows.Forms.Label(); - this.arg4label = new System.Windows.Forms.Label(); - this.arg0label = new System.Windows.Forms.Label(); this.hexenpanel = new System.Windows.Forms.Panel(); this.activation = new System.Windows.Forms.ComboBox(); this.action = new CodeImp.DoomBuilder.Controls.ActionSelectorControl(); @@ -92,7 +81,6 @@ namespace CodeImp.DoomBuilder.Windows label12 = new System.Windows.Forms.Label(); activationlabel = new System.Windows.Forms.Label(); this.actiongroup.SuspendLayout(); - this.argspanel.SuspendLayout(); this.hexenpanel.SuspendLayout(); this.flagsgroup.SuspendLayout(); this.idgroup.SuspendLayout(); @@ -236,8 +224,8 @@ namespace CodeImp.DoomBuilder.Windows // this.actiongroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.actiongroup.Controls.Add(this.argscontrol); this.actiongroup.Controls.Add(this.actionhelp); - this.actiongroup.Controls.Add(this.argspanel); this.actiongroup.Controls.Add(this.hexenpanel); this.actiongroup.Controls.Add(label2); this.actiongroup.Controls.Add(this.action); @@ -249,136 +237,28 @@ namespace CodeImp.DoomBuilder.Windows this.actiongroup.TabStop = false; this.actiongroup.Text = " Action "; // + // argscontrol + // + this.argscontrol.Location = new System.Drawing.Point(9, 52); + this.argscontrol.Name = "argscontrol"; + this.argscontrol.Size = new System.Drawing.Size(526, 76); + this.argscontrol.TabIndex = 12; + this.argscontrol.Visible = false; + // // actionhelp // - this.actionhelp.Location = new System.Drawing.Point(497, 21); + this.actionhelp.Location = new System.Drawing.Point(505, 21); this.actionhelp.Name = "actionhelp"; this.actionhelp.Size = new System.Drawing.Size(28, 25); this.actionhelp.TabIndex = 11; // - // argspanel - // - this.argspanel.Controls.Add(this.scriptNumbers); - this.argspanel.Controls.Add(this.arg2); - this.argspanel.Controls.Add(this.arg1); - this.argspanel.Controls.Add(this.arg0); - this.argspanel.Controls.Add(this.arg3); - this.argspanel.Controls.Add(this.arg4); - this.argspanel.Controls.Add(this.arg1label); - this.argspanel.Controls.Add(this.arg3label); - this.argspanel.Controls.Add(this.arg2label); - this.argspanel.Controls.Add(this.arg4label); - this.argspanel.Controls.Add(this.arg0label); - this.argspanel.Location = new System.Drawing.Point(6, 50); - this.argspanel.Name = "argspanel"; - this.argspanel.Size = new System.Drawing.Size(521, 83); - this.argspanel.TabIndex = 2; - this.argspanel.Visible = false; - // - // scriptNumbers - // - this.scriptNumbers.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.scriptNumbers.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.scriptNumbers.BackColor = System.Drawing.Color.LemonChiffon; - this.scriptNumbers.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.scriptNumbers.FormattingEnabled = true; - this.scriptNumbers.Location = new System.Drawing.Point(398, 57); - this.scriptNumbers.Name = "scriptNumbers"; - this.scriptNumbers.Size = new System.Drawing.Size(120, 21); - this.scriptNumbers.TabIndex = 39; - // - // arg2 - // - this.arg2.Location = new System.Drawing.Point(153, 55); - this.arg2.Name = "arg2"; - this.arg2.Size = new System.Drawing.Size(120, 24); - this.arg2.TabIndex = 2; - // - // arg1 - // - this.arg1.Location = new System.Drawing.Point(153, 29); - this.arg1.Name = "arg1"; - this.arg1.Size = new System.Drawing.Size(120, 24); - this.arg1.TabIndex = 1; - // - // arg0 - // - this.arg0.Location = new System.Drawing.Point(153, 3); - this.arg0.Name = "arg0"; - this.arg0.Size = new System.Drawing.Size(120, 24); - this.arg0.TabIndex = 0; - // - // arg3 - // - this.arg3.Location = new System.Drawing.Point(398, 3); - this.arg3.Name = "arg3"; - this.arg3.Size = new System.Drawing.Size(120, 24); - this.arg3.TabIndex = 3; - // - // arg4 - // - this.arg4.Location = new System.Drawing.Point(398, 29); - this.arg4.Name = "arg4"; - this.arg4.Size = new System.Drawing.Size(120, 24); - this.arg4.TabIndex = 4; - // - // arg1label - // - this.arg1label.Location = new System.Drawing.Point(-32, 34); - this.arg1label.Name = "arg1label"; - this.arg1label.Size = new System.Drawing.Size(179, 14); - this.arg1label.TabIndex = 33; - this.arg1label.Text = "Argument 2:"; - this.arg1label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg1label.UseMnemonic = false; - // - // arg3label - // - this.arg3label.Location = new System.Drawing.Point(213, 8); - this.arg3label.Name = "arg3label"; - this.arg3label.Size = new System.Drawing.Size(179, 14); - this.arg3label.TabIndex = 36; - this.arg3label.Text = "Argument 4:"; - this.arg3label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg3label.UseMnemonic = false; - // - // arg2label - // - this.arg2label.Location = new System.Drawing.Point(-32, 60); - this.arg2label.Name = "arg2label"; - this.arg2label.Size = new System.Drawing.Size(179, 14); - this.arg2label.TabIndex = 35; - this.arg2label.Text = "Argument 3:"; - this.arg2label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg2label.UseMnemonic = false; - // - // arg4label - // - this.arg4label.Location = new System.Drawing.Point(213, 34); - this.arg4label.Name = "arg4label"; - this.arg4label.Size = new System.Drawing.Size(179, 14); - this.arg4label.TabIndex = 34; - this.arg4label.Text = "Argument 5:"; - this.arg4label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg4label.UseMnemonic = false; - // - // arg0label - // - this.arg0label.Location = new System.Drawing.Point(-32, 8); - this.arg0label.Name = "arg0label"; - this.arg0label.Size = new System.Drawing.Size(179, 14); - this.arg0label.TabIndex = 32; - this.arg0label.Text = "Argument 1:"; - this.arg0label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg0label.UseMnemonic = false; - // // hexenpanel // this.hexenpanel.Controls.Add(this.activation); this.hexenpanel.Controls.Add(activationlabel); this.hexenpanel.Location = new System.Drawing.Point(6, 134); this.hexenpanel.Name = "hexenpanel"; - this.hexenpanel.Size = new System.Drawing.Size(521, 36); + this.hexenpanel.Size = new System.Drawing.Size(529, 36); this.hexenpanel.TabIndex = 3; this.hexenpanel.Visible = false; // @@ -388,7 +268,7 @@ namespace CodeImp.DoomBuilder.Windows this.activation.FormattingEnabled = true; this.activation.Location = new System.Drawing.Point(56, 7); this.activation.Name = "activation"; - this.activation.Size = new System.Drawing.Size(463, 21); + this.activation.Size = new System.Drawing.Size(470, 21); this.activation.TabIndex = 0; // // action @@ -400,7 +280,7 @@ namespace CodeImp.DoomBuilder.Windows this.action.GeneralizedOptions = null; this.action.Location = new System.Drawing.Point(62, 23); this.action.Name = "action"; - this.action.Size = new System.Drawing.Size(402, 21); + this.action.Size = new System.Drawing.Size(412, 21); this.action.TabIndex = 0; this.action.Value = 402; this.action.ValueChanges += new System.EventHandler(this.action_ValueChanges); @@ -408,7 +288,7 @@ namespace CodeImp.DoomBuilder.Windows // browseaction // this.browseaction.Image = global::CodeImp.DoomBuilder.Properties.Resources.List; - this.browseaction.Location = new System.Drawing.Point(467, 21); + this.browseaction.Location = new System.Drawing.Point(476, 21); this.browseaction.Name = "browseaction"; this.browseaction.Size = new System.Drawing.Size(28, 25); this.browseaction.TabIndex = 1; @@ -436,9 +316,9 @@ namespace CodeImp.DoomBuilder.Windows | System.Windows.Forms.AnchorStyles.Right))); this.flags.AutoScroll = true; this.flags.Columns = 3; - this.flags.Location = new System.Drawing.Point(18, 17); + this.flags.Location = new System.Drawing.Point(8, 17); this.flags.Name = "flags"; - this.flags.Size = new System.Drawing.Size(517, 96); + this.flags.Size = new System.Drawing.Size(532, 96); this.flags.TabIndex = 0; this.flags.VerticalSpacing = 1; this.flags.OnValueChanged += new System.EventHandler(this.flags_OnValueChanged); @@ -700,7 +580,6 @@ namespace CodeImp.DoomBuilder.Windows this.HelpRequested += new System.Windows.Forms.HelpEventHandler(this.LinedefEditForm_HelpRequested); this.actiongroup.ResumeLayout(false); this.actiongroup.PerformLayout(); - this.argspanel.ResumeLayout(false); this.hexenpanel.ResumeLayout(false); this.hexenpanel.PerformLayout(); this.flagsgroup.ResumeLayout(false); @@ -735,27 +614,16 @@ namespace CodeImp.DoomBuilder.Windows private System.Windows.Forms.ComboBox activation; private System.Windows.Forms.Panel hexenpanel; private System.Windows.Forms.GroupBox idgroup; - private System.Windows.Forms.Panel argspanel; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg2; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg1; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg0; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg3; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg4; - private System.Windows.Forms.Label arg1label; - private System.Windows.Forms.Label arg0label; - private System.Windows.Forms.Label arg3label; - private System.Windows.Forms.Label arg2label; - private System.Windows.Forms.Label arg4label; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox frontsector; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox backsector; private CodeImp.DoomBuilder.GZBuilder.Controls.TagSelector tagSelector; private CodeImp.DoomBuilder.GZBuilder.Controls.PairedIntControl frontTextureOffset; private CodeImp.DoomBuilder.GZBuilder.Controls.PairedIntControl backTextureOffset; - private CodeImp.DoomBuilder.Controls.ColoredComboBox scriptNumbers; private System.Windows.Forms.Panel panel; private CodeImp.DoomBuilder.Controls.ActionSpecialHelpButton actionhelp; private System.Windows.Forms.ToolTip tooltip; private System.Windows.Forms.Label labelFrontTextureOffset; private System.Windows.Forms.Label labelBackTextureOffset; + private CodeImp.DoomBuilder.Controls.ArgumentsControl argscontrol; } } \ No newline at end of file diff --git a/Source/Core/Windows/LinedefEditForm.cs b/Source/Core/Windows/LinedefEditForm.cs index b814ef77733cb353fc39e45a5a6c1f9ea31726df..27436f1a36416627cb9adc99f4b4ae14c4859594 100644 --- a/Source/Core/Windows/LinedefEditForm.cs +++ b/Source/Core/Windows/LinedefEditForm.cs @@ -20,11 +20,8 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; -using CodeImp.DoomBuilder.Controls; -using CodeImp.DoomBuilder.Geometry; -using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Config; -using CodeImp.DoomBuilder.GZBuilder.Data; //mxd +using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Types; #endregion @@ -37,11 +34,6 @@ namespace CodeImp.DoomBuilder.Windows public event EventHandler OnValuesChanged; //mxd - #endregion - - #region ================== Constants - - #endregion #region ================== Variables @@ -124,29 +116,20 @@ namespace CodeImp.DoomBuilder.Windows backhigh.Initialize(); backmid.Initialize(); backlow.Initialize(); - - //mxd. Setup script numbers - scriptNumbers.Location = new Point(arg0.Location.X, arg0.Location.Y + 2); - - foreach(ScriptItem si in General.Map.NumberedScripts) - scriptNumbers.Items.Add(new ColoredComboBoxItem(si, si.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); - - scriptNumbers.DropDownWidth = Tools.GetDropDownWidth(scriptNumbers); // Mixed activations? if(General.Map.FormatInterface.HasPresetActivations) hexenpanel.Visible = true; // Action arguments? - if(General.Map.FormatInterface.HasActionArgs) - argspanel.Visible = true; + if(General.Map.FormatInterface.HasActionArgs) argscontrol.Visible = true; // Arrange panels if(!General.Map.FormatInterface.HasMixedActivations && !General.Map.FormatInterface.HasActionArgs && !General.Map.FormatInterface.HasPresetActivations) { - actiongroup.Height = argspanel.Top + argspanel.Margin.Top; //mxd + actiongroup.Height = argscontrol.Top + argscontrol.Margin.Top; //mxd } // Arrange or hide Identification panel @@ -208,11 +191,8 @@ namespace CodeImp.DoomBuilder.Windows tagSelector.SetTag(fl.Tag); } - arg0.SetValue(fl.Args[0]); - arg1.SetValue(fl.Args[1]); - arg2.SetValue(fl.Args[2]); - arg3.SetValue(fl.Args[3]); - arg4.SetValue(fl.Args[4]); + //mxd. Args + argscontrol.SetValue(fl, true); // Front side and back side checkboxes frontside.Checked = (fl.Front != null); @@ -274,11 +254,9 @@ namespace CodeImp.DoomBuilder.Windows // Action/tags if(l.Action != action.Value) action.Empty = true; if(General.Map.FormatInterface.HasLinedefTag && l.Tag != fl.Tag) tagSelector.ClearTag(); //mxd - if(l.Args[0] != arg0.GetResult(-1)) arg0.ClearValue(); - if(l.Args[1] != arg1.GetResult(-1)) arg1.ClearValue(); - if(l.Args[2] != arg2.GetResult(-1)) arg2.ClearValue(); - if(l.Args[3] != arg3.GetResult(-1)) arg3.ClearValue(); - if(l.Args[4] != arg4.GetResult(-1)) arg4.ClearValue(); + + //mxd. Arguments + argscontrol.SetValue(l, false); // Front side checkbox if((l.Front != null) != frontside.Checked) @@ -364,7 +342,7 @@ namespace CodeImp.DoomBuilder.Windows preventchanges = false; - UpdateScriptControls(); //mxd + argscontrol.UpdateScriptControls(); //mxd actionhelp.UpdateAction(action.GetValue()); //mxd //mxd. Update some labels @@ -376,32 +354,6 @@ namespace CodeImp.DoomBuilder.Windows { labelBackTextureOffset.Enabled = backTextureOffset.NonDefaultValue; } - - //mxd. Set intial script-related values, if required - if(Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1) - { - int a0 = arg0.GetResult(0); - if(a0 > 0) - { - for(int i = 0; i < General.Map.NumberedScripts.Count; i++) - { - if(General.Map.NumberedScripts[i].Index == a0) - { - scriptNumbers.SelectedIndex = i; - break; - } - } - } - - if(scriptNumbers.SelectedIndex == -1) - { - scriptNumbers.Text = a0.ToString(); - } - } - else - { - scriptNumbers.Text = "0"; - } } //mxd @@ -414,36 +366,6 @@ namespace CodeImp.DoomBuilder.Windows General.Map.UndoRedo.CreateUndo("Edit " + (lines.Count > 1 ? lines.Count + " linedefs" : "linedef")); } - //mxd - private void UpdateScriptControls() - { - scriptNumbers.Visible = (Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1); - arg0.Visible = !scriptNumbers.Visible; - } - - //mxd - private void UpdateArgument(ArgumentBox arg, Label label, ArgumentInfo info) - { - label.Text = info.Title + ":"; - label.Enabled = info.Used; - arg.ForeColor = (label.Enabled ? SystemColors.WindowText : SystemColors.GrayText); - arg.Setup(info); - - // Update tooltip - if(info.Used && !string.IsNullOrEmpty(info.ToolTip)) - { - tooltip.SetToolTip(label, info.ToolTip); - label.Font = new Font(label.Font, FontStyle.Underline); - label.ForeColor = SystemColors.HotTrack; - } - else - { - tooltip.SetToolTip(label, null); - label.Font = new Font(label.Font, FontStyle.Regular); - label.ForeColor = SystemColors.WindowText; - } - } - #endregion #region ================== Events @@ -473,9 +395,6 @@ namespace CodeImp.DoomBuilder.Windows } MakeUndo(); //mxd - - //mxd - bool hasAcs = !action.Empty && Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1; // Go for all the lines int tagoffset = 0; //mxd @@ -487,35 +406,10 @@ namespace CodeImp.DoomBuilder.Windows // Action/tags l.Tag = General.Clamp(tagSelector.GetSmartTag(l.Tag, tagoffset++), General.Map.FormatInterface.MinTag, General.Map.FormatInterface.MaxTag); //mxd - if(!action.Empty) - { - l.Action = action.Value; - - //mxd. Script name/number handling - if(hasAcs) - { - if(!string.IsNullOrEmpty(scriptNumbers.Text)) - { - if(scriptNumbers.SelectedItem != null) - l.Args[0] = ((ScriptItem)((ColoredComboBoxItem)scriptNumbers.SelectedItem).Value).Index; - else if(!int.TryParse(scriptNumbers.Text.Trim(), out l.Args[0])) - l.Args[0] = 0; - } - } - else - { - l.Args[0] = arg0.GetResult(l.Args[0]); - } - } - else - { - l.Args[0] = arg0.GetResult(l.Args[0]); - } + if(!action.Empty) l.Action = action.Value; - l.Args[1] = arg1.GetResult(l.Args[1]); - l.Args[2] = arg2.GetResult(l.Args[2]); - l.Args[3] = arg3.GetResult(l.Args[3]); - l.Args[4] = arg4.GetResult(l.Args[4]); + //mxd. Apply args + argscontrol.Apply(l); // Remove front side? if((l.Front != null) && (frontside.CheckState == CheckState.Unchecked)) @@ -616,37 +510,15 @@ namespace CodeImp.DoomBuilder.Windows // Only when line type is known if(General.Map.Config.LinedefActions.ContainsKey(action.Value)) showaction = action.Value; - // Change the argument descriptions - UpdateArgument(arg0, arg0label, General.Map.Config.LinedefActions[showaction].Args[0]); //mxd - UpdateArgument(arg1, arg1label, General.Map.Config.LinedefActions[showaction].Args[1]); //mxd - UpdateArgument(arg2, arg2label, General.Map.Config.LinedefActions[showaction].Args[2]); //mxd - UpdateArgument(arg3, arg3label, General.Map.Config.LinedefActions[showaction].Args[3]); //mxd - UpdateArgument(arg4, arg4label, General.Map.Config.LinedefActions[showaction].Args[4]); //mxd + //mxd. Change the argument descriptions + argscontrol.UpdateAction(showaction, preventchanges); if(!preventchanges) { MakeUndo(); //mxd - - // mxd. Apply action's default arguments - if(showaction != 0) - { - arg0.SetDefaultValue(); - arg1.SetDefaultValue(); - arg2.SetDefaultValue(); - arg3.SetDefaultValue(); - arg4.SetDefaultValue(); - } - else //or set them to 0 - { - arg0.SetValue(0); - arg1.SetValue(0); - arg2.SetValue(0); - arg3.SetValue(0); - arg4.SetValue(0); - } //mxd. Update what must be updated - UpdateScriptControls(); + argscontrol.UpdateScriptControls(); actionhelp.UpdateAction(showaction); } } diff --git a/Source/Core/Windows/LinedefEditFormUDMF.Designer.cs b/Source/Core/Windows/LinedefEditFormUDMF.Designer.cs index 563474baf053bda9dd5ea93bb1b6612c8e39c7c0..62157fe1e4b193569d0cad94da830d9b312d5c41 100644 --- a/Source/Core/Windows/LinedefEditFormUDMF.Designer.cs +++ b/Source/Core/Windows/LinedefEditFormUDMF.Designer.cs @@ -41,20 +41,6 @@ namespace CodeImp.DoomBuilder.Windows this.apply = new System.Windows.Forms.Button(); this.actiongroup = new System.Windows.Forms.GroupBox(); this.actionhelp = new CodeImp.DoomBuilder.Controls.ActionSpecialHelpButton(); - this.argspanel = new System.Windows.Forms.Panel(); - this.scriptNumbers = new CodeImp.DoomBuilder.Controls.ColoredComboBox(); - this.scriptNames = new CodeImp.DoomBuilder.Controls.ColoredComboBox(); - this.arg2 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg1 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg0 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg3 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg4 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg1label = new System.Windows.Forms.Label(); - this.arg3label = new System.Windows.Forms.Label(); - this.arg2label = new System.Windows.Forms.Label(); - this.arg4label = new System.Windows.Forms.Label(); - this.cbArgStr = new System.Windows.Forms.CheckBox(); - this.arg0label = new System.Windows.Forms.Label(); this.action = new CodeImp.DoomBuilder.Controls.ActionSelectorControl(); this.browseaction = new System.Windows.Forms.Button(); this.udmfactivates = new CodeImp.DoomBuilder.Controls.CheckboxArrayControl(); @@ -129,18 +115,18 @@ namespace CodeImp.DoomBuilder.Windows this.backlow = new CodeImp.DoomBuilder.Controls.TextureSelectorControl(); this.backmid = new CodeImp.DoomBuilder.Controls.TextureSelectorControl(); this.backhigh = new CodeImp.DoomBuilder.Controls.TextureSelectorControl(); + this.tabcomment = new System.Windows.Forms.TabPage(); + this.commenteditor = new CodeImp.DoomBuilder.Controls.CommentEditor(); this.tabcustom = new System.Windows.Forms.TabPage(); this.fieldslist = new CodeImp.DoomBuilder.Controls.FieldsEditorControl(); this.imagelist = new System.Windows.Forms.ImageList(this.components); this.tooltip = new System.Windows.Forms.ToolTip(this.components); - this.tabcomment = new System.Windows.Forms.TabPage(); - this.commenteditor = new CodeImp.DoomBuilder.Controls.CommentEditor(); + this.argscontrol = new CodeImp.DoomBuilder.Controls.ArgumentsControl(); label2 = new System.Windows.Forms.Label(); label11 = new System.Windows.Forms.Label(); label12 = new System.Windows.Forms.Label(); label6 = new System.Windows.Forms.Label(); this.actiongroup.SuspendLayout(); - this.argspanel.SuspendLayout(); this.flagsgroup.SuspendLayout(); this.tabs.SuspendLayout(); this.tabproperties.SuspendLayout(); @@ -160,8 +146,8 @@ namespace CodeImp.DoomBuilder.Windows this.backflagsgroup.SuspendLayout(); this.backscalegroup.SuspendLayout(); this.groupBox1.SuspendLayout(); - this.tabcustom.SuspendLayout(); this.tabcomment.SuspendLayout(); + this.tabcustom.SuspendLayout(); this.SuspendLayout(); // // label2 @@ -255,8 +241,8 @@ namespace CodeImp.DoomBuilder.Windows // this.actiongroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.actiongroup.Controls.Add(this.argscontrol); this.actiongroup.Controls.Add(this.actionhelp); - this.actiongroup.Controls.Add(this.argspanel); this.actiongroup.Controls.Add(label2); this.actiongroup.Controls.Add(this.action); this.actiongroup.Controls.Add(this.browseaction); @@ -274,145 +260,6 @@ namespace CodeImp.DoomBuilder.Windows this.actionhelp.Size = new System.Drawing.Size(28, 25); this.actionhelp.TabIndex = 10; // - // argspanel - // - this.argspanel.Controls.Add(this.scriptNumbers); - this.argspanel.Controls.Add(this.scriptNames); - this.argspanel.Controls.Add(this.arg2); - this.argspanel.Controls.Add(this.arg1); - this.argspanel.Controls.Add(this.arg0); - this.argspanel.Controls.Add(this.arg3); - this.argspanel.Controls.Add(this.arg4); - this.argspanel.Controls.Add(this.arg1label); - this.argspanel.Controls.Add(this.arg3label); - this.argspanel.Controls.Add(this.arg2label); - this.argspanel.Controls.Add(this.arg4label); - this.argspanel.Controls.Add(this.cbArgStr); - this.argspanel.Controls.Add(this.arg0label); - this.argspanel.Location = new System.Drawing.Point(6, 54); - this.argspanel.Name = "argspanel"; - this.argspanel.Size = new System.Drawing.Size(521, 83); - this.argspanel.TabIndex = 2; - // - // scriptNumbers - // - this.scriptNumbers.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.scriptNumbers.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.scriptNumbers.BackColor = System.Drawing.Color.LemonChiffon; - this.scriptNumbers.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.scriptNumbers.FormattingEnabled = true; - this.scriptNumbers.Location = new System.Drawing.Point(407, 57); - this.scriptNumbers.Name = "scriptNumbers"; - this.scriptNumbers.Size = new System.Drawing.Size(120, 21); - this.scriptNumbers.TabIndex = 39; - // - // scriptNames - // - this.scriptNames.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.scriptNames.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.scriptNames.BackColor = System.Drawing.Color.Honeydew; - this.scriptNames.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.scriptNames.FormattingEnabled = true; - this.scriptNames.Location = new System.Drawing.Point(283, 57); - this.scriptNames.Name = "scriptNames"; - this.scriptNames.Size = new System.Drawing.Size(120, 21); - this.scriptNames.TabIndex = 38; - // - // arg2 - // - this.arg2.Location = new System.Drawing.Point(153, 57); - this.arg2.Name = "arg2"; - this.arg2.Size = new System.Drawing.Size(120, 24); - this.arg2.TabIndex = 2; - // - // arg1 - // - this.arg1.Location = new System.Drawing.Point(153, 30); - this.arg1.Name = "arg1"; - this.arg1.Size = new System.Drawing.Size(120, 24); - this.arg1.TabIndex = 1; - // - // arg0 - // - this.arg0.Location = new System.Drawing.Point(153, 3); - this.arg0.Name = "arg0"; - this.arg0.Size = new System.Drawing.Size(120, 24); - this.arg0.TabIndex = 0; - // - // arg3 - // - this.arg3.Location = new System.Drawing.Point(398, 3); - this.arg3.Name = "arg3"; - this.arg3.Size = new System.Drawing.Size(120, 24); - this.arg3.TabIndex = 3; - // - // arg4 - // - this.arg4.Location = new System.Drawing.Point(398, 30); - this.arg4.Name = "arg4"; - this.arg4.Size = new System.Drawing.Size(120, 24); - this.arg4.TabIndex = 4; - // - // arg1label - // - this.arg1label.Location = new System.Drawing.Point(-32, 35); - this.arg1label.Name = "arg1label"; - this.arg1label.Size = new System.Drawing.Size(179, 14); - this.arg1label.TabIndex = 33; - this.arg1label.Text = "Argument 2:"; - this.arg1label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg1label.UseMnemonic = false; - // - // arg3label - // - this.arg3label.Location = new System.Drawing.Point(213, 8); - this.arg3label.Name = "arg3label"; - this.arg3label.Size = new System.Drawing.Size(179, 14); - this.arg3label.TabIndex = 36; - this.arg3label.Text = "Argument 4:"; - this.arg3label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg3label.UseMnemonic = false; - // - // arg2label - // - this.arg2label.Location = new System.Drawing.Point(-32, 62); - this.arg2label.Name = "arg2label"; - this.arg2label.Size = new System.Drawing.Size(179, 14); - this.arg2label.TabIndex = 35; - this.arg2label.Text = "Argument 3:"; - this.arg2label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg2label.UseMnemonic = false; - // - // arg4label - // - this.arg4label.Location = new System.Drawing.Point(213, 35); - this.arg4label.Name = "arg4label"; - this.arg4label.Size = new System.Drawing.Size(179, 14); - this.arg4label.TabIndex = 34; - this.arg4label.Text = "Argument 5:"; - this.arg4label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg4label.UseMnemonic = false; - // - // cbArgStr - // - this.cbArgStr.Location = new System.Drawing.Point(8, -4); - this.cbArgStr.Name = "cbArgStr"; - this.cbArgStr.Size = new System.Drawing.Size(63, 40); - this.cbArgStr.TabIndex = 37; - this.cbArgStr.Text = "Named script"; - this.cbArgStr.UseVisualStyleBackColor = true; - this.cbArgStr.CheckedChanged += new System.EventHandler(this.cbArgStr_CheckedChanged); - // - // arg0label - // - this.arg0label.Location = new System.Drawing.Point(-32, 8); - this.arg0label.Name = "arg0label"; - this.arg0label.Size = new System.Drawing.Size(179, 14); - this.arg0label.TabIndex = 32; - this.arg0label.Text = "Argument 1:"; - this.arg0label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg0label.UseMnemonic = false; - // // action // this.action.BackColor = System.Drawing.Color.Transparent; @@ -1432,6 +1279,27 @@ namespace CodeImp.DoomBuilder.Windows this.backhigh.UsePreviews = false; this.backhigh.OnValueChanged += new System.EventHandler(this.backhigh_OnValueChanged); // + // tabcomment + // + this.tabcomment.Controls.Add(this.commenteditor); + this.tabcomment.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.tabcomment.Location = new System.Drawing.Point(4, 23); + this.tabcomment.Name = "tabcomment"; + this.tabcomment.Size = new System.Drawing.Size(549, 621); + this.tabcomment.TabIndex = 4; + this.tabcomment.Text = "Comment"; + this.tabcomment.UseVisualStyleBackColor = true; + // + // commenteditor + // + this.commenteditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.commenteditor.Location = new System.Drawing.Point(3, 3); + this.commenteditor.Name = "commenteditor"; + this.commenteditor.Size = new System.Drawing.Size(543, 615); + this.commenteditor.TabIndex = 0; + // // tabcustom // this.tabcustom.Controls.Add(this.fieldslist); @@ -1471,26 +1339,12 @@ namespace CodeImp.DoomBuilder.Windows this.imagelist.Images.SetKeyName(0, "Check.png"); this.imagelist.Images.SetKeyName(1, "SearchClear.png"); // - // tabcomment - // - this.tabcomment.Controls.Add(this.commenteditor); - this.tabcomment.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.tabcomment.Location = new System.Drawing.Point(4, 23); - this.tabcomment.Name = "tabcomment"; - this.tabcomment.Size = new System.Drawing.Size(549, 621); - this.tabcomment.TabIndex = 4; - this.tabcomment.Text = "Comment"; - this.tabcomment.UseVisualStyleBackColor = true; - // - // commenteditor + // argscontrol // - this.commenteditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.commenteditor.Location = new System.Drawing.Point(3, 3); - this.commenteditor.Name = "commenteditor"; - this.commenteditor.Size = new System.Drawing.Size(543, 615); - this.commenteditor.TabIndex = 0; + this.argscontrol.Location = new System.Drawing.Point(6, 56); + this.argscontrol.Name = "argscontrol"; + this.argscontrol.Size = new System.Drawing.Size(521, 80); + this.argscontrol.TabIndex = 11; // // LinedefEditFormUDMF // @@ -1515,7 +1369,6 @@ namespace CodeImp.DoomBuilder.Windows this.HelpRequested += new System.Windows.Forms.HelpEventHandler(this.LinedefEditForm_HelpRequested); this.actiongroup.ResumeLayout(false); this.actiongroup.PerformLayout(); - this.argspanel.ResumeLayout(false); this.flagsgroup.ResumeLayout(false); this.tabs.ResumeLayout(false); this.tabproperties.ResumeLayout(false); @@ -1540,8 +1393,8 @@ namespace CodeImp.DoomBuilder.Windows this.backflagsgroup.ResumeLayout(false); this.backscalegroup.ResumeLayout(false); this.groupBox1.ResumeLayout(false); - this.tabcustom.ResumeLayout(false); this.tabcomment.ResumeLayout(false); + this.tabcustom.ResumeLayout(false); this.ResumeLayout(false); } @@ -1572,23 +1425,10 @@ namespace CodeImp.DoomBuilder.Windows private CodeImp.DoomBuilder.Controls.FieldsEditorControl fieldslist; private System.Windows.Forms.GroupBox idgroup; private CodeImp.DoomBuilder.Controls.CheckboxArrayControl udmfactivates; - private System.Windows.Forms.Panel argspanel; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg2; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg1; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg0; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg3; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg4; - private System.Windows.Forms.Label arg1label; - private System.Windows.Forms.Label arg0label; - private System.Windows.Forms.Label arg3label; - private System.Windows.Forms.Label arg2label; - private System.Windows.Forms.Label arg4label; private System.Windows.Forms.Button customfrontbutton; private System.Windows.Forms.Button custombackbutton; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox frontsector; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox backsector; - private System.Windows.Forms.CheckBox cbArgStr; - private CodeImp.DoomBuilder.Controls.ColoredComboBox scriptNames; private CodeImp.DoomBuilder.GZBuilder.Controls.TagSelector tagSelector; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox lightFront; private System.Windows.Forms.CheckBox cbLightAbsoluteFront; @@ -1615,7 +1455,6 @@ namespace CodeImp.DoomBuilder.Windows private CodeImp.DoomBuilder.GZBuilder.Controls.PairedIntControl backTextureOffset; private CodeImp.DoomBuilder.Controls.CheckboxArrayControl flagsFront; private CodeImp.DoomBuilder.Controls.CheckboxArrayControl flagsBack; - private CodeImp.DoomBuilder.Controls.ColoredComboBox scriptNumbers; private System.Windows.Forms.GroupBox activationGroup; private System.Windows.Forms.PictureBox missingactivation; private System.Windows.Forms.ToolTip tooltip; @@ -1649,5 +1488,6 @@ namespace CodeImp.DoomBuilder.Windows private System.Windows.Forms.Label labelBackOffsetTop; private System.Windows.Forms.TabPage tabcomment; private CodeImp.DoomBuilder.Controls.CommentEditor commenteditor; + private CodeImp.DoomBuilder.Controls.ArgumentsControl argscontrol; } } \ No newline at end of file diff --git a/Source/Core/Windows/LinedefEditFormUDMF.cs b/Source/Core/Windows/LinedefEditFormUDMF.cs index 5627f6f9e7faea0d63349ba5980cf16204b8ab32..bc81221ed56148dd22d6876994651f1117f93003 100644 --- a/Source/Core/Windows/LinedefEditFormUDMF.cs +++ b/Source/Core/Windows/LinedefEditFormUDMF.cs @@ -20,14 +20,11 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; -using CodeImp.DoomBuilder.Geometry; -using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Config; -using CodeImp.DoomBuilder.GZBuilder.Data; //mxd -using CodeImp.DoomBuilder.Types; -using CodeImp.DoomBuilder.GZBuilder.Tools; using CodeImp.DoomBuilder.GZBuilder.Controls; -using CodeImp.DoomBuilder.Controls; +using CodeImp.DoomBuilder.GZBuilder.Tools; +using CodeImp.DoomBuilder.Map; +using CodeImp.DoomBuilder.Types; #endregion @@ -39,11 +36,6 @@ namespace CodeImp.DoomBuilder.Windows public event EventHandler OnValuesChanged; //mxd - #endregion - - #region ================== Constants - - #endregion #region ================== Variables @@ -52,8 +44,6 @@ namespace CodeImp.DoomBuilder.Windows private List<LinedefProperties> linedefprops; //mxd private bool preventchanges; private bool undocreated; //mxd - private string arg0str; //mxd - private bool haveArg0Str; //mxd private readonly string[] renderstyles; //mxd private readonly List<int> keynumbers; //mxd @@ -216,18 +206,6 @@ namespace CodeImp.DoomBuilder.Windows backmid.Initialize(); backlow.Initialize(); - //mxd. Setup script numbers - scriptNumbers.Location = new Point(arg0.Location.X, arg0.Location.Y + 2); - foreach (ScriptItem si in General.Map.NumberedScripts) - scriptNumbers.Items.Add(new ColoredComboBoxItem(si, si.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); - scriptNumbers.DropDownWidth = Tools.GetDropDownWidth(scriptNumbers); - - //mxd. Setup script names - scriptNames.Location = scriptNumbers.Location; - foreach (ScriptItem nsi in General.Map.NamedScripts) - scriptNames.Items.Add(new ColoredComboBoxItem(nsi, nsi.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); - scriptNames.DropDownWidth = Tools.GetDropDownWidth(scriptNames); - // Initialize custom fields editor fieldslist.Setup("linedef"); @@ -293,8 +271,6 @@ namespace CodeImp.DoomBuilder.Windows commenteditor.SetValues(fl.Fields, true); //mxd. Comments renderStyle.SelectedIndex = Array.IndexOf(renderstyles, fl.Fields.GetValue("renderstyle", "translucent")); alpha.Text = General.Clamp(fl.Fields.GetValue("alpha", 1.0f), 0f, 1f).ToString(); - arg0str = fl.Fields.GetValue("arg0str", string.Empty); - haveArg0Str = !string.IsNullOrEmpty(arg0str); // Locknumber int locknumber = fl.Fields.GetValue("locknumber", 0); @@ -310,11 +286,8 @@ namespace CodeImp.DoomBuilder.Windows tagSelector.SetTag(fl.Tag); } - arg0.SetValue(fl.Args[0]); - arg1.SetValue(fl.Args[1]); - arg2.SetValue(fl.Args[2]); - arg3.SetValue(fl.Args[3]); - arg4.SetValue(fl.Args[4]); + //mxd. Args + argscontrol.SetValue(fl, true); // Front side and back side checkboxes frontside.Checked = (fl.Front != null); @@ -429,13 +402,6 @@ namespace CodeImp.DoomBuilder.Windows } } - // arg0str - if(arg0str != l.Fields.GetValue("arg0str", string.Empty)) - { - haveArg0Str = true; - arg0str = string.Empty; - } - // Custom fields fieldslist.SetValues(l.Fields, false); @@ -445,11 +411,9 @@ namespace CodeImp.DoomBuilder.Windows // Action/tags if(l.Action != action.Value) action.Empty = true; if(General.Map.FormatInterface.HasLinedefTag && l.Tag != fl.Tag) tagSelector.ClearTag(); //mxd - if(l.Args[0] != arg0.GetResult(-1)) arg0.ClearValue(); - if(l.Args[1] != arg1.GetResult(-1)) arg1.ClearValue(); - if(l.Args[2] != arg2.GetResult(-1)) arg2.ClearValue(); - if(l.Args[3] != arg3.GetResult(-1)) arg3.ClearValue(); - if(l.Args[4] != arg4.GetResult(-1)) arg4.ClearValue(); + + //mxd. Arguments + argscontrol.SetValue(l, false); // Front side checkbox if((l.Front != null) != frontside.Checked) @@ -590,8 +554,8 @@ namespace CodeImp.DoomBuilder.Windows preventchanges = false; - UpdateScriptControls(); //mxd CheckActivationFlagsRequired(); //mxd + argscontrol.UpdateScriptControls(); //mxd actionhelp.UpdateAction(action.GetValue()); //mxd commenteditor.FinishSetup(); //mxd @@ -622,40 +586,6 @@ namespace CodeImp.DoomBuilder.Windows labelBackScaleMid.Enabled = pfcBackScaleMid.NonDefaultValue; labelBackScaleBottom.Enabled = pfcBackScaleBottom.NonDefaultValue; } - - //mxd. Set intial script-related values, if required - if(Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1) - { - if(haveArg0Str) - { - scriptNames.Text = arg0str; - arg0label.Text = "Script Name:"; - } - else - { - int a0 = arg0.GetResult(0); - if(a0 > 0) - { - for(int i = 0; i < General.Map.NumberedScripts.Count; i++) - { - if(General.Map.NumberedScripts[i].Index == a0) - { - scriptNumbers.SelectedIndex = i; - break; - } - } - } - - if(scriptNumbers.SelectedIndex == -1) - { - scriptNumbers.Text = a0.ToString(); - } - } - } - else - { - scriptNumbers.Text = "0"; - } } //mxd @@ -678,51 +608,6 @@ namespace CodeImp.DoomBuilder.Windows } } - //mxd - private void UpdateScriptControls() - { - if(Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1) - { - bool showNamedScripts = General.Map.UDMF && haveArg0Str; - cbArgStr.Visible = General.Map.UDMF; - cbArgStr.Checked = showNamedScripts; - scriptNames.Visible = showNamedScripts; - scriptNumbers.Visible = !showNamedScripts; - } - else - { - cbArgStr.Visible = false; - scriptNames.Visible = false; - scriptNumbers.Visible = false; - cbArgStr.Checked = false; - } - - arg0.Visible = (!scriptNames.Visible && !scriptNumbers.Visible); - } - - //mxd - private void UpdateArgument(ArgumentBox arg, Label label, ArgumentInfo info) - { - label.Text = info.Title + ":"; - label.Enabled = info.Used; - arg.ForeColor = (label.Enabled ? SystemColors.WindowText : SystemColors.GrayText); - arg.Setup(info); - - // Update tooltip - if(info.Used && !string.IsNullOrEmpty(info.ToolTip)) - { - tooltip.SetToolTip(label, info.ToolTip); - label.Font = new Font(label.Font, FontStyle.Underline); - label.ForeColor = SystemColors.HotTrack; - } - else - { - tooltip.SetToolTip(label, null); - label.Font = new Font(label.Font, FontStyle.Regular); - label.ForeColor = SystemColors.WindowText; - } - } - //mxd private void CheckActivationFlagsRequired() { @@ -782,7 +667,6 @@ namespace CodeImp.DoomBuilder.Windows MakeUndo(); //mxd - bool hasAcs = !action.Empty && Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1; int locknumber = 0; bool setlocknumber = false; if(!string.IsNullOrEmpty(lockpick.Text)) @@ -815,47 +699,10 @@ namespace CodeImp.DoomBuilder.Windows // Action/tags l.Tag = General.Clamp(tagSelector.GetSmartTag(l.Tag, tagoffset++), General.Map.FormatInterface.MinTag, General.Map.FormatInterface.MaxTag); //mxd - if(!action.Empty) - { - l.Action = action.Value; - - //mxd. Script name/number handling - if(hasAcs) - { - //apply script number - if(!cbArgStr.Checked) - { - if(!string.IsNullOrEmpty(scriptNumbers.Text)) - { - if(scriptNumbers.SelectedItem != null) - l.Args[0] = ((ScriptItem)((ColoredComboBoxItem)scriptNumbers.SelectedItem).Value).Index; - else if(!int.TryParse(scriptNumbers.Text.Trim(), out l.Args[0])) - l.Args[0] = 0; - - if(l.Fields.ContainsKey("arg0str")) l.Fields.Remove("arg0str"); - } - } - else //apply arg0str - { - if(!string.IsNullOrEmpty(scriptNames.Text)) - l.Fields["arg0str"] = new UniValue(UniversalType.String, scriptNames.Text); - } - } - else - { - l.Args[0] = arg0.GetResult(l.Args[0]); - if(l.Fields.ContainsKey("arg0str")) l.Fields.Remove("arg0str"); - } - } - else - { - l.Args[0] = arg0.GetResult(l.Args[0]); - } + if(!action.Empty) l.Action = action.Value; - l.Args[1] = arg1.GetResult(l.Args[1]); - l.Args[2] = arg2.GetResult(l.Args[2]); - l.Args[3] = arg3.GetResult(l.Args[3]); - l.Args[4] = arg4.GetResult(l.Args[4]); + //mxd. Apply args + argscontrol.Apply(l); // Remove front side? if((l.Front != null) && (frontside.CheckState == CheckState.Unchecked)) @@ -971,39 +818,17 @@ namespace CodeImp.DoomBuilder.Windows // Only when line type is known if(General.Map.Config.LinedefActions.ContainsKey(action.Value)) showaction = action.Value; - - // Change the argument descriptions - UpdateArgument(arg0, arg0label, General.Map.Config.LinedefActions[showaction].Args[0]); //mxd - UpdateArgument(arg1, arg1label, General.Map.Config.LinedefActions[showaction].Args[1]); //mxd - UpdateArgument(arg2, arg2label, General.Map.Config.LinedefActions[showaction].Args[2]); //mxd - UpdateArgument(arg3, arg3label, General.Map.Config.LinedefActions[showaction].Args[3]); //mxd - UpdateArgument(arg4, arg4label, General.Map.Config.LinedefActions[showaction].Args[4]); //mxd + + //mxd. Change the argument descriptions + argscontrol.UpdateAction(showaction, preventchanges); if(!preventchanges) { MakeUndo(); //mxd - - // mxd. Apply action's default arguments - if(showaction != 0) - { - arg0.SetDefaultValue(); - arg1.SetDefaultValue(); - arg2.SetDefaultValue(); - arg3.SetDefaultValue(); - arg4.SetDefaultValue(); - } - else //or set them to 0 - { - arg0.SetValue(0); - arg1.SetValue(0); - arg2.SetValue(0); - arg3.SetValue(0); - arg4.SetValue(0); - } //mxd. Update what must be updated - UpdateScriptControls(); CheckActivationFlagsRequired(); + argscontrol.UpdateScriptControls(); actionhelp.UpdateAction(showaction); } } @@ -1014,15 +839,6 @@ namespace CodeImp.DoomBuilder.Windows action.Value = ActionBrowserForm.BrowseAction(this, action.Value); } - //mxd - private void cbArgStr_CheckedChanged(object sender, EventArgs e) - { - if(!cbArgStr.Visible) return; - scriptNames.Visible = cbArgStr.Checked; - scriptNumbers.Visible = !cbArgStr.Checked; - arg0label.Text = cbArgStr.Checked ? "Script Name:" : "Script Number:"; - } - //mxd private void tabcustom_MouseEnter(object sender, EventArgs e) { diff --git a/Source/Core/Windows/LinedefEditFormUDMF.resx b/Source/Core/Windows/LinedefEditFormUDMF.resx index 16536e5e4fcaa76e9b4a53c97681170dc067f900..5912cdba636ba0dff607da7bd3efdf1a45851a68 100644 --- a/Source/Core/Windows/LinedefEditFormUDMF.resx +++ b/Source/Core/Windows/LinedefEditFormUDMF.resx @@ -132,9 +132,6 @@ <metadata name="label6.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </metadata> - <metadata name="argspanel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> <metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> @@ -152,7 +149,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADM - CAAAAk1TRnQBSQFMAgEBAgEAAbABAAGwAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAAbgBAAG4AQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/Source/Core/Windows/ThingEditForm.Designer.cs b/Source/Core/Windows/ThingEditForm.Designer.cs index 2aa795b0eed78a2815f1fe1cb0b3af2a582946db..83f17cac8fe0ced8d9f46ee72dd6552fa5ad52d1 100644 --- a/Source/Core/Windows/ThingEditForm.Designer.cs +++ b/Source/Core/Windows/ThingEditForm.Designer.cs @@ -48,20 +48,10 @@ namespace CodeImp.DoomBuilder.Windows this.missingflags = new System.Windows.Forms.PictureBox(); this.flags = new CodeImp.DoomBuilder.Controls.CheckboxArrayControl(); this.actiongroup = new System.Windows.Forms.GroupBox(); - this.arg3 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.scriptNumbers = new CodeImp.DoomBuilder.Controls.ColoredComboBox(); - this.arg4 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); + this.argscontrol = new CodeImp.DoomBuilder.Controls.ArgumentsControl(); this.actionhelp = new CodeImp.DoomBuilder.Controls.ActionSpecialHelpButton(); - this.arg3label = new System.Windows.Forms.Label(); - this.arg4label = new System.Windows.Forms.Label(); - this.arg2 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg1 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); this.action = new CodeImp.DoomBuilder.Controls.ActionSelectorControl(); - this.arg0 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); this.browseaction = new System.Windows.Forms.Button(); - this.arg0label = new System.Windows.Forms.Label(); - this.arg1label = new System.Windows.Forms.Label(); - this.arg2label = new System.Windows.Forms.Label(); this.idgroup = new System.Windows.Forms.GroupBox(); this.tagSelector = new CodeImp.DoomBuilder.GZBuilder.Controls.TagSelector(); this.cancel = new System.Windows.Forms.Button(); @@ -314,21 +304,11 @@ namespace CodeImp.DoomBuilder.Windows // // actiongroup // - this.actiongroup.Controls.Add(this.arg3); - this.actiongroup.Controls.Add(this.scriptNumbers); - this.actiongroup.Controls.Add(this.arg4); + this.actiongroup.Controls.Add(this.argscontrol); this.actiongroup.Controls.Add(this.actionhelp); - this.actiongroup.Controls.Add(this.arg3label); - this.actiongroup.Controls.Add(this.arg4label); - this.actiongroup.Controls.Add(this.arg2); this.actiongroup.Controls.Add(label7); - this.actiongroup.Controls.Add(this.arg1); this.actiongroup.Controls.Add(this.action); - this.actiongroup.Controls.Add(this.arg0); this.actiongroup.Controls.Add(this.browseaction); - this.actiongroup.Controls.Add(this.arg0label); - this.actiongroup.Controls.Add(this.arg1label); - this.actiongroup.Controls.Add(this.arg2label); this.actiongroup.Location = new System.Drawing.Point(4, 382); this.actiongroup.Name = "actiongroup"; this.actiongroup.Size = new System.Drawing.Size(546, 145); @@ -336,31 +316,12 @@ namespace CodeImp.DoomBuilder.Windows this.actiongroup.TabStop = false; this.actiongroup.Text = " Action "; // - // arg3 + // argscontrol // - this.arg3.Location = new System.Drawing.Point(420, 57); - this.arg3.Name = "arg3"; - this.arg3.Size = new System.Drawing.Size(120, 24); - this.arg3.TabIndex = 3; - // - // scriptNumbers - // - this.scriptNumbers.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.scriptNumbers.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.scriptNumbers.BackColor = System.Drawing.Color.LemonChiffon; - this.scriptNumbers.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.scriptNumbers.FormattingEnabled = true; - this.scriptNumbers.Location = new System.Drawing.Point(420, 109); - this.scriptNumbers.Name = "scriptNumbers"; - this.scriptNumbers.Size = new System.Drawing.Size(120, 21); - this.scriptNumbers.TabIndex = 23; - // - // arg4 - // - this.arg4.Location = new System.Drawing.Point(420, 83); - this.arg4.Name = "arg4"; - this.arg4.Size = new System.Drawing.Size(120, 24); - this.arg4.TabIndex = 4; + this.argscontrol.Location = new System.Drawing.Point(6, 57); + this.argscontrol.Name = "argscontrol"; + this.argscontrol.Size = new System.Drawing.Size(534, 80); + this.argscontrol.TabIndex = 15; // // actionhelp // @@ -369,40 +330,6 @@ namespace CodeImp.DoomBuilder.Windows this.actionhelp.Size = new System.Drawing.Size(28, 25); this.actionhelp.TabIndex = 14; // - // arg3label - // - this.arg3label.Location = new System.Drawing.Point(280, 62); - this.arg3label.Name = "arg3label"; - this.arg3label.Size = new System.Drawing.Size(134, 14); - this.arg3label.TabIndex = 20; - this.arg3label.Text = "Argument 4:"; - this.arg3label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg3label.UseMnemonic = false; - // - // arg4label - // - this.arg4label.Location = new System.Drawing.Point(280, 88); - this.arg4label.Name = "arg4label"; - this.arg4label.Size = new System.Drawing.Size(134, 14); - this.arg4label.TabIndex = 16; - this.arg4label.Text = "Argument 5:"; - this.arg4label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg4label.UseMnemonic = false; - // - // arg2 - // - this.arg2.Location = new System.Drawing.Point(156, 109); - this.arg2.Name = "arg2"; - this.arg2.Size = new System.Drawing.Size(120, 24); - this.arg2.TabIndex = 2; - // - // arg1 - // - this.arg1.Location = new System.Drawing.Point(156, 83); - this.arg1.Name = "arg1"; - this.arg1.Size = new System.Drawing.Size(120, 24); - this.arg1.TabIndex = 1; - // // action // this.action.BackColor = System.Drawing.SystemColors.Control; @@ -417,13 +344,6 @@ namespace CodeImp.DoomBuilder.Windows this.action.Value = 402; this.action.ValueChanges += new System.EventHandler(this.action_ValueChanges); // - // arg0 - // - this.arg0.Location = new System.Drawing.Point(156, 57); - this.arg0.Name = "arg0"; - this.arg0.Size = new System.Drawing.Size(120, 24); - this.arg0.TabIndex = 0; - // // browseaction // this.browseaction.Image = global::CodeImp.DoomBuilder.Properties.Resources.List; @@ -436,36 +356,6 @@ namespace CodeImp.DoomBuilder.Windows this.browseaction.UseVisualStyleBackColor = true; this.browseaction.Click += new System.EventHandler(this.browseaction_Click); // - // arg0label - // - this.arg0label.Location = new System.Drawing.Point(6, 62); - this.arg0label.Name = "arg0label"; - this.arg0label.Size = new System.Drawing.Size(144, 14); - this.arg0label.TabIndex = 12; - this.arg0label.Text = "Argument 1:"; - this.arg0label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg0label.UseMnemonic = false; - // - // arg1label - // - this.arg1label.Location = new System.Drawing.Point(6, 88); - this.arg1label.Name = "arg1label"; - this.arg1label.Size = new System.Drawing.Size(144, 14); - this.arg1label.TabIndex = 14; - this.arg1label.Text = "Argument 2:"; - this.arg1label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg1label.UseMnemonic = false; - // - // arg2label - // - this.arg2label.Location = new System.Drawing.Point(6, 114); - this.arg2label.Name = "arg2label"; - this.arg2label.Size = new System.Drawing.Size(144, 14); - this.arg2label.TabIndex = 18; - this.arg2label.Text = "Argument 3:"; - this.arg2label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg2label.UseMnemonic = false; - // // idgroup // this.idgroup.Controls.Add(this.tagSelector); @@ -595,18 +485,8 @@ namespace CodeImp.DoomBuilder.Windows private CodeImp.DoomBuilder.Controls.CheckboxArrayControl flags; private System.Windows.Forms.GroupBox idgroup; private System.Windows.Forms.GroupBox actiongroup; - private System.Windows.Forms.Label arg1label; - private System.Windows.Forms.Label arg0label; - private System.Windows.Forms.Label arg3label; - private System.Windows.Forms.Label arg2label; - private System.Windows.Forms.Label arg4label; private CodeImp.DoomBuilder.Controls.ActionSelectorControl action; private System.Windows.Forms.Button browseaction; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg2; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg1; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg0; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg3; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg4; private System.Windows.Forms.Label zlabel; private CodeImp.DoomBuilder.Controls.ThingBrowserControl thingtype; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox angle; @@ -618,7 +498,6 @@ namespace CodeImp.DoomBuilder.Windows private System.Windows.Forms.CheckBox cbAbsoluteHeight; private System.Windows.Forms.CheckBox cbRandomAngle; private CodeImp.DoomBuilder.GZBuilder.Controls.TagSelector tagSelector; - private CodeImp.DoomBuilder.Controls.ColoredComboBox scriptNumbers; private CodeImp.DoomBuilder.GZBuilder.Controls.AngleControl anglecontrol; private System.Windows.Forms.PictureBox hint; private System.Windows.Forms.Label hintlabel; @@ -629,5 +508,6 @@ namespace CodeImp.DoomBuilder.Windows private System.Windows.Forms.Panel panel; private System.Windows.Forms.GroupBox typegroup; private System.Windows.Forms.Panel applypanel; + private CodeImp.DoomBuilder.Controls.ArgumentsControl argscontrol; } } \ No newline at end of file diff --git a/Source/Core/Windows/ThingEditForm.cs b/Source/Core/Windows/ThingEditForm.cs index 0da52ae92e5b53e6270bb623bad095ae42c612df..3fe4bfb3031b4a8a7464466d43be979fee2779b0 100644 --- a/Source/Core/Windows/ThingEditForm.cs +++ b/Source/Core/Windows/ThingEditForm.cs @@ -20,12 +20,9 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; -using CodeImp.DoomBuilder.Controls; -using CodeImp.DoomBuilder.Map; -using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.Config; using CodeImp.DoomBuilder.Geometry; -using CodeImp.DoomBuilder.GZBuilder.Data; +using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Types; #endregion @@ -102,16 +99,6 @@ namespace CodeImp.DoomBuilder.Windows // Tag/Effects? actiongroup.Visible = General.Map.FormatInterface.HasThingAction; idgroup.Visible = General.Map.FormatInterface.HasThingTag; - - if(General.Map.FormatInterface.HasThingAction && General.Map.FormatInterface.HasThingTag) //mxd. Setup script numbers - { - scriptNumbers.Location = new Point(arg0.Location.X, arg0.Location.Y + 2); - - foreach(ScriptItem si in General.Map.NumberedScripts) - scriptNumbers.Items.Add(new ColoredComboBoxItem(si, si.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); - - scriptNumbers.DropDownWidth = Tools.GetDropDownWidth(scriptNumbers); - } // Thing height? posZ.Visible = General.Map.FormatInterface.HasThingHeight; @@ -202,11 +189,9 @@ namespace CodeImp.DoomBuilder.Windows tagSelector.Setup(UniversalType.ThingTag); tagSelector.SetTag(ft.Tag); } - arg0.SetValue(ft.Args[0]); - arg1.SetValue(ft.Args[1]); - arg2.SetValue(ft.Args[2]); - arg3.SetValue(ft.Args[3]); - arg4.SetValue(ft.Args[4]); + + //mxd. Args + argscontrol.SetValue(ft, true); //////////////////////////////////////////////////////////////////////// // Now go for all lines and change the options when a setting is different @@ -256,11 +241,9 @@ namespace CodeImp.DoomBuilder.Windows // Action/tags if(t.Action != action.Value) action.Empty = true; if(General.Map.FormatInterface.HasThingTag && t.Tag != ft.Tag) tagSelector.ClearTag(); //mxd - if(t.Args[0] != arg0.GetResult(-1)) arg0.ClearValue(); - if(t.Args[1] != arg1.GetResult(-1)) arg1.ClearValue(); - if(t.Args[2] != arg2.GetResult(-1)) arg2.ClearValue(); - if(t.Args[3] != arg3.GetResult(-1)) arg3.ClearValue(); - if(t.Args[4] != arg4.GetResult(-1)) arg4.ClearValue(); + + //mxd. Arguments + argscontrol.SetValue(t, false); //mxd. Store initial properties thingprops.Add(new ThingProperties(t)); @@ -274,34 +257,8 @@ namespace CodeImp.DoomBuilder.Windows flags_OnValueChanged(flags, EventArgs.Empty); preventmapchange = false; - UpdateScriptControls(); //mxd + argscontrol.UpdateScriptControls(); //mxd actionhelp.UpdateAction(action.GetValue()); //mxd - - //mxd. Set intial script-related values, if required - if(Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1) - { - int a0 = arg0.GetResult(0); - if(a0 > 0) - { - for(int i = 0; i < General.Map.NumberedScripts.Count; i++) - { - if(General.Map.NumberedScripts[i].Index == a0) - { - scriptNumbers.SelectedIndex = i; - break; - } - } - } - - if(scriptNumbers.SelectedIndex == -1) - { - scriptNumbers.Text = a0.ToString(); - } - } - else - { - scriptNumbers.Text = "0"; - } } //mxd @@ -313,36 +270,6 @@ namespace CodeImp.DoomBuilder.Windows //mxd. Make undo General.Map.UndoRedo.CreateUndo("Edit " + (things.Count > 1 ? things.Count + " things" : "thing")); } - - //mxd - private void UpdateScriptControls() - { - scriptNumbers.Visible = (Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1); - arg0.Visible = !scriptNumbers.Visible; - } - - //mxd - private void UpdateArgument(ArgumentBox arg, Label label, ArgumentInfo info) - { - label.Text = info.Title + ":"; - label.Enabled = info.Used; - arg.ForeColor = (label.Enabled ? SystemColors.WindowText : SystemColors.GrayText); - arg.Setup(info); - - // Update tooltip - if(info.Used && !string.IsNullOrEmpty(info.ToolTip)) - { - tooltip.SetToolTip(label, info.ToolTip); - label.Font = new Font(label.Font, FontStyle.Underline); - label.ForeColor = SystemColors.HotTrack; - } - else - { - tooltip.SetToolTip(label, null); - label.Font = new Font(label.Font, FontStyle.Regular); - label.ForeColor = SystemColors.WindowText; - } - } #endregion @@ -358,44 +285,19 @@ namespace CodeImp.DoomBuilder.Windows private void action_ValueChanges(object sender, EventArgs e) { int showaction = 0; - ArgumentInfo[] arginfo; // Only when line type is known, otherwise use the thing arguments if(General.Map.Config.LinedefActions.ContainsKey(action.Value)) showaction = action.Value; - if((showaction == 0) && (thinginfo != null)) arginfo = thinginfo.Args; - else arginfo = General.Map.Config.LinedefActions[showaction].Args; - // Change the argument descriptions - UpdateArgument(arg0, arg0label, arginfo[0]); //mxd - UpdateArgument(arg1, arg1label, arginfo[1]); //mxd - UpdateArgument(arg2, arg2label, arginfo[2]); //mxd - UpdateArgument(arg3, arg3label, arginfo[3]); //mxd - UpdateArgument(arg4, arg4label, arginfo[4]); //mxd + //mxd. Change the argument descriptions + argscontrol.UpdateAction(showaction, preventchanges, (action.Empty ? null : thinginfo)); if(!preventchanges) { MakeUndo(); - - // mxd. Apply action's or thing's default arguments - if (showaction != 0 || thinginfo != null) - { - arg0.SetDefaultValue(); - arg1.SetDefaultValue(); - arg2.SetDefaultValue(); - arg3.SetDefaultValue(); - arg4.SetDefaultValue(); - } - else //or set them to 0 - { - arg0.SetValue(0); - arg1.SetValue(0); - arg2.SetValue(0); - arg3.SetValue(0); - arg4.SetValue(0); - } //mxd. Update what must be updated - UpdateScriptControls(); + argscontrol.UpdateScriptControls(); actionhelp.UpdateAction(showaction); } } @@ -456,8 +358,6 @@ namespace CodeImp.DoomBuilder.Windows return; } - bool hasAcs = !action.Empty && Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1; //mxd - // Go for all the things int tagoffset = 0; //mxd foreach(Thing t in things) @@ -482,38 +382,10 @@ namespace CodeImp.DoomBuilder.Windows // Action/tags t.Tag = General.Clamp(tagSelector.GetSmartTag(t.Tag, tagoffset++), General.Map.FormatInterface.MinTag, General.Map.FormatInterface.MaxTag); //mxd - if (!action.Empty) - { - t.Action = action.Value; - - //mxd. Script number handling - if(hasAcs) - { - if(!string.IsNullOrEmpty(scriptNumbers.Text)) - { - if(scriptNumbers.SelectedItem != null) - t.Args[0] = ((ScriptItem)((ColoredComboBoxItem)scriptNumbers.SelectedItem).Value).Index; - else if(!int.TryParse(scriptNumbers.Text.Trim(), out t.Args[0])) - t.Args[0] = 0; - - if(t.Fields.ContainsKey("arg0str")) t.Fields.Remove("arg0str"); - } - } - else - { - t.Args[0] = arg0.GetResult(t.Args[0]); - if(t.Fields.ContainsKey("arg0str")) t.Fields.Remove("arg0str"); - } - } - else - { - t.Args[0] = arg0.GetResult(t.Args[0]); - } + if (!action.Empty) t.Action = action.Value; - t.Args[1] = arg1.GetResult(t.Args[1]); - t.Args[2] = arg2.GetResult(t.Args[2]); - t.Args[3] = arg3.GetResult(t.Args[3]); - t.Args[4] = arg4.GetResult(t.Args[4]); + //mxd. Apply args + argscontrol.Apply(t); // Update settings t.UpdateConfiguration(); diff --git a/Source/Core/Windows/ThingEditForm.resx b/Source/Core/Windows/ThingEditForm.resx index 4ae749ebc7839816c626d5131362ec379fa33cbe..70059d962f8dd43d36758cab2d0907985adb74e1 100644 --- a/Source/Core/Windows/ThingEditForm.resx +++ b/Source/Core/Windows/ThingEditForm.resx @@ -129,4 +129,7 @@ <metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> + <metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> </root> \ No newline at end of file diff --git a/Source/Core/Windows/ThingEditFormUDMF.Designer.cs b/Source/Core/Windows/ThingEditFormUDMF.Designer.cs index c243488f50f497e2dd9a6babead5d6b46c31d449..b3d721934817fd12808fd7319555e5af2f167406 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.Designer.cs +++ b/Source/Core/Windows/ThingEditFormUDMF.Designer.cs @@ -80,25 +80,14 @@ this.renderStyle = new System.Windows.Forms.ComboBox(); this.labelrenderstyle = new System.Windows.Forms.Label(); this.actiongroup = new System.Windows.Forms.GroupBox(); + this.argscontrol = new CodeImp.DoomBuilder.Controls.ArgumentsControl(); this.actionhelp = new CodeImp.DoomBuilder.Controls.ActionSpecialHelpButton(); - this.hexenpanel = new System.Windows.Forms.Panel(); - this.scriptNumbers = new CodeImp.DoomBuilder.Controls.ColoredComboBox(); - this.scriptNames = new CodeImp.DoomBuilder.Controls.ColoredComboBox(); - this.cbArgStr = new System.Windows.Forms.CheckBox(); - this.arg2 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg1 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg0 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg3 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg4 = new CodeImp.DoomBuilder.Controls.ArgumentBox(); - this.arg1label = new System.Windows.Forms.Label(); - this.arg0label = new System.Windows.Forms.Label(); - this.arg3label = new System.Windows.Forms.Label(); - this.arg2label = new System.Windows.Forms.Label(); - this.arg4label = new System.Windows.Forms.Label(); this.action = new CodeImp.DoomBuilder.Controls.ActionSelectorControl(); this.browseaction = new System.Windows.Forms.Button(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.tagSelector = new CodeImp.DoomBuilder.GZBuilder.Controls.TagSelector(); + this.tabcomment = new System.Windows.Forms.TabPage(); + this.commenteditor = new CodeImp.DoomBuilder.Controls.CommentEditor(); this.tabcustom = new System.Windows.Forms.TabPage(); this.fieldslist = new CodeImp.DoomBuilder.Controls.FieldsEditorControl(); this.cancel = new System.Windows.Forms.Button(); @@ -106,8 +95,6 @@ this.hint = new System.Windows.Forms.PictureBox(); this.hintlabel = new System.Windows.Forms.Label(); this.tooltip = new System.Windows.Forms.ToolTip(this.components); - this.tabcomment = new System.Windows.Forms.TabPage(); - this.commenteditor = new CodeImp.DoomBuilder.Controls.CommentEditor(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.tabs.SuspendLayout(); @@ -122,11 +109,10 @@ this.groupbehaviour.SuspendLayout(); this.grouprendering.SuspendLayout(); this.actiongroup.SuspendLayout(); - this.hexenpanel.SuspendLayout(); this.groupBox3.SuspendLayout(); + this.tabcomment.SuspendLayout(); this.tabcustom.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.hint)).BeginInit(); - this.tabcomment.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -769,8 +755,8 @@ this.actiongroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.actiongroup.Controls.Add(this.argscontrol); this.actiongroup.Controls.Add(this.actionhelp); - this.actiongroup.Controls.Add(this.hexenpanel); this.actiongroup.Controls.Add(this.label7); this.actiongroup.Controls.Add(this.action); this.actiongroup.Controls.Add(this.browseaction); @@ -781,6 +767,13 @@ this.actiongroup.TabStop = false; this.actiongroup.Text = " Action "; // + // argscontrol + // + this.argscontrol.Location = new System.Drawing.Point(6, 56); + this.argscontrol.Name = "argscontrol"; + this.argscontrol.Size = new System.Drawing.Size(603, 80); + this.argscontrol.TabIndex = 15; + // // actionhelp // this.actionhelp.Location = new System.Drawing.Point(581, 24); @@ -788,148 +781,6 @@ this.actionhelp.Size = new System.Drawing.Size(28, 26); this.actionhelp.TabIndex = 14; // - // hexenpanel - // - this.hexenpanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.hexenpanel.Controls.Add(this.scriptNumbers); - this.hexenpanel.Controls.Add(this.scriptNames); - this.hexenpanel.Controls.Add(this.cbArgStr); - this.hexenpanel.Controls.Add(this.arg2); - this.hexenpanel.Controls.Add(this.arg1); - this.hexenpanel.Controls.Add(this.arg0); - this.hexenpanel.Controls.Add(this.arg3); - this.hexenpanel.Controls.Add(this.arg4); - this.hexenpanel.Controls.Add(this.arg1label); - this.hexenpanel.Controls.Add(this.arg0label); - this.hexenpanel.Controls.Add(this.arg3label); - this.hexenpanel.Controls.Add(this.arg2label); - this.hexenpanel.Controls.Add(this.arg4label); - this.hexenpanel.Location = new System.Drawing.Point(6, 53); - this.hexenpanel.Name = "hexenpanel"; - this.hexenpanel.Size = new System.Drawing.Size(603, 94); - this.hexenpanel.TabIndex = 13; - // - // scriptNumbers - // - this.scriptNumbers.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.scriptNumbers.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.scriptNumbers.BackColor = System.Drawing.Color.LemonChiffon; - this.scriptNumbers.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.scriptNumbers.FormattingEnabled = true; - this.scriptNumbers.Location = new System.Drawing.Point(435, 63); - this.scriptNumbers.Name = "scriptNumbers"; - this.scriptNumbers.Size = new System.Drawing.Size(127, 21); - this.scriptNumbers.TabIndex = 23; - // - // scriptNames - // - this.scriptNames.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.scriptNames.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.scriptNames.BackColor = System.Drawing.Color.Honeydew; - this.scriptNames.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.scriptNames.FormattingEnabled = true; - this.scriptNames.Location = new System.Drawing.Point(305, 63); - this.scriptNames.Name = "scriptNames"; - this.scriptNames.Size = new System.Drawing.Size(127, 21); - this.scriptNames.TabIndex = 22; - // - // cbArgStr - // - this.cbArgStr.Location = new System.Drawing.Point(14, 1); - this.cbArgStr.Name = "cbArgStr"; - this.cbArgStr.Size = new System.Drawing.Size(63, 40); - this.cbArgStr.TabIndex = 21; - this.cbArgStr.Text = "Named script"; - this.cbArgStr.UseVisualStyleBackColor = true; - this.cbArgStr.CheckedChanged += new System.EventHandler(this.cbArgStr_CheckedChanged); - // - // arg2 - // - this.arg2.Location = new System.Drawing.Point(172, 63); - this.arg2.Name = "arg2"; - this.arg2.Size = new System.Drawing.Size(127, 24); - this.arg2.TabIndex = 2; - // - // arg1 - // - this.arg1.Location = new System.Drawing.Point(172, 36); - this.arg1.Name = "arg1"; - this.arg1.Size = new System.Drawing.Size(127, 24); - this.arg1.TabIndex = 1; - // - // arg0 - // - this.arg0.Location = new System.Drawing.Point(172, 9); - this.arg0.Name = "arg0"; - this.arg0.Size = new System.Drawing.Size(127, 24); - this.arg0.TabIndex = 0; - // - // arg3 - // - this.arg3.Location = new System.Drawing.Point(473, 9); - this.arg3.Name = "arg3"; - this.arg3.Size = new System.Drawing.Size(127, 24); - this.arg3.TabIndex = 3; - // - // arg4 - // - this.arg4.Location = new System.Drawing.Point(473, 36); - this.arg4.Name = "arg4"; - this.arg4.Size = new System.Drawing.Size(127, 24); - this.arg4.TabIndex = 4; - // - // arg1label - // - this.arg1label.Location = new System.Drawing.Point(-13, 41); - this.arg1label.Name = "arg1label"; - this.arg1label.Size = new System.Drawing.Size(179, 14); - this.arg1label.TabIndex = 14; - this.arg1label.Text = "Argument 2:"; - this.arg1label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg1label.UseMnemonic = false; - // - // arg0label - // - this.arg0label.Location = new System.Drawing.Point(-13, 14); - this.arg0label.Name = "arg0label"; - this.arg0label.Size = new System.Drawing.Size(179, 14); - this.arg0label.TabIndex = 12; - this.arg0label.Text = "Argument 1:"; - this.arg0label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg0label.UseMnemonic = false; - // - // arg3label - // - this.arg3label.Location = new System.Drawing.Point(288, 14); - this.arg3label.Name = "arg3label"; - this.arg3label.Size = new System.Drawing.Size(179, 14); - this.arg3label.TabIndex = 20; - this.arg3label.Text = "Argument 4:"; - this.arg3label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg3label.UseMnemonic = false; - // - // arg2label - // - this.arg2label.Location = new System.Drawing.Point(-13, 68); - this.arg2label.Name = "arg2label"; - this.arg2label.Size = new System.Drawing.Size(179, 14); - this.arg2label.TabIndex = 18; - this.arg2label.Text = "Argument 3:"; - this.arg2label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg2label.UseMnemonic = false; - // - // arg4label - // - this.arg4label.Location = new System.Drawing.Point(288, 41); - this.arg4label.Name = "arg4label"; - this.arg4label.Size = new System.Drawing.Size(179, 14); - this.arg4label.TabIndex = 16; - this.arg4label.Text = "Argument 5:"; - this.arg4label.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.arg4label.UseMnemonic = false; - // // action // this.action.BackColor = System.Drawing.SystemColors.Control; @@ -973,6 +824,27 @@ this.tagSelector.Size = new System.Drawing.Size(569, 35); this.tagSelector.TabIndex = 8; // + // tabcomment + // + this.tabcomment.Controls.Add(this.commenteditor); + this.tabcomment.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tabcomment.Location = new System.Drawing.Point(4, 23); + this.tabcomment.Name = "tabcomment"; + this.tabcomment.Size = new System.Drawing.Size(627, 402); + this.tabcomment.TabIndex = 3; + this.tabcomment.Text = "Comment"; + this.tabcomment.UseVisualStyleBackColor = true; + // + // commenteditor + // + this.commenteditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.commenteditor.Location = new System.Drawing.Point(3, 3); + this.commenteditor.Name = "commenteditor"; + this.commenteditor.Size = new System.Drawing.Size(621, 396); + this.commenteditor.TabIndex = 0; + // // tabcustom // this.tabcustom.Controls.Add(this.fieldslist); @@ -1047,27 +919,6 @@ this.hintlabel.TabIndex = 4; this.hintlabel.Text = "Select categories or several thing types to randomly assign them to selection"; // - // tabcomment - // - this.tabcomment.Controls.Add(this.commenteditor); - this.tabcomment.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tabcomment.Location = new System.Drawing.Point(4, 23); - this.tabcomment.Name = "tabcomment"; - this.tabcomment.Size = new System.Drawing.Size(627, 402); - this.tabcomment.TabIndex = 3; - this.tabcomment.Text = "Comment"; - this.tabcomment.UseVisualStyleBackColor = true; - // - // commenteditor - // - this.commenteditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.commenteditor.Location = new System.Drawing.Point(3, 3); - this.commenteditor.Name = "commenteditor"; - this.commenteditor.Size = new System.Drawing.Size(621, 396); - this.commenteditor.TabIndex = 0; - // // ThingEditFormUDMF // this.AcceptButton = this.apply; @@ -1109,11 +960,10 @@ this.grouprendering.ResumeLayout(false); this.actiongroup.ResumeLayout(false); this.actiongroup.PerformLayout(); - this.hexenpanel.ResumeLayout(false); this.groupBox3.ResumeLayout(false); + this.tabcomment.ResumeLayout(false); this.tabcustom.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.hint)).EndInit(); - this.tabcomment.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -1129,27 +979,13 @@ private System.Windows.Forms.TabPage tabcustom; private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.GroupBox actiongroup; - private System.Windows.Forms.Panel hexenpanel; - private System.Windows.Forms.Label arg1label; - private System.Windows.Forms.Label arg0label; - private System.Windows.Forms.Label arg3label; - private System.Windows.Forms.Label arg2label; - private System.Windows.Forms.Label arg4label; private CodeImp.DoomBuilder.Controls.ActionSelectorControl action; private System.Windows.Forms.Button browseaction; private CodeImp.DoomBuilder.Controls.FieldsEditorControl fieldslist; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg2; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg1; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg0; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg3; - private CodeImp.DoomBuilder.Controls.ArgumentBox arg4; private CodeImp.DoomBuilder.Controls.ThingBrowserControl thingtype; - private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox angle; - private System.Windows.Forms.CheckBox cbArgStr; - private CodeImp.DoomBuilder.Controls.ColoredComboBox scriptNames; + private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox angle; private System.Windows.Forms.Label labelAngle; - private CodeImp.DoomBuilder.GZBuilder.Controls.TagSelector tagSelector; - private CodeImp.DoomBuilder.Controls.ColoredComboBox scriptNumbers; + private CodeImp.DoomBuilder.GZBuilder.Controls.TagSelector tagSelector; private System.Windows.Forms.Label labelGravity; private CodeImp.DoomBuilder.GZBuilder.Controls.AngleControl anglecontrol; private System.Windows.Forms.PictureBox hint; @@ -1200,5 +1036,6 @@ private System.Windows.Forms.CheckBox cbrandompitch; private System.Windows.Forms.TabPage tabcomment; private CodeImp.DoomBuilder.Controls.CommentEditor commenteditor; + private CodeImp.DoomBuilder.Controls.ArgumentsControl argscontrol; } } \ No newline at end of file diff --git a/Source/Core/Windows/ThingEditFormUDMF.cs b/Source/Core/Windows/ThingEditFormUDMF.cs index 58458dd1786ded28e5aaf9190f8089c540c705d1..d0ee6f4474d1ce494bae49f9bafdd79398ce8f85 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.cs +++ b/Source/Core/Windows/ThingEditFormUDMF.cs @@ -20,12 +20,10 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; -using CodeImp.DoomBuilder.Controls; -using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Config; using CodeImp.DoomBuilder.Geometry; -using CodeImp.DoomBuilder.GZBuilder.Data; using CodeImp.DoomBuilder.GZBuilder.Tools; +using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Types; #endregion @@ -51,8 +49,6 @@ namespace CodeImp.DoomBuilder.Windows private bool preventmapchange; //mxd private bool undocreated; //mxd private static bool useabsoluteheight; //mxd - private string arg0str; - private bool haveArg0Str; private List<ThingProperties> thingprops; //mxd private readonly string[] renderstyles; //mxd @@ -132,18 +128,6 @@ namespace CodeImp.DoomBuilder.Windows // Fill universal fields list fieldslist.ListFixedFields(General.Map.Config.ThingFields); - // Tag/Effects - scriptNumbers.Location = new Point(arg0.Location.X, arg0.Location.Y + 2); - scriptNames.Location = scriptNumbers.Location; - - // Setup script names - foreach(ScriptItem nsi in General.Map.NamedScripts) - scriptNames.Items.Add(new ColoredComboBoxItem(nsi, nsi.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); - foreach(ScriptItem si in General.Map.NumberedScripts) - scriptNumbers.Items.Add(new ColoredComboBoxItem(si, si.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); - scriptNames.DropDownWidth = Tools.GetDropDownWidth(scriptNames); - scriptNumbers.DropDownWidth = Tools.GetDropDownWidth(scriptNumbers); - // Thing height? posZ.Visible = General.Map.FormatInterface.HasThingHeight; zlabel.Visible = General.Map.FormatInterface.HasThingHeight; @@ -218,8 +202,6 @@ namespace CodeImp.DoomBuilder.Windows health.Text = ft.Fields.GetValue("health", 1).ToString(); alpha.Text = ft.Fields.GetValue("alpha", 1.0f).ToString(); color.SetValueFrom(ft.Fields); - arg0str = ft.Fields.GetValue("arg0str", string.Empty); - haveArg0Str = !string.IsNullOrEmpty(arg0str); scale.SetValues(ft.ScaleX, ft.ScaleY, true); pitch.Text = ft.Pitch.ToString(); roll.Text = ft.Roll.ToString(); @@ -229,11 +211,9 @@ namespace CodeImp.DoomBuilder.Windows action.Value = ft.Action; tagSelector.Setup(UniversalType.ThingTag); tagSelector.SetTag(ft.Tag); - arg0.SetValue(ft.Args[0]); - arg1.SetValue(ft.Args[1]); - arg2.SetValue(ft.Args[2]); - arg3.SetValue(ft.Args[3]); - arg4.SetValue(ft.Args[4]); + + //mxd. Args + argscontrol.SetValue(ft, true); //////////////////////////////////////////////////////////////////////// // Now go for all lines and change the options when a setting is different @@ -281,11 +261,9 @@ namespace CodeImp.DoomBuilder.Windows // Action/tags if(t.Action != action.Value) action.Empty = true; if(t.Tag != ft.Tag) tagSelector.ClearTag(); //mxd - if(t.Args[0] != arg0.GetResult(-1)) arg0.ClearValue(); - if(t.Args[1] != arg1.GetResult(-1)) arg1.ClearValue(); - if(t.Args[2] != arg2.GetResult(-1)) arg2.ClearValue(); - if(t.Args[3] != arg3.GetResult(-1)) arg3.ClearValue(); - if(t.Args[4] != arg4.GetResult(-1)) arg4.ClearValue(); + + //mxd. Arguments + argscontrol.SetValue(t, false); //mxd. Custom fields fieldslist.SetValues(t.Fields, false); @@ -306,12 +284,6 @@ namespace CodeImp.DoomBuilder.Windows if(renderStyle.SelectedIndex > -1 && renderStyle.SelectedIndex != Array.IndexOf(renderstyles, t.Fields.GetValue("renderstyle", "normal"))) renderStyle.SelectedIndex = -1; - if (arg0str != t.Fields.GetValue("arg0str", string.Empty)) - { - haveArg0Str = true; - arg0str = string.Empty; - } - //mxd. Store initial properties thingprops.Add(new ThingProperties(t)); @@ -336,44 +308,10 @@ namespace CodeImp.DoomBuilder.Windows flags_OnValueChanged(flags, EventArgs.Empty); preventmapchange = false; - UpdateScriptControls(); //mxd + argscontrol.UpdateScriptControls(); //mxd actionhelp.UpdateAction(action.GetValue()); //mxd labelScale.Enabled = scale.NonDefaultValue; //mxd commenteditor.FinishSetup(); //mxd - - //mxd. Set intial script-related values, if required - if(Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1) - { - if(haveArg0Str) - { - scriptNames.Text = arg0str; - arg0label.Text = "Script Name:"; - } - else - { - int a0 = arg0.GetResult(0); - if(a0 > 0) - { - for(int i = 0; i < General.Map.NumberedScripts.Count; i++) - { - if(General.Map.NumberedScripts[i].Index == a0) - { - scriptNumbers.SelectedIndex = i; - break; - } - } - } - - if(scriptNumbers.SelectedIndex == -1) - { - scriptNumbers.Text = a0.ToString(); - } - } - } - else - { - scriptNumbers.Text = "0"; - } } //mxd @@ -387,51 +325,6 @@ namespace CodeImp.DoomBuilder.Windows foreach(Thing t in things) t.Fields.BeforeFieldsChange(); } - //mxd - private void UpdateScriptControls() - { - if(Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1) - { - bool showNamedScripts = haveArg0Str; - cbArgStr.Visible = true; - cbArgStr.Checked = showNamedScripts; - scriptNames.Visible = showNamedScripts; - scriptNumbers.Visible = !showNamedScripts; - } - else - { - cbArgStr.Visible = false; - scriptNames.Visible = false; - scriptNumbers.Visible = false; - cbArgStr.Checked = false; - } - - arg0.Visible = (!scriptNames.Visible && !scriptNumbers.Visible); - } - - //mxd - private void UpdateArgument(ArgumentBox arg, Label label, ArgumentInfo info) - { - label.Text = info.Title + ":"; - label.Enabled = info.Used; - arg.ForeColor = (label.Enabled ? SystemColors.WindowText : SystemColors.GrayText); - arg.Setup(info); - - // Update tooltip - if(info.Used && !string.IsNullOrEmpty(info.ToolTip)) - { - tooltip.SetToolTip(label, info.ToolTip); - label.Font = new Font(label.Font, FontStyle.Underline); - label.ForeColor = SystemColors.HotTrack; - } - else - { - tooltip.SetToolTip(label, null); - label.Font = new Font(label.Font, FontStyle.Regular); - label.ForeColor = SystemColors.WindowText; - } - } - #endregion #region ================== Events @@ -446,44 +339,19 @@ namespace CodeImp.DoomBuilder.Windows private void action_ValueChanges(object sender, EventArgs e) { int showaction = 0; - ArgumentInfo[] arginfo; // Only when line type is known, otherwise use the thing arguments if(General.Map.Config.LinedefActions.ContainsKey(action.Value)) showaction = action.Value; - if((showaction == 0) && (thinginfo != null)) arginfo = thinginfo.Args; - else arginfo = General.Map.Config.LinedefActions[showaction].Args; - // Change the argument descriptions - UpdateArgument(arg0, arg0label, arginfo[0]); //mxd - UpdateArgument(arg1, arg1label, arginfo[1]); //mxd - UpdateArgument(arg2, arg2label, arginfo[2]); //mxd - UpdateArgument(arg3, arg3label, arginfo[3]); //mxd - UpdateArgument(arg4, arg4label, arginfo[4]); //mxd + //mxd. Change the argument descriptions + argscontrol.UpdateAction(showaction, preventchanges, (action.Empty ? null : thinginfo)); if(!preventchanges) { MakeUndo(); //mxd - - // mxd. Apply action's or thing's default arguments - if(showaction != 0 || thinginfo != null) - { - arg0.SetDefaultValue(); - arg1.SetDefaultValue(); - arg2.SetDefaultValue(); - arg3.SetDefaultValue(); - arg4.SetDefaultValue(); - } - else //or set them to 0 - { - arg0.SetValue(0); - arg1.SetValue(0); - arg2.SetValue(0); - arg3.SetValue(0); - arg4.SetValue(0); - } //mxd. Update what must be updated - UpdateScriptControls(); + argscontrol.UpdateScriptControls(); actionhelp.UpdateAction(showaction); } } @@ -579,8 +447,6 @@ namespace CodeImp.DoomBuilder.Windows return; } - bool hasAcs = !action.Empty && Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1; //mxd - //mxd string[] rskeys = null; if(General.Map.Config.ThingRenderStyles.Count > 0) @@ -616,46 +482,10 @@ namespace CodeImp.DoomBuilder.Windows // Action/tags t.Tag = General.Clamp(tagSelector.GetSmartTag(t.Tag, tagoffset++), General.Map.FormatInterface.MinTag, General.Map.FormatInterface.MaxTag); //mxd - if(!action.Empty) - { - t.Action = action.Value; - - //mxd. Script name/number handling - if(hasAcs) - { - if(!cbArgStr.Checked) //apply script number - { - if(!string.IsNullOrEmpty(scriptNumbers.Text)) - { - if(scriptNumbers.SelectedItem != null) - t.Args[0] = ((ScriptItem)((ColoredComboBoxItem)scriptNumbers.SelectedItem).Value).Index; - else if(!int.TryParse(scriptNumbers.Text.Trim(), out t.Args[0])) - t.Args[0] = 0; - - if(t.Fields.ContainsKey("arg0str")) t.Fields.Remove("arg0str"); - } - } - else //apply arg0str - { - if(!string.IsNullOrEmpty(scriptNames.Text)) - t.Fields["arg0str"] = new UniValue(UniversalType.String, scriptNames.Text); - } - } - else - { - t.Args[0] = arg0.GetResult(t.Args[0]); - if(t.Fields.ContainsKey("arg0str")) t.Fields.Remove("arg0str"); - } - } - else - { - t.Args[0] = arg0.GetResult(t.Args[0]); - } + if(!action.Empty) t.Action = action.Value; - t.Args[1] = arg1.GetResult(t.Args[1]); - t.Args[2] = arg2.GetResult(t.Args[2]); - t.Args[3] = arg3.GetResult(t.Args[3]); - t.Args[4] = arg4.GetResult(t.Args[4]); + //mxd. Apply args + argscontrol.Apply(t); //mxd. Custom fields fieldslist.Apply(t.Fields); @@ -711,15 +541,6 @@ namespace CodeImp.DoomBuilder.Windows this.Close(); } - //mxd - private void cbArgStr_CheckedChanged(object sender, EventArgs e) - { - if(!cbArgStr.Visible) return; - scriptNames.Visible = cbArgStr.Checked; - scriptNumbers.Visible = !cbArgStr.Checked; - arg0label.Text = cbArgStr.Checked ? "Script Name:" : "Script Number:"; - } - //mxd private void cbAbsoluteHeight_CheckedChanged(object sender, EventArgs e) { diff --git a/Source/Core/Windows/ThingEditFormUDMF.resx b/Source/Core/Windows/ThingEditFormUDMF.resx index 90f1f8dc7d85d2e04c18fe1a9a0c6266ac4d320a..853abdf8011009e3993edd75d2aaeadab30db487 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.resx +++ b/Source/Core/Windows/ThingEditFormUDMF.resx @@ -120,4 +120,7 @@ <metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> + <metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> </root> \ No newline at end of file