mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
prevent NPE
This commit is contained in:
@@ -61,7 +61,6 @@ public class InventoryScene extends UIScene {
|
||||
|
||||
Array<Actor> children = ui.getChildren();
|
||||
for (int i = 0, n = children.size; i < n; i++) {
|
||||
|
||||
if (children.get(i).getName() != null && children.get(i).getName().startsWith("Equipment")) {
|
||||
String slotName = children.get(i).getName().split("_")[1];
|
||||
equipmentSlots.put(slotName, (Button) children.get(i));
|
||||
@@ -80,7 +79,10 @@ public class InventoryScene extends UIScene {
|
||||
if (item != null && !item.isEmpty()) {
|
||||
Button changeButton = null;
|
||||
for (Button invButton : inventoryButtons) {
|
||||
if (itemLocation.get(invButton) != null && itemLocation.get(invButton).equals(item)) {
|
||||
if(itemLocation.get(invButton) == null)
|
||||
continue;
|
||||
ItemData data = itemLocation.get(invButton).getRight();
|
||||
if (data != null && item.equals(data.equipmentSlot)) {
|
||||
changeButton = invButton;
|
||||
break;
|
||||
}
|
||||
@@ -91,7 +93,6 @@ public class InventoryScene extends UIScene {
|
||||
setSelected(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -121,6 +122,8 @@ public class InventoryScene extends UIScene {
|
||||
private void repair() {
|
||||
if (selected == null)
|
||||
return;
|
||||
if (itemLocation.get(selected) == null)
|
||||
return;
|
||||
ItemData data = itemLocation.get(selected).getRight();
|
||||
if (data == null)
|
||||
return;
|
||||
@@ -166,6 +169,10 @@ public class InventoryScene extends UIScene {
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (selected == null)
|
||||
return;
|
||||
if (itemLocation.get(selected) == null)
|
||||
return;
|
||||
ItemData data = itemLocation.get(selected).getRight();
|
||||
if (data != null) {
|
||||
data.isEquipped = false;
|
||||
@@ -176,7 +183,10 @@ public class InventoryScene extends UIScene {
|
||||
}
|
||||
|
||||
public void equip() {
|
||||
if (selected == null) return;
|
||||
if (selected == null)
|
||||
return;
|
||||
if (itemLocation.get(selected) == null)
|
||||
return;
|
||||
ItemData data = itemLocation.get(selected).getRight();
|
||||
if (data == null) return;
|
||||
Current.player().equip(data);
|
||||
@@ -189,8 +199,10 @@ public class InventoryScene extends UIScene {
|
||||
}
|
||||
|
||||
private void triggerUse() {
|
||||
if (selected == null) return;
|
||||
|
||||
if (selected == null)
|
||||
return;
|
||||
if (itemLocation.get(selected) == null)
|
||||
return;
|
||||
ItemData data = itemLocation.get(selected).getRight();
|
||||
if (data == null) return;
|
||||
Current.player().addShards(-data.shardsNeeded);
|
||||
@@ -324,7 +336,6 @@ public class InventoryScene extends UIScene {
|
||||
}
|
||||
|
||||
private void updateInventory() {
|
||||
clearItemDescription();
|
||||
clearSelectable();
|
||||
inventoryButtons.clear();
|
||||
inventory.clear();
|
||||
@@ -454,6 +465,7 @@ public class InventoryScene extends UIScene {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
clearItemDescription();
|
||||
updateInventory();
|
||||
//inventory.add().expand();
|
||||
super.enter();
|
||||
|
||||
@@ -470,6 +470,15 @@
|
||||
"focused": "item_frame_selected",
|
||||
"checked": "item_frame_selected",
|
||||
"checkedOver": "item_frame_selected_hover"
|
||||
},
|
||||
"item_frame_static": {
|
||||
"imageCheckedOver": "item_frame",
|
||||
"up": "item_frame",
|
||||
"over": "item_frame",
|
||||
"focused": "item_frame",
|
||||
"checked": "item_frame",
|
||||
"checkedOver": "item_frame",
|
||||
"checkedDown": "item_frame"
|
||||
}
|
||||
},
|
||||
"ImageTextButtonStyle": {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Ability1",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 17,
|
||||
@@ -29,7 +29,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Ability2",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 107,
|
||||
@@ -38,7 +38,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Neck",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 62,
|
||||
@@ -47,7 +47,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Body",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 62,
|
||||
@@ -56,7 +56,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Boots",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 62,
|
||||
@@ -65,7 +65,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Left",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 17,
|
||||
@@ -74,7 +74,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Right",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 107,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Ability1",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 17,
|
||||
@@ -29,7 +29,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Ability2",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 107,
|
||||
@@ -38,7 +38,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Neck",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 62,
|
||||
@@ -47,7 +47,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Body",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 62,
|
||||
@@ -56,7 +56,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Boots",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 62,
|
||||
@@ -65,7 +65,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Left",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 17,
|
||||
@@ -74,7 +74,7 @@
|
||||
{
|
||||
"type": "ImageButton",
|
||||
"name": "Equipment_Right",
|
||||
"style": "item_frame",
|
||||
"style": "item_frame_static",
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"x": 107,
|
||||
|
||||
Reference in New Issue
Block a user