freeso/TSOClient/FSO.IDE/EditorComponent/Primitives/RandomNumberDescriptor.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

38 lines
1.6 KiB
C#

using FSO.IDE.EditorComponent.Model;
using FSO.IDE.EditorComponent.OperandForms;
using FSO.IDE.EditorComponent.OperandForms.DataProviders;
using FSO.SimAntics.Engine.Primitives;
using System;
using System.Text;
using System.Windows.Forms;
namespace FSO.IDE.EditorComponent.Primitives
{
public class RandomNumberDescriptor : PrimitiveDescriptor
{
public override PrimitiveGroup Group { get { return PrimitiveGroup.Math; } }
public override PrimitiveReturnTypes Returns { get { return PrimitiveReturnTypes.Done; } }
public override Type OperandType { get { return typeof(VMRandomNumberOperand); } }
public override string GetBody(EditorScope scope)
{
var op = (VMRandomNumberOperand)Operand;
var result = new StringBuilder();
result.Append(scope.GetVarName(op.DestinationScope, (short)op.DestinationData));
result.Append(" := between 0 and ");
result.Append(scope.GetVarName(op.RangeScope, (short)op.RangeData));
return result.ToString();
}
public override void PopulateOperandView(BHAVEditor master, EditorScope escope, TableLayoutPanel panel)
{
panel.Controls.Add(new OpLabelControl(master, escope, Operand, new OpStaticTextProvider("Places a random number between 0 and the specified range into the specified variable scope.")));
panel.Controls.Add(new OpScopeControl(master, escope, Operand, "Range:", "RangeScope", "RangeData"));
panel.Controls.Add(new OpScopeControl(master, escope, Operand, "Destination:", "DestinationScope", "DestinationData"));
}
}
}