Fixed: handling of arg0str in non-script specials in info panel; default arg0str.

This commit is contained in:
ZZYZX 2017-02-23 15:01:36 +02:00
parent 5ff54ab319
commit 3748ea6398
5 changed files with 139 additions and 114 deletions

View file

@ -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.
}
}
@ -164,6 +135,7 @@ namespace CodeImp.DoomBuilder.Controls
//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)
@ -299,6 +274,8 @@ namespace CodeImp.DoomBuilder.Controls
arg3.SetValue(0);
arg4.SetValue(0);
}
// arg0str currently can't have any default
arg0str.Text = arg0strval = " ";
}
// Store current action
@ -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);

View file

@ -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,7 +258,7 @@ namespace CodeImp.DoomBuilder.Controls
}
else
{
arglabels[i].Text = act.Args[i].Title + ":";
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].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]);

View file

@ -136,8 +136,8 @@ namespace CodeImp.DoomBuilder.Controls
//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);
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
@ -145,27 +145,35 @@ 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(t.Args[0]))
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());
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 };
if(scriptitem != null)
if (scriptitem != null)
{
string[] argnames = scriptitem.GetArgumentsDescriptions(t.Action);
for(int i = 0; i < argnames.Length; i++)
int first;
string[] argnames = scriptitem.GetArgumentsDescriptions(t.Action, out first);
for (int i = 0; i < first; i++)
{
if(!string.IsNullOrEmpty(argnames[i]))
arglabels[i].Text = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":";
arglabels[i].Enabled = arginfo[i].Used;
args[i].Enabled = arginfo[i].Used;
}
for (int i = first; i < argnames.Length; i++)
{
if (!string.IsNullOrEmpty(argnames[i]))
{
arglabels[i].Text = argnames[i] + ":";
arglabels[i].Enabled = true;
@ -173,7 +181,7 @@ namespace CodeImp.DoomBuilder.Controls
}
else
{
arglabels[i].Text = arginfo[i].Title + ":";
arglabels[i].Text = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":";
arglabels[i].Enabled = arginfo[i].Used;
args[i].Enabled = arginfo[i].Used;
}
@ -181,25 +189,25 @@ namespace CodeImp.DoomBuilder.Controls
}
else
{
for(int i = 0; i < arginfo.Length; i++)
for (int i = 0; i < arginfo.Length; i++)
{
arglabels[i].Text = arginfo[i].Title + ":";
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)
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;
else SetArgumentText(arginfo[0], arg1, t.Args[0]);
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]);

View file

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

View file

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