Refactoring, options screen and more detailed balance history
This commit is contained in:
@@ -11,7 +11,6 @@ public class Start {
|
|||||||
was.reload();
|
was.reload();
|
||||||
was.setup();
|
was.setup();
|
||||||
|
|
||||||
I18n.getInstance().setLang("de_de", was.getContentManager());
|
|
||||||
Util.LOGGER.log(Level.INFO, I18n.getInstance().getString("test.hello-world"));
|
Util.LOGGER.log(Level.INFO, I18n.getInstance().getString("test.hello-world"));
|
||||||
|
|
||||||
was.run();
|
was.run();
|
||||||
|
|||||||
@@ -9,13 +9,12 @@ import de.siphalor.was.content.product.ProductManager;
|
|||||||
import de.siphalor.was.content.quest.Quest;
|
import de.siphalor.was.content.quest.Quest;
|
||||||
import de.siphalor.was.content.quest.QuestGenerator;
|
import de.siphalor.was.content.quest.QuestGenerator;
|
||||||
import de.siphalor.was.content.quest.QuestManager;
|
import de.siphalor.was.content.quest.QuestManager;
|
||||||
import de.siphalor.was.content.quest.RandomQuestGenerator;
|
import de.siphalor.was.game.*;
|
||||||
import de.siphalor.was.game.Balance;
|
import de.siphalor.was.util.Pair;
|
||||||
import de.siphalor.was.game.Options;
|
|
||||||
import de.siphalor.was.game.Storage;
|
|
||||||
import de.siphalor.was.util.Util;
|
import de.siphalor.was.util.Util;
|
||||||
import de.siphalor.was.visual.JFXVisual;
|
import de.siphalor.was.visual.JFXVisual;
|
||||||
import de.siphalor.was.visual.Visual;
|
import de.siphalor.was.visual.Visual;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -90,6 +89,7 @@ public class WhatAStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options.load();
|
||||||
I18n.getInstance().reload(contentManager);
|
I18n.getInstance().reload(contentManager);
|
||||||
|
|
||||||
productManager.clear();
|
productManager.clear();
|
||||||
@@ -137,16 +137,34 @@ public class WhatAStorage {
|
|||||||
}).toArray(String[]::new);
|
}).toArray(String[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTransaction(Balance.Transaction transaction, int change) {
|
private void addTransaction(@NotNull Transaction.Type type, int change, @Nullable Product product) {
|
||||||
balance.add(transaction, change);
|
Transaction transaction = balance.add(type, change, product);
|
||||||
visual.onBalanceChanged(balance.getBudget(), transaction, change, balance.getTotalIncome(), balance.getTotalLoss());
|
visual.onBalanceChanged(balance.getBudget(), transaction, balance.getTotalIncome(), balance.getTotalLoss());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean requestQuest() {
|
public void invalidateI18n() {
|
||||||
|
visual.invalidateI18n();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resendVisualGameData() {
|
||||||
|
for (int x = 0; x < storage.getWidth(); x++) {
|
||||||
|
for (int y = 0; y < storage.getHeight(); y++) {
|
||||||
|
for (Pair<Integer, Product> entry : storage.get(x, y).getProductsIndexed()) {
|
||||||
|
visual.onProductSet(x, y, entry.getFirst(), entry.getSecond());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Quest quest : quests) {
|
||||||
|
visual.onQuestAdded(quest, quests.size() < MAX_QUESTS);
|
||||||
|
}
|
||||||
|
visual.onBalanceChanged(balance.getBudget(), new Transaction(Transaction.Type.NOOP, 0, ""), balance.getTotalIncome(), balance.getTotalLoss());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean userRequestQuest() {
|
||||||
if (quests.size() >= MAX_QUESTS) return false;
|
if (quests.size() >= MAX_QUESTS) return false;
|
||||||
|
|
||||||
if (!questGenerator.hasMoreElements()) {
|
if (!questGenerator.hasMoreElements()) {
|
||||||
return false;
|
questGenerator.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
Quest next = questGenerator.nextElement();
|
Quest next = questGenerator.nextElement();
|
||||||
@@ -156,14 +174,14 @@ public class WhatAStorage {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void abandonQuest(int index) {
|
public void userAbandonQuest(int index) {
|
||||||
if (index >= quests.size()) {
|
if (index >= quests.size()) {
|
||||||
Util.LOGGER.log(Level.SEVERE, "Attempted to abandon non-existent quest!");
|
Util.LOGGER.log(Level.SEVERE, "Attempted to abandon non-existent quest!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quest quest = quests.remove(index);
|
Quest quest = quests.remove(index);
|
||||||
addTransaction(Balance.Transaction.ABANDON, -quest.getReward());
|
addTransaction(Transaction.Type.ABANDON, -quest.getReward(), quest.getProduct());
|
||||||
|
|
||||||
visual.onQuestRemoved(index);
|
visual.onQuestRemoved(index);
|
||||||
}
|
}
|
||||||
@@ -180,7 +198,7 @@ public class WhatAStorage {
|
|||||||
return canStoreProduct(storage.get(x1, y1).front(), x2, y2);
|
return canStoreProduct(storage.get(x1, y1).front(), x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeProduct(int questIndex, int x, int y) {
|
public void userStoreProduct(int questIndex, int x, int y) {
|
||||||
Quest quest = quests.get(questIndex);
|
Quest quest = quests.get(questIndex);
|
||||||
if (quest != null && quest.getType() == Quest.Type.IN) {
|
if (quest != null && quest.getType() == Quest.Type.IN) {
|
||||||
Product product = quest.getProduct();
|
Product product = quest.getProduct();
|
||||||
@@ -188,7 +206,7 @@ public class WhatAStorage {
|
|||||||
int z = storage.get(x, y).add(product);
|
int z = storage.get(x, y).add(product);
|
||||||
if (z >= 0 && product.testY(y)) {
|
if (z >= 0 && product.testY(y)) {
|
||||||
quests.remove(questIndex);
|
quests.remove(questIndex);
|
||||||
addTransaction(Balance.Transaction.STORE, quest.getReward());
|
addTransaction(Transaction.Type.STORE, quest.getReward(), product);
|
||||||
visual.onQuestRemoved(questIndex);
|
visual.onQuestRemoved(questIndex);
|
||||||
visual.onProductSet(x, y, z, quest.getProduct());
|
visual.onProductSet(x, y, z, quest.getProduct());
|
||||||
}
|
}
|
||||||
@@ -203,11 +221,11 @@ public class WhatAStorage {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deliverProduct(int questIndex, int x, int y) {
|
public boolean userDeliverProduct(int questIndex, int x, int y) {
|
||||||
if (canDeliverProduct(questIndex, x, y)) {
|
if (canDeliverProduct(questIndex, x, y)) {
|
||||||
Product product = storage.get(x, y).front();
|
Product product = storage.get(x, y).front();
|
||||||
int z = storage.get(x, y).pop();
|
int z = storage.get(x, y).pop();
|
||||||
addTransaction(Balance.Transaction.DELIVER, quests.get(questIndex).getReward());
|
addTransaction(Transaction.Type.DELIVER, quests.get(questIndex).getReward(), product);
|
||||||
quests.remove(questIndex);
|
quests.remove(questIndex);
|
||||||
visual.onQuestRemoved(questIndex);
|
visual.onQuestRemoved(questIndex);
|
||||||
visual.onProductCleared(x, y, z, product);
|
visual.onProductCleared(x, y, z, product);
|
||||||
@@ -227,15 +245,15 @@ public class WhatAStorage {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean resolveQuests(int in, int out) {
|
public boolean userResolveQuests(int in, int out) {
|
||||||
if (options.getAllowQuestResolving()) {
|
if (options.getAllowQuestResolving()) {
|
||||||
int s = quests.size();
|
int s = quests.size();
|
||||||
if (in < s && in >= 0 && out < s && out >= 0) {
|
if (in < s && in >= 0 && out < s && out >= 0) {
|
||||||
if (quests.get(in).getType() == Quest.Type.IN && quests.get(out).getType() == Quest.Type.OUT) {
|
if (quests.get(in).getType() == Quest.Type.IN && quests.get(out).getType() == Quest.Type.OUT) {
|
||||||
Product product = quests.get(in).getProduct();
|
Product product = quests.get(in).getProduct();
|
||||||
if (product.equals(quests.get(out).getProduct())) {
|
if (product.equals(quests.get(out).getProduct())) {
|
||||||
addTransaction(Balance.Transaction.STORE, quests.get(in).getReward());
|
addTransaction(Transaction.Type.STORE, quests.get(in).getReward(), product);
|
||||||
addTransaction(Balance.Transaction.DELIVER, quests.get(out).getReward());
|
addTransaction(Transaction.Type.DELIVER, quests.get(out).getReward(), product);
|
||||||
|
|
||||||
if (out > in) out--;
|
if (out > in) out--;
|
||||||
quests.remove(in);
|
quests.remove(in);
|
||||||
@@ -251,25 +269,25 @@ public class WhatAStorage {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveProduct(int x1, int y1, int x2, int y2) {
|
public void userMoveProduct(int x1, int y1, int x2, int y2) {
|
||||||
Product product = storage.get(x1, y1).front();
|
Product product = storage.get(x1, y1).front();
|
||||||
if (product != null && product.testY(y2)) {
|
if (product != null && product.testY(y2)) {
|
||||||
int z2 = storage.get(x2, y2).add(product);
|
int z2 = storage.get(x2, y2).add(product);
|
||||||
if (z2 >= 0) {
|
if (z2 >= 0) {
|
||||||
int z1 = storage.get(x1, y1).pop();
|
int z1 = storage.get(x1, y1).pop();
|
||||||
|
|
||||||
addTransaction(Balance.Transaction.MOVE, -100);
|
addTransaction(Transaction.Type.MOVE, -100, product);
|
||||||
visual.onProductCleared(x1, y1, z1, product);
|
visual.onProductCleared(x1, y1, z1, product);
|
||||||
visual.onProductSet(x2, y2, z2, product);
|
visual.onProductSet(x2, y2, z2, product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroyProduct(int x, int y) {
|
public void userDestroyProduct(int x, int y) {
|
||||||
Product product = storage.get(x, y).front();
|
Product product = storage.get(x, y).front();
|
||||||
int z = storage.get(x, y).pop();
|
int z = storage.get(x, y).pop();
|
||||||
if (z >= 0) {
|
if (z >= 0) {
|
||||||
addTransaction(Balance.Transaction.DESTROY, -500);
|
addTransaction(Transaction.Type.DESTROY, -500, product);
|
||||||
visual.onProductCleared(x, y, z, product);
|
visual.onProductCleared(x, y, z, product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package de.siphalor.was.game;
|
package de.siphalor.was.game;
|
||||||
|
|
||||||
import de.siphalor.was.util.Pair;
|
import de.siphalor.was.content.product.Product;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
@@ -10,21 +11,27 @@ public class Balance {
|
|||||||
private int budget = 0;
|
private int budget = 0;
|
||||||
private int totalIncome = 0;
|
private int totalIncome = 0;
|
||||||
private int totalLoss = 0;
|
private int totalLoss = 0;
|
||||||
private final Queue<Pair<Transaction, Integer>> history = new ConcurrentLinkedQueue<>();
|
private final Queue<Transaction> history = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
public void add(Transaction transaction, int change) {
|
public Transaction add(@NotNull Transaction.Type type, int change, @Nullable Product product) {
|
||||||
history.add(Pair.of(transaction, change));
|
return add(new Transaction(type, change, product != null ? product.getTranslationKey() : ""));
|
||||||
|
}
|
||||||
|
|
||||||
budget += change;
|
public Transaction add(@NotNull Transaction transaction) {
|
||||||
|
history.add(transaction);
|
||||||
|
|
||||||
if (change < 0) {
|
budget += transaction.getChange();
|
||||||
totalLoss -= change;
|
|
||||||
|
if (transaction.getChange() < 0) {
|
||||||
|
totalLoss -= transaction.getChange();
|
||||||
} else {
|
} else {
|
||||||
totalIncome += change;
|
totalIncome += transaction.getChange();
|
||||||
}
|
}
|
||||||
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Queue<Pair<Transaction, Integer>> getHistory() {
|
@NotNull
|
||||||
|
public Queue<Transaction> getHistory() {
|
||||||
return history;
|
return history;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,11 +47,4 @@ public class Balance {
|
|||||||
return totalLoss;
|
return totalLoss;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Transaction {
|
|
||||||
ABANDON, DESTROY, MOVE, NOOP, DELIVER, STORE;
|
|
||||||
|
|
||||||
public String getTranslationKey() {
|
|
||||||
return "game.balance.history.type." + name().toLowerCase(Locale.ENGLISH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
package de.siphalor.was.game;
|
package de.siphalor.was.game;
|
||||||
|
|
||||||
|
import de.siphalor.was.WhatAStorage;
|
||||||
|
import de.siphalor.was.content.lang.I18n;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
public class Options {
|
public class Options {
|
||||||
private boolean autoRefillQuests;
|
private boolean autoRefillQuests;
|
||||||
private boolean allowQuestResolving;
|
private boolean allowQuestResolving;
|
||||||
@@ -19,4 +25,24 @@ public class Options {
|
|||||||
public void setAutoRefillQuests(boolean autoRefillQuests) {
|
public void setAutoRefillQuests(boolean autoRefillQuests) {
|
||||||
this.autoRefillQuests = autoRefillQuests;
|
this.autoRefillQuests = autoRefillQuests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Preferences getPreferences() {
|
||||||
|
return Preferences.userNodeForPackage(WhatAStorage.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
Preferences preferences = getPreferences();
|
||||||
|
autoRefillQuests = preferences.getBoolean("auto-refill-quests", false);
|
||||||
|
allowQuestResolving = preferences.getBoolean("allow-quest-resolving", true);
|
||||||
|
|
||||||
|
String lang = preferences.get("preferred-lang", Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry());
|
||||||
|
I18n.getInstance().setLang(lang, WhatAStorage.getInstance().getContentManager());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
Preferences preferences = getPreferences();
|
||||||
|
preferences.putBoolean("auto-refill-quests", autoRefillQuests);
|
||||||
|
preferences.putBoolean("allow-quest-resolving", allowQuestResolving);
|
||||||
|
preferences.put("preferred-lang", I18n.getInstance().getLang().getCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package de.siphalor.was.game;
|
package de.siphalor.was.game;
|
||||||
|
|
||||||
import de.siphalor.was.content.product.Product;
|
import de.siphalor.was.content.product.Product;
|
||||||
|
import de.siphalor.was.util.Pair;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
public class StorageSlot {
|
public class StorageSlot {
|
||||||
final int depth;
|
final int depth;
|
||||||
@@ -20,6 +24,21 @@ public class StorageSlot {
|
|||||||
return products;
|
return products;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Collection<Pair<Integer, Product>> getProductsIndexed() {
|
||||||
|
Queue<Pair<Integer, Product>> queue = new ConcurrentLinkedQueue<>();
|
||||||
|
int index = 0;
|
||||||
|
for (int i = 0; i < depth; i++) {
|
||||||
|
if (products[i] == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.add(Pair.of(index, products[i]));
|
||||||
|
index += products[i].getDepth();
|
||||||
|
}
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
Arrays.fill(products, null);
|
Arrays.fill(products, null);
|
||||||
}
|
}
|
||||||
|
|||||||
39
src/main/java/de/siphalor/was/game/Transaction.java
Normal file
39
src/main/java/de/siphalor/was/game/Transaction.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package de.siphalor.was.game;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class Transaction {
|
||||||
|
private final Type type;
|
||||||
|
private final int change;
|
||||||
|
private final String productKey;
|
||||||
|
|
||||||
|
public Transaction(@NotNull Type type, int change, @NotNull String productKey) {
|
||||||
|
this.type = type;
|
||||||
|
this.change = change;
|
||||||
|
this.productKey = productKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChange() {
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getProductKey() {
|
||||||
|
return productKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
ABANDON, DESTROY, MOVE, NOOP, DELIVER, STORE;
|
||||||
|
|
||||||
|
public String getTranslationKey() {
|
||||||
|
return "game.balance.history.type." + name().toLowerCase(Locale.ENGLISH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import de.siphalor.was.WhatAStorage;
|
|||||||
import de.siphalor.was.assets.AssetsManager;
|
import de.siphalor.was.assets.AssetsManager;
|
||||||
import de.siphalor.was.content.product.Product;
|
import de.siphalor.was.content.product.Product;
|
||||||
import de.siphalor.was.content.quest.Quest;
|
import de.siphalor.was.content.quest.Quest;
|
||||||
import de.siphalor.was.game.Balance;
|
import de.siphalor.was.game.Transaction;
|
||||||
import de.siphalor.was.visual.canvas.layout.FixedAspectLayout;
|
import de.siphalor.was.visual.canvas.layout.FixedAspectLayout;
|
||||||
import de.siphalor.was.visual.canvas.layout.FulfillingLayout;
|
import de.siphalor.was.visual.canvas.layout.FulfillingLayout;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -155,7 +155,12 @@ public class CanvasVisual implements Visual {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBalanceChanged(int budget, Balance.Transaction transaction, int change, int totalIncome, int totalLoss) {
|
public void invalidateI18n() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBalanceChanged(int budget, Transaction transaction, int totalIncome, int totalLoss) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ import de.siphalor.was.content.lang.I18n;
|
|||||||
import de.siphalor.was.content.product.Product;
|
import de.siphalor.was.content.product.Product;
|
||||||
import de.siphalor.was.content.quest.Quest;
|
import de.siphalor.was.content.quest.Quest;
|
||||||
import de.siphalor.was.content.resource.Resource;
|
import de.siphalor.was.content.resource.Resource;
|
||||||
import de.siphalor.was.game.Balance;
|
import de.siphalor.was.game.Transaction;
|
||||||
import de.siphalor.was.util.Util;
|
import de.siphalor.was.util.Util;
|
||||||
import de.siphalor.was.visual.jfx.controller.BalanceController;
|
import de.siphalor.was.visual.jfx.controller.BalanceController;
|
||||||
import de.siphalor.was.visual.jfx.controller.MainController;
|
import de.siphalor.was.visual.jfx.controller.MainController;
|
||||||
import de.siphalor.was.visual.jfx.controller.OptionsController;
|
import de.siphalor.was.visual.jfx.controller.OptionsController;
|
||||||
import de.siphalor.was.visual.jfx.controller.QuestController;
|
import de.siphalor.was.visual.jfx.controller.QuestController;
|
||||||
import de.siphalor.was.visual.jfx.util.JFXUtil;
|
import de.siphalor.was.visual.jfx.util.JFXUtil;
|
||||||
import de.siphalor.was.visual.jfx.util.StorageSlot;
|
import de.siphalor.was.visual.jfx.util.JFXStorageSlot;
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.FadeTransition;
|
||||||
import javafx.animation.Interpolator;
|
import javafx.animation.Interpolator;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
@@ -37,12 +37,13 @@ import java.util.Optional;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class JFXVisual extends Application implements Visual {
|
public class JFXVisual extends Application implements Visual {
|
||||||
|
private static boolean i18nInvalidated = false;
|
||||||
private static Stage primaryStage;
|
private static Stage primaryStage;
|
||||||
|
|
||||||
private static Scene mainScene;
|
private static Scene gameScene;
|
||||||
private static MainController mainController;
|
private static MainController gameController;
|
||||||
private static GridPane storageGrid;
|
private static GridPane storageGrid;
|
||||||
private static StorageSlot[][] storageSlots;
|
private static JFXStorageSlot[][] storageSlots;
|
||||||
|
|
||||||
private static Scene optionsScene;
|
private static Scene optionsScene;
|
||||||
private static OptionsController optionsController;
|
private static OptionsController optionsController;
|
||||||
@@ -85,14 +86,19 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBalanceChanged(int budget, Balance.Transaction transaction, int change, int totalIncome, int totalLoss) {
|
public void invalidateI18n() {
|
||||||
|
i18nInvalidated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBalanceChanged(int budget, Transaction transaction, int totalIncome, int totalLoss) {
|
||||||
I18n i18n = I18n.getInstance();
|
I18n i18n = I18n.getInstance();
|
||||||
|
|
||||||
mainController.budgetLabel.setText(i18n.format("game.budget", budget));
|
gameController.budgetLabel.setText(i18n.format("game.budget", budget));
|
||||||
JFXUtil.setStyleClass(mainController.budgetLabel, "red", budget < 0);
|
JFXUtil.setStyleClass(gameController.budgetLabel, "red", budget < 0);
|
||||||
|
|
||||||
if (balanceController != null) {
|
if (balanceController != null) {
|
||||||
balanceController.onBalanceChanged(budget, transaction, change, totalIncome, totalLoss);
|
balanceController.onBalanceChanged(budget, transaction, totalIncome, totalLoss);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,24 +106,24 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
public void onQuestAdded(Quest newQuest, boolean canCreateMore) {
|
public void onQuestAdded(Quest newQuest, boolean canCreateMore) {
|
||||||
addQuest(newQuest);
|
addQuest(newQuest);
|
||||||
|
|
||||||
mainController.nextQuestButton.setDisable(!canCreateMore);
|
gameController.nextQuestButton.setDisable(!canCreateMore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onQuestRemoved(int index) {
|
public void onQuestRemoved(int index) {
|
||||||
mainController.questBox.getChildren().remove(index);
|
gameController.questBox.getChildren().remove(index);
|
||||||
|
|
||||||
mainController.nextQuestButton.setDisable(false);
|
gameController.nextQuestButton.setDisable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
JFXVisual.primaryStage = primaryStage;
|
JFXVisual.primaryStage = primaryStage;
|
||||||
|
primaryStage.setTitle(WhatAStorage.TITLE);
|
||||||
primaryStage.setMinWidth(850);
|
primaryStage.setMinWidth(850);
|
||||||
primaryStage.setMinHeight(500);
|
primaryStage.setMinHeight(500);
|
||||||
primaryStage.setTitle(WhatAStorage.TITLE);
|
|
||||||
|
|
||||||
loadMainScene();
|
loadGameScene();
|
||||||
loadOptionsScene();
|
loadOptionsScene();
|
||||||
|
|
||||||
primaryStage.setOnCloseRequest(event -> {
|
primaryStage.setOnCloseRequest(event -> {
|
||||||
@@ -125,31 +131,50 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
balanceStage.hide();
|
balanceStage.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
primaryStage.setScene(mainScene);
|
changeScene(gameScene);
|
||||||
|
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadMainScene() {
|
private void changeScene(Scene nextScene) {
|
||||||
mainController = new MainController(WhatAStorage.getInstance());
|
primaryStage.setScene(nextScene);
|
||||||
|
}
|
||||||
|
|
||||||
mainScene = JFXUtil.loadScene("game", mainController, I18n.getInstance());
|
public void loadGameScene() {
|
||||||
|
gameController = new MainController(WhatAStorage.getInstance());
|
||||||
|
|
||||||
|
gameScene = JFXUtil.loadScene("game", gameController, I18n.getInstance());
|
||||||
|
|
||||||
prepareStorageGrid(3, 3, 3);
|
prepareStorageGrid(3, 3, 3);
|
||||||
|
|
||||||
AssetsManager.getStream("textures/bin_closed.png").ifPresent(inputStream -> {
|
AssetsManager.getStream("textures/bin_closed.png").ifPresent(inputStream -> {
|
||||||
mainController.trash.setImage(new Image(inputStream));
|
gameController.trash.setImage(new Image(inputStream));
|
||||||
});
|
});
|
||||||
|
|
||||||
onBalanceChanged(0, Balance.Transaction.NOOP, 0, 0, 0);
|
onBalanceChanged(0, new Transaction(Transaction.Type.NOOP, 0, ""), 0, 0);
|
||||||
|
|
||||||
mainController.balanceButton.setOnAction(event -> {
|
gameController.balanceButton.setOnAction(event -> {
|
||||||
if (balanceStage != null && balanceStage.isShowing()) {
|
if (balanceStage != null && balanceStage.isShowing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
balanceStage = new Stage();
|
balanceStage = new Stage();
|
||||||
|
|
||||||
|
setupBalanceStage();
|
||||||
|
|
||||||
|
balanceStage.show();
|
||||||
|
});
|
||||||
|
|
||||||
|
gameController.optionsButton.setOnAction(event -> openOptionsScene());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadOptionsScene() {
|
||||||
|
optionsController = new OptionsController();
|
||||||
|
optionsScene = JFXUtil.loadScene("options", optionsController, I18n.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupBalanceStage() {
|
||||||
|
if (balanceStage != null) {
|
||||||
balanceController = new BalanceController();
|
balanceController = new BalanceController();
|
||||||
Scene scene = JFXUtil.loadScene("balance", balanceController, I18n.getInstance());
|
Scene scene = JFXUtil.loadScene("balance", balanceController, I18n.getInstance());
|
||||||
|
|
||||||
@@ -160,23 +185,25 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
balanceController = null;
|
balanceController = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
balanceStage.setAlwaysOnTop(true);
|
|
||||||
balanceStage.setScene(scene);
|
balanceStage.setScene(scene);
|
||||||
balanceStage.setTitle(I18n.getInstance().getString("game.balance"));
|
balanceStage.setTitle(I18n.getInstance().getString("game.balance"));
|
||||||
balanceStage.show();
|
|
||||||
});
|
|
||||||
|
|
||||||
mainController.optionsButton.setOnAction(event -> openOptionsScene());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadOptionsScene() {
|
|
||||||
optionsController = new OptionsController();
|
|
||||||
optionsScene = JFXUtil.loadScene("options", optionsController, I18n.getInstance());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openOptionsScene() {
|
private void openOptionsScene() {
|
||||||
optionsController.beforeOpen(() -> primaryStage.setScene(mainScene));
|
optionsController.beforeOpen(() -> {
|
||||||
primaryStage.setScene(optionsScene);
|
if (i18nInvalidated) {
|
||||||
|
loadGameScene();
|
||||||
|
WhatAStorage.getInstance().resendVisualGameData();
|
||||||
|
changeScene(gameScene);
|
||||||
|
loadOptionsScene();
|
||||||
|
setupBalanceStage();
|
||||||
|
i18nInvalidated = false;
|
||||||
|
} else {
|
||||||
|
changeScene(gameScene);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
changeScene(optionsScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addQuest(Quest quest) {
|
private void addQuest(Quest quest) {
|
||||||
@@ -192,7 +219,7 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
transition.setByValue(1D);
|
transition.setByValue(1D);
|
||||||
transition.setInterpolator(Interpolator.EASE_OUT);
|
transition.setInterpolator(Interpolator.EASE_OUT);
|
||||||
|
|
||||||
mainController.questBox.getChildren().add(parent);
|
gameController.questBox.getChildren().add(parent);
|
||||||
transition.play();
|
transition.play();
|
||||||
|
|
||||||
Product product = quest.getProduct();
|
Product product = quest.getProduct();
|
||||||
@@ -232,10 +259,10 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
RowConstraints rowConstraints = new RowConstraints();
|
RowConstraints rowConstraints = new RowConstraints();
|
||||||
rowConstraints.setPercentHeight(100D / height);
|
rowConstraints.setPercentHeight(100D / height);
|
||||||
|
|
||||||
storageSlots = new StorageSlot[width][height];
|
storageSlots = new JFXStorageSlot[width][height];
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
StorageSlot storageSlot = new StorageSlot(x, y, depth);
|
JFXStorageSlot storageSlot = new JFXStorageSlot(x, y, depth);
|
||||||
storageSlots[y][x] = storageSlot;
|
storageSlots[y][x] = storageSlot;
|
||||||
storageGrid.add(storageSlot.getGrid(), x, y);
|
storageGrid.add(storageSlot.getGrid(), x, y);
|
||||||
}
|
}
|
||||||
@@ -245,7 +272,7 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
storageGrid.getColumnConstraints().add(columnConstraints);
|
storageGrid.getColumnConstraints().add(columnConstraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
mainController.storagePane.getChildren().add(storageGrid);
|
gameController.storagePane.getChildren().add(storageGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -253,7 +280,7 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
ContentManager contentManager = WhatAStorage.getInstance().getContentManager();
|
ContentManager contentManager = WhatAStorage.getInstance().getContentManager();
|
||||||
I18n i18n = I18n.getInstance();
|
I18n i18n = I18n.getInstance();
|
||||||
|
|
||||||
StorageSlot slot = storageSlots[y][x];
|
JFXStorageSlot slot = storageSlots[y][x];
|
||||||
|
|
||||||
int depth = product.getDepth();
|
int depth = product.getDepth();
|
||||||
int dz = z + depth - 1;
|
int dz = z + depth - 1;
|
||||||
@@ -273,7 +300,7 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProductCleared(int x, int y, int z, Product product) {
|
public void onProductCleared(int x, int y, int z, Product product) {
|
||||||
StorageSlot slot = storageSlots[y][x];
|
JFXStorageSlot slot = storageSlots[y][x];
|
||||||
String empty = I18n.getInstance().getString("game.storage.empty");
|
String empty = I18n.getInstance().getString("game.storage.empty");
|
||||||
|
|
||||||
int dz = z + product.getDepth() - 1;
|
int dz = z + product.getDepth() - 1;
|
||||||
|
|||||||
@@ -3,14 +3,16 @@ package de.siphalor.was.visual;
|
|||||||
import de.siphalor.was.WhatAStorage;
|
import de.siphalor.was.WhatAStorage;
|
||||||
import de.siphalor.was.content.product.Product;
|
import de.siphalor.was.content.product.Product;
|
||||||
import de.siphalor.was.content.quest.Quest;
|
import de.siphalor.was.content.quest.Quest;
|
||||||
import de.siphalor.was.game.Balance;
|
import de.siphalor.was.game.Transaction;
|
||||||
|
|
||||||
public interface Visual {
|
public interface Visual {
|
||||||
void setup(WhatAStorage whatAStorage);
|
void setup(WhatAStorage whatAStorage);
|
||||||
void run();
|
void run();
|
||||||
void onScheduleStop();
|
void onScheduleStop();
|
||||||
|
|
||||||
void onBalanceChanged(int budget, Balance.Transaction transaction, int change, int totalIncome, int totalLoss);
|
void invalidateI18n();
|
||||||
|
|
||||||
|
void onBalanceChanged(int budget, Transaction transaction, int totalIncome, int totalLoss);
|
||||||
|
|
||||||
void onQuestAdded(Quest newQuest, boolean canCreateMore);
|
void onQuestAdded(Quest newQuest, boolean canCreateMore);
|
||||||
void onQuestRemoved(int index);
|
void onQuestRemoved(int index);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package de.siphalor.was.visual.jfx.controller;
|
|||||||
import de.siphalor.was.WhatAStorage;
|
import de.siphalor.was.WhatAStorage;
|
||||||
import de.siphalor.was.content.lang.I18n;
|
import de.siphalor.was.content.lang.I18n;
|
||||||
import de.siphalor.was.game.Balance;
|
import de.siphalor.was.game.Balance;
|
||||||
import de.siphalor.was.util.Pair;
|
import de.siphalor.was.game.Transaction;
|
||||||
import de.siphalor.was.visual.jfx.util.BalanceEntry;
|
import de.siphalor.was.visual.jfx.util.BalanceEntry;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.scene.chart.LineChart;
|
import javafx.scene.chart.LineChart;
|
||||||
@@ -32,38 +32,42 @@ public class BalanceController {
|
|||||||
columns.get(0).setCellValueFactory(new PropertyValueFactory<>("index"));
|
columns.get(0).setCellValueFactory(new PropertyValueFactory<>("index"));
|
||||||
columns.get(1).setCellValueFactory(new PropertyValueFactory<>("change"));
|
columns.get(1).setCellValueFactory(new PropertyValueFactory<>("change"));
|
||||||
columns.get(2).setCellValueFactory(new PropertyValueFactory<>("description"));
|
columns.get(2).setCellValueFactory(new PropertyValueFactory<>("description"));
|
||||||
|
columns.get(3).setCellValueFactory(new PropertyValueFactory<>("product"));
|
||||||
|
|
||||||
|
budgetChart.getData().clear();
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
budgetChart.getData().add((XYChart.Series<NumberAxis, NumberAxis>)(Object) budgetChartSeries);
|
budgetChart.getData().add((XYChart.Series<NumberAxis, NumberAxis>)(Object) budgetChartSeries);
|
||||||
ObservableList<XYChart.Data<Integer, Integer>> chartItems = budgetChartSeries.getData();
|
ObservableList<XYChart.Data<Integer, Integer>> chartItems = budgetChartSeries.getData();
|
||||||
chartItems.add(new XYChart.Data<>(0, 0));
|
chartItems.add(new XYChart.Data<>(0, 0));
|
||||||
|
|
||||||
ObservableList<BalanceEntry> tableItems = balanceHistoryTable.getItems();
|
ObservableList<BalanceEntry> tableItems = balanceHistoryTable.getItems();
|
||||||
|
tableItems.clear();
|
||||||
|
|
||||||
I18n i18n = I18n.getInstance();
|
I18n i18n = I18n.getInstance();
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
int budget = 0;
|
int budget = 0;
|
||||||
|
|
||||||
for (Pair<Balance.Transaction, Integer> entry : balance.getHistory()) {
|
for (Transaction entry : balance.getHistory()) {
|
||||||
budget += entry.getSecond();
|
budget += entry.getChange();
|
||||||
|
|
||||||
tableItems.add(new BalanceEntry(i, entry.getSecond(), i18n.getString(entry.getFirst().getTranslationKey())));
|
tableItems.add(new BalanceEntry(i, entry.getChange(), i18n.getString(entry.getType().getTranslationKey()), i18n.getString(entry.getProductKey())));
|
||||||
|
|
||||||
chartItems.add(new XYChart.Data<>(i, budget));
|
chartItems.add(new XYChart.Data<>(i, budget));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTotalValues(balance.getTotalIncome(), balance.getTotalLoss(), i18n);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBalanceChanged(int budget, Balance.Transaction transaction, int change, int totalIncome, int totalLoss) {
|
public void onBalanceChanged(int budget, Transaction transaction, int totalIncome, int totalLoss) {
|
||||||
I18n i18n = I18n.getInstance();
|
I18n i18n = I18n.getInstance();
|
||||||
|
|
||||||
totalIncomeLabel.setText(i18n.format("game.balance.total-income", totalIncome));
|
updateTotalValues(totalIncome, totalLoss, i18n);
|
||||||
totalLossLabel.setText(i18n.format("game.balance.total-loss", totalLoss));
|
|
||||||
|
|
||||||
if (transaction != Balance.Transaction.NOOP) {
|
if (transaction.getType() != Transaction.Type.NOOP) {
|
||||||
ObservableList<BalanceEntry> items = balanceHistoryTable.getItems();
|
ObservableList<BalanceEntry> items = balanceHistoryTable.getItems();
|
||||||
items.add(new BalanceEntry(items.size(), change, i18n.getString(transaction.getTranslationKey())));
|
items.add(new BalanceEntry(items.size(), transaction.getChange(), i18n.getString(transaction.getType().getTranslationKey()), i18n.getString(transaction.getProductKey())));
|
||||||
balanceHistoryTable.sort();
|
balanceHistoryTable.sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,4 +75,9 @@ public class BalanceController {
|
|||||||
|
|
||||||
data.add(new XYChart.Data<>(data.size(), budget));
|
data.add(new XYChart.Data<>(data.size(), budget));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateTotalValues(int totalIncome, int totalLoss, I18n i18n) {
|
||||||
|
totalIncomeLabel.setText(i18n.format("game.balance.total-income", totalIncome));
|
||||||
|
totalLossLabel.setText(i18n.format("game.balance.total-loss", totalLoss));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class MainController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void nextQuest() {
|
private void nextQuest() {
|
||||||
was.requestQuest();
|
was.userRequestQuest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@@ -72,13 +72,13 @@ public class MainController {
|
|||||||
|
|
||||||
if (origin instanceof DraggedProduct.Quest) {
|
if (origin instanceof DraggedProduct.Quest) {
|
||||||
DraggedProduct.Quest questOrigin = (DraggedProduct.Quest) origin;
|
DraggedProduct.Quest questOrigin = (DraggedProduct.Quest) origin;
|
||||||
was.abandonQuest(questOrigin.index);
|
was.userAbandonQuest(questOrigin.index);
|
||||||
|
|
||||||
dragEvent.setDropCompleted(true);
|
dragEvent.setDropCompleted(true);
|
||||||
dragEvent.consume();
|
dragEvent.consume();
|
||||||
return;
|
return;
|
||||||
} else if (origin instanceof DraggedProduct.Slot) {
|
} else if (origin instanceof DraggedProduct.Slot) {
|
||||||
was.destroyProduct(((DraggedProduct.Slot) origin).x, ((DraggedProduct.Slot) origin).y);
|
was.userDestroyProduct(((DraggedProduct.Slot) origin).x, ((DraggedProduct.Slot) origin).y);
|
||||||
|
|
||||||
dragEvent.setDropCompleted(true);
|
dragEvent.setDropCompleted(true);
|
||||||
dragEvent.consume();
|
dragEvent.consume();
|
||||||
|
|||||||
@@ -43,10 +43,17 @@ public class OptionsController {
|
|||||||
private void onLeaveClicked() {
|
private void onLeaveClicked() {
|
||||||
Options options = WhatAStorage.getInstance().getOptions();
|
Options options = WhatAStorage.getInstance().getOptions();
|
||||||
|
|
||||||
|
String oldLang = I18n.getInstance().getLang().getCode();
|
||||||
I18n.getInstance().setLang(languageChoice.getValue().getCode(), WhatAStorage.getInstance().getContentManager());
|
I18n.getInstance().setLang(languageChoice.getValue().getCode(), WhatAStorage.getInstance().getContentManager());
|
||||||
options.setAllowQuestResolving(allowQuestResolvingToggle.isSelected());
|
options.setAllowQuestResolving(allowQuestResolvingToggle.isSelected());
|
||||||
options.setAutoRefillQuests(autoQuestRefillToggle.isSelected());
|
options.setAutoRefillQuests(autoQuestRefillToggle.isSelected());
|
||||||
|
|
||||||
|
options.save();
|
||||||
|
|
||||||
|
if (!oldLang.equals(I18n.getInstance().getLang().getCode())) {
|
||||||
|
WhatAStorage.getInstance().invalidateI18n();
|
||||||
|
}
|
||||||
|
|
||||||
exitRunnable.run();
|
exitRunnable.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class QuestController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void abandon() {
|
private void abandon() {
|
||||||
WhatAStorage.getInstance().abandonQuest(getIndex());
|
WhatAStorage.getInstance().userAbandonQuest(getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canDropHere(DragEvent dragEvent) {
|
private boolean canDropHere(DragEvent dragEvent) {
|
||||||
@@ -90,14 +90,14 @@ public class QuestController {
|
|||||||
DraggedProduct product = (DraggedProduct) dragboard.getContent(DraggedProduct.FORMAT);
|
DraggedProduct product = (DraggedProduct) dragboard.getContent(DraggedProduct.FORMAT);
|
||||||
if (product instanceof DraggedProduct.Slot) {
|
if (product instanceof DraggedProduct.Slot) {
|
||||||
DraggedProduct.Slot slot = (DraggedProduct.Slot) product;
|
DraggedProduct.Slot slot = (DraggedProduct.Slot) product;
|
||||||
if (WhatAStorage.getInstance().deliverProduct(getIndex(), slot.x, slot.y)) {
|
if (WhatAStorage.getInstance().userDeliverProduct(getIndex(), slot.x, slot.y)) {
|
||||||
dragEvent.setDropCompleted(true);
|
dragEvent.setDropCompleted(true);
|
||||||
dragEvent.consume();
|
dragEvent.consume();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (product instanceof DraggedProduct.Quest) {
|
} else if (product instanceof DraggedProduct.Quest) {
|
||||||
DraggedProduct.Quest quest = (DraggedProduct.Quest) product;
|
DraggedProduct.Quest quest = (DraggedProduct.Quest) product;
|
||||||
if (WhatAStorage.getInstance().resolveQuests(quest.index, getIndex())) {
|
if (WhatAStorage.getInstance().userResolveQuests(quest.index, getIndex())) {
|
||||||
dragEvent.setDropCompleted(true);
|
dragEvent.setDropCompleted(true);
|
||||||
dragEvent.consume();
|
dragEvent.consume();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package de.siphalor.was.visual.jfx.util;
|
package de.siphalor.was.visual.jfx.util;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class BalanceEntry {
|
public class BalanceEntry {
|
||||||
public final int index;
|
public final int index;
|
||||||
public final int change;
|
public final int change;
|
||||||
public final String description;
|
public final String description;
|
||||||
|
public final String product;
|
||||||
|
|
||||||
public BalanceEntry(int index, int change, String description) {
|
public BalanceEntry(int index, int change, String description, String product) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.change = change;
|
this.change = change;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.product = product;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
@@ -22,4 +25,8 @@ public class BalanceEntry {
|
|||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProduct() {
|
||||||
|
return product;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import javafx.scene.layout.GridPane;
|
|||||||
import javafx.scene.layout.RowConstraints;
|
import javafx.scene.layout.RowConstraints;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class StorageSlot {
|
public class JFXStorageSlot {
|
||||||
private final int x;
|
private final int x;
|
||||||
private final int y;
|
private final int y;
|
||||||
private final int depth;
|
private final int depth;
|
||||||
@@ -22,7 +22,7 @@ public class StorageSlot {
|
|||||||
private final ScalingImagePane[] images;
|
private final ScalingImagePane[] images;
|
||||||
private final Label[] labels;
|
private final Label[] labels;
|
||||||
|
|
||||||
public StorageSlot(int x, int y, int depth) {
|
public JFXStorageSlot(int x, int y, int depth) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
@@ -66,7 +66,9 @@ public class StorageSlot {
|
|||||||
grid.getColumnConstraints().add(columnConstraints);
|
grid.getColumnConstraints().add(columnConstraints);
|
||||||
}
|
}
|
||||||
grid.getColumnConstraints().add(columnConstraints);
|
grid.getColumnConstraints().add(columnConstraints);
|
||||||
grid.getColumnConstraints().add(new ColumnConstraints(30D));
|
ColumnConstraints lastCC = new ColumnConstraints();
|
||||||
|
lastCC.setPercentWidth(30D);
|
||||||
|
grid.getColumnConstraints().add(lastCC);
|
||||||
grid.getRowConstraints().add(rowConstraints);
|
grid.getRowConstraints().add(rowConstraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,12 +137,12 @@ public class StorageSlot {
|
|||||||
if (dragEvent.getGestureSource() != grid && dragEvent.getDragboard().hasContent(DraggedProduct.FORMAT)) {
|
if (dragEvent.getGestureSource() != grid && dragEvent.getDragboard().hasContent(DraggedProduct.FORMAT)) {
|
||||||
DraggedProduct origin = (DraggedProduct) dragEvent.getDragboard().getContent(DraggedProduct.FORMAT);
|
DraggedProduct origin = (DraggedProduct) dragEvent.getDragboard().getContent(DraggedProduct.FORMAT);
|
||||||
if (origin instanceof DraggedProduct.Quest) {
|
if (origin instanceof DraggedProduct.Quest) {
|
||||||
WhatAStorage.getInstance().storeProduct(((DraggedProduct.Quest) origin).index, x, y);
|
WhatAStorage.getInstance().userStoreProduct(((DraggedProduct.Quest) origin).index, x, y);
|
||||||
dragEvent.setDropCompleted(true);
|
dragEvent.setDropCompleted(true);
|
||||||
return;
|
return;
|
||||||
} else if (origin instanceof DraggedProduct.Slot) {
|
} else if (origin instanceof DraggedProduct.Slot) {
|
||||||
DraggedProduct.Slot slot = (DraggedProduct.Slot) origin;
|
DraggedProduct.Slot slot = (DraggedProduct.Slot) origin;
|
||||||
WhatAStorage.getInstance().moveProduct(slot.x, slot.y, x, y);
|
WhatAStorage.getInstance().userMoveProduct(slot.x, slot.y, x, y);
|
||||||
dragEvent.setDropCompleted(true);
|
dragEvent.setDropCompleted(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<VBox maxHeight="1.7976931348623157E308" minHeight="500.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
<VBox maxHeight="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="850.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<children>
|
<children>
|
||||||
<AnchorPane>
|
<AnchorPane>
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
56
src/main/resources/assets/jfx/options.fxml
Normal file
56
src/main/resources/assets/jfx/options.fxml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.ChoiceBox?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.ScrollPane?>
|
||||||
|
<?import javafx.scene.control.ToggleButton?>
|
||||||
|
<?import javafx.scene.control.ToolBar?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
|
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="850.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<children>
|
||||||
|
<ToolBar prefHeight="40.0" prefWidth="200.0">
|
||||||
|
<items>
|
||||||
|
<Button mnemonicParsing="false" onAction="#onLeaveClicked" text="%menu.options.back" />
|
||||||
|
</items>
|
||||||
|
</ToolBar>
|
||||||
|
<ScrollPane fitToWidth="true" VBox.vgrow="ALWAYS">
|
||||||
|
<content>
|
||||||
|
<GridPane styleClass="options-menu">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
|
||||||
|
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Label styleClass="heading" text="%menu.options.general" GridPane.columnSpan="2147483647" />
|
||||||
|
<Label text="Language" GridPane.rowIndex="1" />
|
||||||
|
<ChoiceBox fx:id="languageChoice" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
|
<Label styleClass="heading" text="%menu.options.gameplay" GridPane.columnSpan="2147483647" GridPane.rowIndex="2" />
|
||||||
|
<Label text="%menu.options.gameplay.quest-resolving" GridPane.rowIndex="3" />
|
||||||
|
<ToggleButton fx:id="allowQuestResolvingToggle" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||||
|
<Label text="%menu.options.gameplay.auto-quest-refill" GridPane.rowIndex="4" />
|
||||||
|
<ToggleButton fx:id="autoQuestRefillToggle" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets left="20.0" right="20.0" />
|
||||||
|
</padding>
|
||||||
|
</GridPane>
|
||||||
|
</content>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" top="10.0" />
|
||||||
|
</padding>
|
||||||
|
</ScrollPane>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
@@ -3,7 +3,7 @@ package de.siphalor.was.dummy;
|
|||||||
import de.siphalor.was.WhatAStorage;
|
import de.siphalor.was.WhatAStorage;
|
||||||
import de.siphalor.was.content.product.Product;
|
import de.siphalor.was.content.product.Product;
|
||||||
import de.siphalor.was.content.quest.Quest;
|
import de.siphalor.was.content.quest.Quest;
|
||||||
import de.siphalor.was.game.Balance;
|
import de.siphalor.was.game.Transaction;
|
||||||
import de.siphalor.was.visual.Visual;
|
import de.siphalor.was.visual.Visual;
|
||||||
|
|
||||||
public class DummyVisual implements Visual {
|
public class DummyVisual implements Visual {
|
||||||
@@ -23,7 +23,12 @@ public class DummyVisual implements Visual {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBalanceChanged(int budget, Balance.Transaction transaction, int change, int totalIncome, int totalLoss) {
|
public void invalidateI18n() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBalanceChanged(int budget, Transaction transaction, int totalIncome, int totalLoss) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user