diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.java
index 761c044..9b5aa5c 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.java
@@ -81,7 +81,7 @@ protected void initInteractions() {
}
/**
- * Synchronizes the controller pointers with the active game engine state references.
+ * Synchronizes the controller pointers with the active exchange and player objects.
*
* @param criticalExchange the current active exchange engine.
* @param activePlayer the current active player context profile.
@@ -98,16 +98,13 @@ public void handleContextUpdate(final Exchange criticalExchange, final Player ac
}
this.playerNetWorthHistory.clear();
- // 1. Recover history from the updated player instance if available
if (this.player.getNetWorthHistory() != null && !this.player.getNetWorthHistory().isEmpty()) {
this.playerNetWorthHistory.addAll(this.player.getNetWorthHistory());
} else {
- // Safe fallback trajectory baseline points
this.playerNetWorthHistory.add(this.player.getStartingMoney());
this.playerNetWorthHistory.add(this.player.getNetWorth());
}
- // Flush updates directly into view layer
getViewElement().setWeek(this.exchange.getWeek());
getViewElement().updateChart(this.playerNetWorthHistory.stream().map(BigDecimal::floatValue).toList());
getViewElement().setBalance(this.player.getMoney().floatValue(), this.player.getNetWorth().floatValue());
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryView.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryView.java
index 74a3c55..e95e0e1 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryView.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryView.java
@@ -2,6 +2,7 @@
import edu.ntnu.idi.idatt2003.g40.mappe.model.PlayerStatus;
import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement;
+import java.util.List;
import javafx.geometry.Pos;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
@@ -12,19 +13,63 @@
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
-import java.util.List;
+/**
+ * Summary view is a view that is found under the topbar.
+ * It includes balance, status, current week, and a chart
+ * representing net worth over time.
+ *
+ *
Extends {@link ViewElement}
+ * */
public class SummaryView extends ViewElement {
+ /**
+ * Current balance.
+ * */
private Label balanceLabel;
+
+ /**
+ * Current {@link PlayerStatus}.
+ * */
private Label statusLabel;
+
+ /**
+ * Current week.
+ * */
private Label weekLabel;
+
+ /**
+ * Balance title ("Balance/NetWorth").
+ * */
private Label titleLabel;
+
+ /**
+ * Chart representing net worth over time.
+ * */
private LineChart chart;
+
+ /**
+ * Data series for chart.
+ * */
private XYChart.Series dataSeries;
+
+ /**
+ * Next week button (advances week).
+ * */
private Button nextBtn;
+
+ /**
+ * X axis for chart.
+ * */
private NumberAxis xAxis;
+
+ /**
+ * Y axis for chart.
+ * */
private NumberAxis yAxis;
+ /**
+ * Constructor.
+ * */
public SummaryView() {
super(new HBox(), SummaryActions.class);
}
@@ -43,7 +88,7 @@ protected void initLayout() {
VBox balanceInfo = new VBox();
- titleLabel = new Label("Networth");
+ titleLabel = new Label("Balance/NetWorth");
balanceLabel = new Label("0$");
statusLabel = new Label(PlayerStatus.NOOB.getDisplayName());
@@ -113,6 +158,12 @@ protected void initStyling() {
nextBtn.getStyleClass().add("next-button");
}
+ /**
+ * Sets the current balance and money label values.
+ *
+ * @param money the current balance.
+ * @param netWorth the current total networth.
+ * */
public void setBalance(final float money, final float netWorth) {
balanceLabel.setText(Math.round(money*100f)/100f + "NOK / " + Math.round(netWorth*100f)/100f + "NOK");
}
@@ -137,10 +188,21 @@ public void setStatus(final PlayerStatus status) {
statusLabel.getStyleClass().add("status-tier-" + status.name().toLowerCase());
}
+ /**
+ * Sets the week label text to a new week.
+ *
+ * @param week week to set.
+ * */
public void setWeek(int week) {
weekLabel.setText("week: " + week);
}
+ /**
+ * Updates the chart based on player net worth history.
+ *
+ * @param playerNetWorthHistory list of float values
+ * representing all net worth values.
+ * */
public void updateChart(final List playerNetWorthHistory) {
dataSeries.getData().clear();
xAxis.setLowerBound(Math.max(1, playerNetWorthHistory.size() - 10));
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarActions.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarActions.java
index 6f07799..ec6f530 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarActions.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarActions.java
@@ -1,10 +1,36 @@
package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.topbar;
+/**
+ * Action set for top bar.
+ * */
public enum TopBarActions {
+ /**
+ * Returns to main menu.
+ * */
EXIT,
+
+ /**
+ * Go to stats page.
+ * */
STATS,
+
+ /**
+ * Go to market page.
+ * */
MARKET,
+
+ /**
+ * Go to settings page.
+ * */
SETTINGS,
+
+ /**
+ * Go to transactions page.
+ * */
TRANSACTIONS,
+
+ /**
+ * Go to minigames page.
+ * */
MINIGAMES;
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarController.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarController.java
index e338eb6..ef677b0 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarController.java
@@ -3,10 +3,14 @@
import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager;
import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewController;
import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewEnum;
-import javafx.scene.Node;
-
import java.util.function.Consumer;
+import javafx.scene.Node;
+/**
+ * Controller class for {@link TopBarView}.
+ *
+ * Extends {@link ViewController}
+ * */
public class TopBarController extends ViewController {
/**
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarView.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarView.java
index bf9beb6..2000276 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarView.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarView.java
@@ -2,6 +2,7 @@
import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement;
import edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.financialsummary.SummaryView;
+import java.util.stream.Stream;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
@@ -9,23 +10,62 @@
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
-import java.util.stream.Stream;
-
+/**
+ * View element containing navigation buttons and summary.
+ *
+ * Extends {@link ViewElement}
+ * */
public class TopBarView extends ViewElement {
+ /**
+ * Quit button.
+ * */
private Button quitBtn;
+
+ /**
+ * Stats button.
+ * */
private Button statsBtn;
+
+ /**
+ * Market button.
+ * */
private Button marketBtn;
+
+ /**
+ * Settings button.
+ * */
private Button settingsBtn;
+
+ /**
+ * Transactions button.
+ * */
private Button transactionsBtn;
+
+ /**
+ * Minigames button.
+ * */
private Button minigamesBtn;
- private SummaryView summaryView;
+ /**
+ * Summary section.
+ *
+ * @see SummaryView
+ * */
+ private SummaryView summaryView;
+ /**
+ * Constructor.
+ *
+ * @param summaryView the {@link SummaryView} section to include.
+ * */
public TopBarView(final SummaryView summaryView) {
this.summaryView = summaryView;
super(new VBox(10), TopBarActions.class);
}
+ /**
+ * Constructor without summary section.
+ * */
public TopBarView() {
super(new VBox(10), TopBarActions.class);
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsView.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsView.java
index 632b8b0..b55efd3 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsView.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/transactions/TransactionsView.java
@@ -1,6 +1,7 @@
package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.transactions;
import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement;
+import java.util.List;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
@@ -9,7 +10,6 @@
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
-import java.util.List;
/**
* View for displaying a history of all transactions for the active player.