Move some code around
This commit is contained in:
@@ -79,66 +79,6 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
launch();
|
launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGameStart(int width, int height, int depth) {
|
|
||||||
JFXVisual.width = width;
|
|
||||||
JFXVisual.height = height;
|
|
||||||
JFXVisual.depth = depth;
|
|
||||||
loadGameScene();
|
|
||||||
changeScene(gameScene);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScheduleStop() {
|
|
||||||
primaryStage.close();
|
|
||||||
if (balanceStage != null)
|
|
||||||
balanceStage.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invalidateI18n() {
|
|
||||||
i18nInvalidated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBalanceChanged(int budget, Transaction transaction, int totalIncome, int totalLoss) {
|
|
||||||
I18n i18n = I18n.getInstance();
|
|
||||||
|
|
||||||
gameController.budgetLabel.setText(i18n.format("game.budget.label", budget));
|
|
||||||
JFXUtil.setStyleClass(gameController.budgetLabel, "red", budget < 0);
|
|
||||||
|
|
||||||
if (balanceController != null) {
|
|
||||||
balanceController.onBalanceChanged(budget, transaction, totalIncome, totalLoss);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transaction.getChange() != 0) {
|
|
||||||
gameController.budgetChangeLabel.getStyleClass().clear();
|
|
||||||
if (transaction.getChange() > 0) {
|
|
||||||
JFXUtil.setStyleClass(gameController.budgetChangeLabel, "green", true);
|
|
||||||
gameController.budgetChangeLabel.setText(i18n.format("game.budget.change.income", transaction.getChange()));
|
|
||||||
} else {
|
|
||||||
JFXUtil.setStyleClass(gameController.budgetChangeLabel, "red", true);
|
|
||||||
gameController.budgetChangeLabel.setText(i18n.format("game.budget.change.loss", transaction.getChange()));
|
|
||||||
}
|
|
||||||
gameController.budgetChangeLabel.setOpacity(1D);
|
|
||||||
gameController.budgetChangeTransition.playFromStart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onQuestAdded(Quest newQuest, boolean canCreateMore) {
|
|
||||||
addQuest(newQuest);
|
|
||||||
|
|
||||||
gameController.nextQuestButton.setDisable(!canCreateMore);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onQuestRemoved(int index) {
|
|
||||||
gameController.questBox.getChildren().remove(index);
|
|
||||||
|
|
||||||
gameController.nextQuestButton.setDisable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
JFXVisual.primaryStage = primaryStage;
|
JFXVisual.primaryStage = primaryStage;
|
||||||
@@ -169,9 +109,9 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
|
|
||||||
prepareStorageGrid();
|
prepareStorageGrid();
|
||||||
|
|
||||||
AssetsManager.getStream("textures/bin_closed.png").ifPresent(inputStream -> {
|
AssetsManager.getStream("textures/bin_closed.png").ifPresent(inputStream ->
|
||||||
gameController.trash.setImage(new Image(inputStream));
|
gameController.trash.setImage(new Image(inputStream))
|
||||||
});
|
);
|
||||||
|
|
||||||
onBalanceChanged(0, new Transaction(Transaction.Type.NOOP, 0, ""), 0, 0);
|
onBalanceChanged(0, new Transaction(Transaction.Type.NOOP, 0, ""), 0, 0);
|
||||||
|
|
||||||
@@ -261,9 +201,7 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}, () -> {
|
}, () -> Util.LOGGER.log(Level.SEVERE, "INTERNAL ERROR: Failed to load quest widget"));
|
||||||
Util.LOGGER.log(Level.SEVERE, "INTERNAL ERROR: Failed to load quest widget");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareStorageGrid() {
|
private void prepareStorageGrid() {
|
||||||
@@ -297,6 +235,66 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
gameController.storagePane.getChildren().add(storageGrid);
|
gameController.storagePane.getChildren().add(storageGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGameStart(int width, int height, int depth) {
|
||||||
|
JFXVisual.width = width;
|
||||||
|
JFXVisual.height = height;
|
||||||
|
JFXVisual.depth = depth;
|
||||||
|
loadGameScene();
|
||||||
|
changeScene(gameScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScheduleStop() {
|
||||||
|
primaryStage.close();
|
||||||
|
if (balanceStage != null)
|
||||||
|
balanceStage.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidateI18n() {
|
||||||
|
i18nInvalidated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBalanceChanged(int budget, Transaction transaction, int totalIncome, int totalLoss) {
|
||||||
|
I18n i18n = I18n.getInstance();
|
||||||
|
|
||||||
|
gameController.budgetLabel.setText(i18n.format("game.budget.label", budget));
|
||||||
|
JFXUtil.setStyleClass(gameController.budgetLabel, "red", budget < 0);
|
||||||
|
|
||||||
|
if (balanceController != null) {
|
||||||
|
balanceController.onBalanceChanged(budget, transaction, totalIncome, totalLoss);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transaction.getChange() != 0) {
|
||||||
|
gameController.budgetChangeLabel.getStyleClass().clear();
|
||||||
|
if (transaction.getChange() > 0) {
|
||||||
|
JFXUtil.setStyleClass(gameController.budgetChangeLabel, "green", true);
|
||||||
|
gameController.budgetChangeLabel.setText(i18n.format("game.budget.change.income", transaction.getChange()));
|
||||||
|
} else {
|
||||||
|
JFXUtil.setStyleClass(gameController.budgetChangeLabel, "red", true);
|
||||||
|
gameController.budgetChangeLabel.setText(i18n.format("game.budget.change.loss", transaction.getChange()));
|
||||||
|
}
|
||||||
|
gameController.budgetChangeLabel.setOpacity(1D);
|
||||||
|
gameController.budgetChangeTransition.playFromStart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onQuestAdded(Quest newQuest, boolean canCreateMore) {
|
||||||
|
addQuest(newQuest);
|
||||||
|
|
||||||
|
gameController.nextQuestButton.setDisable(!canCreateMore);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onQuestRemoved(int index) {
|
||||||
|
gameController.questBox.getChildren().remove(index);
|
||||||
|
|
||||||
|
gameController.nextQuestButton.setDisable(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProductSet(int x, int y, int z, Product product) {
|
public void onProductSet(int x, int y, int z, Product product) {
|
||||||
ContentManager contentManager = WhatAStorage.getInstance().getContentManager();
|
ContentManager contentManager = WhatAStorage.getInstance().getContentManager();
|
||||||
@@ -307,6 +305,10 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
int depth = product.getDepth();
|
int depth = product.getDepth();
|
||||||
int dz = z + depth - 1;
|
int dz = z + depth - 1;
|
||||||
|
|
||||||
|
for (int i = z; i < dz; i++) {
|
||||||
|
slot.getLabels()[i].setText("");
|
||||||
|
}
|
||||||
|
|
||||||
slot.getImages()[dz].setImage(getProductImage(product, contentManager));
|
slot.getImages()[dz].setImage(getProductImage(product, contentManager));
|
||||||
slot.getImages()[dz].setTooltip(createTooltip(product, i18n));
|
slot.getImages()[dz].setTooltip(createTooltip(product, i18n));
|
||||||
slot.getLabels()[dz].setText(product.getName(i18n));
|
slot.getLabels()[dz].setText(product.getName(i18n));
|
||||||
@@ -326,9 +328,13 @@ public class JFXVisual extends Application implements Visual {
|
|||||||
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;
|
||||||
|
|
||||||
|
for (int i = z; i <= dz; i++) {
|
||||||
|
slot.getLabels()[i].setText(empty);
|
||||||
|
}
|
||||||
|
|
||||||
slot.getImages()[dz].setImage(null);
|
slot.getImages()[dz].setImage(null);
|
||||||
slot.getImages()[dz].setTooltip(null);
|
slot.getImages()[dz].setTooltip(null);
|
||||||
slot.getLabels()[dz].setText(empty);
|
|
||||||
GridPane.setConstraints(slot.getImages()[dz], GridPane.getColumnIndex(slot.getImages()[dz]), dz, 1, 1);
|
GridPane.setConstraints(slot.getImages()[dz], GridPane.getColumnIndex(slot.getImages()[dz]), dz, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user