mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
ControlSheetRow hides property based on ShowIf etc
This commit is contained in:
@@ -34,8 +34,15 @@ public class ControlSheet : Panel, IControlSheet
|
||||
|
||||
if ( Target is null ) return;
|
||||
|
||||
var so = Game.TypeLibrary.GetSerializedObject( Target );
|
||||
IControlSheet.FilterSortAndAdd( sheet, so.ToList() );
|
||||
if ( Target is List<SerializedProperty> propertyList )
|
||||
{
|
||||
IControlSheet.FilterSortAndAdd( sheet, propertyList );
|
||||
}
|
||||
else
|
||||
{
|
||||
var so = Game.TypeLibrary.GetSerializedObject( Target );
|
||||
IControlSheet.FilterSortAndAdd( sheet, so.ToList() );
|
||||
}
|
||||
}
|
||||
|
||||
int _hash;
|
||||
|
||||
@@ -13,6 +13,8 @@ public class ControlSheetRow : Panel
|
||||
Label _title;
|
||||
Panel _right;
|
||||
|
||||
InspectorVisibilityAttribute[] _visibilityAttributes;
|
||||
|
||||
public ControlSheetRow()
|
||||
{
|
||||
_left = AddChild<Panel>( "left" );
|
||||
@@ -24,6 +26,8 @@ public class ControlSheetRow : Panel
|
||||
internal void Initialize( SerializedProperty prop )
|
||||
{
|
||||
Property = prop;
|
||||
|
||||
_visibilityAttributes = Property.GetAttributes<InspectorVisibilityAttribute>()?.ToArray();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
@@ -39,4 +43,15 @@ public class ControlSheetRow : Panel
|
||||
if ( c is null ) return;
|
||||
_right.AddChild( c );
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
{
|
||||
base.Tick();
|
||||
|
||||
if ( _visibilityAttributes?.Length == 0 ) return;
|
||||
if ( Property.Parent is null ) return;
|
||||
|
||||
bool hidden = _visibilityAttributes.All( x => x.TestCondition( Property.Parent ) );
|
||||
SetClass( "hidden", hidden );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,11 @@ ControlSheetRow
|
||||
flex-shrink: 0;
|
||||
max-height: 32px;
|
||||
border-radius: 4px;
|
||||
|
||||
&.hidden
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
ControlSheetRow > .left
|
||||
|
||||
Reference in New Issue
Block a user