From 3748ea63989507af98000fd9e50b88c2cd67a677 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Thu, 23 Feb 2017 15:01:36 +0200 Subject: [PATCH] Fixed: handling of arg0str in non-script specials in info panel; default arg0str. --- Source/Core/Controls/ArgumentsControl.cs | 81 ++++++----- Source/Core/Controls/LinedefInfoPanel.cs | 36 +++-- Source/Core/Controls/ThingInfoPanel.cs | 130 ++++++++++-------- Source/Core/Properties/AssemblyInfo.cs | 4 +- .../BuilderModes/Properties/AssemblyInfo.cs | 2 +- 5 files changed, 139 insertions(+), 114 deletions(-) diff --git a/Source/Core/Controls/ArgumentsControl.cs b/Source/Core/Controls/ArgumentsControl.cs index f6007c33..86f01b9a 100755 --- a/Source/Core/Controls/ArgumentsControl.cs +++ b/Source/Core/Controls/ArgumentsControl.cs @@ -75,36 +75,7 @@ namespace CodeImp.DoomBuilder.Controls // 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) { - bool isacs = (Array.IndexOf(GZGeneral.ACS_SPECIALS, action) != -1); - //mxd. Setup script numbers - arg0int.Location = new Point(arg0.Location.X, arg0.Location.Y + 2); - arg0int.Items.Clear(); - // [ZZ] note: only do this if our action is acs. - if (isacs) - { - foreach (ScriptItem si in General.Map.NumberedScripts.Values) - arg0int.Items.Add(new ColoredComboBoxItem(si, si.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); - arg0int.DropDownWidth = Tools.GetDropDownWidth(arg0int); - } - - //mxd. Setup script names - if (General.Map.UDMF) - { - arg0str.Items.Clear(); - arg0str.Location = arg0int.Location; - // [ZZ] note: only do this if our action is acs. - if (isacs) - { - foreach (ScriptItem nsi in General.Map.NamedScripts.Values) - arg0str.Items.Add(new ColoredComboBoxItem(nsi, nsi.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); - arg0str.DropDownWidth = Tools.GetDropDownWidth(arg0str); - } - } - else - { - arg0str.Visible = false; - cbuseargstr.Visible = false; - } + // do nothing. } } @@ -161,9 +132,10 @@ namespace CodeImp.DoomBuilder.Controls public void Apply(Linedef l, int step) { - //mxd. Script name/number handling - // We can't rely on control visibility here, because all controlls will be invisible if ArgumentsControl is invisible - // (for example, when a different tab is selected) + //mxd. Script name/number handling + // We can't rely on control visibility here, because all controlls will be invisible if ArgumentsControl is invisible + // (for example, when a different tab is selected) + bool isacs = (Array.IndexOf(GZGeneral.ACS_SPECIALS, action) != -1); switch(Arg0Mode) { // Apply arg0str @@ -174,6 +146,9 @@ namespace CodeImp.DoomBuilder.Controls // Apply script number case ArgZeroMode.INT: + if (!isacs) + goto case ArgZeroMode.DEFAULT; + // if(!string.IsNullOrEmpty(arg0int.Text)) { if(arg0int.SelectedItem != null) @@ -286,7 +261,7 @@ namespace CodeImp.DoomBuilder.Controls if(showaction != 0 || info != null) { arg0.SetDefaultValue(); - arg1.SetDefaultValue(); + arg1.SetDefaultValue(); arg2.SetDefaultValue(); arg3.SetDefaultValue(); arg4.SetDefaultValue(); @@ -294,12 +269,14 @@ namespace CodeImp.DoomBuilder.Controls else //or set them to 0 { arg0.SetValue(0); - arg1.SetValue(0); + arg1.SetValue(0); arg2.SetValue(0); arg3.SetValue(0); arg4.SetValue(0); } - } + // arg0str currently can't have any default + arg0str.Text = arg0strval = " "; + } // Store current action this.action = showaction; @@ -313,6 +290,38 @@ namespace CodeImp.DoomBuilder.Controls if (arginfo[0].Str) { bool isacs = (Array.IndexOf(GZGeneral.ACS_SPECIALS, action) != -1); + + //mxd. Setup script numbers + arg0int.Location = new Point(arg0.Location.X, arg0.Location.Y + 2); + arg0int.Items.Clear(); + // [ZZ] note: only do this if our action is acs. + if (isacs) + { + foreach (ScriptItem si in General.Map.NumberedScripts.Values) + arg0int.Items.Add(new ColoredComboBoxItem(si, si.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); + arg0int.DropDownWidth = Tools.GetDropDownWidth(arg0int); + } + + //mxd. Setup script names + if (General.Map.UDMF) + { + arg0str.Items.Clear(); + arg0str.Location = arg0int.Location; + // [ZZ] note: only do this if our action is acs. + if (isacs) + { + foreach (ScriptItem nsi in General.Map.NamedScripts.Values) + arg0str.Items.Add(new ColoredComboBoxItem(nsi, nsi.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText)); + arg0str.DropDownWidth = Tools.GetDropDownWidth(arg0str); + } + } + else + { + arg0str.Visible = false; + cbuseargstr.Visible = false; + } + // + arg0str.DropDownStyle = isacs ? ComboBoxStyle.DropDown : ComboBoxStyle.Simple; // Update script controls visibility bool showarg0str = (General.Map.UDMF && havearg0str); diff --git a/Source/Core/Controls/LinedefInfoPanel.cs b/Source/Core/Controls/LinedefInfoPanel.cs index 4a3e9ee9..20873b54 100755 --- a/Source/Core/Controls/LinedefInfoPanel.cs +++ b/Source/Core/Controls/LinedefInfoPanel.cs @@ -213,8 +213,8 @@ namespace CodeImp.DoomBuilder.Controls //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); + bool isarg0str = (General.Map.UDMF && l.Fields.ContainsKey("arg0str")); + string arg0str = isarg0str ? l.Fields.GetValue("arg0str", string.Empty) : string.Empty; ScriptItem scriptitem = null; //mxd. Set default label colors @@ -222,15 +222,15 @@ namespace CodeImp.DoomBuilder.Controls arglbl1.ForeColor = SystemColors.ControlText; // Named script? - if(isnamedacsscript && General.Map.NamedScripts.ContainsKey(scriptname.ToLowerInvariant())) + if(isacsscript && isarg0str && General.Map.NamedScripts.ContainsKey(arg0str.ToLowerInvariant())) { - scriptitem = General.Map.NamedScripts[scriptname.ToLowerInvariant()]; + scriptitem = General.Map.NamedScripts[arg0str.ToLowerInvariant()]; } // Script number? else if(isacsscript && General.Map.NumberedScripts.ContainsKey(l.Args[0])) { scriptitem = General.Map.NumberedScripts[l.Args[0]]; - scriptname = (scriptitem.HasCustomName ? scriptitem.Name : scriptitem.Index.ToString()); + arg0str = (scriptitem.HasCustomName ? scriptitem.Name : scriptitem.Index.ToString()); } // Apply script args? @@ -239,8 +239,16 @@ namespace CodeImp.DoomBuilder.Controls if(scriptitem != null) { - string[] argnames = scriptitem.GetArgumentsDescriptions(l.Action); - for(int i = 0; i < argnames.Length; i++) + int first; + string[] argnames = scriptitem.GetArgumentsDescriptions(l.Action, out first); + for (int i = 0; i < first; i++) + { + arglabels[i].Text = (isarg0str ? act.Args[i].TitleStr : act.Args[i].Title) + ":"; + arglabels[i].Enabled = act.Args[i].Used; + args[i].Enabled = act.Args[i].Used; + } + + for (int i = first; i < argnames.Length; i++) { if(!string.IsNullOrEmpty(argnames[i])) { @@ -250,8 +258,8 @@ namespace CodeImp.DoomBuilder.Controls } else { - arglabels[i].Text = act.Args[i].Title + ":"; - arglabels[i].Enabled = act.Args[i].Used; + arglabels[i].Text = (isarg0str ? act.Args[i].TitleStr : act.Args[i].Title) + ":"; + arglabels[i].Enabled = act.Args[i].Used; args[i].Enabled = act.Args[i].Used; } } @@ -260,22 +268,22 @@ namespace CodeImp.DoomBuilder.Controls { for(int i = 0; i < act.Args.Length; i++) { - arglabels[i].Text = act.Args[i].Title + ":"; - arglabels[i].Enabled = act.Args[i].Used; + arglabels[i].Text = (isarg0str ? act.Args[i].TitleStr : act.Args[i].Title) + ":"; + arglabels[i].Enabled = act.Args[i].Used; args[i].Enabled = act.Args[i].Used; } // Special cases: unknown script name/index - if(isacsscript || isnamedacsscript) + if(isacsscript) { - arglbl1.Text = "Unknown script " + (isnamedacsscript ? "name" : "number") + ":"; + arglbl1.Text = "Unknown script " + (isarg0str ? "name" : "number") + ":"; arg1.ForeColor = Color.DarkRed; arglbl1.ForeColor = Color.DarkRed; } } //mxd. Set argument value and label - if(!string.IsNullOrEmpty(scriptname)) arg1.Text = scriptname; + if(isarg0str) arg1.Text = arg0str; 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]); diff --git a/Source/Core/Controls/ThingInfoPanel.cs b/Source/Core/Controls/ThingInfoPanel.cs index 725816d1..dbd3c174 100755 --- a/Source/Core/Controls/ThingInfoPanel.cs +++ b/Source/Core/Controls/ThingInfoPanel.cs @@ -134,73 +134,81 @@ namespace CodeImp.DoomBuilder.Controls // Arguments ArgumentInfo[] arginfo = ((t.Action == 0 && ti.Args[0] != null) ? ti.Args : act.Args); //mxd - //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. ACS script argument names + bool isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, t.Action) != -1); + bool isarg0str = (General.Map.UDMF && t.Fields.ContainsKey("arg0str")); + string arg0str = isarg0str ? t.Fields.GetValue("arg0str", string.Empty) : string.Empty; + ScriptItem scriptitem = null; - //mxd. Set default label colors - arg1.ForeColor = SystemColors.ControlText; - arglbl1.ForeColor = SystemColors.ControlText; + //mxd. Set default label colors + arg1.ForeColor = SystemColors.ControlText; + arglbl1.ForeColor = SystemColors.ControlText; - // 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(t.Args[0])) - { - scriptitem = General.Map.NumberedScripts[t.Args[0]]; - scriptname = (scriptitem.HasCustomName ? scriptitem.Name : scriptitem.Index.ToString()); - } + // Named script? + if (isacsscript && isarg0str && General.Map.NamedScripts.ContainsKey(arg0str.ToLowerInvariant())) + { + scriptitem = General.Map.NamedScripts[arg0str.ToLowerInvariant()]; + } + // Script number? + else if (isacsscript && General.Map.NumberedScripts.ContainsKey(t.Args[0])) + { + scriptitem = General.Map.NumberedScripts[t.Args[0]]; + arg0str = (scriptitem.HasCustomName ? scriptitem.Name : scriptitem.Index.ToString()); + } - // Apply script args? - Label[] arglabels = { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 }; - Label[] args = { arg1, arg2, arg3, arg4, arg5 }; + // Apply script args? + Label[] arglabels = { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 }; + Label[] args = { 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; - } + if (scriptitem != null) + { + int first; + string[] argnames = scriptitem.GetArgumentsDescriptions(t.Action, out first); + for (int i = 0; i < first; i++) + { + arglabels[i].Text = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":"; + arglabels[i].Enabled = arginfo[i].Used; + args[i].Enabled = arginfo[i].Used; + } - // Special cases: unknown script name/index - if(isacsscript || isnamedacsscript) - { - arglbl1.Text = "Unknown script " + (isnamedacsscript ? "name" : "number") + ":"; - arg1.ForeColor = Color.DarkRed; - arglbl1.ForeColor = Color.DarkRed; - } - } + for (int i = first; 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 = (isarg0str ? arginfo[i].TitleStr : 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 = (isarg0str ? arginfo[i].TitleStr : 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]); + // Special cases: unknown script name/index + if (isacsscript) + { + arglbl1.Text = "Unknown script " + (isarg0str ? "name" : "number") + ":"; + arg1.ForeColor = Color.DarkRed; + arglbl1.ForeColor = Color.DarkRed; + } + } + + //mxd. Set argument value and label + if (isarg0str) arg1.Text = arg0str; + else SetArgumentText(act.Args[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]); SetArgumentText(arginfo[4], arg5, t.Args[4]); diff --git a/Source/Core/Properties/AssemblyInfo.cs b/Source/Core/Properties/AssemblyInfo.cs index 2aca4e30..a8360583 100755 --- a/Source/Core/Properties/AssemblyInfo.cs +++ b/Source/Core/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ using CodeImp.DoomBuilder; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.2911")] +[assembly: AssemblyVersion("2.3.0.2913")] [assembly: NeutralResourcesLanguageAttribute("en")] -[assembly: AssemblyHash("1cb3682")] +[assembly: AssemblyHash("5ff54ab")] diff --git a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs index abbbad7e..995c59ac 100755 --- a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs +++ b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Resources; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.2911")] +[assembly: AssemblyVersion("2.3.0.2913")] [assembly: NeutralResourcesLanguageAttribute("en")]