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 61fb506..3284e51 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
@@ -3,6 +3,7 @@
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.EventPublisher;
+import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventType;
/**
* Handles logic and event publishing for {@link ViewElement} objects.
@@ -18,7 +19,7 @@
* @see EventManager
*
*/
-public abstract class ViewController Extends {@link Pane}
- * Wires up the category buttons to switch the right-hand content, - * and the Back button to return to the main menu. - *
+ *Wires up the category buttons to switch the right-hand content, + * and the Back button to return to the main menu.
*/ public class SettingsController extends ViewController- * Layout: left sidebar with category buttons (audio, video, hot keys) + *
Layout: left sidebar with category buttons (audio, video, hot keys) * and a Back button at the bottom. Right pane shows the content for the - * currently selected category. - *
+ * currently selected category. */ -public class SettingsView extends ViewElement- * Constructs with name "SettingsView" - *
- */ - public SettingsView() { - super(new StackPane(), "SettingsView"); - } - - public Button getAudioButton() { - return audioButton; - } - - public Button getVideoButton() { - return videoButton; - } - - public Button getHotKeysButton() { - return hotKeysButton; - } - - public Button getBackButton() { - return backButton; - } - - public Slider getMasterVolumeSlider() { - return masterVolumeSlider; - } - - /** - * Replaces the content area with the audio section (master volume). - */ - public void showAudioSection() { - Label title = new Label("master volume"); - title.getStyleClass().add("settings-title"); - - masterVolumeSlider = new Slider(0, 100, 50); - masterVolumeSlider.setMaxWidth(360); - masterVolumeSlider.getStyleClass().add("settings-slider"); - - VBox audioBox = new VBox(20, title, masterVolumeSlider); - audioBox.setAlignment(Pos.TOP_CENTER); - audioBox.setPadding(new Insets(30)); - - contentArea.getChildren().setAll(audioBox); - } - - /** - * Replaces the content area with the video section placeholder. - */ - public void showVideoSection() { - Label title = new Label("video"); - title.getStyleClass().add("settings-title"); - Label placeholder = new Label("(video settings coming soon)"); - placeholder.getStyleClass().add("settings-placeholder"); - - VBox videoBox = new VBox(20, title, placeholder); - videoBox.setAlignment(Pos.TOP_CENTER); - videoBox.setPadding(new Insets(30)); - - contentArea.getChildren().setAll(videoBox); - } - - /** - * Replaces the content area with the hot keys section placeholder. - */ - public void showHotKeysSection() { - Label title = new Label("hot keys"); - title.getStyleClass().add("settings-title"); - Label placeholder = new Label("(hot key bindings coming soon)"); - placeholder.getStyleClass().add("settings-placeholder"); - - VBox hotKeysBox = new VBox(20, title, placeholder); - hotKeysBox.setAlignment(Pos.TOP_CENTER); - hotKeysBox.setPadding(new Insets(30)); - - contentArea.getChildren().setAll(hotKeysBox); - } - - /** {@inheritDoc} */ - @Override - protected void initLayout() { - backgroundImage = new ImageView(new Image(Objects.requireNonNull( - getClass().getResourceAsStream("/millionsbackground.png")))); - backgroundImage.setPreserveRatio(false); - - audioButton = new Button("audio"); - videoButton = new Button("video"); - hotKeysButton = new Button("hot keys"); - backButton = new Button("Back"); - - // Spacer pushes the Back button to the bottom of the sidebar. - Region spacer = new Region(); - VBox.setVgrow(spacer, javafx.scene.layout.Priority.ALWAYS); - - VBox sidebar = new VBox(15, - audioButton, videoButton, hotKeysButton, spacer, backButton); - sidebar.setAlignment(Pos.TOP_LEFT); - sidebar.setPadding(new Insets(30)); - sidebar.setPrefWidth(180); - - contentArea = new StackPane(); - contentArea.setPadding(new Insets(30)); - - mainPanel = new BorderPane(); - mainPanel.setLeft(sidebar); - mainPanel.setCenter(contentArea); - mainPanel.setMaxWidth(800); - mainPanel.setMaxHeight(500); - - // Center the BorderPane on top of the background. - HBox centerWrapper = new HBox(mainPanel); - centerWrapper.setAlignment(Pos.CENTER); - - getRootPane().getChildren().addAll(backgroundImage, centerWrapper); - - // Make the background fill the root pane. - backgroundImage.fitWidthProperty().bind(getRootPane().widthProperty()); - backgroundImage.fitHeightProperty().bind(getRootPane().heightProperty()); - - // Default section shown when settings opens. - showAudioSection(); - } - - /** {@inheritDoc} */ - @Override - protected void initStyling() { - getRootPane().getStyleClass().add("main-menu-bg"); - mainPanel.getStyleClass().add("settings-panel"); - audioButton.getStyleClass().add("settings-tab-button"); - videoButton.getStyleClass().add("settings-tab-button"); - hotKeysButton.getStyleClass().add("settings-tab-button"); - backButton.getStyleClass().add("settings-tab-button"); - } - - /** {@inheritDoc} */ - @Override - public void onUpdate() { - // Reset til audio-section hver gang viewet vises. - if (contentArea != null) { - showAudioSection(); - } +public class SettingsView extends ViewElementConstructs with name "SettingsView"
+ */ + public SettingsView() { + super(new StackPane(), ViewEnum.SETTINGS, SettingsActions.class); + } + + public Slider getMasterVolumeSlider() { + return masterVolumeSlider; + } + + /** + * Replaces the content area with the audio section (master volume). + */ + public void showAudioSection() { + Label title = new Label("master volume"); + title.getStyleClass().add("settings-title"); + + masterVolumeSlider = new Slider(0, 100, 50); + masterVolumeSlider.setMaxWidth(360); + masterVolumeSlider.getStyleClass().add("settings-slider"); + + VBox audioBox = new VBox(20, title, masterVolumeSlider); + audioBox.setAlignment(Pos.TOP_CENTER); + audioBox.setPadding(new Insets(30)); + + contentArea.getChildren().setAll(audioBox); + } + + /** + * Replaces the content area with the video section placeholder. + */ + public void showVideoSection() { + Label title = new Label("video"); + title.getStyleClass().add("settings-title"); + Label placeholder = new Label("(video settings coming soon)"); + placeholder.getStyleClass().add("settings-placeholder"); + + VBox videoBox = new VBox(20, title, placeholder); + videoBox.setAlignment(Pos.TOP_CENTER); + videoBox.setPadding(new Insets(30)); + + contentArea.getChildren().setAll(videoBox); + } + + /** + * Replaces the content area with the hot keys section placeholder. + */ + public void showHotKeysSection() { + Label title = new Label("hot keys"); + title.getStyleClass().add("settings-title"); + Label placeholder = new Label("(hot key bindings coming soon)"); + placeholder.getStyleClass().add("settings-placeholder"); + + VBox hotKeysBox = new VBox(20, title, placeholder); + hotKeysBox.setAlignment(Pos.TOP_CENTER); + hotKeysBox.setPadding(new Insets(30)); + + contentArea.getChildren().setAll(hotKeysBox); + } + + /** {@inheritDoc} */ + @Override + protected void initLayout() { + backgroundImage = new ImageView(new Image(Objects.requireNonNull( + getClass().getResourceAsStream("/millionsbackground.png")))); + backgroundImage.setPreserveRatio(false); + + audioButton = new Button("audio"); + videoButton = new Button("video"); + hotKeysButton = new Button("hot keys"); + backButton = new Button("Back"); + + // Spacer pushes the Back button to the bottom of the sidebar. + Region spacer = new Region(); + VBox.setVgrow(spacer, javafx.scene.layout.Priority.ALWAYS); + + VBox sidebar = new VBox(15, + audioButton, videoButton, hotKeysButton, spacer, backButton); + sidebar.setAlignment(Pos.TOP_LEFT); + sidebar.setPadding(new Insets(30)); + sidebar.setPrefWidth(180); + + contentArea = new StackPane(); + contentArea.setPadding(new Insets(30)); + + mainPanel = new BorderPane(); + mainPanel.setLeft(sidebar); + mainPanel.setCenter(contentArea); + mainPanel.setMaxWidth(800); + mainPanel.setMaxHeight(500); + + // Center the BorderPane on top of the background. + HBox centerWrapper = new HBox(mainPanel); + centerWrapper.setAlignment(Pos.CENTER); + + getRootPane().getChildren().addAll(backgroundImage, centerWrapper); + + // Make the background fill the root pane. + backgroundImage.fitWidthProperty().bind(getRootPane().widthProperty()); + backgroundImage.fitHeightProperty().bind(getRootPane().heightProperty()); + + // Default section shown when settings opens. + showAudioSection(); + + registerButton(SettingsActions.AUDIO, audioButton); + registerButton(SettingsActions.VIDEO, videoButton); + registerButton(SettingsActions.HOTKEYS, hotKeysButton); + registerButton(SettingsActions.BACK, backButton); + } + + /** {@inheritDoc} */ + @Override + protected void initStyling() { + getRootPane().getStyleClass().add("main-menu-bg"); + mainPanel.getStyleClass().add("settings-panel"); + audioButton.getStyleClass().add("settings-tab-button"); + videoButton.getStyleClass().add("settings-tab-button"); + hotKeysButton.getStyleClass().add("settings-tab-button"); + backButton.getStyleClass().add("settings-tab-button"); + } + + /** {@inheritDoc} */ + @Override + public void onUpdate() { + // Reset til audio-section hver gang viewet vises. + if (contentArea != null) { + showAudioSection(); } + } } \ No newline at end of file diff --git a/src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/service/event/EventManagerTest.java b/src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/service/event/EventManagerTest.java index 58d6d0e..716e96e 100644 --- a/src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/service/event/EventManagerTest.java +++ b/src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/service/event/EventManagerTest.java @@ -1,6 +1,7 @@ package edu.ntnu.idi.idatt2003.g40.mappe.service.event; import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewData; +import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewEnum; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -72,7 +73,7 @@ private class GenericEventPublisher implements EventPublisher { private final EventManager eventManager; public GenericEventPublisher(final EventManager eventManager, final TestEventTypes eventType) { - viewData = new ViewData("Test"); + viewData = new ViewData(ViewEnum.IN_GAME); eventData = new EventData