mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Basic entity highlighting
This commit is contained in:
@@ -716,6 +716,28 @@ namespace GlitchyEditor.EditWindows
|
||||
}
|
||||
}
|
||||
|
||||
private static Entity? ShowEntitySelector()
|
||||
{
|
||||
static char8[128] entitySearch = .();
|
||||
|
||||
Entity? result = null;
|
||||
|
||||
if (ImGui.BeginPopup("ENTITY_SELECTOR"))
|
||||
{
|
||||
ImGui.TextUnformatted("Search:");
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGui.InputText("##entitySearcher", &entitySearch, (uint64)entitySearch.Count))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void ShowEntityReceiver(ScriptFieldInstance* field, StringView fieldName, ScriptClass scriptClass)
|
||||
{
|
||||
var entityId = field.GetData<UUID>();
|
||||
@@ -724,7 +746,9 @@ namespace GlitchyEditor.EditWindows
|
||||
|
||||
String entityName = scope .(32);
|
||||
|
||||
if (fieldEntity case .Ok(Entity e))
|
||||
if (entityId == UUID(0))
|
||||
entityName.Set("None");
|
||||
else if (fieldEntity case .Ok(Entity e))
|
||||
entityName.Set(e.Name);
|
||||
else
|
||||
entityName..Clear().AppendF($"Missing entity ({entityId})");
|
||||
@@ -734,7 +758,8 @@ namespace GlitchyEditor.EditWindows
|
||||
|
||||
if (ImGui.Button(entityName))
|
||||
{
|
||||
// TODO: Show a selector or something
|
||||
if (fieldEntity case .Ok)
|
||||
Editor.Instance.EntityHierarchyWindow.HighlightEntity(fieldEntity);
|
||||
}
|
||||
|
||||
if (ImGui.BeginDragDropTarget())
|
||||
@@ -783,6 +808,8 @@ namespace GlitchyEditor.EditWindows
|
||||
}
|
||||
}
|
||||
|
||||
//private static Entity?
|
||||
|
||||
private static void ShowComponentReceiver(ScriptFieldInstance* field, StringView fieldName, ScriptClass scriptClass)
|
||||
{
|
||||
var entityId = field.GetData<UUID>();
|
||||
@@ -791,7 +818,9 @@ namespace GlitchyEditor.EditWindows
|
||||
|
||||
String entityName = scope .(32);
|
||||
|
||||
if (fieldEntity case .Ok(Entity e))
|
||||
if (entityId == UUID(0))
|
||||
entityName.Set("None");
|
||||
else if (fieldEntity case .Ok(Entity e))
|
||||
entityName.Set(e.Name);
|
||||
else
|
||||
entityName..Clear().AppendF($"Missing reference ({entityId})");
|
||||
@@ -801,7 +830,8 @@ namespace GlitchyEditor.EditWindows
|
||||
|
||||
if (ImGui.Button(entityName))
|
||||
{
|
||||
// TODO: Show a selector or something
|
||||
if (fieldEntity case .Ok)
|
||||
Editor.Instance.EntityHierarchyWindow.HighlightEntity(fieldEntity);
|
||||
}
|
||||
|
||||
if (ImGui.BeginDragDropTarget())
|
||||
|
||||
@@ -21,8 +21,26 @@ namespace GlitchyEditor.EditWindows
|
||||
|
||||
private List<Entity> _selectedEntities = new .() ~ delete _;
|
||||
|
||||
private Entity _entityToHighlight;
|
||||
|
||||
public List<Entity> SelectedEntities => _selectedEntities;
|
||||
|
||||
private List<Entity> _entitiesToUnfold = new .() ~ delete _;
|
||||
|
||||
public void HighlightEntity(Entity e)
|
||||
{
|
||||
_entityToHighlight = e;
|
||||
|
||||
Entity walker = _entityToHighlight;
|
||||
|
||||
while (walker.Parent != null)
|
||||
{
|
||||
walker = walker.Parent.Value;
|
||||
|
||||
_entitiesToUnfold.Add(walker);
|
||||
}
|
||||
}
|
||||
|
||||
public this(Editor editor, Scene scene)
|
||||
{
|
||||
_editor = editor;
|
||||
@@ -322,8 +340,21 @@ namespace GlitchyEditor.EditWindows
|
||||
if(inSelectedList)
|
||||
flags |= .Selected;
|
||||
|
||||
if (_entitiesToUnfold.Contains(tree.Value))
|
||||
{
|
||||
_entitiesToUnfold.Remove(tree.Value);
|
||||
|
||||
ImGui.SetNextItemOpen(true, .None);
|
||||
}
|
||||
|
||||
bool isOpen = ImGui.TreeNodeEx((void*)(uint)tree.Value.Handle.[Friend]Index, flags, $"{name}");
|
||||
|
||||
if (_entityToHighlight == tree.Value)
|
||||
{
|
||||
ImGui.SetScrollHereY(0);
|
||||
_entityToHighlight = .();
|
||||
}
|
||||
|
||||
ImGui.PushID((void*)(uint)tree.Value.Handle.[Friend]Index);
|
||||
|
||||
bool deleted = false;
|
||||
|
||||
Reference in New Issue
Block a user