diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java index b601ff9..c44d5e8 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java @@ -193,26 +193,29 @@ private void setupDesktopUI() { } private void setupListeners() { - timeAndWeatherController.hourProperty().addListener((o, ov, nv) -> + timeAndWeatherController.hourProperty().addListener((obs, ov, nv) -> desktopView.updateClock(timeAndWeatherController.getTimeString())); - timeAndWeatherController.dayIndexProperty().addListener((o, ov, nv) -> { + timeAndWeatherController.dayIndexProperty().addListener((obs, ov, nv) -> { String dayName = timeAndWeatherController.getDayOfWeekString(); desktopView.updateDay(dayName, dayName.equals("SUN")); }); - timeAndWeatherController.weekIndexProperty().addListener((o, ov, nv) -> + timeAndWeatherController.weekIndexProperty().addListener((obs, ov, nv) -> desktopView.updateWeek(timeAndWeatherController.getWeekString())); - timeAndWeatherController.weatherProperty().addListener((o, ov, nv) -> + timeAndWeatherController.weatherProperty().addListener((obs, ov, nv) -> desktopView.updateWeather(nv)); - timeAndWeatherController.temperatureProperty().addListener((o, ov, nv) -> + timeAndWeatherController.temperatureProperty().addListener((obs, ov, nv) -> desktopView.updateTemperature(String.valueOf(nv))); player.getNameProperty().addListener((obs, ov, nv) -> desktopView.updatePlayerName(nv)); + player.getStatusProperty().addListener((obs, ov, nv) -> + desktopView.updatePlayerStatus(nv.name())); + desktopView.updateClock(timeAndWeatherController.getTimeString()); String startDay = timeAndWeatherController.getDayOfWeekString(); desktopView.updateDay(startDay, startDay.equals("SUN")); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java index 3ff6577..1fcf6e3 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java @@ -3,10 +3,8 @@ import edu.ntnu.idi.idatt2003.gruppe42.Model.Exceptions.InsufficientFunds; import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.TransactionArchive; import java.math.BigDecimal; -import javafx.beans.property.IntegerProperty; -import javafx.beans.property.SimpleIntegerProperty; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; + +import javafx.beans.property.*; /** Represents a player. */ public class Player { @@ -19,6 +17,7 @@ public class Player { private final Portfolio portfolio; private final TransactionArchive transactionArchive; private final IntegerProperty lives = new SimpleIntegerProperty(MAX_LIVES); + private final ObjectProperty status = new SimpleObjectProperty<>(Status.NOVICE); public Player(final String name, final BigDecimal startingMoney) { this.name.set(name); @@ -53,6 +52,10 @@ public BigDecimal getMoney() { return money; } + public String getStatus() { + return status.get().name(); + } + /** Adds money. */ public void addMoney(final BigDecimal amount) { money = money.add(amount); @@ -110,7 +113,7 @@ public TransactionArchive getTransactionArchive() { /** @return player status. */ - public Status getStatus() { + public ObjectProperty getStatusProperty() { final int investorWeeks = 10; final int speculatorWeeks = 20; final double investorMult = 1.2; @@ -127,8 +130,13 @@ public Status getStatus() { boolean isInvestor = weeksActive >= investorWeeks && netWorth.compareTo(investorTarget) >= 0; - if (isSpeculator) return Status.SPECULATOR; - if (isInvestor) return Status.INVESTOR; - return Status.NOVICE; + if (isSpeculator) { + status.set(Status.SPECULATOR); + } else if (isInvestor) { + status.set(Status.INVESTOR); + } else { + status.set(Status.NOVICE); + } + return status; } } \ No newline at end of file diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/DesktopBottomBar.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/DesktopBottomBar.java index af35d30..f709f28 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/DesktopBottomBar.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/DesktopBottomBar.java @@ -19,6 +19,7 @@ public final class DesktopBottomBar extends HBox { private static final int HEART_COUNT = 3; private final Label playerLabel; + private final Label playerStatusLabel; private final Label weatherLabel; private final Label tempLabel; private final Label dayLabel; @@ -45,6 +46,10 @@ public DesktopBottomBar(Player player) { playerLabel.getStyleClass().add("desktop-label-bold"); playerLabel.setMinWidth(Region.USE_PREF_SIZE); + playerStatusLabel = new Label("Status: " + player.getStatus()); + playerStatusLabel.getStyleClass().add("desktop-label-bold"); + playerStatusLabel.setMinWidth(Region.USE_PREF_SIZE); + HBox heartsBox = buildHeartsBox(player); nextWeekButton = new Button("Advance to next week"); @@ -66,7 +71,7 @@ public DesktopBottomBar(Player player) { statusBox.setMinWidth(Region.USE_PREF_SIZE); getChildren().addAll( - settingsButton, playerLabel, heartsBox, + settingsButton, playerLabel, playerStatusLabel, heartsBox, spacerLeft, nextWeekButton, spacerRight, statusBox ); @@ -99,15 +104,19 @@ private HBox buildHeartsBox(final Player player) { } private Label styledLabel(final String styleClass) { - Label l = new Label(); - l.getStyleClass().add(styleClass); - return l; + Label label = new Label(); + label.getStyleClass().add(styleClass); + return label; } public Label getPlayerLabel() { return playerLabel; } + public Label getPlayerStatusLabel() { + return playerStatusLabel; + } + public Label getWeatherLabel() { return weatherLabel; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java index e475aef..ce812f1 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java @@ -315,6 +315,11 @@ public void updatePlayerName(final String name) { Platform.runLater(() -> bottomBar.getPlayerLabel().setText("User: " + name)); } + /** Updates player status. */ + public void updatePlayerStatus(final String status) { + Platform.runLater(() -> bottomBar.getPlayerStatusLabel().setText("Status: " + status)); + } + /** Updates clock. */ public void updateClock(final String time) { Platform.runLater(() -> bottomBar.getClockLabel().setText(time)); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java index fac1ce6..f753a88 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java @@ -73,9 +73,9 @@ public BorderPane getRoot() { startingMoneyOptions.setAlignment(Pos.CENTER); // Starting Money Options - RadioButton easyCheck = new RadioButton("Easy ($1000)"); + RadioButton easyCheck = new RadioButton("Easy ($1000)"); RadioButton mediumCheck = new RadioButton("Medium ($100)"); - RadioButton hardCheck = new RadioButton("Hard ($0)"); + RadioButton hardCheck = new RadioButton("Hard ($0)"); easyCheck.getStyleClass().add("difficulty-label"); mediumCheck.getStyleClass().add("difficulty-label"); hardCheck.getStyleClass().add("difficulty-label"); @@ -90,8 +90,11 @@ public BorderPane getRoot() { ); settingsButton = new Button("⚙"); - settingsButton.getStyleClass().add("desktop-settings-button"); - root.setBottom(settingsButton); + settingsButton.getStyleClass().add("login-settings-button"); + + HBox bottomBar = new HBox(settingsButton); + bottomBar.getStyleClass().add("login-bottom-bar"); + root.setBottom(bottomBar); content.getChildren().add(loginContainer); content.getStyleClass().add("login-root"); diff --git a/src/main/resources/css/login.css b/src/main/resources/css/login.css index b75b5d7..d1301e8 100644 --- a/src/main/resources/css/login.css +++ b/src/main/resources/css/login.css @@ -51,3 +51,14 @@ -fx-font-size: 14px; -fx-effect: dropshadow(one-pass-box, rgba(0, 0, 0, 0.8), 2, 0, 0, 1); } + +.login-settings-button { + -fx-background-color: transparent; + -fx-text-fill: white; + -fx-font-size: 18px; + -fx-cursor: hand; +} + +.login-bottom-bar { + -fx-background-color: rgba(0, 0, 0, 0.7); +}