Files
UnityExplorer/src/CacheObject/CacheConfigEntry.cs

46 lines
1.4 KiB
C#
Raw Normal View History

using UnityExplorer.CacheObject.Views;
using UnityExplorer.Config;
2021-05-13 23:03:30 +10:00
namespace UnityExplorer.CacheObject
2021-05-13 23:03:30 +10:00
{
public class CacheConfigEntry : CacheObjectBase
{
public CacheConfigEntry(IConfigElement configElement)
{
this.RefConfigElement = configElement;
this.FallbackType = configElement.ElementType;
2021-05-13 23:03:30 +10:00
this.NameLabelText = $"<color=cyan>{configElement.Name}</color>" +
$"\r\n<color=grey><i>{configElement.Description}</i></color>";
this.NameLabelTextRaw = string.Empty;
2021-05-13 23:03:30 +10:00
configElement.OnValueChangedNotify += UpdateValueFromSource;
}
public IConfigElement RefConfigElement;
public override bool ShouldAutoEvaluate => true;
public override bool HasArguments => false;
public override bool CanWrite => true;
public void UpdateValueFromSource()
{
2021-05-15 06:20:07 +10:00
//if (RefConfigElement.BoxedValue.Equals(this.Value))
// return;
2021-05-13 23:03:30 +10:00
SetValueFromSource(RefConfigElement.BoxedValue);
if (this.CellView != null)
this.SetDataToCell(CellView);
2021-05-13 23:03:30 +10:00
}
public override void TrySetUserValue(object value)
{
this.Value = value;
RefConfigElement.BoxedValue = value;
}
protected override bool TryAutoEvaluateIfUnitialized(CacheObjectCell cell) => true;
2021-05-13 23:03:30 +10:00
}
}