Skip to content

Commit

Permalink
Merge pull request #377 from Advanced-Programming-2021/gui
Browse files Browse the repository at this point in the history
Gui
  • Loading branch information
kysre authored Jul 9, 2021
2 parents d8dbc55 + d6932af commit 266ea80
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 58 deletions.
4 changes: 4 additions & 0 deletions src/main/java/controller/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,4 +677,8 @@ public int getPlayerDeckSize() {
public int getOpponentDeckSize() {
return game.getOpponentGameBoard().getOwner().getUserDeck().getActiveDeck().getMainDeck().size();
}

public String getGamePhase() {
return game.getPhase();
}
}
11 changes: 10 additions & 1 deletion src/main/java/view/gui/DuelMenuGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class DuelMenuGui extends MenuGui {
public Text playerNickNameText;
@FXML
public Text playerUserNameText;
@FXML
public Label phaseLabel;

static {
duelMenuMethods = DuelMenuGui.class.getDeclaredMethods();
Expand Down Expand Up @@ -200,6 +202,7 @@ public void updateGameBoard() {
updatePlayerLifePoint();
updateOpponentLifePoint();
updateDecks();
updatePhase();
}

private void updateFields(ArrayList<String> cardData, String fieldName) {
Expand Down Expand Up @@ -319,6 +322,11 @@ private void updateDecks() {
fieldPane.getChildren().addAll(playerDeckStackPane, opponentDeckStackPane);
}

private void updatePhase() {
String phase = gameController.getGamePhase();
phaseLabel.setText(phase);
}

private boolean getVisibility(String fieldName, String cardName) {
boolean isVisible = true;
if (fieldName.equals(CARD_FIELDS[3])) {
Expand Down Expand Up @@ -645,8 +653,9 @@ public ArrayList<Integer> getCardsForTribute(int i) {
"Leave field empty to cancel summon.");
String[] numbers = input.split(" ");
ArrayList<Integer> positions = new ArrayList<>();
// add (position - 1) to ArrayList because zero-indexed fields:
for (String num : numbers)
positions.add(Integer.parseInt(num));
positions.add(Integer.parseInt(num) - 1);
return positions;
} catch (NumberFormatException exception) {
showMessage("Invalid input format. Try again!");
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/view/gui/GetInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static Boolean getTwoChoiceAnswer(String question, String trueOption, Str

BorderPane borderPane = new BorderPane();
Text text = new Text(question);
text.setWrappingWidth(350);
text.setFont(new Font("Bold", 14));
text.setStyle("-fx-fill: white");
HBox hBox = new HBox(text);
Expand Down Expand Up @@ -67,7 +68,7 @@ public static Boolean getTwoChoiceAnswer(String question, String trueOption, Str
hBox1.getChildren().addAll(yesButton, noButton);
borderPane.setBottom(hBox1);

Scene scene = new Scene(borderPane, 350, 70);
Scene scene = new Scene(borderPane, 400, 150);
getYesOrNoAnswerPopupWindow.setScene(scene);
getYesOrNoAnswerPopupWindow.setTitle("Duel");
getYesOrNoAnswerPopupWindow.showAndWait();
Expand All @@ -83,6 +84,7 @@ public static String getStringAnswerPopupWindow(String title, String question) {

BorderPane borderPane = new BorderPane();
Text text = new Text(question);
text.setWrappingWidth(450);
text.setFont(new Font("Bold", 14));
text.setStyle("-fx-background-color: #0404e9; -fx-fill: white");
TextField textField = new TextField(null);
Expand Down Expand Up @@ -111,7 +113,7 @@ public static String getStringAnswerPopupWindow(String title, String question) {
hBox.setAlignment(Pos.CENTER);
borderPane.setBottom(hBox);

getStringAnswerPopupWindow.setScene(new Scene(borderPane, 450, 250));
getStringAnswerPopupWindow.setScene(new Scene(borderPane, 500, 300));
getStringAnswerPopupWindow.setResizable(false);
getStringAnswerPopupWindow.setTitle(title);
getStringAnswerPopupWindow.showAndWait();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/view/gui/ShowGameMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void start(Stage prevStage) throws IOException {
stage.initStyle(StageStyle.UNDECORATED);
stage.toFront();
stage.requestFocus();
stage.setAlwaysOnTop(true);

stage.show();
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/view/gui/ShowOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static void showOutput(String title, String header) {

BorderPane borderPane = new BorderPane();
Text text = new Text(header);
text.setWrappingWidth(400);
text.setFont(new Font("Arial", 14));
text.setStyle("-fx-fill: white");
HBox hBox = new HBox(text);
Expand All @@ -39,7 +40,7 @@ public static void showOutput(String title, String header) {
bottomHBox.setAlignment(Pos.CENTER);
borderPane.setBottom(bottomHBox);

showOutPutPopUpWindow.setScene(new Scene(borderPane, 400, 120));
showOutPutPopUpWindow.setScene(new Scene(borderPane, 450, 150));
showOutPutPopUpWindow.setTitle(title);
showOutPutPopUpWindow.showAndWait();
}
Expand Down
Loading

0 comments on commit 266ea80

Please sign in to comment.