Skip to content

Commit

Permalink
Feat: Minor changes to certain classes and added aptos font as standard.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyah committed May 11, 2026
1 parent da76e31 commit 8335216
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 35 deletions.
21 changes: 15 additions & 6 deletions src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>Extends {@link Application}</p>
*
* <p>Initializes the application through the javafx framework.</p>
* */
public class Main extends Application {
static void main() {
FileParser parser1 = new FileParser("src/main/resources/dummydata.txt");
Expand All @@ -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());
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
*
* <p>Implements {@link EventPublisher}</p>
*
* @param <T1> 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 <T1> 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
Expand All @@ -35,13 +36,21 @@ public abstract class ViewController<T1 extends ViewElement<?>>
* 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();
}
}

/**
Expand Down Expand Up @@ -71,7 +80,8 @@ public T1 getViewElement() {
protected abstract void initInteractions();

@Override
public final <T> void invoke(final EventData<T> data, final EventManager eventManager) {
public final <T> void invoke(final EventData<T> data,
final EventManager eventManager) {
eventManager.invokeEvent(data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,4 @@ protected void initLayout() {
protected void initStyling() {

}

@Override
public void onUpdate() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected void initInteractions() {
ViewData viewData = new ViewData("InGameView");
EventData<ViewData> eventData =
new EventData<>(EventType.SCENE_CHANGE, viewData);
getEventManager().invokeEvent(eventData);
invoke(eventData, getEventManager());
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
* */
public class MainMenuView extends ViewElement<StackPane> {

/**
* Game title.
* */
private Text titleText;

/**
* "Play Game" Button.
* */
Expand Down Expand Up @@ -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
Expand All @@ -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() {

}
}
Binary file added src/main/resources/Fonts/Aptos.ttf
Binary file not shown.
9 changes: 8 additions & 1 deletion src/main/resources/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.root {
-fx-font-family: "Aptos";
}

/* Container for the buttons */
.button-container {
-fx-spacing: 20;
Expand All @@ -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;
Expand All @@ -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;
}

0 comments on commit 8335216

Please sign in to comment.