mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Add support for strings and BoolX in script engine, show strings as textfields in editor
This commit is contained in:
@@ -274,6 +274,10 @@ internal class EntityEditor
|
||||
// TODO: Show component drop target
|
||||
ImGui.Text($"{fieldName} Component ({fieldType.Name})");
|
||||
}
|
||||
else if (fieldType == typeof(string))
|
||||
{
|
||||
newValue = ShowStringEditor(reference, fieldType, fieldName, attributes);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.EndDisabled();
|
||||
@@ -328,6 +332,29 @@ internal class EntityEditor
|
||||
return newValue;
|
||||
}
|
||||
|
||||
private static object ShowStringEditor(object reference, Type fieldType, string fieldName, IEnumerable<Attribute> attributes)
|
||||
{
|
||||
object newValue = DidNotChange;
|
||||
|
||||
TextFieldAttribute textField = GetAttribute<TextFieldAttribute>(attributes);
|
||||
|
||||
string value = reference as string ?? $"{float.MinValue}";
|
||||
|
||||
if (textField?.Multiline == true)
|
||||
{
|
||||
ImGui.Text(fieldName);
|
||||
if (ImGui.InputTextMultiline($"##{fieldName}", ref value, 1000, new Vector2(-1.0f, ImGui.GetTextLineHeight() * textField.TextFieldLines)))
|
||||
newValue = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ImGui.InputText(fieldName, ref value, 1000))
|
||||
newValue = value;
|
||||
}
|
||||
|
||||
return newValue;
|
||||
}
|
||||
|
||||
public static void ShowEditor(Type type, object reference)
|
||||
{
|
||||
T GetValue<T>(FieldInfo fieldInfo)
|
||||
|
||||
Reference in New Issue
Block a user