mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-12 16:58:57 +00:00
update InventoryScene, add repair cracked item for gold
This commit is contained in:
@@ -7,12 +7,15 @@ import com.badlogic.gdx.utils.Json;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Paths;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Data class that will be used to read Json configuration files
|
||||
* ItemData
|
||||
* contains the information for equipment and items.
|
||||
*/
|
||||
public class ItemData {
|
||||
public class ItemData implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public String name;
|
||||
public String equipmentSlot;
|
||||
public EffectData effect;
|
||||
@@ -24,6 +27,7 @@ public class ItemData {
|
||||
public boolean usableOnWorldMap;
|
||||
public boolean usableInPoi;
|
||||
public boolean isCracked;
|
||||
public boolean isEquipped;
|
||||
public String commandOnUse;
|
||||
public int shardsNeeded;
|
||||
public DialogData dialogOnUse;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
private final Map<String, Byte> characterFlags = new HashMap<>();
|
||||
private final Map<String, Byte> tutorialFlags = new HashMap<>();
|
||||
|
||||
private final Array<String> inventoryItems = new Array<>();
|
||||
private final Array<ItemData> inventoryItems = new Array<>();
|
||||
private final Array<Deck> boostersOwned = new Array<>();
|
||||
private final HashMap<String, String> equippedItems = new HashMap<>();
|
||||
private final List<AdventureQuestData> quests = new ArrayList<>();
|
||||
@@ -174,7 +174,13 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
life = maxLife = difficultyData.startingLife;
|
||||
shards = difficultyData.startingShards;
|
||||
|
||||
inventoryItems.addAll(difficultyData.startItems);
|
||||
for (String s : difficultyData.startItems) {
|
||||
ItemData i = ItemData.getItem(s);
|
||||
if (i == null)
|
||||
continue;
|
||||
inventoryItems.add(i);
|
||||
}
|
||||
|
||||
onGoldChangeList.emit();
|
||||
onLifeTotalChangeList.emit();
|
||||
onShardsChangeList.emit();
|
||||
@@ -213,10 +219,30 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
return deck;
|
||||
}
|
||||
|
||||
public Array<String> getItems() {
|
||||
public Array<ItemData> getItems() {
|
||||
return inventoryItems;
|
||||
}
|
||||
|
||||
public ItemData getItemFromInventory(String name) {
|
||||
for (ItemData data : inventoryItems) {
|
||||
if (data == null)
|
||||
continue;
|
||||
if (data.name.equals(name))
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemData getEquippedItem(String name) {
|
||||
for (ItemData data : inventoryItems) {
|
||||
if (data == null)
|
||||
continue;
|
||||
if (data.name.equals(name) && data.isEquipped)
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Array<Deck> getBoostersOwned() {
|
||||
return boostersOwned;
|
||||
}
|
||||
@@ -374,16 +400,32 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
}
|
||||
|
||||
if (data.containsKey("inventory")) {
|
||||
String[] inv = (String[]) data.readObject("inventory");
|
||||
// Prevent items with wrong names from getting through. Hell breaks loose if it causes null pointers.
|
||||
// This only needs to be done on load.
|
||||
for (String i : inv) {
|
||||
if (ItemData.getItem(i) != null) inventoryItems.add(i);
|
||||
else {
|
||||
System.err.printf("Cannot find item name %s\n", i);
|
||||
// Allow official© permission for the player to get a refund. We will allow it this time.
|
||||
// TODO: Divine retribution if the player refunds too much. Use the orbital laser cannon.
|
||||
System.out.println("Developers have blessed you! You are allowed to cheat the cost of the item back!");
|
||||
try {
|
||||
ItemData[] inv = (ItemData[]) data.readObject("inventory");
|
||||
for (ItemData itemData : inv) {
|
||||
if (itemData != null)
|
||||
inventoryItems.add(itemData);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// migrate from string..
|
||||
try {
|
||||
String[] inv = (String[]) data.readObject("inventory");
|
||||
// Prevent items with wrong names from getting through. Hell breaks loose if it causes null pointers.
|
||||
// This only needs to be done on load.
|
||||
for (String i : inv) {
|
||||
ItemData itemData = ItemData.getItem(i);
|
||||
if (itemData != null)
|
||||
inventoryItems.add(itemData);
|
||||
else {
|
||||
System.err.printf("Cannot find item name %s\n", i);
|
||||
// Allow official© permission for the player to get a refund. We will allow it this time.
|
||||
// TODO: Divine retribution if the player refunds too much. Use the orbital laser cannon.
|
||||
System.out.println("Developers have blessed you! You are allowed to cheat the cost of the item back!");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//shouldn't crash if coming from string...
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -394,9 +436,11 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
assert (slots.length == items.length);
|
||||
// Prevent items with wrong names. If it triggered in inventory, it'll trigger here as well.
|
||||
for (int i = 0; i < slots.length; i++) {
|
||||
if (ItemData.getItem(items[i]) != null)
|
||||
ItemData itemData = getItemFromInventory(items[i]);
|
||||
if (itemData != null) {
|
||||
itemData.isEquipped = true;
|
||||
equippedItems.put(slots[i], items[i]);
|
||||
else {
|
||||
} else {
|
||||
System.err.printf("Cannot find equip name %s\n", items[i]);
|
||||
}
|
||||
}
|
||||
@@ -608,7 +652,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
data.store("shards", shards);
|
||||
data.store("deckName", deck.getName());
|
||||
|
||||
data.storeObject("inventory", inventoryItems.toArray(String.class));
|
||||
data.storeObject("inventory", inventoryItems.toArray(ItemData.class));
|
||||
|
||||
ArrayList<String> slots = new ArrayList<>();
|
||||
ArrayList<String> items = new ArrayList<>();
|
||||
@@ -939,18 +983,22 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemData getRandomEquippedArmor() {
|
||||
Array<ItemData> armor = new Array<>();
|
||||
public ItemData getRandomEquippedItem() {
|
||||
Array<ItemData> items = new Array<>();
|
||||
for (String name : equippedItems.values()) {
|
||||
ItemData data = ItemData.getItem(name);
|
||||
if (data != null
|
||||
&& ("Boots".equalsIgnoreCase(data.equipmentSlot)
|
||||
|| "Body".equalsIgnoreCase(data.equipmentSlot)
|
||||
|| "Neck".equalsIgnoreCase(data.equipmentSlot))) {
|
||||
armor.add(data);
|
||||
ItemData item = getEquippedItem(name);
|
||||
if (item == null)
|
||||
continue;
|
||||
if (isHardorInsaneDifficulty()) {
|
||||
items.add(item);
|
||||
} else {
|
||||
switch (item.equipmentSlot) {
|
||||
// limit to these for easy and normal
|
||||
case "Boots", "Body", "Neck" -> items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return armor.random();
|
||||
return items.random();
|
||||
}
|
||||
|
||||
public ItemData getEquippedAbility1() {
|
||||
@@ -1051,17 +1099,27 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
}
|
||||
|
||||
public void removeItem(String name) {
|
||||
if (name == null || name.isEmpty()) return;
|
||||
inventoryItems.removeValue(name, false);
|
||||
if (equippedItems.values().contains(name) && !inventoryItems.contains(name, false)) {
|
||||
equippedItems.values().remove(name);
|
||||
ItemData item = ItemData.getItem(name);
|
||||
if (item != null)
|
||||
removeItem(item);
|
||||
}
|
||||
|
||||
public void removeItem(ItemData item) {
|
||||
if (item == null)
|
||||
return;
|
||||
inventoryItems.removeValue(item, false);
|
||||
if (equippedItems.values().contains(item.name) && !inventoryItems.contains(item, false)) {
|
||||
item.isEquipped = false;
|
||||
equippedItems.values().remove(item.name);
|
||||
}
|
||||
}
|
||||
|
||||
public void equip(ItemData item) {
|
||||
if (equippedItems.get(item.equipmentSlot) != null && equippedItems.get(item.equipmentSlot).equals(item.name)) {
|
||||
item.isEquipped = false;
|
||||
equippedItems.remove(item.equipmentSlot);
|
||||
} else {
|
||||
item.isEquipped = true;
|
||||
equippedItems.put(item.equipmentSlot, item.name);
|
||||
}
|
||||
onEquipmentChange.emit();
|
||||
@@ -1105,34 +1163,42 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
}
|
||||
|
||||
public boolean hasItem(String name) {
|
||||
return inventoryItems.contains(name, false);
|
||||
ItemData itemData = ItemData.getItem(name);
|
||||
if (itemData == null)
|
||||
return false;
|
||||
return inventoryItems.contains(itemData, false);
|
||||
}
|
||||
|
||||
public int countItem(String name) {
|
||||
int count = 0;
|
||||
if (!hasItem(name))
|
||||
return count;
|
||||
for (String s : inventoryItems) {
|
||||
if (s.equals(name))
|
||||
for (ItemData i : inventoryItems) {
|
||||
if (i == null)
|
||||
continue;
|
||||
if (i.name.equals(name))
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public boolean addItem(String name) {
|
||||
return addItem(name, true);
|
||||
}
|
||||
public boolean addItem(String name, boolean updateEvent) {
|
||||
ItemData item = ItemData.getItem(name);
|
||||
if (item == null)
|
||||
return false;
|
||||
inventoryItems.add(name);
|
||||
AdventureQuestController.instance().updateItemReceived(item);
|
||||
inventoryItems.add(item);
|
||||
if (updateEvent)
|
||||
AdventureQuestController.instance().updateItemReceived(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void removeAllQuestItems(){
|
||||
for (String s : inventoryItems) {
|
||||
ItemData data = ItemData.getItem(s);
|
||||
for (ItemData data : inventoryItems) {
|
||||
if(data != null && data.questItem){
|
||||
removeItem(data.name);
|
||||
removeItem(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.utils.Align;
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.adventure.data.AdventureEventData;
|
||||
import forge.adventure.data.ItemData;
|
||||
import forge.adventure.player.AdventurePlayer;
|
||||
import forge.adventure.util.AdventureEventController;
|
||||
import forge.adventure.util.Config;
|
||||
@@ -77,7 +78,10 @@ public class AdventureDeckEditor extends FDeckEditor {
|
||||
}
|
||||
|
||||
String sketchbookPrefix = "landscape sketchbook - ";
|
||||
for (String itemName : AdventurePlayer.current().getItems()) {
|
||||
for (ItemData itemData : AdventurePlayer.current().getItems()) {
|
||||
if (itemData == null)
|
||||
continue;
|
||||
String itemName = itemData.name;
|
||||
if (!itemName.toLowerCase().startsWith(sketchbookPrefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import forge.adventure.stage.GameHUD;
|
||||
import forge.adventure.stage.MapStage;
|
||||
import forge.adventure.util.*;
|
||||
import forge.deck.Deck;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -28,12 +29,13 @@ public class InventoryScene extends UIScene {
|
||||
private final Table inventory;
|
||||
private final Array<Button> inventoryButtons = new Array<>();
|
||||
private final HashMap<String, Button> equipmentSlots = new HashMap<>();
|
||||
HashMap<Button, String> itemLocation = new HashMap<>();
|
||||
HashMap<Button, Pair<String, ItemData>> itemLocation = new HashMap<>();
|
||||
HashMap<Button, Deck> deckLocation = new HashMap<>();
|
||||
Button selected;
|
||||
Button deleteButton;
|
||||
TextraButton repairButton;
|
||||
Texture equipOverlay;
|
||||
Dialog useDialog, deleteDialog, openDialog;
|
||||
Dialog useDialog, deleteDialog;
|
||||
int columns = 0;
|
||||
|
||||
public InventoryScene() {
|
||||
@@ -41,6 +43,8 @@ public class InventoryScene extends UIScene {
|
||||
equipOverlay = Forge.getAssets().getTexture(Config.instance().getFile(Paths.ITEMS_EQUIP));
|
||||
ui.onButtonPress("return", this::done);
|
||||
leave = ui.findActor("return");
|
||||
repairButton = ui.findActor("repair");
|
||||
ui.onButtonPress("repair", this::repair);
|
||||
ui.onButtonPress("delete", this::showConfirm);
|
||||
ui.onButtonPress("equip", this::equip);
|
||||
ui.onButtonPress("use", this::use);
|
||||
@@ -65,28 +69,28 @@ public class InventoryScene extends UIScene {
|
||||
slot.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Button button = ((Button) actor);
|
||||
if (button.isChecked()) {
|
||||
for (Button otherButton : equipmentSlots.values()) {
|
||||
if (button != otherButton && otherButton.isChecked()) {
|
||||
otherButton.setChecked(false);
|
||||
}
|
||||
}
|
||||
String item = Current.player().itemInSlot(slotName);
|
||||
if (item != null && !item.isEmpty()) {
|
||||
Button changeButton = null;
|
||||
for (Button invButton : inventoryButtons) {
|
||||
if (itemLocation.get(invButton) != null && itemLocation.get(invButton).equals(item)) {
|
||||
changeButton = invButton;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (changeButton != null)
|
||||
changeButton.setChecked(true);
|
||||
} else {
|
||||
setSelected(null);
|
||||
Button button = ((Button) actor);
|
||||
if (button.isChecked()) {
|
||||
for (Button otherButton : equipmentSlots.values()) {
|
||||
if (button != otherButton && otherButton.isChecked()) {
|
||||
otherButton.setChecked(false);
|
||||
}
|
||||
}
|
||||
String item = Current.player().itemInSlot(slotName);
|
||||
if (item != null && !item.isEmpty()) {
|
||||
Button changeButton = null;
|
||||
for (Button invButton : inventoryButtons) {
|
||||
if (itemLocation.get(invButton) != null && itemLocation.get(invButton).equals(item)) {
|
||||
changeButton = invButton;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (changeButton != null)
|
||||
changeButton.setChecked(true);
|
||||
} else {
|
||||
setSelected(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@@ -105,15 +109,48 @@ public class InventoryScene extends UIScene {
|
||||
private void showConfirm() {
|
||||
if (deleteDialog == null) {
|
||||
deleteDialog = createGenericDialog("", Forge.getLocalizer().getMessage("lblDelete"),
|
||||
Forge.getLocalizer().getMessage("lblYes"),
|
||||
Forge.getLocalizer().getMessage("lblNo"), () -> {
|
||||
this.delete();
|
||||
removeDialog();
|
||||
}, this::removeDialog);
|
||||
Forge.getLocalizer().getMessage("lblYes"),
|
||||
Forge.getLocalizer().getMessage("lblNo"), () -> {
|
||||
this.delete();
|
||||
removeDialog();
|
||||
}, this::removeDialog);
|
||||
}
|
||||
showDialog(deleteDialog);
|
||||
}
|
||||
|
||||
private void repair() {
|
||||
if (selected == null)
|
||||
return;
|
||||
ItemData data = itemLocation.get(selected).getRight();
|
||||
if (data == null)
|
||||
return;
|
||||
int initialCost;
|
||||
try {
|
||||
//TODO apply modifiers from reputation..
|
||||
initialCost = (int) (data.cost * 0.4f);
|
||||
} catch (Exception e) {
|
||||
initialCost = 500;
|
||||
}
|
||||
if (Current.player().getGold() < initialCost) {
|
||||
showDialog(createGenericDialog("", Forge.getLocalizer().getMessage("lblNotEnoughCredits") + "\n[+GoldCoin] " + initialCost,
|
||||
Forge.getLocalizer().getMessage("lblOK"), null, this::removeDialog, null));
|
||||
return;
|
||||
}
|
||||
final int cost = initialCost;
|
||||
showDialog(createGenericDialog("", "[+" + data.iconName + "] " + data.name + "\n" +
|
||||
Forge.getLocalizer().getMessage("lblRepairCost", "[+GoldCoin] " + cost),
|
||||
Forge.getLocalizer().getMessage("lblYes"),
|
||||
Forge.getLocalizer().getMessage("lblNo"), () -> {
|
||||
if (data.isCracked) {
|
||||
data.isCracked = false;
|
||||
setSelected(selected);
|
||||
Current.player().takeGold(cost);
|
||||
}
|
||||
removeDialog();
|
||||
}, this::removeDialog)
|
||||
);
|
||||
}
|
||||
|
||||
private static InventoryScene object;
|
||||
|
||||
public static InventoryScene instance() {
|
||||
@@ -129,9 +166,10 @@ public class InventoryScene extends UIScene {
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
ItemData data = itemLocation.get(selected).getRight();
|
||||
if (data != null) {
|
||||
Current.player().removeItem(data.name);
|
||||
data.isEquipped = false;
|
||||
Current.player().removeItem(data);
|
||||
}
|
||||
updateInventory();
|
||||
|
||||
@@ -139,7 +177,7 @@ public class InventoryScene extends UIScene {
|
||||
|
||||
public void equip() {
|
||||
if (selected == null) return;
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
ItemData data = itemLocation.get(selected).getRight();
|
||||
if (data == null) return;
|
||||
Current.player().equip(data);
|
||||
updateInventory();
|
||||
@@ -153,7 +191,7 @@ public class InventoryScene extends UIScene {
|
||||
private void triggerUse() {
|
||||
if (selected == null) return;
|
||||
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
ItemData data = itemLocation.get(selected).getRight();
|
||||
if (data == null) return;
|
||||
Current.player().addShards(-data.shardsNeeded);
|
||||
done();
|
||||
@@ -189,7 +227,7 @@ public class InventoryScene extends UIScene {
|
||||
|
||||
private void use() {
|
||||
if (itemLocation.containsKey(selected)) {
|
||||
ItemData data = ItemData.getItem(itemLocation.get(selected));
|
||||
ItemData data = itemLocation.get(selected).getRight();
|
||||
if (data == null)
|
||||
return;
|
||||
if (useDialog == null) {
|
||||
@@ -220,13 +258,14 @@ public class InventoryScene extends UIScene {
|
||||
deleteButton.setDisabled(true);
|
||||
equipButton.setDisabled(true);
|
||||
useButton.setDisabled(true);
|
||||
repairButton.setVisible(false);
|
||||
for (Button button : inventoryButtons) {
|
||||
button.setChecked(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (itemLocation.containsKey(actor)) {
|
||||
ItemData data = ItemData.getItem(itemLocation.get(actor));
|
||||
ItemData data = itemLocation.get(actor).getRight();
|
||||
if (data == null) return;
|
||||
|
||||
deleteButton.setDisabled(data.questItem);
|
||||
@@ -248,7 +287,7 @@ public class InventoryScene extends UIScene {
|
||||
if (equipButton instanceof TextraButton) {
|
||||
TextraButton button = (TextraButton) equipButton;
|
||||
String item = Current.player().itemInSlot(data.equipmentSlot);
|
||||
if (item != null && item.equals(data.name)) {
|
||||
if (item != null && item.equals(data.name) && data.isEquipped) {
|
||||
button.setText("Unequip");
|
||||
} else {
|
||||
button.setText("Equip");
|
||||
@@ -256,6 +295,7 @@ public class InventoryScene extends UIScene {
|
||||
button.layout();
|
||||
}
|
||||
}
|
||||
repairButton.setVisible(data.isCracked);
|
||||
String status = data.isCracked ? " (" + Forge.getLocalizer().getMessage("lblCracked") + ")" : "";
|
||||
itemDescription.setText(data.name + status + "\n[%98]" + data.getDescription());
|
||||
}
|
||||
@@ -268,6 +308,7 @@ public class InventoryScene extends UIScene {
|
||||
useButton.setText("Open");
|
||||
useButton.layout();
|
||||
equipButton.setDisabled(true);
|
||||
repairButton.setVisible(false);
|
||||
|
||||
itemDescription.setText(data.getName() + "\n[%98]" + (data.getComment() == null?"":data.getComment()+" - ") + data.getAllCardsInASinglePool(true, true).countAll() + " cards");
|
||||
}
|
||||
@@ -283,20 +324,17 @@ public class InventoryScene extends UIScene {
|
||||
}
|
||||
|
||||
private void updateInventory() {
|
||||
clearItemDescription();
|
||||
clearSelectable();
|
||||
inventoryButtons.clear();
|
||||
inventory.clear();
|
||||
repairButton.setVisible(false);
|
||||
|
||||
int itemSlotsUsed = 0;
|
||||
// Turn item strings into actual ItemData
|
||||
// THen sort but these by slot type and name
|
||||
|
||||
Array<ItemData> items = new Array<>();
|
||||
for (int i = 0; i < Current.player().getItems().size; i++) {
|
||||
String name = Current.player().getItems().get(i);
|
||||
ItemData item = ItemData.getItem(name);
|
||||
ItemData item = Current.player().getItems().get(i);
|
||||
if (item == null) {
|
||||
System.err.print("Can not find item name " + name + "\n");
|
||||
continue;
|
||||
}
|
||||
if (item.sprite() == null) {
|
||||
@@ -306,6 +344,7 @@ public class InventoryScene extends UIScene {
|
||||
|
||||
items.add(item);
|
||||
}
|
||||
// sort these by slot type and name
|
||||
items.sort((o1, o2) -> {
|
||||
if (o1.equipmentSlot == null && o2.equipmentSlot == null) {
|
||||
return o1.name.compareTo(o2.name);
|
||||
@@ -342,8 +381,8 @@ public class InventoryScene extends UIScene {
|
||||
img.setX((newActor.getWidth() - img.getWidth()) / 2);
|
||||
img.setY((newActor.getHeight() - img.getHeight()) / 2);
|
||||
newActor.addActor(img);
|
||||
itemLocation.put(newActor, item.name);
|
||||
if (Current.player().getEquippedItems().contains(item.name)) {
|
||||
itemLocation.put(newActor, Pair.of(item.name, item));
|
||||
if (item.isEquipped && Current.player().getEquippedItems().contains(item.name)) {
|
||||
Image overlay = new Image(equipOverlay);
|
||||
overlay.setX((newActor.getWidth() - img.getWidth()) / 2);
|
||||
overlay.setY((newActor.getHeight() - img.getHeight()) / 2);
|
||||
@@ -361,7 +400,6 @@ public class InventoryScene extends UIScene {
|
||||
}
|
||||
|
||||
for (int i = 0; i < Current.player().getBoostersOwned().size; i++) {
|
||||
|
||||
if ((i + itemSlotsUsed) % columns == 0)
|
||||
inventory.row();
|
||||
Button newActor = createInventorySlot();
|
||||
@@ -396,14 +434,13 @@ public class InventoryScene extends UIScene {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
for (Map.Entry<String, Button> slot : equipmentSlots.entrySet()) {
|
||||
if (slot.getValue().getChildren().size >= 2)
|
||||
slot.getValue().removeActorAt(1, false);
|
||||
String equippedItem = Current.player().itemInSlot(slot.getKey());
|
||||
if (equippedItem == null || equippedItem.isEmpty())
|
||||
continue;
|
||||
ItemData item = ItemData.getItem(equippedItem);
|
||||
ItemData item = Current.player().getEquippedItem(equippedItem);
|
||||
if (item != null) {
|
||||
Image img = new Image(item.sprite());
|
||||
img.setX((slot.getValue().getWidth() - img.getWidth()) / 2);
|
||||
@@ -411,6 +448,8 @@ public class InventoryScene extends UIScene {
|
||||
slot.getValue().addActor(img);
|
||||
}
|
||||
}
|
||||
// make sure repair is clickable
|
||||
repairButton.setZIndex(ui.getChildren().size);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.badlogic.gdx.utils.Null;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.viewport.ScalingViewport;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
@@ -247,18 +246,18 @@ public class UIScene extends Scene {
|
||||
public Dialog createGenericDialog(String title, String label, String stringYes, String stringNo, Runnable runnableYes, Runnable runnableNo, boolean cancelButton, String stringCancel) {
|
||||
Dialog dialog = new Dialog(title == null ? "" : title, Controls.getSkin());
|
||||
textboxOpen = true;
|
||||
|
||||
if (label != null)
|
||||
dialog.text(label);
|
||||
TextraButton yes = Controls.newTextButton(stringYes, runnableYes);
|
||||
dialog.button(yes);
|
||||
if (stringNo != null) {
|
||||
TextraButton no = Controls.newTextButton(stringNo, runnableNo);
|
||||
dialog.button(no);
|
||||
}
|
||||
if (cancelButton) {
|
||||
TextraButton cancel = Controls.newTextButton(stringCancel, this::removeDialog);
|
||||
dialog.button(cancel);
|
||||
}
|
||||
dialog.getContentTable().add(Controls.newTextraLabel(label));
|
||||
|
||||
dialog.button(Controls.newTextButton(stringYes, runnableYes));
|
||||
|
||||
if (stringNo != null)
|
||||
dialog.button(Controls.newTextButton(stringNo, runnableNo));
|
||||
|
||||
if (cancelButton)
|
||||
dialog.button(Controls.newTextButton(stringCancel, this::removeDialog));
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,16 +27,14 @@ public class Current {
|
||||
public static void setLatestDeck(Deck generateDeck) {
|
||||
deck=generateDeck;
|
||||
}
|
||||
public static String generateDefeatMessage() {;
|
||||
public static String generateDefeatMessage() {
|
||||
String message = Forge.getLocalizer().getMessage("lblYouDied", player().getName());
|
||||
if (player().isHardorInsaneDifficulty()) {
|
||||
ItemData itemData = player().getRandomEquippedArmor();
|
||||
if (itemData != null) {
|
||||
itemData.isCracked = true;
|
||||
player().equip(itemData); //unequip...
|
||||
InventoryScene.instance().clearItemDescription();
|
||||
message += "\n{GRADIENT=RED;GRAY;1;1}" + itemData.name + " {ENDGRADIENT}" + Forge.getLocalizer().getMessage("lblCracked");
|
||||
}
|
||||
ItemData itemData = player().getRandomEquippedItem();
|
||||
if (itemData != null) {
|
||||
itemData.isCracked = true;
|
||||
player().equip(itemData); //un-equip
|
||||
InventoryScene.instance().clearItemDescription();
|
||||
message += "\n{GRADIENT=RED;GRAY;1;1}" + itemData.name + " {ENDGRADIENT}" + Forge.getLocalizer().getMessage("lblCracked");
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@@ -489,6 +489,9 @@ Star
|
||||
TreasureChest
|
||||
xy: 464, 32
|
||||
size: 16, 16
|
||||
ToolBox
|
||||
xy: 448, 79
|
||||
size: 16, 16
|
||||
UnderworldCookbook
|
||||
xy: 304, 960
|
||||
size: 16, 16
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 102 KiB |
@@ -142,6 +142,15 @@
|
||||
"height": 30,
|
||||
"x": 160,
|
||||
"y": 222
|
||||
},
|
||||
{
|
||||
"type": "TextButton",
|
||||
"name": "repair",
|
||||
"text": "[%80][+ToolBox] tr(lblRepair)",
|
||||
"width": 42,
|
||||
"height": 22,
|
||||
"x": 152,
|
||||
"y": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -138,6 +138,15 @@
|
||||
"height": 30,
|
||||
"x": 205,
|
||||
"y": 363
|
||||
},
|
||||
{
|
||||
"type": "TextButton",
|
||||
"name": "repair",
|
||||
"text": "[%80][+ToolBox] tr(lblRepair)",
|
||||
"width": 42,
|
||||
"height": 22,
|
||||
"x": 16,
|
||||
"y": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -3540,3 +3540,5 @@ lblRestoreMsg=Wiederherstellen von Dateien
|
||||
lblSuccess=Erfolg
|
||||
cbPreloadCustomDrafts=Benutzerdefinierte Entwürfe vorladen
|
||||
nlPreloadCustomDrafts=Wenn aktiviert, werden die benutzerdefinierten Entwurfsdateien beim Start vorab geladen (Forge benötigt beim Parsen von Entwurfsdateien eine längere Startzeit).
|
||||
lblRepairCost=Reparaturkosten: {0} ?
|
||||
lblRepair=Reparieren
|
||||
@@ -3293,4 +3293,6 @@ lblBackupMsg=Backing up files
|
||||
lblRestoreMsg=Restoring files
|
||||
lblSuccess=Success
|
||||
cbPreloadCustomDrafts=Preload Custom Drafts
|
||||
nlPreloadCustomDrafts=If enabled, the custom drafts files are preloaded on startup (Forge will have longer startup time when parsing drafts files).
|
||||
nlPreloadCustomDrafts=If enabled, the custom drafts files are preloaded on startup (Forge will have longer startup time when parsing drafts files).
|
||||
lblRepairCost=Repair Cost: {0} ?
|
||||
lblRepair=Repair
|
||||
@@ -3544,3 +3544,5 @@ lblRestoreMsg=Restaurando archivos
|
||||
lblSuccess=Éxito
|
||||
cbPreloadCustomDrafts=Precargar borradores personalizados
|
||||
nlPreloadCustomDrafts=Si está habilitado, los archivos de borradores personalizados se precargan al inicio (Forge tendrá un tiempo de inicio más largo al analizar los archivos de borradores).
|
||||
lblRepairCost=Costo de reparación: {0} ?
|
||||
lblRepair=Reparar
|
||||
@@ -3545,3 +3545,5 @@ lblRestoreMsg=Restauration de fichiers
|
||||
lblSuccess=Succès
|
||||
cbPreloadCustomDrafts=Précharger les brouillons personnalisés
|
||||
nlPreloadCustomDrafts=Si cette option est activée, les fichiers de brouillons personnalisés sont préchargés au démarrage (Forge aura un temps de démarrage plus long lors de l'analyse des fichiers de brouillons).
|
||||
lblRepairCost=Coût de réparation : {0} ?
|
||||
lblRepair=Réparation
|
||||
@@ -3543,3 +3543,5 @@ lblRestoreMsg=Ripristino dei file
|
||||
lblSuccess=Successo
|
||||
cbPreloadCustomDrafts=Precarica bozze personalizzate
|
||||
nlPreloadCustomDrafts=Se abilitato, i file delle bozze personalizzate vengono precaricati all'avvio (Forge avrà tempi di avvio più lunghi durante l'analisi dei file delle bozze).
|
||||
lblRepairCost=Costo di riparazione: {0} ?
|
||||
lblRepair=Riparazione
|
||||
@@ -3539,3 +3539,5 @@ lblRestoreMsg=ファイルの復元
|
||||
lblSuccess=成功
|
||||
cbPreloadCustomDrafts=カスタムドラフトをプリロードする
|
||||
nlPreloadCustomDrafts=有効にすると、起動時にカスタム ドラフト ファイルがプリロードされます (ドラフト ファイルを解析するときに Forge の起動時間が長くなります)。
|
||||
lblRepairCost=修理費用: {0}?
|
||||
lblRepair=修理
|
||||
@@ -3628,3 +3628,5 @@ lblRestoreMsg=Restaurando arquivos
|
||||
lblSuccess=Sucesso
|
||||
cbPreloadCustomDrafts=Pré-carregar rascunhos personalizados
|
||||
nlPreloadCustomDrafts=Se habilitado, os arquivos de rascunhos personalizados serão pré-carregados na inicialização (o Forge terá um tempo de inicialização maior ao analisar arquivos de rascunhos).
|
||||
lblRepairCost=Custo do reparo: {0} ?
|
||||
lblRepair=Reparar
|
||||
@@ -3530,3 +3530,5 @@ lblRestoreMsg=恢复文件
|
||||
lblSuccess=成功
|
||||
cbPreloadCustomDrafts=预加载自定义草稿
|
||||
nlPreloadCustomDrafts=如果启用,自定义草稿文件将在启动时预加载(Forge 在解析草稿文件时会有更长的启动时间)。
|
||||
lblRepairCost=维修费用:{0}?
|
||||
lblRepair=维修
|
||||
Reference in New Issue
Block a user