🔎 Inspector Gadget 🔍

wip/source-generators
copygirl 1 year ago
parent 4903728e0e
commit b45a050526
  1. 12
      src/gaemstone.Client/Systems/EntityInspector.cs

@ -62,6 +62,8 @@ public class EntityInspector
public struct DocIcon { public char Value; }
private const string DefaultWindowTitle = "Inspector Gadget";
public void Initialize(EntityRef module)
{
void SetDocInfo(string path, float priority, string icon, float r, float g, float b)
@ -89,7 +91,7 @@ public class EntityInspector
foreach (var entity in Iterator.FromTerm(world, new(inspectorWindow)))
{ hasAnyInspector = true; break; }
if (ImGuiUtility.UIButton(0, Icon.Search, "Entity Inspector", hasAnyInspector))
if (ImGuiUtility.UIButton(0, Icon.Search, DefaultWindowTitle, hasAnyInspector))
NewEntityInspectorWindow(world);
}
@ -102,7 +104,8 @@ public class EntityInspector
ImGui.SetNextWindowPos(viewCenter, ImGuiCond.Appearing, new(0.5f, 0.5f));
ImGui.SetNextWindowSize(new(fontSize * 40, fontSize * 25), ImGuiCond.Appearing);
ImGui.PushFont(ImGui.GetIO().Fonts.Fonts[1]);
if (ImGui.Begin($"{Icon.Search} Entity Inspector##{window.Id}",
var title = window.GetDocName() ?? DefaultWindowTitle;
if (ImGui.Begin($"{Icon.Search} {title}###{window.Id}",
ref isOpen, ImGuiWindowFlags.NoScrollbar)) {
ImGui.PushFont(ImGui.GetIO().Fonts.Fonts[0]);
@ -237,7 +240,7 @@ public class EntityInspector
var visiblePathTextSize = ImGui.CalcTextSize(path.ToString()).X
+ style.ItemSpacing.X * 2 * (path.Count - 0.5f)
+ style.FramePadding.X * 2 * path.Count;
while ((visiblePath.Count > 3) && (visiblePathTextSize > availableWidth)) {
while ((visiblePath.Count > 3) && (visiblePathTextSize > availableWidth))
if (visiblePath[1] != "...") {
visiblePathTextSize -= ImGui.CalcTextSize(visiblePath[1]).X - ImGui.CalcTextSize("...").X;
visiblePath[1] = "...";
@ -246,7 +249,6 @@ public class EntityInspector
+ (style.ItemSpacing.X + style.FramePadding.X) * 2;
visiblePath.RemoveAt(2);
}
}
var numHiddenItems = path.Count - visiblePath.Count;
for (var i = 0; i < visiblePath.Count - 1; i++) {
@ -582,7 +584,7 @@ public class EntityInspector
private EntityRef NewEntityInspectorWindow(World world)
=> world.New().Add<InspectorWindow>().Set(new History())
.Build().SetDocName("Entity Inspector");
.Build().SetDocName(DefaultWindowTitle);
private void SetSelected(
EntityRef window, // The InspectorWindow entity.

Loading…
Cancel
Save