mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
ScriptCore: Open newly created dictionary entry
This commit is contained in:
@@ -13,6 +13,7 @@ public class DictionaryEditor
|
|||||||
{
|
{
|
||||||
private static object? dictionaryForNewValue = null;
|
private static object? dictionaryForNewValue = null;
|
||||||
private static DictionaryEntry newDictionaryValue = new();
|
private static DictionaryEntry newDictionaryValue = new();
|
||||||
|
private static object? keyLastCreated = null;
|
||||||
|
|
||||||
public static object? ShowEditor(object? reference, Type fieldType, string fieldName)
|
public static object? ShowEditor(object? reference, Type fieldType, string fieldName)
|
||||||
{
|
{
|
||||||
@@ -47,14 +48,6 @@ public class DictionaryEditor
|
|||||||
|
|
||||||
dictionaryForNewValue = dictionary;
|
dictionaryForNewValue = dictionary;
|
||||||
|
|
||||||
// TODO: show fake entry!
|
|
||||||
|
|
||||||
//object? newKey = ActivatorExtension.CreateInstanceSafe(keyType);
|
|
||||||
//object? newValue = ActivatorExtension.CreateInstanceSafe(valueType);
|
|
||||||
|
|
||||||
//if (newKey != null)
|
|
||||||
// dictionary!.Add(newKey, newValue);
|
|
||||||
|
|
||||||
newDictionaryValue = new DictionaryEntry();
|
newDictionaryValue = new DictionaryEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +67,13 @@ public class DictionaryEditor
|
|||||||
id++;
|
id++;
|
||||||
ImGui.PushID(id);
|
ImGui.PushID(id);
|
||||||
|
|
||||||
|
if (entry.Key == keyLastCreated)
|
||||||
|
{
|
||||||
|
// The current key is the one that was last created. Open the tree node.
|
||||||
|
ImGui.SetNextItemOpen(true);
|
||||||
|
keyLastCreated = null;
|
||||||
|
}
|
||||||
|
|
||||||
bool isEntryOpen = ImGui.TreeNode("");
|
bool isEntryOpen = ImGui.TreeNode("");
|
||||||
|
|
||||||
ImGui.SameLine(ImGui.GetWindowContentRegionMax().X - removeButtonWidth);
|
ImGui.SameLine(ImGui.GetWindowContentRegionMax().X - removeButtonWidth);
|
||||||
@@ -136,6 +136,7 @@ public class DictionaryEditor
|
|||||||
newEntries.Add(new DictionaryEntry(newKey, newDictionaryValue.Value));
|
newEntries.Add(new DictionaryEntry(newKey, newDictionaryValue.Value));
|
||||||
dictionaryForNewValue = null;
|
dictionaryForNewValue = null;
|
||||||
newDictionaryValue = new();
|
newDictionaryValue = new();
|
||||||
|
keyLastCreated = newKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
object newValue = EntityEditor.ShowFieldEditor(newDictionaryValue.Value, newDictionaryValue.Value?.GetType() ?? valueType, "Value");
|
object newValue = EntityEditor.ShowFieldEditor(newDictionaryValue.Value, newDictionaryValue.Value?.GetType() ?? valueType, "Value");
|
||||||
|
|||||||
Reference in New Issue
Block a user