From bea7626042aceb770af4aea89aaac88bb0313bf8 Mon Sep 17 00:00:00 2001 From: austin Date: Tue, 13 May 2025 14:28:49 -0400 Subject: [PATCH] debug ui for natural inventory state --- docs/src/progress/renderertodo.md | 1 + .../debug/entity/ImGuiEntityInventoryTab.java | 35 +++++++++++++++++++ .../menu/debug/entity/ImGuiEntityMacros.java | 9 +++++ 3 files changed, 45 insertions(+) create mode 100644 src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityInventoryTab.java diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 9eff8534..d0396229 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1747,6 +1747,7 @@ Full-sized wheat plants spawn in forest now Natural inventory size explicitly defined in data Fix server life tree missing nullcheck Inventory interaction type +Debug ui for natural inventory on entity view diff --git a/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityInventoryTab.java b/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityInventoryTab.java new file mode 100644 index 00000000..6237270c --- /dev/null +++ b/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityInventoryTab.java @@ -0,0 +1,35 @@ +package electrosphere.client.ui.menu.debug.entity; + +import electrosphere.entity.Entity; +import electrosphere.entity.state.inventory.InventoryUtils; +import electrosphere.entity.state.inventory.UnrelationalInventoryState; +import electrosphere.entity.types.item.ItemUtils; +import imgui.ImGui; + +/** + * Tab for inventory data + */ +public class ImGuiEntityInventoryTab { + + /** + * Inventory view + */ + protected static void drawInventoryTab(boolean show, Entity detailViewEntity){ + if(detailViewEntity == null){ + return; + } + if(show && ImGui.collapsingHeader("Inventory Data")){ + ImGui.indent(); + if(InventoryUtils.hasNaturalInventory(detailViewEntity)){ + if(ImGui.collapsingHeader("Natural Inventory")){ + UnrelationalInventoryState naturalInventory = InventoryUtils.getNaturalInventory(detailViewEntity); + for(Entity itemEnt : naturalInventory.getItems()){ + ImGui.text(itemEnt.getId() + " - " + ItemUtils.getType(itemEnt)); + } + } + } + ImGui.unindent(); + } + } + +} diff --git a/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityMacros.java b/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityMacros.java index bab493ee..a207c932 100644 --- a/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityMacros.java +++ b/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityMacros.java @@ -23,6 +23,7 @@ import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientToolbarState; import electrosphere.entity.state.foliage.AmbientFoliage; import electrosphere.entity.state.hitbox.HitboxCollectionState; +import electrosphere.entity.state.inventory.InventoryUtils; import electrosphere.entity.state.server.ServerPlayerViewDirTree; import electrosphere.entity.types.common.CommonEntityUtils; import electrosphere.entity.types.creature.CreatureUtils; @@ -73,6 +74,7 @@ public class ImGuiEntityMacros { private static boolean showPhysicsTab = false; //show physics values private static boolean showFoliageTab = false; //show foliage data private static boolean showToolbarTab = false; //show toolbar data + private static boolean showInventoryTab = false; //show inventory data private static boolean showDebugActionsTab = false; //show debug actions /** @@ -199,6 +201,12 @@ public class ImGuiEntityMacros { if(ClientToolbarState.getClientToolbarState(detailViewEntity) != null && ImGui.checkbox("Toolbar Data", showToolbarTab)){ showToolbarTab = !showToolbarTab; } + if( + (InventoryUtils.hasNaturalInventory(detailViewEntity) || InventoryUtils.hasEquipInventory(detailViewEntity) || InventoryUtils.hasToolbarInventory(detailViewEntity)) && + ImGui.checkbox("Inventory Data", showInventoryTab) + ){ + showInventoryTab = !showInventoryTab; + } if(ImGui.checkbox("Debug Actions", showDebugActionsTab)){ showDebugActionsTab = !showDebugActionsTab; } @@ -217,6 +225,7 @@ public class ImGuiEntityMacros { ImGuiEntityPhysicsTab.drawPhysicsView(showPhysicsTab, detailViewEntity); ImGuiEntityFoliageTab.drawFoliageView(showFoliageTab, detailViewEntity); ImGuiEntityToolbarTab.drawToolbarTab(showToolbarTab, detailViewEntity); + ImGuiEntityInventoryTab.drawInventoryTab(showInventoryTab, detailViewEntity); ImGuiEntityDebugActions.drawDebugActions(showDebugActionsTab, detailViewEntity); ImGuiEntityMacros.drawDataView(); }