Skip to content

Einar/login bar style #124

Merged
merged 2 commits into from
May 18, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,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"));
Expand Down
24 changes: 16 additions & 8 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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> status = new SimpleObjectProperty<>(Status.NOVICE);

public Player(final String name, final BigDecimal startingMoney) {
this.name.set(name);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -110,7 +113,7 @@ public TransactionArchive getTransactionArchive() {


/** @return player status. */
public Status getStatus() {
public ObjectProperty<Status> getStatusProperty() {
final int investorWeeks = 10;
final int speculatorWeeks = 20;
final double investorMult = 1.2;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand All @@ -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
);
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/css/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}