mirror of
https://github.com/riperiperi/FreeSO
synced 2026-08-13 20:26:13 -04:00
MPL per-file was used in older project files, but should apply to the whole project, so having it there was redundant.
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using FSO.SimAntics.Engine;
|
|
using FSO.IDE.EditorComponent.OperandForms.DataProviders;
|
|
|
|
namespace FSO.IDE.EditorComponent.OperandForms
|
|
{
|
|
public partial class OpValueControl : UserControl, IOpControl
|
|
{
|
|
private OpValueBoundsProvider BoundsProvider;
|
|
private BHAVEditor Master;
|
|
private VMPrimitiveOperand Operand;
|
|
private EditorScope Scope;
|
|
private string Property;
|
|
|
|
private bool IgnoreSet;
|
|
|
|
public OpValueControl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public OpValueControl(BHAVEditor master, EditorScope scope, VMPrimitiveOperand operand, string title, string property, OpValueBoundsProvider bounds, bool isHex = false)
|
|
{
|
|
InitializeComponent();
|
|
Master = master;
|
|
Scope = scope;
|
|
Operand = operand;
|
|
TitleLabel.Text = title;
|
|
ValueEntry.Hexadecimal = isHex;
|
|
Property = property;
|
|
BoundsProvider = bounds;
|
|
this.Dock = DockStyle.Fill;
|
|
OperandUpdated();
|
|
}
|
|
|
|
public void OperandUpdated()
|
|
{
|
|
var bounds = BoundsProvider.GetBounds(Scope, Operand);
|
|
ValueEntry.Minimum = bounds[0];
|
|
ValueEntry.Maximum = bounds[1];
|
|
|
|
var prop = OpUtils.GetOperandProperty(Operand, Property);
|
|
if (prop.GetType() == typeof(uint)) prop = unchecked((int)Convert.ToUInt32(prop));
|
|
int value = Convert.ToInt32(prop);
|
|
|
|
IgnoreSet = true;
|
|
ValueEntry.Value = value;
|
|
IgnoreSet = false;
|
|
}
|
|
|
|
private void ValueEntry_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (IgnoreSet) return;
|
|
OpUtils.SetOperandProperty(Operand, Property, ValueEntry.Value);
|
|
|
|
Master.SignalOperandUpdate();
|
|
}
|
|
|
|
}
|
|
}
|