mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-18 05:17:53 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
42 lines
997 B
C#
42 lines
997 B
C#
namespace Sandbox.UI;
|
|
|
|
/// <summary>
|
|
/// Like TextEntry, except just for numbers
|
|
/// </summary>
|
|
[CustomEditor( typeof( Vector2 ) )]
|
|
[CustomEditor( typeof( Vector3 ) )]
|
|
[CustomEditor( typeof( Vector4 ) )]
|
|
public partial class VectorControl : BaseControl
|
|
{
|
|
NumberEntry _x;
|
|
NumberEntry _y;
|
|
NumberEntry _z;
|
|
NumberEntry _w;
|
|
|
|
public VectorControl()
|
|
{
|
|
_x = AddChild<NumberEntry>( "x" );
|
|
_y = AddChild<NumberEntry>( "y" );
|
|
_z = AddChild<NumberEntry>( "z" );
|
|
_w = AddChild<NumberEntry>( "w" );
|
|
}
|
|
|
|
public override void Rebuild()
|
|
{
|
|
if ( Property == null ) return;
|
|
|
|
// get the vector3 as a so
|
|
if ( Property.TryGetAsObject( out var so ) )
|
|
{
|
|
_x.Property = so.GetProperty( "x" );
|
|
_y.Property = so.GetProperty( "y" );
|
|
|
|
_z.Property = so.GetProperty( "z" );
|
|
_z.Style.Display = _z.Property is not null ? DisplayMode.Flex : DisplayMode.None;
|
|
|
|
_w.Property = so.GetProperty( "w" );
|
|
_w.Style.Display = _w.Property is not null ? DisplayMode.Flex : DisplayMode.None;
|
|
}
|
|
}
|
|
}
|