charge state work
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
c083aaf05f
commit
dec244c509
@ -2,6 +2,7 @@
|
|||||||
"items" : [
|
"items" : [
|
||||||
{
|
{
|
||||||
"id" : "Rock",
|
"id" : "Rock",
|
||||||
|
"maxStack" : 100,
|
||||||
"tokens" : [
|
"tokens" : [
|
||||||
"GRAVITY",
|
"GRAVITY",
|
||||||
"TARGETABLE"
|
"TARGETABLE"
|
||||||
@ -32,6 +33,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "Copper",
|
"id" : "Copper",
|
||||||
|
"maxStack" : 100,
|
||||||
"tokens" : [
|
"tokens" : [
|
||||||
"GRAVITY",
|
"GRAVITY",
|
||||||
"TARGETABLE"
|
"TARGETABLE"
|
||||||
@ -69,6 +71,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "Tin",
|
"id" : "Tin",
|
||||||
|
"maxStack" : 100,
|
||||||
"tokens" : [
|
"tokens" : [
|
||||||
"GRAVITY",
|
"GRAVITY",
|
||||||
"TARGETABLE"
|
"TARGETABLE"
|
||||||
@ -99,6 +102,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "Clay",
|
"id" : "Clay",
|
||||||
|
"maxStack" : 100,
|
||||||
"tokens" : [
|
"tokens" : [
|
||||||
"GRAVITY",
|
"GRAVITY",
|
||||||
"TARGETABLE"
|
"TARGETABLE"
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
"items" : [
|
"items" : [
|
||||||
{
|
{
|
||||||
"id" : "Log",
|
"id" : "Log",
|
||||||
|
"maxStack" : 100,
|
||||||
"tokens" : [
|
"tokens" : [
|
||||||
"GRAVITY",
|
"GRAVITY",
|
||||||
"TARGETABLE"
|
"TARGETABLE"
|
||||||
@ -32,6 +33,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "Stick",
|
"id" : "Stick",
|
||||||
|
"maxStack" : 100,
|
||||||
"tokens" : [
|
"tokens" : [
|
||||||
"GRAVITY",
|
"GRAVITY",
|
||||||
"TARGETABLE"
|
"TARGETABLE"
|
||||||
|
|||||||
@ -1603,6 +1603,8 @@ Texture loading from model files (ie can load texture path from model file)
|
|||||||
Clean up material class a bit
|
Clean up material class a bit
|
||||||
Cleaning up dead code
|
Cleaning up dead code
|
||||||
Fab items
|
Fab items
|
||||||
|
Items keep charge state
|
||||||
|
UI renders charge state
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,213 @@
|
|||||||
|
package electrosphere.client.ui.components;
|
||||||
|
|
||||||
|
import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
|
||||||
|
import electrosphere.client.ui.menu.WindowStrings;
|
||||||
|
import electrosphere.client.ui.menu.WindowUtils;
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||||
|
import electrosphere.engine.signal.Signal.SignalType;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
||||||
|
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||||
|
import electrosphere.entity.state.item.ClientChargeState;
|
||||||
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
|
import electrosphere.game.data.item.Item;
|
||||||
|
import electrosphere.renderer.ui.elements.Div;
|
||||||
|
import electrosphere.renderer.ui.elements.ImagePanel;
|
||||||
|
import electrosphere.renderer.ui.elements.Label;
|
||||||
|
import electrosphere.renderer.ui.elements.Tooltip;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.ContainerElement;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaPositionType;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.DraggableElement.DragEventCallback;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.HoverableElement.HoverEventCallback;
|
||||||
|
import electrosphere.renderer.ui.events.DragEvent;
|
||||||
|
import electrosphere.renderer.ui.events.HoverEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates item icon panels
|
||||||
|
*/
|
||||||
|
public class ItemIconPanel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tooltip for the currently hovered item
|
||||||
|
*/
|
||||||
|
static Tooltip itemTooltip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The starting drag container
|
||||||
|
*/
|
||||||
|
static ContainerElement dragStartContainer = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an item panel
|
||||||
|
* @param currentItem The item entity
|
||||||
|
* @return The item panel
|
||||||
|
*/
|
||||||
|
public static Div createPanel(Entity currentItem, int itemId, Object inventory){
|
||||||
|
Div rVal = Div.createDiv();
|
||||||
|
|
||||||
|
String texturePath = "Textures/ui/uiFrame1.png";
|
||||||
|
if(currentItem != null){
|
||||||
|
//get texture path from item
|
||||||
|
texturePath = ItemUtils.getItemIcon(currentItem);
|
||||||
|
}
|
||||||
|
Entity finalEnt = currentItem;
|
||||||
|
if(!Globals.assetManager.hasLoadedTexture(texturePath)){
|
||||||
|
Globals.assetManager.addTexturePathtoQueue(texturePath);
|
||||||
|
}
|
||||||
|
int panelWidth = 50;
|
||||||
|
int panelHeight = 50;
|
||||||
|
ImagePanel panel = ImagePanel.createImagePanel(texturePath);
|
||||||
|
panel.setMinWidth(panelWidth);
|
||||||
|
panel.setMinHeight(panelHeight);
|
||||||
|
panel.setMarginRight(5);
|
||||||
|
panel.setMarginBottom(5);
|
||||||
|
panel.setMarginLeft(5);
|
||||||
|
panel.setMarginTop(5);
|
||||||
|
panel.setAlignSelf(YogaAlignment.Start);
|
||||||
|
panel.setAbsolutePosition(false);
|
||||||
|
panel.setOnDragStart(new DragEventCallback() {public boolean execute(DragEvent event){
|
||||||
|
ItemIconPanel.dragStartContainer = panel.getParent();
|
||||||
|
// System.out.println("Drag start");
|
||||||
|
Globals.dragSourceInventory = inventory;
|
||||||
|
if(inventory instanceof RelationalInventoryState){
|
||||||
|
Globals.draggedItem = ((RelationalInventoryState)inventory).getItemSlot("" + itemId);
|
||||||
|
} else {
|
||||||
|
Globals.draggedItem = ((UnrelationalInventoryState)inventory).getItems().get(itemId);
|
||||||
|
}
|
||||||
|
ContainerElement container = (ContainerElement)panel.getParent();
|
||||||
|
container.removeChild(panel);
|
||||||
|
WindowUtils.pushItemIconToItemWindow(panel);
|
||||||
|
//set new flex values now that its in this item dragging window
|
||||||
|
panel.setPositionType(YogaPositionType.Absolute);
|
||||||
|
panel.setPositionX(panel.getAbsoluteX());
|
||||||
|
panel.setPositionY(panel.getAbsoluteY());
|
||||||
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, PlayerInventoryWindow.createPlayerInventoryWindow(Globals.playerEntity));
|
||||||
|
//play sound effect
|
||||||
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(finalEnt));
|
||||||
|
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIGrabAudio() != null){
|
||||||
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIGrabAudio(), VirtualAudioSourceType.UI, false);
|
||||||
|
} else {
|
||||||
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_GRAB, VirtualAudioSourceType.UI, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
panel.setOnDrag(new DragEventCallback() {public boolean execute(DragEvent event){
|
||||||
|
// System.out.println("Drag");
|
||||||
|
panel.setPositionX(event.getCurrentX() - panelWidth / 2);
|
||||||
|
panel.setPositionY(event.getCurrentY() - panelHeight / 2);
|
||||||
|
Globals.signalSystem.post(SignalType.YOGA_APPLY, Globals.elementService.getWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER));
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
||||||
|
if(panel.getParent() != ItemIconPanel.dragStartContainer){
|
||||||
|
if(panel.getParent() != null){
|
||||||
|
ContainerElement container = (ContainerElement)panel.getParent();
|
||||||
|
container.removeChild(panel);
|
||||||
|
}
|
||||||
|
panel.setPositionType(YogaPositionType.Relative);
|
||||||
|
Globals.elementService.fireEvent(event, event.getCurrentX(), event.getCurrentY());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
panel.setOnHoverCallback(new HoverEventCallback() {public boolean execute(HoverEvent event){
|
||||||
|
if(event.isHovered() && Globals.draggedItem == null){
|
||||||
|
if(itemTooltip != null){
|
||||||
|
Tooltip.destroy(itemTooltip);
|
||||||
|
}
|
||||||
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(currentItem);
|
||||||
|
Globals.signalSystem.post(SignalType.UI_MODIFICATION,()->{
|
||||||
|
itemTooltip = Tooltip.create(Div.createCol(Label.createLabel(itemData.getId())));
|
||||||
|
itemTooltip.setPositionX(panel.getAbsoluteX() + panelWidth);
|
||||||
|
itemTooltip.setPositionY(panel.getAbsoluteY());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if(itemTooltip != null){
|
||||||
|
Tooltip.destroy(itemTooltip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
rVal.addChild(panel);
|
||||||
|
|
||||||
|
if(ClientChargeState.hasClientChargeState(currentItem)){
|
||||||
|
ImagePanel labelBackground = ImagePanel.createImagePanel(Globals.blackTexture);
|
||||||
|
labelBackground.setPositionType(YogaPositionType.Absolute);
|
||||||
|
labelBackground.setWidth(20);
|
||||||
|
labelBackground.setHeight(20);
|
||||||
|
labelBackground.setPositionY(5);
|
||||||
|
rVal.addChild(labelBackground);
|
||||||
|
|
||||||
|
|
||||||
|
ClientChargeState clientChargeState = ClientChargeState.getClientChargeState(currentItem);
|
||||||
|
Label chargeLabel = Label.createLabel("" + clientChargeState.getCharges());
|
||||||
|
chargeLabel.setPositionX(5);
|
||||||
|
chargeLabel.setPositionY(5);
|
||||||
|
chargeLabel.setPositionType(YogaPositionType.Absolute);
|
||||||
|
rVal.addChild(chargeLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a panel that can receive items
|
||||||
|
* @param onReceiveItem The logic to run when the item is received
|
||||||
|
* @return The panel
|
||||||
|
*/
|
||||||
|
public static Div createEmptyItemPanel(Runnable onReceiveItem){
|
||||||
|
Div rVal = Div.createDiv();
|
||||||
|
|
||||||
|
String texturePath = "Textures/ui/uiFrame1.png";
|
||||||
|
if(!Globals.assetManager.hasLoadedTexture(texturePath)){
|
||||||
|
Globals.assetManager.addTexturePathtoQueue(texturePath);
|
||||||
|
}
|
||||||
|
int panelWidth = 50;
|
||||||
|
int panelHeight = 50;
|
||||||
|
ImagePanel panel = ImagePanel.createImagePanel(texturePath);
|
||||||
|
panel.setMinWidth(panelWidth);
|
||||||
|
panel.setMinHeight(panelHeight);
|
||||||
|
panel.setMarginRight(5);
|
||||||
|
panel.setMarginBottom(5);
|
||||||
|
panel.setMarginLeft(5);
|
||||||
|
panel.setMarginTop(5);
|
||||||
|
panel.setAlignSelf(YogaAlignment.Start);
|
||||||
|
panel.setAbsolutePosition(false);
|
||||||
|
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
||||||
|
onReceiveItem.run();
|
||||||
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.draggedItem));
|
||||||
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
|
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
||||||
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
||||||
|
} else {
|
||||||
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//update ui
|
||||||
|
Globals.dragSourceInventory = null;
|
||||||
|
Globals.draggedItem = null;
|
||||||
|
//clear item container ui
|
||||||
|
WindowUtils.cleanItemDraggingWindow();
|
||||||
|
//rerender inventories
|
||||||
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, PlayerInventoryWindow.createPlayerInventoryWindow(Globals.playerEntity));
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
rVal.addChild(panel);
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the tooltip
|
||||||
|
*/
|
||||||
|
public static void clearTooltip(){
|
||||||
|
if(itemTooltip != null){
|
||||||
|
Tooltip.destroy(itemTooltip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -5,7 +5,6 @@ import electrosphere.client.ui.menu.WindowStrings;
|
|||||||
import electrosphere.client.ui.menu.WindowUtils;
|
import electrosphere.client.ui.menu.WindowUtils;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||||
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;
|
||||||
@ -15,31 +14,20 @@ import electrosphere.entity.types.item.ItemUtils;
|
|||||||
import electrosphere.game.data.item.Item;
|
import electrosphere.game.data.item.Item;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.renderer.ui.elements.Div;
|
import electrosphere.renderer.ui.elements.Div;
|
||||||
import electrosphere.renderer.ui.elements.ImagePanel;
|
|
||||||
import electrosphere.renderer.ui.elements.Label;
|
import electrosphere.renderer.ui.elements.Label;
|
||||||
import electrosphere.renderer.ui.elements.Tooltip;
|
|
||||||
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.YogaFlexDirection;
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaFlexDirection;
|
||||||
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification;
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification;
|
||||||
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;
|
||||||
import electrosphere.renderer.ui.elementtypes.HoverableElement.HoverEventCallback;
|
|
||||||
import electrosphere.renderer.ui.events.ClickEvent;
|
import electrosphere.renderer.ui.events.ClickEvent;
|
||||||
import electrosphere.renderer.ui.events.DragEvent;
|
import electrosphere.renderer.ui.events.DragEvent;
|
||||||
import electrosphere.renderer.ui.events.HoverEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An inventory panel showing a natural inventory
|
* An inventory panel showing a natural inventory
|
||||||
*/
|
*/
|
||||||
public class NaturalInventoryPanel {
|
public class NaturalInventoryPanel {
|
||||||
|
|
||||||
/**
|
|
||||||
* The tooltip for the currently hovered item
|
|
||||||
*/
|
|
||||||
static Tooltip itemTooltip;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the natural inventory panel
|
* Creates the natural inventory panel
|
||||||
* @param entity The entity who has the inventory
|
* @param entity The entity who has the inventory
|
||||||
@ -129,85 +117,16 @@ public class NaturalInventoryPanel {
|
|||||||
//flag that this isn't an empty slot
|
//flag that this isn't an empty slot
|
||||||
hasItem = true;
|
hasItem = true;
|
||||||
}
|
}
|
||||||
Entity finalEnt = currentItem;
|
|
||||||
if(!Globals.assetManager.hasLoadedTexture(texturePath)){
|
if(!Globals.assetManager.hasLoadedTexture(texturePath)){
|
||||||
Globals.assetManager.addTexturePathtoQueue(texturePath);
|
Globals.assetManager.addTexturePathtoQueue(texturePath);
|
||||||
}
|
}
|
||||||
int panelWidth = 50;
|
|
||||||
int panelHeight = 50;
|
//create the actual item panel
|
||||||
ImagePanel panel = ImagePanel.createImagePanel(texturePath);
|
Div panel = null;
|
||||||
panel.setMinWidth(panelWidth);
|
|
||||||
panel.setMinHeight(panelHeight);
|
|
||||||
panel.setMarginRight(15);
|
|
||||||
panel.setMarginBottom(15);
|
|
||||||
panel.setMarginLeft(15);
|
|
||||||
panel.setMarginTop(15);
|
|
||||||
panel.setAlignSelf(YogaAlignment.Start);
|
|
||||||
panel.setAbsolutePosition(false);
|
|
||||||
if(hasItem == true && inventory.getItems().get(i) != Globals.draggedItem){
|
if(hasItem == true && inventory.getItems().get(i) != Globals.draggedItem){
|
||||||
int itemId = i;
|
panel = ItemIconPanel.createPanel(currentItem, i, inventory);
|
||||||
panel.setOnDragStart(new DragEventCallback() {public boolean execute(DragEvent event){
|
|
||||||
// System.out.println("Drag start");
|
|
||||||
Globals.dragSourceInventory = inventory;
|
|
||||||
Globals.draggedItem = inventory.getItems().get(itemId);
|
|
||||||
ContainerElement container = (ContainerElement)panel.getParent();
|
|
||||||
container.removeChild(panel);
|
|
||||||
WindowUtils.pushItemIconToItemWindow(panel);
|
|
||||||
//set new flex values now that its in this item dragging window
|
|
||||||
panel.setAbsolutePosition(true);
|
|
||||||
panel.setPositionX(panel.getAbsoluteX());
|
|
||||||
panel.setPositionY(panel.getAbsoluteY());
|
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, PlayerInventoryWindow.createPlayerInventoryWindow(Globals.playerEntity));
|
|
||||||
//play sound effect
|
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(finalEnt));
|
|
||||||
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIGrabAudio() != null){
|
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIGrabAudio(), VirtualAudioSourceType.UI, false);
|
|
||||||
} else {
|
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_GRAB, VirtualAudioSourceType.UI, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
panel.setOnDrag(new DragEventCallback() {public boolean execute(DragEvent event){
|
|
||||||
// System.out.println("Drag");
|
|
||||||
panel.setPositionX(event.getCurrentX() - panelWidth / 2);
|
|
||||||
panel.setPositionY(event.getCurrentY() - panelHeight / 2);
|
|
||||||
Globals.signalSystem.post(SignalType.YOGA_APPLY, Globals.elementService.getWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER));
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
|
||||||
if(panel.getParent() != div){
|
|
||||||
if(panel.getParent() != null){
|
|
||||||
ContainerElement container = (ContainerElement)panel.getParent();
|
|
||||||
container.removeChild(panel);
|
|
||||||
}
|
|
||||||
panel.setAbsolutePosition(false);
|
|
||||||
Globals.elementService.fireEvent(event, event.getCurrentX(), event.getCurrentY());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
panel.setOnHoverCallback(new HoverEventCallback() {public boolean execute(HoverEvent event){
|
|
||||||
if(event.isHovered() && Globals.draggedItem == null){
|
|
||||||
if(itemTooltip != null){
|
|
||||||
Tooltip.destroy(itemTooltip);
|
|
||||||
}
|
|
||||||
Entity itemEntity = finalEnt;
|
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(itemEntity);
|
|
||||||
Globals.signalSystem.post(SignalType.UI_MODIFICATION,()->{
|
|
||||||
itemTooltip = Tooltip.create(Div.createCol(Label.createLabel(itemData.getId())));
|
|
||||||
itemTooltip.setPositionX(panel.getAbsoluteX() + panelWidth);
|
|
||||||
itemTooltip.setPositionY(panel.getAbsoluteY());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if(itemTooltip != null){
|
|
||||||
Tooltip.destroy(itemTooltip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
} else {
|
} else {
|
||||||
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
panel = ItemIconPanel.createEmptyItemPanel(() -> {
|
||||||
if(Globals.dragSourceInventory instanceof RelationalInventoryState){
|
if(Globals.dragSourceInventory instanceof RelationalInventoryState){
|
||||||
if(Globals.dragSourceInventory == InventoryUtils.getToolbarInventory(entity)){
|
if(Globals.dragSourceInventory == InventoryUtils.getToolbarInventory(entity)){
|
||||||
InventoryUtils.clientAddToNatural(Globals.draggedItem);
|
InventoryUtils.clientAddToNatural(Globals.draggedItem);
|
||||||
@ -221,21 +140,7 @@ public class NaturalInventoryPanel {
|
|||||||
throw new UnsupportedOperationException("Unimplemented!");
|
throw new UnsupportedOperationException("Unimplemented!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.draggedItem));
|
});
|
||||||
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
|
||||||
} else {
|
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
|
|
||||||
}
|
|
||||||
//update ui
|
|
||||||
Globals.dragSourceInventory = null;
|
|
||||||
Globals.draggedItem = null;
|
|
||||||
//clear item container ui
|
|
||||||
WindowUtils.cleanItemDraggingWindow();
|
|
||||||
//rerender inventories
|
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, PlayerInventoryWindow.createPlayerInventoryWindow(Globals.playerEntity));
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
}
|
}
|
||||||
panelContainer.addChild(panel);
|
panelContainer.addChild(panel);
|
||||||
}
|
}
|
||||||
@ -244,13 +149,4 @@ public class NaturalInventoryPanel {
|
|||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the tooltip
|
|
||||||
*/
|
|
||||||
public static void clearTooltip(){
|
|
||||||
if(itemTooltip != null){
|
|
||||||
Tooltip.destroy(itemTooltip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,8 +51,7 @@ public class PlayerInventoryWindow {
|
|||||||
if(Globals.virtualAudioSourceManager != null){
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_INVENTORY_CLOSE, VirtualAudioSourceType.UI, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_INVENTORY_CLOSE, VirtualAudioSourceType.UI, false);
|
||||||
}
|
}
|
||||||
NaturalInventoryPanel.clearTooltip();
|
ItemIconPanel.clearTooltip();
|
||||||
ToolbarInventoryPanel.clearTooltip();
|
|
||||||
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
|
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
@ -71,7 +70,7 @@ public class PlayerInventoryWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(InventoryUtils.hasToolbarInventory(entity)){
|
if(InventoryUtils.hasToolbarInventory(entity)){
|
||||||
rVal.addChild(ToolbarInventoryPanel.createToolbarInventoryPanel(entity));
|
rVal.addChild(ToolbarInventoryPanel.createToolbarInventoryPanel(entity, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import electrosphere.client.ui.menu.WindowStrings;
|
|||||||
import electrosphere.client.ui.menu.WindowUtils;
|
import electrosphere.client.ui.menu.WindowUtils;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||||
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.equip.ClientToolbarState;
|
import electrosphere.entity.state.equip.ClientToolbarState;
|
||||||
@ -18,38 +17,28 @@ import electrosphere.entity.types.item.ItemUtils;
|
|||||||
import electrosphere.game.data.item.Item;
|
import electrosphere.game.data.item.Item;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.renderer.ui.elements.Div;
|
import electrosphere.renderer.ui.elements.Div;
|
||||||
import electrosphere.renderer.ui.elements.ImagePanel;
|
|
||||||
import electrosphere.renderer.ui.elements.Label;
|
import electrosphere.renderer.ui.elements.Label;
|
||||||
import electrosphere.renderer.ui.elements.Panel;
|
import electrosphere.renderer.ui.elements.Panel;
|
||||||
import electrosphere.renderer.ui.elements.Tooltip;
|
|
||||||
import electrosphere.renderer.ui.elementtypes.ClickableElement.ClickEventCallback;
|
import electrosphere.renderer.ui.elementtypes.ClickableElement.ClickEventCallback;
|
||||||
import electrosphere.renderer.ui.elementtypes.ContainerElement;
|
import electrosphere.renderer.ui.elementtypes.ContainerElement;
|
||||||
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
|
|
||||||
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaFlexDirection;
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaFlexDirection;
|
||||||
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification;
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification;
|
||||||
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;
|
||||||
import electrosphere.renderer.ui.elementtypes.HoverableElement.HoverEventCallback;
|
|
||||||
import electrosphere.renderer.ui.events.ClickEvent;
|
import electrosphere.renderer.ui.events.ClickEvent;
|
||||||
import electrosphere.renderer.ui.events.DragEvent;
|
import electrosphere.renderer.ui.events.DragEvent;
|
||||||
import electrosphere.renderer.ui.events.HoverEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toolbar inventory panel
|
* Toolbar inventory panel
|
||||||
*/
|
*/
|
||||||
public class ToolbarInventoryPanel {
|
public class ToolbarInventoryPanel {
|
||||||
|
|
||||||
/**
|
|
||||||
* The tooltip for the currently hovered item
|
|
||||||
*/
|
|
||||||
static Tooltip itemTooltip;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the toolbar inventory panel
|
* Creates the toolbar inventory panel
|
||||||
* @param entity The entity who has the inventory
|
* @param entity The entity who has the inventory
|
||||||
* @return The panel element
|
* @return The panel element
|
||||||
*/
|
*/
|
||||||
public static Element createToolbarInventoryPanel(Entity entity){
|
public static Element createToolbarInventoryPanel(Entity entity, boolean showTitle){
|
||||||
RelationalInventoryState inventory = InventoryUtils.getToolbarInventory(entity);
|
RelationalInventoryState inventory = InventoryUtils.getToolbarInventory(entity);
|
||||||
|
|
||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
@ -119,9 +108,11 @@ public class ToolbarInventoryPanel {
|
|||||||
|
|
||||||
|
|
||||||
//label 1 (inventory)
|
//label 1 (inventory)
|
||||||
Label menuTitle = Label.createLabel("TOOLBAR");
|
if(showTitle){
|
||||||
menuTitle.setMarginBottom(10);
|
Label menuTitle = Label.createLabel("TOOLBAR");
|
||||||
div.addChild(menuTitle);
|
menuTitle.setMarginBottom(10);
|
||||||
|
div.addChild(menuTitle);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
//contains all the item panels
|
//contains all the item panels
|
||||||
@ -139,86 +130,17 @@ public class ToolbarInventoryPanel {
|
|||||||
//flag that this isn't an empty slot
|
//flag that this isn't an empty slot
|
||||||
hasItem = true;
|
hasItem = true;
|
||||||
}
|
}
|
||||||
Entity finalEnt = currentItem;
|
|
||||||
if(!Globals.assetManager.hasLoadedTexture(texturePath)){
|
if(!Globals.assetManager.hasLoadedTexture(texturePath)){
|
||||||
Globals.assetManager.addTexturePathtoQueue(texturePath);
|
Globals.assetManager.addTexturePathtoQueue(texturePath);
|
||||||
}
|
}
|
||||||
int panelWidth = 50;
|
|
||||||
int panelHeight = 50;
|
//create the actual item panel
|
||||||
ImagePanel panel = ImagePanel.createImagePanel(texturePath);
|
Div panel = null;
|
||||||
panel.setMinWidth(panelWidth);
|
|
||||||
panel.setMinHeight(panelHeight);
|
|
||||||
panel.setMarginRight(5);
|
|
||||||
panel.setMarginBottom(5);
|
|
||||||
panel.setMarginLeft(5);
|
|
||||||
panel.setMarginTop(5);
|
|
||||||
panel.setAlignSelf(YogaAlignment.Start);
|
|
||||||
panel.setAbsolutePosition(false);
|
|
||||||
if(hasItem == true && inventory.getItemSlot("" + i) != Globals.draggedItem){
|
if(hasItem == true && inventory.getItemSlot("" + i) != Globals.draggedItem){
|
||||||
int itemId = i;
|
panel = ItemIconPanel.createPanel(currentItem, i, inventory);
|
||||||
panel.setOnDragStart(new DragEventCallback() {public boolean execute(DragEvent event){
|
|
||||||
// System.out.println("Drag start");
|
|
||||||
Globals.dragSourceInventory = inventory;
|
|
||||||
Globals.draggedItem = inventory.getItemSlot("" + itemId);
|
|
||||||
ContainerElement container = (ContainerElement)panel.getParent();
|
|
||||||
container.removeChild(panel);
|
|
||||||
WindowUtils.pushItemIconToItemWindow(panel);
|
|
||||||
//set new flex values now that its in this item dragging window
|
|
||||||
panel.setAbsolutePosition(true);
|
|
||||||
panel.setPositionX(panel.getAbsoluteX());
|
|
||||||
panel.setPositionY(panel.getAbsoluteY());
|
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, PlayerInventoryWindow.createPlayerInventoryWindow(Globals.playerEntity));
|
|
||||||
//play sound effect
|
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(finalEnt));
|
|
||||||
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIGrabAudio() != null){
|
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIGrabAudio(), VirtualAudioSourceType.UI, false);
|
|
||||||
} else {
|
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_GRAB, VirtualAudioSourceType.UI, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
panel.setOnDrag(new DragEventCallback() {public boolean execute(DragEvent event){
|
|
||||||
// System.out.println("Drag");
|
|
||||||
panel.setPositionX(event.getCurrentX() - panelWidth / 2);
|
|
||||||
panel.setPositionY(event.getCurrentY() - panelHeight / 2);
|
|
||||||
Globals.signalSystem.post(SignalType.YOGA_APPLY, Globals.elementService.getWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER));
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
|
||||||
if(panel.getParent() != div){
|
|
||||||
if(panel.getParent() != null){
|
|
||||||
ContainerElement container = (ContainerElement)panel.getParent();
|
|
||||||
container.removeChild(panel);
|
|
||||||
}
|
|
||||||
panel.setAbsolutePosition(false);
|
|
||||||
Globals.elementService.fireEvent(event, event.getCurrentX(), event.getCurrentY());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
panel.setOnHoverCallback(new HoverEventCallback() {public boolean execute(HoverEvent event){
|
|
||||||
if(event.isHovered() && Globals.draggedItem == null){
|
|
||||||
if(itemTooltip != null){
|
|
||||||
Tooltip.destroy(itemTooltip);
|
|
||||||
}
|
|
||||||
Entity itemEntity = inventory.getItemSlot("" + itemId) ;
|
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(itemEntity);
|
|
||||||
Globals.signalSystem.post(SignalType.UI_MODIFICATION,()->{
|
|
||||||
itemTooltip = Tooltip.create(Div.createCol(Label.createLabel(itemData.getId())));
|
|
||||||
itemTooltip.setPositionX(panel.getAbsoluteX() + panelWidth);
|
|
||||||
itemTooltip.setPositionY(panel.getAbsoluteY());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if(itemTooltip != null){
|
|
||||||
Tooltip.destroy(itemTooltip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
} else {
|
} else {
|
||||||
int slotId = i;
|
int slotId = i;
|
||||||
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
panel = ItemIconPanel.createEmptyItemPanel(() -> {
|
||||||
if(Globals.dragSourceInventory instanceof RelationalInventoryState){
|
if(Globals.dragSourceInventory instanceof RelationalInventoryState){
|
||||||
if(Globals.dragSourceInventory == InventoryUtils.getToolbarInventory(Globals.playerEntity)){
|
if(Globals.dragSourceInventory == InventoryUtils.getToolbarInventory(Globals.playerEntity)){
|
||||||
ClientToolbarState clientToolbarState = ClientToolbarState.getClientToolbarState(entity);
|
ClientToolbarState clientToolbarState = ClientToolbarState.getClientToolbarState(entity);
|
||||||
@ -235,24 +157,9 @@ public class ToolbarInventoryPanel {
|
|||||||
clientToolbarState.attemptAddToToolbar(Globals.draggedItem, slotId);
|
clientToolbarState.attemptAddToToolbar(Globals.draggedItem, slotId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.draggedItem));
|
});
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
|
||||||
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
|
||||||
} else {
|
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//update ui
|
|
||||||
Globals.dragSourceInventory = null;
|
|
||||||
Globals.draggedItem = null;
|
|
||||||
//clear item container ui
|
|
||||||
WindowUtils.cleanItemDraggingWindow();
|
|
||||||
//rerender inventories
|
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, PlayerInventoryWindow.createPlayerInventoryWindow(Globals.playerEntity));
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerElement container = null;
|
ContainerElement container = null;
|
||||||
if(i == selectedIndex){
|
if(i == selectedIndex){
|
||||||
container = Panel.createPanel(panel);
|
container = Panel.createPanel(panel);
|
||||||
@ -271,13 +178,4 @@ public class ToolbarInventoryPanel {
|
|||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the tooltip
|
|
||||||
*/
|
|
||||||
public static void clearTooltip(){
|
|
||||||
if(itemTooltip != null){
|
|
||||||
Tooltip.destroy(itemTooltip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class ToolbarPreviewWindow {
|
|||||||
rVal.setJustifyContent(YogaJustification.End);
|
rVal.setJustifyContent(YogaJustification.End);
|
||||||
|
|
||||||
//attach scrollable after search input for organzation purposes
|
//attach scrollable after search input for organzation purposes
|
||||||
rVal.addChild(ToolbarInventoryPanel.createToolbarInventoryPanel(Globals.playerEntity));
|
rVal.addChild(ToolbarInventoryPanel.createToolbarInventoryPanel(Globals.playerEntity, false));
|
||||||
|
|
||||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
||||||
|
|
||||||
|
|||||||
@ -10,10 +10,10 @@ import electrosphere.net.synchronization.annotation.SyncedField;
|
|||||||
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
||||||
|
|
||||||
|
|
||||||
@SynchronizedBehaviorTree(name = "clientChargeState", isServer = false, correspondingTree="serverChargeState")
|
|
||||||
/**
|
/**
|
||||||
* Item charge state
|
* Item charge state
|
||||||
*/
|
*/
|
||||||
|
@SynchronizedBehaviorTree(name = "clientChargeState", isServer = false, correspondingTree="serverChargeState")
|
||||||
public class ClientChargeState implements BehaviorTree {
|
public class ClientChargeState implements BehaviorTree {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,6 +22,11 @@ public class ClientChargeState implements BehaviorTree {
|
|||||||
@SyncedField
|
@SyncedField
|
||||||
int charges;
|
int charges;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum allowed charges for this item
|
||||||
|
*/
|
||||||
|
int maxCharges;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent of this state
|
* The parent of this state
|
||||||
*/
|
*/
|
||||||
@ -34,6 +39,8 @@ public class ClientChargeState implements BehaviorTree {
|
|||||||
*/
|
*/
|
||||||
private ClientChargeState(Entity parent, Object ... params){
|
private ClientChargeState(Entity parent, Object ... params){
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
this.maxCharges = (Integer)params[0];
|
||||||
|
this.charges = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -14,10 +14,10 @@ import electrosphere.net.synchronization.annotation.SyncedField;
|
|||||||
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
||||||
|
|
||||||
|
|
||||||
@SynchronizedBehaviorTree(name = "serverChargeState", isServer = true, correspondingTree="clientChargeState")
|
|
||||||
/**
|
/**
|
||||||
* Item charge state
|
* Item charge state
|
||||||
*/
|
*/
|
||||||
|
@SynchronizedBehaviorTree(name = "serverChargeState", isServer = true, correspondingTree="clientChargeState")
|
||||||
public class ServerChargeState implements BehaviorTree {
|
public class ServerChargeState implements BehaviorTree {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,6 +26,11 @@ public class ServerChargeState implements BehaviorTree {
|
|||||||
@SyncedField
|
@SyncedField
|
||||||
int charges;
|
int charges;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum allowed charges for this item
|
||||||
|
*/
|
||||||
|
int maxCharges;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent of this state
|
* The parent of this state
|
||||||
*/
|
*/
|
||||||
@ -38,6 +43,8 @@ public class ServerChargeState implements BehaviorTree {
|
|||||||
*/
|
*/
|
||||||
private ServerChargeState(Entity parent, Object ... params){
|
private ServerChargeState(Entity parent, Object ... params){
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
this.maxCharges = (Integer)params[0];
|
||||||
|
this.charges = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -24,6 +24,8 @@ import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
|||||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||||
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
||||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||||
|
import electrosphere.entity.state.item.ClientChargeState;
|
||||||
|
import electrosphere.entity.state.item.ServerChargeState;
|
||||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
@ -119,6 +121,13 @@ public class ItemUtils {
|
|||||||
rVal.putData(EntityDataStrings.ITEM_FAB_DATA, item.getFabData());
|
rVal.putData(EntityDataStrings.ITEM_FAB_DATA, item.getFabData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//stacking behavior
|
||||||
|
//
|
||||||
|
if(item.getMaxStack() != null){
|
||||||
|
ClientChargeState.attachTree(rVal, item.getMaxStack());
|
||||||
|
}
|
||||||
|
|
||||||
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.ITEM);
|
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.ITEM);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
@ -209,6 +218,13 @@ public class ItemUtils {
|
|||||||
rVal.putData(EntityDataStrings.ITEM_FAB_DATA, item.getFabData());
|
rVal.putData(EntityDataStrings.ITEM_FAB_DATA, item.getFabData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//stacking behavior
|
||||||
|
//
|
||||||
|
if(item.getMaxStack() != null){
|
||||||
|
ServerChargeState.attachTree(rVal, item.getMaxStack());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -442,12 +458,23 @@ public class ItemUtils {
|
|||||||
if(ItemUtils.getEquipWhitelist(item) != null){
|
if(ItemUtils.getEquipWhitelist(item) != null){
|
||||||
rVal.putData(EntityDataStrings.ITEM_EQUIP_WHITELIST, getEquipWhitelist(item));
|
rVal.putData(EntityDataStrings.ITEM_EQUIP_WHITELIST, getEquipWhitelist(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//weapon data
|
||||||
|
//
|
||||||
if(itemData.getWeaponData() != null){
|
if(itemData.getWeaponData() != null){
|
||||||
rVal.putData(EntityDataStrings.ITEM_IS_WEAPON, true);
|
rVal.putData(EntityDataStrings.ITEM_IS_WEAPON, true);
|
||||||
WeaponData weaponData = itemData.getWeaponData();
|
WeaponData weaponData = itemData.getWeaponData();
|
||||||
rVal.putData(EntityDataStrings.ITEM_WEAPON_CLASS,weaponData.getWeaponClass());
|
rVal.putData(EntityDataStrings.ITEM_WEAPON_CLASS,weaponData.getWeaponClass());
|
||||||
rVal.putData(EntityDataStrings.ITEM_WEAPON_DATA_RAW,weaponData);
|
rVal.putData(EntityDataStrings.ITEM_WEAPON_DATA_RAW,weaponData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//stacking behavior
|
||||||
|
//
|
||||||
|
if(itemData.getMaxStack() != null){
|
||||||
|
ClientChargeState.attachTree(rVal, itemData.getMaxStack());
|
||||||
|
}
|
||||||
rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item));
|
rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item));
|
||||||
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS));
|
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS));
|
||||||
CommonEntityUtils.setEntityType(rVal, EntityType.ITEM);
|
CommonEntityUtils.setEntityType(rVal, EntityType.ITEM);
|
||||||
@ -470,10 +497,19 @@ public class ItemUtils {
|
|||||||
*/
|
*/
|
||||||
public static Entity serverRecreateContainerItem(Entity item, Entity containingParent){
|
public static Entity serverRecreateContainerItem(Entity item, Entity containingParent){
|
||||||
if(ItemUtils.isItem(item)){
|
if(ItemUtils.isItem(item)){
|
||||||
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(item));
|
||||||
Entity rVal = EntityCreationUtils.createRealmlessServerEntity();
|
Entity rVal = EntityCreationUtils.createRealmlessServerEntity();
|
||||||
if(ItemUtils.getEquipWhitelist(item) != null){
|
if(ItemUtils.getEquipWhitelist(item) != null){
|
||||||
rVal.putData(EntityDataStrings.ITEM_EQUIP_WHITELIST, getEquipWhitelist(item));
|
rVal.putData(EntityDataStrings.ITEM_EQUIP_WHITELIST, getEquipWhitelist(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//stacking behavior
|
||||||
|
//
|
||||||
|
if(itemData.getMaxStack() != null){
|
||||||
|
ClientChargeState.attachTree(rVal, itemData.getMaxStack());
|
||||||
|
}
|
||||||
|
|
||||||
rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item));
|
rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item));
|
||||||
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS));
|
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS));
|
||||||
CommonEntityUtils.setEntityType(rVal, EntityType.ITEM);
|
CommonEntityUtils.setEntityType(rVal, EntityType.ITEM);
|
||||||
|
|||||||
@ -87,6 +87,11 @@ public class Item extends CommonEntityType {
|
|||||||
*/
|
*/
|
||||||
ItemFabData fabData;
|
ItemFabData fabData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum stack of this item
|
||||||
|
*/
|
||||||
|
Integer maxStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates item data from a spawn item description
|
* Creates item data from a spawn item description
|
||||||
* @param description The spawn item description
|
* @param description The spawn item description
|
||||||
@ -274,4 +279,22 @@ public class Item extends CommonEntityType {
|
|||||||
return fabData;
|
return fabData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum stack allowed of this item
|
||||||
|
* @return The maximum stack allowed
|
||||||
|
*/
|
||||||
|
public Integer getMaxStack() {
|
||||||
|
return maxStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the maximum stack allowed of this item
|
||||||
|
* @param maxStack The maximum stack allowed
|
||||||
|
*/
|
||||||
|
public void setMaxStack(Integer maxStack) {
|
||||||
|
this.maxStack = maxStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package electrosphere.renderer.ui.elements;
|
|||||||
import org.lwjgl.util.yoga.Yoga;
|
import org.lwjgl.util.yoga.Yoga;
|
||||||
|
|
||||||
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaPositionType;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.ContainerElement;
|
||||||
import electrosphere.renderer.ui.elementtypes.Element;
|
import electrosphere.renderer.ui.elementtypes.Element;
|
||||||
import electrosphere.renderer.ui.events.Event;
|
import electrosphere.renderer.ui.events.Event;
|
||||||
|
|
||||||
@ -22,7 +24,7 @@ public class StandardElement implements Element {
|
|||||||
private int absoluteY;
|
private int absoluteY;
|
||||||
boolean useAbsolutePosition = false;
|
boolean useAbsolutePosition = false;
|
||||||
|
|
||||||
Element parent = null;
|
ContainerElement parent = null;
|
||||||
|
|
||||||
public boolean visible = false;
|
public boolean visible = false;
|
||||||
|
|
||||||
@ -122,11 +124,11 @@ public class StandardElement implements Element {
|
|||||||
Yoga.YGNodeStyleSetMargin(this.yogaNode, Yoga.YGEdgeLeft, marginLeft);
|
Yoga.YGNodeStyleSetMargin(this.yogaNode, Yoga.YGEdgeLeft, marginLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element getParent(){
|
public ContainerElement getParent(){
|
||||||
return this.parent;
|
return this.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParent(Element parent){
|
public void setParent(ContainerElement parent){
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,4 +296,38 @@ public class StandardElement implements Element {
|
|||||||
Yoga.YGNodeStyleSetPadding(this.yogaNode, Yoga.YGEdgeLeft, paddingLeft);
|
Yoga.YGNodeStyleSetPadding(this.yogaNode, Yoga.YGEdgeLeft, paddingLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPositionType(YogaPositionType positionType) {
|
||||||
|
switch(positionType){
|
||||||
|
case Absolute:{
|
||||||
|
Yoga.YGNodeStyleSetPositionType(yogaNode, Yoga.YGPositionTypeAbsolute);
|
||||||
|
} break;
|
||||||
|
case Relative: {
|
||||||
|
Yoga.YGNodeStyleSetPositionType(yogaNode, Yoga.YGPositionTypeRelative);
|
||||||
|
} break;
|
||||||
|
case Static: {
|
||||||
|
Yoga.YGNodeStyleSetPositionType(yogaNode, Yoga.YGPositionTypeStatic);
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YogaPositionType getPositionType() {
|
||||||
|
int type = Yoga.YGNodeStyleGetPositionType(yogaNode);
|
||||||
|
switch(type){
|
||||||
|
case Yoga.YGPositionTypeAbsolute: {
|
||||||
|
return YogaPositionType.Absolute;
|
||||||
|
}
|
||||||
|
case Yoga.YGPositionTypeRelative: {
|
||||||
|
return YogaPositionType.Relative;
|
||||||
|
}
|
||||||
|
case Yoga.YGPositionTypeStatic: {
|
||||||
|
return YogaPositionType.Static;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw new Error("Unsupported position type! " + type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -658,7 +658,7 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
|||||||
navCallback = callback;
|
navCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element getParent(){
|
public ContainerElement getParent(){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,7 +818,7 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParent(Element parent) {
|
public void setParent(ContainerElement parent) {
|
||||||
//not implemented
|
//not implemented
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
@ -915,6 +915,16 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
|||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPositionType(YogaPositionType positionType) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'setPositionType'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YogaPositionType getPositionType() {
|
||||||
|
return YogaPositionType.Absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,15 @@ public interface ContainerElement extends Element {
|
|||||||
Scroll,
|
Scroll,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The position type of a yoga node
|
||||||
|
*/
|
||||||
|
public static enum YogaPositionType {
|
||||||
|
Absolute,
|
||||||
|
Relative,
|
||||||
|
Static,
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a child element to this element
|
* Add a child element to this element
|
||||||
* @param child The child element
|
* @param child The child element
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package electrosphere.renderer.ui.elementtypes;
|
package electrosphere.renderer.ui.elementtypes;
|
||||||
|
|
||||||
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaPositionType;
|
||||||
import electrosphere.renderer.ui.events.Event;
|
import electrosphere.renderer.ui.events.Event;
|
||||||
|
|
||||||
public interface Element {
|
public interface Element {
|
||||||
@ -38,8 +39,8 @@ public interface Element {
|
|||||||
public void setAbsolutePosition(boolean useAbsolutePosition);
|
public void setAbsolutePosition(boolean useAbsolutePosition);
|
||||||
|
|
||||||
//parent data
|
//parent data
|
||||||
public Element getParent();
|
public ContainerElement getParent();
|
||||||
public void setParent(Element parent);
|
public void setParent(ContainerElement parent);
|
||||||
|
|
||||||
//margin
|
//margin
|
||||||
public void setMarginTop(int marginTop);
|
public void setMarginTop(int marginTop);
|
||||||
@ -53,6 +54,10 @@ public interface Element {
|
|||||||
public void setPaddingBottom(int paddingBottom);
|
public void setPaddingBottom(int paddingBottom);
|
||||||
public void setPaddingLeft(int paddingLeft);
|
public void setPaddingLeft(int paddingLeft);
|
||||||
|
|
||||||
|
//positioning
|
||||||
|
public void setPositionType(YogaPositionType positionType);
|
||||||
|
public YogaPositionType getPositionType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the self alignment
|
* Sets the self alignment
|
||||||
* @param alignment the alignment style
|
* @param alignment the alignment style
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user