diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java index f7876a5..90050c1 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java @@ -9,16 +9,22 @@ import edu.ntnu.idi.idatt2003.g40.mappe.view.ingame.InGameView; import edu.ntnu.idi.idatt2003.g40.mappe.view.mainmenu.MainMenuController; import edu.ntnu.idi.idatt2003.g40.mappe.view.mainmenu.MainMenuView; +import java.io.IOException; +import java.util.List; +import java.util.Objects; import javafx.application.Application; -import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.layout.Pane; +import javafx.scene.text.Font; import javafx.stage.Stage; -import java.io.IOException; -import java.util.List; -import java.util.Objects; - +/** + * Main class. + * + *

Extends {@link Application}

+ * + *

Initializes the application through the javafx framework.

+ * */ public class Main extends Application { static void main() { FileParser parser1 = new FileParser("src/main/resources/dummydata.txt"); @@ -32,11 +38,15 @@ static void main() { } } + /** + * {@inheritDoc} + * */ @Override public void start(final Stage stage) throws Exception { Scene scene = new Scene(new Pane()); scene.getStylesheets() .add(Objects.requireNonNull(getClass().getResource("/styles.css")).toExternalForm()); + Font.loadFont(getClass().getResourceAsStream("/Fonts/Aptos.ttf"), 16); stage.setScene(scene); stage.setWidth(ConfigValues.VIEWPORT_WIDTH.getValue()); stage.setHeight(ConfigValues.VIEWPORT_HEIGHT.getValue()); @@ -48,7 +58,6 @@ public void start(final Stage stage) throws Exception { InGameView inGameView = new InGameView(); - viewManager.addView(mainMenuView); viewManager.addView(inGameView); viewManager.setScene(mainMenuView); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/engine/TransactionArchive.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/engine/TransactionArchive.java index d09a42a..20ca02b 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/engine/TransactionArchive.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/engine/TransactionArchive.java @@ -3,7 +3,6 @@ import edu.ntnu.idi.idatt2003.g40.mappe.model.Purchase; import edu.ntnu.idi.idatt2003.g40.mappe.model.Sale; import edu.ntnu.idi.idatt2003.g40.mappe.model.Transaction; - import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/utils/ConfigValues.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/utils/ConfigValues.java index 0af1843..6034df8 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/utils/ConfigValues.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/utils/ConfigValues.java @@ -1,15 +1,38 @@ package edu.ntnu.idi.idatt2003.g40.mappe.utils; +/** + * Enum containing configuration values for the application. + * */ public enum ConfigValues { + /** + * Standard viewport width. + * */ VIEWPORT_WIDTH(600), + + /** + * Standard viewport height. + * */ VIEWPORT_HEIGHT(600); - private int value; + /** + * Integer parameter of a config value. + * */ + private final int value; + /** + * Constructor. + * + * @param value the value to assign this configuration. + * */ ConfigValues(final int value) { this.value = value; } + /** + * Getter method for value. + * + * @return value of the configuration. + * */ public int getValue() { return value; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ViewController.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ViewController.java index 5d7a7c0..61fb506 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ViewController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ViewController.java @@ -9,9 +9,10 @@ * *

Implements {@link EventPublisher}

* - * @param The type of {@link ViewElement} this controller is attached to. We use generics - * because we want to call methods that may be specific for certain view element - * objects, and we want to reduce casting. + * @param The type of {@link ViewElement} this controller is attached to. + * We use generics because we want to call methods that may be + * specific for certain view element objects, + * and we want to reduce casting. * @see ViewElement * @see EventPublisher * @see EventManager @@ -35,13 +36,21 @@ public abstract class ViewController> * Constructor. * * @param viewElement the instance of type T1 this controller is attached to. - * @param eventManager the {@link EventManager} object this controller communicates with. + * @param eventManager the {@link EventManager} object this controller + * communicates with. * */ - protected ViewController(final T1 viewElement, final EventManager eventManager) { - this.viewElement = viewElement; - this.eventManager = eventManager; - initInteractions(); + protected ViewController(final T1 viewElement, + final EventManager eventManager) + throws IllegalArgumentException { + if (viewElement == null || eventManager == null) { + throw new IllegalArgumentException( + "Improper ViewController instantiating!"); + } else { + this.viewElement = viewElement; + this.eventManager = eventManager; + initInteractions(); + } } /** @@ -71,7 +80,8 @@ public T1 getViewElement() { protected abstract void initInteractions(); @Override - public final void invoke(final EventData data, final EventManager eventManager) { + public final void invoke(final EventData data, + final EventManager eventManager) { eventManager.invokeEvent(data); } } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ingame/InGameView.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ingame/InGameView.java index 9c132de..9ce3bfc 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ingame/InGameView.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ingame/InGameView.java @@ -19,9 +19,4 @@ protected void initLayout() { protected void initStyling() { } - - @Override - public void onUpdate() { - - } } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuController.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuController.java index a1c0dff..167079b 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuController.java @@ -35,7 +35,7 @@ protected void initInteractions() { ViewData viewData = new ViewData("InGameView"); EventData eventData = new EventData<>(EventType.SCENE_CHANGE, viewData); - getEventManager().invokeEvent(eventData); + invoke(eventData, getEventManager()); }); } } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuView.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuView.java index 7b09c70..68527f0 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuView.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuView.java @@ -15,6 +15,11 @@ * */ public class MainMenuView extends ViewElement { + /** + * Game title. + * */ + private Text titleText; + /** * "Play Game" Button. * */ @@ -87,8 +92,10 @@ protected void initLayout() { settingsButton = new Button("Settings"); exitButton = new Button("Exit"); buttonContainer = new VBox(); + titleText = new Text("Millions"); + buttonContainer.getChildren().addAll( - new Text("This is the main menu!"), + titleText, toGameButton, settingsButton, exitButton @@ -103,19 +110,10 @@ protected void initLayout() { @Override protected void initStyling() { getRootPane().getStyleClass().add("main-menu-bg"); - + titleText.getStyleClass().add("title-text"); buttonContainer.getStyleClass().add("button-container"); - toGameButton.getStyleClass().add("menu-button"); settingsButton.getStyleClass().add("menu-button"); exitButton.getStyleClass().add("menu-button"); } - - /** - * {@inheritDoc} - * */ - @Override - public void onUpdate() { - - } } diff --git a/src/main/resources/Fonts/Aptos.ttf b/src/main/resources/Fonts/Aptos.ttf new file mode 100644 index 0000000..e19d992 Binary files /dev/null and b/src/main/resources/Fonts/Aptos.ttf differ diff --git a/src/main/resources/styles.css b/src/main/resources/styles.css index 85ab14b..ee0886f 100644 --- a/src/main/resources/styles.css +++ b/src/main/resources/styles.css @@ -1,3 +1,7 @@ +.root { + -fx-font-family: "Aptos"; +} + /* Container for the buttons */ .button-container { -fx-spacing: 20; @@ -10,7 +14,6 @@ -fx-background-radius: 15; -fx-min-width: 350; -fx-min-height: 60; - -fx-font-family: "System"; -fx-font-weight: bold; -fx-font-style: italic; -fx-font-size: 24px; @@ -30,4 +33,8 @@ -fx-background-image: url("millionsbackground.png"); /* Replace with your image path */ -fx-background-size: cover; -fx-background-position: center; +} + +.title-text { + -fx-font-size: 100px; } \ No newline at end of file