debug ui for natural inventory state

This commit is contained in:
austin 2025-05-13 14:28:49 -04:00
parent 5c062ac984
commit bea7626042
3 changed files with 45 additions and 0 deletions

View File

@ -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

View File

@ -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();
}
}
}

View File

@ -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();
}