freeso/TSOClient/FSO.IDE/EditorComponent/OperandForms/OpObjectControl.cs
riperiperi b57ebbd141 Cleanup: Remove most unused usings and MPL per-file licenses
MPL per-file was used in older project files, but should apply to the whole project, so having it there was redundant.
2023-11-25 03:45:29 +00:00

52 lines
1.5 KiB
C#

using System;
using System.Windows.Forms;
using FSO.SimAntics.Engine;
namespace FSO.IDE.EditorComponent.OperandForms
{
public partial class OpObjectControl : UserControl, IOpControl
{
private BHAVEditor Master;
private VMPrimitiveOperand Operand;
private EditorScope Scope;
private string GUIDProperty;
public OpObjectControl()
{
InitializeComponent();
}
public OpObjectControl(BHAVEditor master, EditorScope scope, VMPrimitiveOperand operand, string title, string guidProperty)
{
InitializeComponent();
this.Dock = DockStyle.Fill;
Master = master;
Scope = scope;
Operand = operand;
TitleLabel.Text = title;
GUIDProperty = guidProperty;
OperandUpdated();
}
public void OperandUpdated()
{
uint guid = Convert.ToUInt32(OpUtils.GetOperandProperty(Operand, GUIDProperty));
var obj = Content.Content.Get().WorldObjects.Get(guid);
ObjectLabel.Text = (obj == null) ? ("0x"+guid.ToString("X8")) : obj.OBJ.ChunkLabel;
}
private void EditButton_Click(object sender, EventArgs e)
{
var popup = new VarObjectSelect();
popup.ShowDialog();
if (popup.DialogResult == DialogResult.OK)
{
OpUtils.SetOperandProperty(Operand, GUIDProperty, popup.GUIDResult);
}
Master.SignalOperandUpdate();
}
}
}