2013-07-19 15:30:58 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
2015-03-23 14:19:23 +00:00
|
|
|
|
using System.Globalization;
|
2013-06-10 14:04:23 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
2013-07-19 15:30:58 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Properties;
|
|
|
|
|
|
|
|
|
|
#endregion
|
2013-06-10 14:04:23 +00:00
|
|
|
|
|
2016-04-27 09:13:07 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.Controls
|
2013-06-10 14:04:23 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class PairedFieldsControl : UserControl
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
#region ================== Events
|
|
|
|
|
|
|
|
|
|
public event EventHandler OnValuesChanged;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
2013-06-10 14:04:23 +00:00
|
|
|
|
private float defaultValue;
|
|
|
|
|
private string field1;
|
|
|
|
|
private string field2;
|
2013-07-19 15:30:58 +00:00
|
|
|
|
private bool allowValueLinking;
|
|
|
|
|
private bool linkValues;
|
|
|
|
|
private bool blockUpdate;
|
2014-07-11 10:13:26 +00:00
|
|
|
|
private readonly int bResetOffsetX;
|
2015-01-05 14:56:44 +00:00
|
|
|
|
private bool changed;
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
2013-06-10 14:04:23 +00:00
|
|
|
|
|
2015-01-05 14:56:44 +00:00
|
|
|
|
public bool NonDefaultValue { get { return changed; } }
|
2013-06-10 14:04:23 +00:00
|
|
|
|
public float DefaultValue { get { return defaultValue; } set { defaultValue = value; } }
|
|
|
|
|
public string Field1 { get { return field1; } set { field1 = value; } }
|
|
|
|
|
public string Field2 { get { return field2; } set { field2 = value; } }
|
|
|
|
|
public bool AllowDecimal { get { return value1.AllowDecimal; } set { value1.AllowDecimal = value; value2.AllowDecimal = value; } }
|
2013-07-08 13:39:06 +00:00
|
|
|
|
public int ButtonStep { get { return value1.ButtonStep; } set { value1.ButtonStep = value; value2.ButtonStep = value; } }
|
|
|
|
|
public float ButtonStepFloat { get { return value1.ButtonStepFloat; } set { value1.ButtonStepFloat = value; value2.ButtonStepFloat = value; } }
|
2015-03-23 14:19:23 +00:00
|
|
|
|
public float ButtonStepBig { get { return value1.ButtonStepBig; } set { value1.ButtonStepBig = value; value2.ButtonStepBig = value; } }
|
|
|
|
|
public float ButtonStepSmall { get { return value1.ButtonStepSmall; } set { value1.ButtonStepSmall = value; value2.ButtonStepSmall = value; } }
|
|
|
|
|
public bool ButtonStepsUseModifierKeys { get { return value1.ButtonStepsUseModifierKeys; } set { value1.ButtonStepsUseModifierKeys = value; value2.ButtonStepsUseModifierKeys = value; } }
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public bool AllowValueLinking { get { return allowValueLinking; } set { allowValueLinking = value; UpdateButtons(); } }
|
|
|
|
|
public bool LinkValues { get { return linkValues; } set { linkValues = value; UpdateButtons(); } }
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public PairedFieldsControl()
|
|
|
|
|
{
|
2013-06-10 14:04:23 +00:00
|
|
|
|
InitializeComponent();
|
2013-07-29 12:01:06 +00:00
|
|
|
|
bResetOffsetX = this.Width - bReset.Left;
|
2013-06-10 14:04:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-19 15:30:58 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public void SetValuesFrom(UniFields fields, bool first)
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
blockUpdate = true;
|
|
|
|
|
|
2013-06-25 12:35:13 +00:00
|
|
|
|
string newValue1;
|
|
|
|
|
string newValue2;
|
2013-06-10 14:04:23 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(AllowDecimal)
|
|
|
|
|
{
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
newValue1 = ((float)Math.Round(UniFields.GetFloat(fields, field1, defaultValue), 2)).ToString();
|
|
|
|
|
newValue2 = ((float)Math.Round(UniFields.GetFloat(fields, field2, defaultValue), 2)).ToString();
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
newValue1 = ((float)Math.Round(UniFields.GetFloat(fields, field1, defaultValue))).ToString();
|
|
|
|
|
newValue2 = ((float)Math.Round(UniFields.GetFloat(fields, field2, defaultValue))).ToString();
|
2013-06-25 12:35:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(first)
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
value1.Text = newValue1;
|
|
|
|
|
value2.Text = newValue2;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
2015-02-06 09:01:33 +00:00
|
|
|
|
else
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-02-06 09:01:33 +00:00
|
|
|
|
if(!string.IsNullOrEmpty(value1.Text)) value1.Text = (value1.Text != newValue1 ? string.Empty : newValue1);
|
|
|
|
|
if(!string.IsNullOrEmpty(value2.Text)) value2.Text = (value2.Text != newValue2 ? string.Empty : newValue2);
|
2013-07-19 15:30:58 +00:00
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
|
CheckValues();
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
|
|
|
|
blockUpdate = false;
|
2013-06-10 14:04:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public void ApplyTo(UniFields fields, int min, int max, float oldValue1, float oldValue2)
|
|
|
|
|
{
|
2016-02-01 22:04:00 +00:00
|
|
|
|
if(!string.IsNullOrEmpty(value1.Text))
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
UniFields.SetFloat(fields, field1, General.Clamp(value1.GetResultFloat(oldValue1), min, max), defaultValue);
|
2013-07-19 15:30:58 +00:00
|
|
|
|
else
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
UniFields.SetFloat(fields, field1, oldValue1, defaultValue);
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
2016-02-01 22:04:00 +00:00
|
|
|
|
if(!string.IsNullOrEmpty(value2.Text))
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
UniFields.SetFloat(fields, field2, General.Clamp(value2.GetResultFloat(oldValue2), min, max), defaultValue);
|
2013-07-19 15:30:58 +00:00
|
|
|
|
else
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
UniFields.SetFloat(fields, field2, oldValue2, defaultValue);
|
2013-06-10 14:04:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void CheckValues()
|
|
|
|
|
{
|
2015-01-05 14:56:44 +00:00
|
|
|
|
changed = string.IsNullOrEmpty(value1.Text) || string.IsNullOrEmpty(value2.Text)
|
2015-07-26 23:18:13 +00:00
|
|
|
|
|| value1.GetResultFloat(defaultValue, 0) != defaultValue || value2.GetResultFloat(defaultValue, 0) != defaultValue;
|
2013-06-11 08:05:32 +00:00
|
|
|
|
bReset.Visible = changed;
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
|
|
|
|
if(!blockUpdate && OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void UpdateButtons()
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
bLink.Visible = allowValueLinking;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(!allowValueLinking)
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
bReset.Left = bLink.Left;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-07-29 12:01:06 +00:00
|
|
|
|
bReset.Left = this.Width - bResetOffsetX;
|
2013-07-19 15:30:58 +00:00
|
|
|
|
bLink.Image = (linkValues ? Resources.Link : Resources.Unlink);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Events
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void bLink_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
linkValues = !linkValues;
|
|
|
|
|
bLink.Image = (linkValues ? Resources.Link : Resources.Unlink);
|
2013-06-10 14:04:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void bReset_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-03-23 14:19:23 +00:00
|
|
|
|
value1.Text = defaultValue.ToString(CultureInfo.CurrentCulture);
|
|
|
|
|
value2.Text = defaultValue.ToString(CultureInfo.CurrentCulture);
|
2014-12-03 23:15:26 +00:00
|
|
|
|
CheckValues();
|
2013-06-10 14:04:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void value1_WhenTextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
if(blockUpdate) return;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(linkValues)
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
blockUpdate = true;
|
|
|
|
|
value2.Text = value1.Text;
|
|
|
|
|
blockUpdate = false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
CheckValues();
|
2013-07-19 15:30:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void value2_WhenTextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
if(blockUpdate) return;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(linkValues)
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
blockUpdate = true;
|
|
|
|
|
value1.Text = value2.Text;
|
|
|
|
|
blockUpdate = false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
CheckValues();
|
2013-06-10 14:04:23 +00:00
|
|
|
|
}
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
2013-06-10 14:04:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|