diff --git a/BeefLibs/Beefy2D/src/utils/StructuredData.bf b/BeefLibs/Beefy2D/src/utils/StructuredData.bf index 6650424f..7dc6fd3a 100644 --- a/BeefLibs/Beefy2D/src/utils/StructuredData.bf +++ b/BeefLibs/Beefy2D/src/utils/StructuredData.bf @@ -589,6 +589,23 @@ namespace Beefy.utils return; } + public T GetCurEnum(T theDefault = default) where T : Enum + { + Object obj = GetCurrent(); + + Result result; + if (let str = obj as String) + result = Enum.Parse(str); + else if (obj is StringView) + result = Enum.Parse((StringView)obj); + else + return theDefault; + + if (result case .Ok(var val)) + return val; + return theDefault; + } + public int32 GetCurInt(int32 theDefault = 0) { Object aVal = GetCurrent();