inventory menu fixes and work
This commit is contained in:
		
							parent
							
								
									e6d946db53
								
							
						
					
					
						commit
						1e13c55f1f
					
				| @ -779,6 +779,7 @@ Fix equipped item packet not being sent to creature's player | |||||||
| Component-ify natural and equip inventory menus | Component-ify natural and equip inventory menus | ||||||
| Post Processing Pipeline w/ blur | Post Processing Pipeline w/ blur | ||||||
| Blur on open inventory/main menu in game | Blur on open inventory/main menu in game | ||||||
|  | Remove legacy UI handling of positioning -- entirely reliant on yoga now | ||||||
| 
 | 
 | ||||||
| (09/17/2024) | (09/17/2024) | ||||||
| Framebuffer position drilling | Framebuffer position drilling | ||||||
|  | |||||||
| @ -4,6 +4,7 @@ import java.util.List; | |||||||
| 
 | 
 | ||||||
| import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType; | import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType; | ||||||
| import electrosphere.engine.Globals; | import electrosphere.engine.Globals; | ||||||
|  | import electrosphere.engine.signal.Signal.SignalType; | ||||||
| import electrosphere.entity.Entity; | import electrosphere.entity.Entity; | ||||||
| import electrosphere.entity.state.equip.ClientEquipState; | import electrosphere.entity.state.equip.ClientEquipState; | ||||||
| import electrosphere.entity.state.inventory.InventoryUtils; | import electrosphere.entity.state.inventory.InventoryUtils; | ||||||
| @ -19,6 +20,7 @@ import electrosphere.renderer.ui.elements.Div; | |||||||
| import electrosphere.renderer.ui.elements.ImagePanel; | import electrosphere.renderer.ui.elements.ImagePanel; | ||||||
| import electrosphere.renderer.ui.elements.Label; | import electrosphere.renderer.ui.elements.Label; | ||||||
| import electrosphere.renderer.ui.elementtypes.ClickableElement.ClickEventCallback; | import electrosphere.renderer.ui.elementtypes.ClickableElement.ClickEventCallback; | ||||||
|  | import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment; | ||||||
| import electrosphere.renderer.ui.elementtypes.ContainerElement; | import electrosphere.renderer.ui.elementtypes.ContainerElement; | ||||||
| import electrosphere.renderer.ui.elementtypes.DraggableElement.DragEventCallback; | import electrosphere.renderer.ui.elementtypes.DraggableElement.DragEventCallback; | ||||||
| import electrosphere.renderer.ui.elementtypes.Element; | import electrosphere.renderer.ui.elementtypes.Element; | ||||||
| @ -80,18 +82,20 @@ public class EquipmentInventoryPanel { | |||||||
|         inventoryLabel.setText("CHARACTER"); |         inventoryLabel.setText("CHARACTER"); | ||||||
|         div.addChild(inventoryLabel); |         div.addChild(inventoryLabel); | ||||||
| 
 | 
 | ||||||
|         // int columns = 8; | 
 | ||||||
|         // int columnWidth = 60; |         { | ||||||
|         // int rowHeight = 60; |             Div leftSlots = Div.createCol(); | ||||||
|         int slotSpacing = 30; |             leftSlots.setFlexGrow(1); | ||||||
|  |             Div rightSlots = Div.createCol(); | ||||||
|  |             rightSlots.setFlexGrow(1); | ||||||
|  |             rightSlots.setAlignItems(YogaAlignment.End); | ||||||
| 
 | 
 | ||||||
|             List<String> slots = inventory.getSlots(); |             List<String> slots = inventory.getSlots(); | ||||||
|         int numSlots = slots.size(); |  | ||||||
|             EquipPoint equipPoint = null; |             EquipPoint equipPoint = null; | ||||||
|         // int numRows = (numSlots / 2) + (numSlots % 2 == 1 ? 1 : 0); |  | ||||||
| 
 | 
 | ||||||
|         int incrementer = 0; |             for(int i = 0; i < slots.size(); i++){ | ||||||
|         for(int i = 0; i < numSlots; i++){ |                 Div colContainer = i % 2 == 0 ? leftSlots : rightSlots; | ||||||
|  |                 boolean endAlign = i % 2 == 1; | ||||||
|                 String texturePath = "Textures/ui/uiFrame1.png"; |                 String texturePath = "Textures/ui/uiFrame1.png"; | ||||||
|                 boolean hasItem = false; |                 boolean hasItem = false; | ||||||
|                 String slotId = slots.get(i); |                 String slotId = slots.get(i); | ||||||
| @ -117,16 +121,12 @@ public class EquipmentInventoryPanel { | |||||||
|                     } |                     } | ||||||
|                     int panelWidth = 50; |                     int panelWidth = 50; | ||||||
|                     int panelHeight = 50; |                     int panelHeight = 50; | ||||||
|                 int posX = 20; |                     ImagePanel panel = ImagePanel.createImagePanel(texturePath); | ||||||
|                 if((incrementer % 2) == 1){ |                     panel.setWidth(50); | ||||||
|                     posX = posX + 400; |                     panel.setHeight(50); | ||||||
|  |                     if(endAlign){ | ||||||
|  |                         panel.setAlignSelf(YogaAlignment.End); | ||||||
|                     } |                     } | ||||||
|                 int posXf = posX; |  | ||||||
|                 int posY = 60 + (i / 2 * (panelHeight + slotSpacing)); |  | ||||||
|                 int posYf = posY; |  | ||||||
|                 int itemPosX = posX; |  | ||||||
|                 int itemPosY = posY; |  | ||||||
|                 ImagePanel panel = ImagePanel.createImagePanelAbsolute(posX,posY,panelWidth,panelHeight,texturePath); |  | ||||||
|                     if(hasItem == true){ |                     if(hasItem == true){ | ||||||
|                         //literally just here to get around finality of variable within callback |                         //literally just here to get around finality of variable within callback | ||||||
|                         String finalSlotId = slotId; |                         String finalSlotId = slotId; | ||||||
| @ -138,9 +138,17 @@ public class EquipmentInventoryPanel { | |||||||
|                                 ContainerElement container = (ContainerElement)panel.getParent(); |                                 ContainerElement container = (ContainerElement)panel.getParent(); | ||||||
|                                 container.removeChild(panel); |                                 container.removeChild(panel); | ||||||
|                                 WindowUtils.pushItemIconToItemWindow(panel); |                                 WindowUtils.pushItemIconToItemWindow(panel); | ||||||
|  |                                 panel.setAbsolutePosition(true); | ||||||
|                                 //add a dummy icon in place of the existing one |                                 //add a dummy icon in place of the existing one | ||||||
|                             dummyPanel = ImagePanel.createImagePanelAbsolute(posXf,posYf,panelWidth,panelHeight,"Textures/ui/uiFrame1.png"); |                                 { | ||||||
|  |                                     dummyPanel = ImagePanel.createImagePanel("Textures/ui/uiFrame1.png"); | ||||||
|  |                                     dummyPanel.setWidth(50); | ||||||
|  |                                     dummyPanel.setHeight(50); | ||||||
|  |                                     if(endAlign){ | ||||||
|  |                                         dummyPanel.setAlignSelf(YogaAlignment.End); | ||||||
|  |                                     } | ||||||
|                                     container.addChild(dummyPanel); |                                     container.addChild(dummyPanel); | ||||||
|  |                                 } | ||||||
|                                 //play sound effect |                                 //play sound effect | ||||||
|                                 if(Globals.virtualAudioSourceManager != null){ |                                 if(Globals.virtualAudioSourceManager != null){ | ||||||
|                                     Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventoryGrabItem.ogg", VirtualAudioSourceType.UI, false); |                                     Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventoryGrabItem.ogg", VirtualAudioSourceType.UI, false); | ||||||
| @ -151,21 +159,21 @@ public class EquipmentInventoryPanel { | |||||||
|                             // System.out.println("Drag"); |                             // System.out.println("Drag"); | ||||||
|                             panel.setPositionX(event.getCurrentX() - panelWidth / 2); |                             panel.setPositionX(event.getCurrentX() - panelWidth / 2); | ||||||
|                             panel.setPositionY(event.getCurrentY() - panelHeight / 2); |                             panel.setPositionY(event.getCurrentY() - panelHeight / 2); | ||||||
|  |                             Globals.signalSystem.post(SignalType.YOGA_APPLY, Globals.elementService.getWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER)); | ||||||
|                             return false; |                             return false; | ||||||
|                         }}); |                         }}); | ||||||
|                         panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){ |                         panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){ | ||||||
|                         if(panel.getParent() != div){ |                             if(panel.getParent() != colContainer){ | ||||||
|                                 if(panel.getParent() != null){ |                                 if(panel.getParent() != null){ | ||||||
|                                     ContainerElement container = (ContainerElement)panel.getParent(); |                                     ContainerElement container = (ContainerElement)panel.getParent(); | ||||||
|                                     container.removeChild(panel); |                                     container.removeChild(panel); | ||||||
|                                 } |                                 } | ||||||
|                                 Globals.elementService.fireEvent(event, event.getCurrentX(), event.getCurrentY()); |                                 Globals.elementService.fireEvent(event, event.getCurrentX(), event.getCurrentY()); | ||||||
|                             div.addChild(panel); |                                 colContainer.addChild(panel); | ||||||
|  |                                 panel.setAbsolutePosition(false); | ||||||
|                             } |                             } | ||||||
|                             //dummy panel handling |                             //dummy panel handling | ||||||
|                             destroyDummyPanel(); |                             destroyDummyPanel(); | ||||||
|                         panel.setPositionX(div.getAbsoluteX() + itemPosX); |  | ||||||
|                         panel.setPositionY(div.getAbsoluteY() + itemPosY); |  | ||||||
|                             return false; |                             return false; | ||||||
|                         }}); |                         }}); | ||||||
|                          |                          | ||||||
| @ -224,24 +232,19 @@ public class EquipmentInventoryPanel { | |||||||
|                             return false; |                             return false; | ||||||
|                         }}); |                         }}); | ||||||
|                     } |                     } | ||||||
|                 div.addChild(panel); |                     colContainer.addChild(panel); | ||||||
| 
 | 
 | ||||||
|                     //create the slot text |                     //create the slot text | ||||||
|                 posX = 80; |  | ||||||
|                 if((incrementer % 2) == 1){ |  | ||||||
|                     posX = posX + 190; |  | ||||||
|                 } |  | ||||||
|                 posY = posY + 15; |  | ||||||
|                     Label slotText = new Label(0.7f); |                     Label slotText = new Label(0.7f); | ||||||
|                     slotText.setText(slots.get(i)); |                     slotText.setText(slots.get(i)); | ||||||
|                 slotText.setPositionX(posX); |                     colContainer.addChild(slotText); | ||||||
|                 slotText.setPositionY(posY); |  | ||||||
|                 slotText.setAbsolutePosition(true); |  | ||||||
|                 div.addChild(slotText); |  | ||||||
| 
 |  | ||||||
|                 incrementer++; |  | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |             Div columnContainer = Div.createRow(leftSlots,rightSlots); | ||||||
|  |             columnContainer.setAlignItems(YogaAlignment.Between); | ||||||
|  |             columnContainer.setFlexGrow(1); | ||||||
|  |             div.addChild(columnContainer); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         return div; |         return div; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ package electrosphere.renderer.ui.components; | |||||||
| 
 | 
 | ||||||
| import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType; | import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType; | ||||||
| import electrosphere.engine.Globals; | import electrosphere.engine.Globals; | ||||||
|  | import electrosphere.engine.signal.Signal.SignalType; | ||||||
| import electrosphere.entity.Entity; | import electrosphere.entity.Entity; | ||||||
| import electrosphere.entity.state.equip.ClientEquipState; | import electrosphere.entity.state.equip.ClientEquipState; | ||||||
| import electrosphere.entity.state.inventory.InventoryUtils; | import electrosphere.entity.state.inventory.InventoryUtils; | ||||||
| @ -149,6 +150,7 @@ public class NaturalInventoryPanel { | |||||||
|                         // System.out.println("Drag"); |                         // System.out.println("Drag"); | ||||||
|                         panel.setPositionX(event.getCurrentX() - panelWidth / 2); |                         panel.setPositionX(event.getCurrentX() - panelWidth / 2); | ||||||
|                         panel.setPositionY(event.getCurrentY() - panelHeight / 2); |                         panel.setPositionY(event.getCurrentY() - panelHeight / 2); | ||||||
|  |                         Globals.signalSystem.post(SignalType.YOGA_APPLY, Globals.elementService.getWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER)); | ||||||
|                         return false; |                         return false; | ||||||
|                     }}); |                     }}); | ||||||
|                     panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){ |                     panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){ | ||||||
|  | |||||||
| @ -37,14 +37,14 @@ public class PlayerInventoryWindow { | |||||||
|         rVal.setParentAlignItem(YogaAlignment.Center); |         rVal.setParentAlignItem(YogaAlignment.Center); | ||||||
|         rVal.setParentJustifyContent(YogaJustification.Center); |         rVal.setParentJustifyContent(YogaJustification.Center); | ||||||
| 
 | 
 | ||||||
|         if(InventoryUtils.hasNaturalInventory(entity)){ |  | ||||||
|             rVal.addChild(NaturalInventoryPanel.createNaturalInventoryPanel(entity)); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(InventoryUtils.hasEquipInventory(entity)){ |         if(InventoryUtils.hasEquipInventory(entity)){ | ||||||
|             rVal.addChild(EquipmentInventoryPanel.createEquipmentInventoryPanel(entity)); |             rVal.addChild(EquipmentInventoryPanel.createEquipmentInventoryPanel(entity)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         if(InventoryUtils.hasNaturalInventory(entity)){ | ||||||
|  |             rVal.addChild(NaturalInventoryPanel.createNaturalInventoryPanel(entity)); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         Globals.signalSystem.post(SignalType.YOGA_APPLY, rVal); |         Globals.signalSystem.post(SignalType.YOGA_APPLY, rVal); | ||||||
| 
 | 
 | ||||||
|          |          | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user