open inventory entities ui on client
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-13 14:43:38 -04:00
parent 4d9ac7aae7
commit 7c9c15ff05
12 changed files with 87 additions and 41 deletions

View File

@ -43,6 +43,9 @@
"offsetZ" : 0.0
}
},
"inventoryData" : {
"naturalSize" : 30
},
"tokens": [
"GRAVITY"
],

View File

@ -1748,6 +1748,7 @@ Natural inventory size explicitly defined in data
Fix server life tree missing nullcheck
Inventory interaction type
Debug ui for natural inventory on entity view
Can open ui menu to view inventories of other entities on client

View File

@ -6,6 +6,7 @@ import electrosphere.client.entity.camera.CameraEntityUtils;
import electrosphere.client.entity.crosshair.Crosshair;
import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.client.ui.menu.dialog.DialogMenuGenerator;
import electrosphere.client.ui.menu.ingame.InventoryMainWindow;
import electrosphere.data.common.interact.InteractionData;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
@ -63,7 +64,8 @@ public class ButtonInteraction {
DialogMenuGenerator.displayEntityDialog(target);
} break;
case InteractionData.ON_INTERACT_INVENTORY: {
LoggerInterface.loggerEngine.WARNING("Interacting with inventory");
LoggerInterface.loggerEngine.DEBUG("Interacting with inventory");
InventoryMainWindow.viewInventory(target);
} break;
default: {
throw new Error("Unhandled interaction signal " + interactionData.getOnInteract());

View File

@ -70,7 +70,7 @@ public class EquipmentInventoryPanel {
//clear item container ui
WindowUtils.cleanItemDraggingWindow();
//re-render inventory
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
return false;
}
return true;
@ -150,7 +150,7 @@ public class EquipmentInventoryPanel {
container.removeChild(panel);
WindowUtils.pushItemIconToItemWindow(panel);
panel.setAbsolutePosition(true);
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
//play sound effect
if(Globals.virtualAudioSourceManager != null){
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(finalEnt));
@ -244,7 +244,7 @@ public class EquipmentInventoryPanel {
//clear item container ui
WindowUtils.cleanItemDraggingWindow();
//rerender inventories
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
return false;
}});
}

View File

@ -84,7 +84,7 @@ public class ItemIconPanel {
panel.setPositionType(YogaPositionType.Absolute);
panel.setPositionX(panel.getAbsoluteX());
panel.setPositionY(panel.getAbsoluteY());
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
//play sound effect
if(Globals.virtualAudioSourceManager != null){
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(finalEnt));
@ -194,7 +194,7 @@ public class ItemIconPanel {
//clear item container ui
WindowUtils.cleanItemDraggingWindow();
//rerender inventories
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
return false;
}});

View File

@ -71,7 +71,7 @@ public class NaturalInventoryPanel {
//clear item container ui
WindowUtils.cleanItemDraggingWindow();
//re-render inventory
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
}
}
}
@ -87,7 +87,7 @@ public class NaturalInventoryPanel {
//clear ui
WindowUtils.cleanItemDraggingWindow();
//re-render inventory
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
return true;
}});

View File

@ -82,7 +82,7 @@ public class ToolbarInventoryPanel {
//clear item container ui
WindowUtils.cleanItemDraggingWindow();
//re-render inventory
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
}
}
}
@ -98,7 +98,7 @@ public class ToolbarInventoryPanel {
//clear ui
WindowUtils.cleanItemDraggingWindow();
//re-render inventory
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
return true;
}});

View File

@ -40,6 +40,11 @@ public class WindowStrings {
*/
public static final String WINDOW_CHARACTER = "windowCharacter";
/**
* Window that is viewing the inventory of a targeted entity
*/
public static final String WINDOW_INVENTORY_TARGET = "windowInventoryTarget";
/**
* the debug menu
*/

View File

@ -195,7 +195,7 @@ public class WindowUtils {
if(Globals.RUN_CLIENT && Globals.playerEntity != null){
if(Globals.elementService.containsWindow(WindowStrings.WINDOW_CHARACTER)){
//redraw if necessary
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
}
}
}

View File

@ -20,7 +20,7 @@ import electrosphere.renderer.ui.elementtypes.NavigableElement.NavigationEventCa
import electrosphere.renderer.ui.events.NavigationEvent;
/**
* The player's inventory
* The main inventory display window
*/
public class InventoryMainWindow {
@ -35,11 +35,69 @@ public class InventoryMainWindow {
public static final int MIN_HEIGHT = 500;
/**
* Creates a character customizer panel
* @param race The race of the character
* @return The panel component
* Views an inventory of an entity
* @param entity The entity
*/
public static Window createPlayerInventoryWindow(Entity entity){
public static void viewInventory(Entity entity){
if(entity == Globals.playerEntity){
if(Globals.elementService.getWindow(WindowStrings.WINDOW_CHARACTER) == null){
//create window
Window mainMenuWindow = InventoryMainWindow.createInventoryWindow(entity);
//register
Globals.elementService.registerWindow(WindowStrings.WINDOW_CHARACTER, mainMenuWindow);
//make visible
WindowUtils.recursiveSetVisible(WindowStrings.WINDOW_CHARACTER, true);
//controls
Globals.controlHandler.hintUpdateControlState(ControlsState.INVENTORY);
//play sound effect
if(Globals.virtualAudioSourceManager != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_INVENTORY_OPEN, VirtualAudioSourceType.UI, false);
}
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(true);
//
Globals.openInventoriesCount++;
} else if(InventoryUtils.hasNaturalInventory(entity) && Globals.elementService.getWindow(WindowStrings.WINDOW_CHARACTER) != null){
Globals.elementService.closeWindow(WindowStrings.WINDOW_CHARACTER);
WindowUtils.clearTooltips();
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
if(Globals.virtualAudioSourceManager != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_INVENTORY_CLOSE, VirtualAudioSourceType.UI, false);
}
}
} else {
if(Globals.elementService.getWindow(WindowStrings.WINDOW_INVENTORY_TARGET) == null){
//create window
Window mainMenuWindow = InventoryMainWindow.createInventoryWindow(entity);
//register
Globals.elementService.registerWindow(WindowStrings.WINDOW_INVENTORY_TARGET, mainMenuWindow);
//make visible
WindowUtils.recursiveSetVisible(WindowStrings.WINDOW_INVENTORY_TARGET, true);
//controls
Globals.controlHandler.hintUpdateControlState(ControlsState.INVENTORY);
//play sound effect
if(Globals.virtualAudioSourceManager != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_INVENTORY_OPEN, VirtualAudioSourceType.UI, false);
}
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(true);
//
Globals.openInventoriesCount++;
} else if(InventoryUtils.hasNaturalInventory(entity) && Globals.elementService.getWindow(WindowStrings.WINDOW_INVENTORY_TARGET) != null){
Globals.elementService.closeWindow(WindowStrings.WINDOW_INVENTORY_TARGET);
WindowUtils.clearTooltips();
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
if(Globals.virtualAudioSourceManager != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_INVENTORY_CLOSE, VirtualAudioSourceType.UI, false);
}
}
}
}
/**
* Creates a window that views an entity's inventory
* @param entity The entity with an inventory
* @return The Window element for the window
*/
public static Window createInventoryWindow(Entity entity){
Window rVal = Window.createExpandableCenterAligned(Globals.renderingEngine.getOpenGLState());
rVal.setParentAlignItem(YogaAlignment.Center);
rVal.setParentJustifyContent(YogaJustification.Center);

View File

@ -38,7 +38,7 @@ public class MenuGeneratorsInventory {
//clear ui
WindowUtils.cleanItemDraggingWindow();
//re-render inventory
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity));
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.playerEntity));
//null globals
Globals.dragSourceInventory = null;
Globals.draggedItem = null;

View File

@ -715,30 +715,7 @@ public class ControlCategoryMainGame {
mainGameControlList.add(controlMap.get(INPUT_CODE_INVENTORY_OPEN));
inventoryControlList.add(controlMap.get(INPUT_CODE_INVENTORY_OPEN));
controlMap.get(INPUT_CODE_INVENTORY_OPEN).setOnClick(new ControlMethod(){public void execute(MouseState mouseState){
if(Globals.elementService.getWindow(WindowStrings.WINDOW_CHARACTER) == null){
//create window
Window mainMenuWindow = InventoryMainWindow.createPlayerInventoryWindow(Globals.playerEntity);
//register
Globals.elementService.registerWindow(WindowStrings.WINDOW_CHARACTER, mainMenuWindow);
//make visible
WindowUtils.recursiveSetVisible(WindowStrings.WINDOW_CHARACTER, true);
//controls
Globals.controlHandler.hintUpdateControlState(ControlsState.INVENTORY);
//play sound effect
if(Globals.virtualAudioSourceManager != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_INVENTORY_OPEN, VirtualAudioSourceType.UI, false);
}
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(true);
//
Globals.openInventoriesCount++;
} else if(InventoryUtils.hasNaturalInventory(Globals.playerEntity) && Globals.elementService.getWindow(WindowStrings.WINDOW_CHARACTER) != null){
Globals.elementService.closeWindow(WindowStrings.WINDOW_CHARACTER);
WindowUtils.clearTooltips();
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
if(Globals.virtualAudioSourceManager != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_INVENTORY_CLOSE, VirtualAudioSourceType.UI, false);
}
}
InventoryMainWindow.viewInventory(Globals.playerEntity);
}});
controlMap.get(INPUT_CODE_INVENTORY_OPEN).setRepeatTimeout(0.5f * Main.targetFrameRate);