-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added css sheet file, and added some example classes to show how the system work
- Loading branch information
Showing
6 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ingame/InGameView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.ingame; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement; | ||
| import javafx.scene.layout.VBox; | ||
| import javafx.scene.text.Text; | ||
|
|
||
| public class InGameView extends ViewElement<VBox> { | ||
|
|
||
| public InGameView() { | ||
| super(new VBox(), "InGameView"); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initLayout() { | ||
| getRootPane().getChildren().add(new Text("This is the game view!")); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initStyling() { | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public void onUpdate() { | ||
|
|
||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.mainmenu; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventData; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventType; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewController; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewData; | ||
|
|
||
| /** | ||
| * Controller for the {@link MainMenuView}. | ||
| * | ||
| * <p>Extends {@link ViewController}</p> | ||
| * */ | ||
| public class MainMenuController extends ViewController<MainMenuView> { | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * @param view The {@link MainMenuView} object to attach this controller to. | ||
| * @param eventManager the active {@link EventManager}. | ||
| * */ | ||
| public MainMenuController(final MainMenuView view, | ||
| final EventManager eventManager) { | ||
| super(view, eventManager); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritDoc} | ||
| * | ||
| * <p>Sets play game button functionality</p> | ||
| * */ | ||
| @Override | ||
| protected void initInteractions() { | ||
| getViewElement().getToGameButton().setOnAction(e -> { | ||
| ViewData viewData = new ViewData("InGameView"); | ||
| EventData<ViewData> eventData = | ||
| new EventData<>(EventType.SCENE_CHANGE, viewData); | ||
| getEventManager().invokeEvent(eventData); | ||
| }); | ||
| } | ||
| } |
121 changes: 121 additions & 0 deletions
121
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/mainmenu/MainMenuView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.mainmenu; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement; | ||
| import javafx.geometry.Pos; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.layout.StackPane; | ||
| import javafx.scene.layout.VBox; | ||
| import javafx.scene.text.Text; | ||
|
|
||
| /** | ||
| * The main menu UI. | ||
| * | ||
| * <p>Extends {@link ViewElement}, | ||
| * with a root pane of {@link StackPane}</p> | ||
| * */ | ||
| public class MainMenuView extends ViewElement<StackPane> { | ||
|
|
||
| /** | ||
| * "Play Game" Button. | ||
| * */ | ||
| private Button toGameButton; | ||
|
|
||
| /** | ||
| * "Settings" Button. | ||
| * */ | ||
| private Button settingsButton; | ||
|
|
||
| /** | ||
| * "Exit" Button. | ||
| * */ | ||
| private Button exitButton; | ||
|
|
||
| /** | ||
| * Container for button elements. | ||
| * */ | ||
| private VBox buttonContainer; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * <p>Constructs with name "MainMenu"</p> | ||
| * */ | ||
| public MainMenuView() { | ||
| super(new StackPane(), "MainMenu"); | ||
| } | ||
|
|
||
| /** | ||
| * Getter method for "Play" button. | ||
| * | ||
| * @return Play game button. | ||
| * */ | ||
| public Button getToGameButton() { | ||
| return toGameButton; | ||
| } | ||
|
|
||
| /** | ||
| * Getter method for "Settings" button. | ||
| * | ||
| * @return Settings button. | ||
| * */ | ||
| public Button getSettingsButton() { | ||
| return settingsButton; | ||
| } | ||
|
|
||
| /** | ||
| * Getter method for "Exit" button. | ||
| * | ||
| * @return Exit button. | ||
| * */ | ||
| public Button getExitButton() { | ||
| return exitButton; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritDoc} | ||
| * | ||
| * <p>Displays three buttons:</p> | ||
| * <ul> | ||
| * <li>"Play"</li> | ||
| * <li>"Settings"</li> | ||
| * <li>"Exit"</li> | ||
| * </ul> | ||
| * */ | ||
| @Override | ||
| protected void initLayout() { | ||
| toGameButton = new Button("Play"); | ||
| settingsButton = new Button("Settings"); | ||
| exitButton = new Button("Exit"); | ||
| buttonContainer = new VBox(); | ||
| buttonContainer.getChildren().addAll( | ||
| new Text("This is the main menu!"), | ||
| toGameButton, | ||
| settingsButton, | ||
| exitButton | ||
| ); | ||
| getRootPane().getChildren().add(buttonContainer); | ||
| StackPane.setAlignment(buttonContainer, Pos.CENTER); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritDoc} | ||
| * */ | ||
| @Override | ||
| protected void initStyling() { | ||
| getRootPane().getStyleClass().add("main-menu-bg"); | ||
|
|
||
| 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() { | ||
|
|
||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* Container for the buttons */ | ||
| .button-container { | ||
| -fx-spacing: 20; | ||
| -fx-alignment: center; | ||
| } | ||
|
|
||
| /* Base button styling */ | ||
| .menu-button { | ||
| -fx-background-color: rgba(255, 255, 255, 0.7); /* Translucent white */ | ||
| -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; | ||
| -fx-text-fill: black; | ||
| -fx-cursor: hand; | ||
| } | ||
|
|
||
| /* Hover effect for interactivity */ | ||
| .menu-button:hover { | ||
| -fx-background-color: rgba(255, 255, 255, 0.9); | ||
| -fx-scale-x: 1.05; | ||
| -fx-scale-y: 1.05; | ||
| } | ||
|
|
||
| /* Background image styling */ | ||
| .main-menu-bg { | ||
| -fx-background-image: url("millionsbackground.png"); /* Replace with your image path */ | ||
| -fx-background-size: cover; | ||
| -fx-background-position: center; | ||
| } |