Made flags value field writable

This commit is contained in:
MascaraSnake 2016-01-13 00:35:07 +01:00
parent ef6f15d919
commit b2696af491
2 changed files with 51 additions and 13 deletions

View file

@ -430,15 +430,15 @@ namespace CodeImp.DoomBuilder.Windows
// flagsvalue
//
this.flagsvalue.AllowDecimal = false;
this.flagsvalue.AllowNegative = true;
this.flagsvalue.AllowRelative = true;
this.flagsvalue.AllowNegative = false;
this.flagsvalue.AllowRelative = false;
this.flagsvalue.ForeColor = System.Drawing.SystemColors.HotTrack;
this.flagsvalue.ImeMode = System.Windows.Forms.ImeMode.Off;
this.flagsvalue.Location = new System.Drawing.Point(177, 196);
this.flagsvalue.Name = "flagsvalue";
this.flagsvalue.ReadOnly = true;
this.flagsvalue.Size = new System.Drawing.Size(72, 20);
this.flagsvalue.TabIndex = 14;
this.flagsvalue.TextChanged += new System.EventHandler(this.flagsvalue_TextChanged);
//
// missingflags
//

View file

@ -49,9 +49,11 @@ namespace CodeImp.DoomBuilder.Windows
private bool undocreated; //mxd
private static bool useabsoluteheight; //mxd
private List<ThingProperties> thingprops; //mxd
private bool flagsvalue_ignore = false;
private bool flags_ignore = false;
//mxd. Window setup stuff
private static Point location = Point.Empty;
//mxd. Window setup stuff
private static Point location = Point.Empty;
private struct ThingProperties //mxd
{
@ -449,7 +451,8 @@ namespace CodeImp.DoomBuilder.Windows
MakeUndo();
useabsoluteheight = cbAbsoluteHeight.Checked;
zlabel.Text = (useabsoluteheight ? "Z:" : "Height:");
flagsvalue.ReadOnly = cbAbsoluteHeight.Checked;
zlabel.Text = (useabsoluteheight ? "Z:" : "Height:");
preventchanges = true;
@ -535,7 +538,7 @@ namespace CodeImp.DoomBuilder.Windows
private void posZ_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
MakeUndo(); //mxd
int i = 0;
if(string.IsNullOrEmpty(posZ.Text))
@ -556,13 +559,43 @@ namespace CodeImp.DoomBuilder.Windows
}
}
flagsvalue.Text = evaluateFlagsValue();
if (!flagsvalue_ignore)
{
flagsvalue_ignore = true;
flagsvalue.Text = evaluateFlagsValue();
flagsvalue_ignore = false;
}
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
}
// Selected type changes
private void thingtype_OnTypeChanged(ThingTypeInfo value)
private void flagsvalue_TextChanged(object sender, EventArgs e)
{
if (!flagsvalue_ignore && !string.IsNullOrEmpty(flagsvalue.Text))
{
flagsvalue_ignore = true;
int value = General.Clamp(flagsvalue.GetResult(0),0,0xFFFF);
int i = 1;
flags_ignore = true;
foreach (CheckBox box in flags.Checkboxes)
{
box.Checked = ((value & i) == i);
i *= 2;
}
flags_ignore = false;
flags_OnValueChanged(this, null);
if (General.Map.SRB2)
{
int z = value >> 4;
posZ.Text = z.ToString();
}
flagsvalue_ignore = false;
}
}
// Selected type changes
private void thingtype_OnTypeChanged(ThingTypeInfo value)
{
thinginfo = value;
@ -617,7 +650,7 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
private void flags_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
if(flags_ignore || preventchanges) return;
// Gather enabled flags
HashSet<string> activeflags = new HashSet<string>();
@ -640,7 +673,12 @@ namespace CodeImp.DoomBuilder.Windows
//everything is OK
missingflags.Visible = false;
settingsgroup.ForeColor = SystemColors.ControlText;
flagsvalue.Text = evaluateFlagsValue();
if (!flagsvalue_ignore)
{
flagsvalue_ignore = true;
flagsvalue.Text = evaluateFlagsValue();
flagsvalue_ignore = false;
}
}
#endregion