From 80688f927daf85cc728bd74dd2ca672baa47a636 Mon Sep 17 00:00:00 2001 From: Roar Date: Thu, 16 Apr 2026 14:11:55 +0200 Subject: [PATCH 1/3] Updated StartView Converted the dummy view to the first user view. --- .../no/ntnu/gruppe53/views/StartView.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/millions/src/main/java/no/ntnu/gruppe53/views/StartView.java b/millions/src/main/java/no/ntnu/gruppe53/views/StartView.java index a1215c6..efbebf3 100644 --- a/millions/src/main/java/no/ntnu/gruppe53/views/StartView.java +++ b/millions/src/main/java/no/ntnu/gruppe53/views/StartView.java @@ -1,11 +1,50 @@ package no.ntnu.gruppe53.views; +import javafx.geometry.Pos; +import javafx.scene.control.Button; import javafx.scene.layout.VBox; +import no.ntnu.gruppe53.controller.StartViewController; import no.ntnu.gruppe53.controller.ViewController; +/** + * Represents the first page seen by the user of the application. + */ public class StartView extends VBox { + private final Button newGameButton; + private final Button quitButton; + /** + * Constructs the view and sets parameters to be exposed for the {@link StartViewController}. + * + * @param vm the {@link ViewController} for the view + */ public StartView(ViewController vm) { + this.setAlignment(Pos.CENTER); + this.setSpacing(20); + newGameButton = new Button("New Game"); + quitButton = new Button("Quit"); + + newGameButton.setPrefWidth(200); + quitButton.setPrefWidth(200); + + this.getChildren().addAll(newGameButton, quitButton); + } + + /** + * Sets the method to be run when + * + * @param action + */ + public void setOnNewGame(Runnable action) { + newGameButton.setOnAction(e -> action.run()); + } + + /** + * + * @param action + */ + public void setOnQuit(Runnable action) { + quitButton.setOnAction(e -> action.run()); } } \ No newline at end of file From 4544ad39cb27d31049914d33a7fba66ab255fb19 Mon Sep 17 00:00:00 2001 From: Roar Date: Thu, 16 Apr 2026 14:13:18 +0200 Subject: [PATCH 2/3] Added StartViewController Controller class for StartView --- .../controller/StartViewController.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 millions/src/main/java/no/ntnu/gruppe53/controller/StartViewController.java diff --git a/millions/src/main/java/no/ntnu/gruppe53/controller/StartViewController.java b/millions/src/main/java/no/ntnu/gruppe53/controller/StartViewController.java new file mode 100644 index 0000000..48bf965 --- /dev/null +++ b/millions/src/main/java/no/ntnu/gruppe53/controller/StartViewController.java @@ -0,0 +1,19 @@ +package no.ntnu.gruppe53.controller; + +import no.ntnu.gruppe53.views.StartView; +import javafx.application.Platform; + +/** + * aaaa + */ +public class StartViewController { + + public StartViewController(StartView view, ViewController vm) { + + view.setOnNewGame(() -> { + System.out.println("Start new game"); + }); + + view.setOnQuit(Platform::exit); + } +} \ No newline at end of file From 3126d0c301a0bc2f7a6d89469ac75de0594b4250 Mon Sep 17 00:00:00 2001 From: Roar Date: Thu, 16 Apr 2026 14:15:03 +0200 Subject: [PATCH 3/3] Updated App Added StartView to the ViewController --- millions/src/main/java/no/ntnu/gruppe53/App.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/millions/src/main/java/no/ntnu/gruppe53/App.java b/millions/src/main/java/no/ntnu/gruppe53/App.java index a446d34..851d613 100644 --- a/millions/src/main/java/no/ntnu/gruppe53/App.java +++ b/millions/src/main/java/no/ntnu/gruppe53/App.java @@ -2,6 +2,7 @@ import javafx.application.Application; import javafx.stage.Stage; +import no.ntnu.gruppe53.controller.StartViewController; import no.ntnu.gruppe53.controller.ViewController; import no.ntnu.gruppe53.views.StartView; @@ -11,8 +12,10 @@ public class App extends Application { public void start(Stage stage) { ViewController vm = new ViewController(stage); - vm.addView("start", new StartView(vm)); + StartView startView = new StartView(vm); + new StartViewController(startView, vm); + vm.addView("start", startView); vm.switchView("start"); stage.setTitle("Millions - the Stock Game");