Added, action argument inputs: added "<" and ">" prefixes. These decrement/increment given value by selected map element number.

Changed, action argument inputs: "+++" and "---" prefixes now do the same thing as they do in other numeric controls (e.g. add/subtract given value multiplied by selected map element number to/from initial value).
Changed, action argument inputs: changed value colors, added tooltips.
This commit is contained in:
MaxED 2016-08-29 11:32:31 +00:00 committed by spherallic
parent 7435d4bd5b
commit 202014f62f
5 changed files with 48 additions and 20 deletions

View File

@ -28,18 +28,24 @@ namespace CodeImp.DoomBuilder.Controls
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.combobox = new System.Windows.Forms.ComboBox();
this.button = new System.Windows.Forms.Button();
this.scrollbuttons = new System.Windows.Forms.VScrollBar();
this.tooltip = new System.Windows.Forms.ToolTip(this.components);
this.SuspendLayout();
//
// combobox
//
this.combobox.DropDownWidth = 130;
this.combobox.ForeColor = System.Drawing.SystemColors.HotTrack;
this.combobox.Location = new System.Drawing.Point(0, 2);
this.combobox.Name = "combobox";
this.combobox.Size = new System.Drawing.Size(149, 21);
this.combobox.TabIndex = 0;
this.tooltip.SetToolTip(this.combobox, "Use ++ or -- prefixes to change by given value.\r\nUse +++ or --- prefixes to incre" +
"mentally change by given value.\r\nUse < or > prefixes to decrementally or increme" +
"ntally set given value.");
this.combobox.Validating += new System.ComponentModel.CancelEventHandler(this.combobox_Validating);
this.combobox.TextChanged += new System.EventHandler(this.combobox_TextChanged);
//
@ -86,5 +92,6 @@ namespace CodeImp.DoomBuilder.Controls
private System.Windows.Forms.ComboBox combobox;
private System.Windows.Forms.Button button;
private System.Windows.Forms.VScrollBar scrollbuttons;
private System.Windows.Forms.ToolTip tooltip;
}
}

View File

@ -89,7 +89,7 @@ namespace CodeImp.DoomBuilder.Controls
private void combobox_Validating(object sender, CancelEventArgs e)
{
string str = combobox.Text.Trim().ToLowerInvariant();
str = str.TrimStart('+', '-');
str = str.TrimStart('+', '-', '<', '>');
// Anything in the box?
if(combobox.Text.Trim().Length > 0)
@ -266,20 +266,22 @@ namespace CodeImp.DoomBuilder.Controls
// This checks if the number is relative
public bool CheckIsRelative()
{
// Prefixed with +++, ---, ++ or --?
// Prefixed with +++, ---, <, >, ++ or --?
string str = combobox.Text.Trim();
return (str.StartsWith("+++") || str.StartsWith("---") || str.StartsWith("++") || str.StartsWith("--"));
return (str.StartsWith("+++") || str.StartsWith("---")
|| str.StartsWith("++") || str.StartsWith("--")
|| str.StartsWith("<") || str.StartsWith(">"));
}
// This returns the selected value
public int GetResult(int original) { return GetResult(original, 0); } //mxd
public int GetResult(int original, int offset)
public int GetResult(int original, int step)
{
int result;
// Strip prefixes
string str = combobox.Text.Trim().ToLowerInvariant();
string numstr = str.TrimStart('+', '-'); //mxd
string numstr = str.TrimStart('+', '-', '<', '>'); //mxd
// Anything in the box?
if(numstr.Length > 0)
@ -290,7 +292,7 @@ namespace CodeImp.DoomBuilder.Controls
// Add offset to number
int num;
if(!int.TryParse(numstr, out num)) num = 0;
result = num + offset;
result = original + num * step;
}
//mxd. Prefixed with ---?
else if(str.StartsWith("---"))
@ -298,7 +300,23 @@ namespace CodeImp.DoomBuilder.Controls
// Subtract offset from number
int num;
if(!int.TryParse(numstr, out num)) num = 0;
result = num - offset;
result = original - num * step;
}
// mxd. Prefixed with <?
else if(str.StartsWith("<"))
{
// Incremental decrease
int num;
if(!int.TryParse(numstr, out num)) num = 0;
result = num - step;
}
// mxd. Prefixed with >?
else if(str.StartsWith(">"))
{
// Incremental increase
int num;
if(!int.TryParse(numstr, out num)) num = 0;
result = num + step;
}
// Prefixed with ++?
else if(str.StartsWith("++"))

View File

@ -120,6 +120,9 @@
<metadata name="combobox.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>
<metadata name="button.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View File

@ -133,7 +133,7 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Apply
public void Apply(Linedef l, int offset)
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
@ -161,7 +161,7 @@ namespace CodeImp.DoomBuilder.Controls
// Apply classic arg
case ArgZeroMode.DEFAULT:
l.Args[0] = arg0.GetResult(l.Args[0], offset);
l.Args[0] = arg0.GetResult(l.Args[0], step);
if(l.Fields.ContainsKey("arg0str")) l.Fields.Remove("arg0str");
break;
@ -169,13 +169,13 @@ namespace CodeImp.DoomBuilder.Controls
}
// Apply the rest of args
l.Args[1] = arg1.GetResult(l.Args[1], offset);
l.Args[2] = arg2.GetResult(l.Args[2], offset);
l.Args[3] = arg3.GetResult(l.Args[3], offset);
l.Args[4] = arg4.GetResult(l.Args[4], offset);
l.Args[1] = arg1.GetResult(l.Args[1], step);
l.Args[2] = arg2.GetResult(l.Args[2], step);
l.Args[3] = arg3.GetResult(l.Args[3], step);
l.Args[4] = arg4.GetResult(l.Args[4], step);
}
public void Apply(Thing t, int offset)
public void Apply(Thing t, 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
@ -203,7 +203,7 @@ namespace CodeImp.DoomBuilder.Controls
// Apply classic arg
case ArgZeroMode.DEFAULT:
t.Args[0] = arg0.GetResult(t.Args[0], offset);
t.Args[0] = arg0.GetResult(t.Args[0], step);
if(t.Fields.ContainsKey("arg0str")) t.Fields.Remove("arg0str");
break;
@ -211,10 +211,10 @@ namespace CodeImp.DoomBuilder.Controls
}
// Apply the rest of args
t.Args[1] = arg1.GetResult(t.Args[1], offset);
t.Args[2] = arg2.GetResult(t.Args[2], offset);
t.Args[3] = arg3.GetResult(t.Args[3], offset);
t.Args[4] = arg4.GetResult(t.Args[4], offset);
t.Args[1] = arg1.GetResult(t.Args[1], step);
t.Args[2] = arg2.GetResult(t.Args[2], step);
t.Args[3] = arg3.GetResult(t.Args[3], step);
t.Args[4] = arg4.GetResult(t.Args[4], step);
}
#endregion

View File

@ -228,7 +228,7 @@ namespace CodeImp.DoomBuilder.Controls
string textpart = this.Text;
// Strip prefixes
textpart = textpart.Replace("+", "").Replace("-", "").Replace("*", "").Replace("/", ""); //mxd
textpart = textpart.TrimStart('+', '-', '*', '/'); //mxd
// Any numbers left?
if(textpart.Length > 0)