From 7586598ff7edbfef245530cf1ec69269ead24616 Mon Sep 17 00:00:00 2001 From: Gaganx0 Date: Fri, 29 Sep 2023 15:48:48 +1000 Subject: [PATCH] Main Menu, Help Screen --- .../src/main/com/csse3200/game/GdxGame.java | 4 +++- .../components/mainmenu/MainMenuActions.java | 12 +++++------- .../components/mainmenu/MainMenuDisplay.java | 10 +++++----- .../com/csse3200/game/screens/AssetLoader.java | 17 ++++++++++++++++- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/GdxGame.java b/source/core/src/main/com/csse3200/game/GdxGame.java index 43f525990..fcb48d1b2 100644 --- a/source/core/src/main/com/csse3200/game/GdxGame.java +++ b/source/core/src/main/com/csse3200/game/GdxGame.java @@ -79,13 +79,15 @@ private Screen newScreen(ScreenType screenType) { return new LosingScreen(this); case TURRET_SELECTION: return new TurretSelectionScreen(this); + case HELP_SCREEN: + return new HelpScreen(this); default: return null; } } public enum ScreenType { - MAIN_MENU, MAIN_GAME, SETTINGS, STORY_SCREEN, LEVEL_SELECT, TURRET_SELECTION, LOSING_SCREEN + MAIN_MENU, MAIN_GAME, SETTINGS, STORY_SCREEN, LEVEL_SELECT, TURRET_SELECTION, LOSING_SCREEN, HELP_SCREEN } /** diff --git a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuActions.java b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuActions.java index 6907caf67..28aaeb805 100644 --- a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuActions.java +++ b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuActions.java @@ -2,6 +2,7 @@ import com.csse3200.game.GdxGame; import com.csse3200.game.components.Component; +import com.csse3200.game.screens.HelpScreen; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,7 +21,7 @@ public MainMenuActions(GdxGame game) { @Override public void create() { entity.getEvents().addListener("start", this::onStart); - entity.getEvents().addListener("load", this::onLoad); + entity.getEvents().addListener("help", this::onHelp); entity.getEvents().addListener("exit", this::onExit); entity.getEvents().addListener("settings", this::onSettings); } @@ -34,12 +35,9 @@ private void onStart() { // game.setScreen(GdxGame.ScreenType.LEVEL_SELECT); } - /** - * Intended for loading a saved game state. - * Load functionality is not actually implemented. - */ - private void onLoad() { - logger.info("Load game"); + private void onHelp() { + logger.info("Help Menu"); + game.setScreen(GdxGame.ScreenType.HELP_SCREEN); } /** diff --git a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java index 3eb3989fe..8a63d630f 100644 --- a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java @@ -63,7 +63,7 @@ private void addActors() { TextButton startBtn = ButtonFactory.createButton("Start"); // Create a "Help" TextButton using the default style - TextButton loadBtn = ButtonFactory.createButton("Help"); + TextButton helpBtn = ButtonFactory.createButton("Help"); // Create a "Settings" TextButton with a custom image TextButton settingsBtn =ButtonFactory.createButton("Settings"); @@ -82,12 +82,12 @@ public void changed(ChangeEvent changeEvent, Actor actor) { } }); - loadBtn.addListener( + helpBtn.addListener( new ChangeListener() { @Override public void changed(ChangeEvent changeEvent, Actor actor) { - logger.debug("Load button clicked"); - entity.getEvents().trigger("load"); + logger.debug("Help button clicked"); + entity.getEvents().trigger("help"); } }); @@ -113,7 +113,7 @@ public void changed(ChangeEvent changeEvent, Actor actor) { table1.row(); table1.add(startBtn).padTop(260f); table1.row(); - table1.add(loadBtn).padTop(15f); + table1.add(helpBtn).padTop(15f); table1.row(); table1.add(settingsBtn).padTop(15f); table1.row(); diff --git a/source/core/src/main/com/csse3200/game/screens/AssetLoader.java b/source/core/src/main/com/csse3200/game/screens/AssetLoader.java index 6bb3c18a9..4c0ec4738 100644 --- a/source/core/src/main/com/csse3200/game/screens/AssetLoader.java +++ b/source/core/src/main/com/csse3200/game/screens/AssetLoader.java @@ -148,5 +148,20 @@ public static void unloadAllAssets() { resourceService.unloadAssets(music); } - // Add methods to access loaded assets as needed (e.g., getTexture, getSound, etc.) + public static Texture getTexture(String assetPath) { + return ServiceLocator.getResourceService().getAsset(assetPath, Texture.class); + } + + public static TextureAtlas getTextureAtlas(String assetPath) { + return ServiceLocator.getResourceService().getAsset(assetPath, TextureAtlas.class); + } + + public static Sound getSound(String assetPath) { + return ServiceLocator.getResourceService().getAsset(assetPath, Sound.class); + } + + public static Music getMusic(String assetPath) { + return ServiceLocator.getResourceService().getAsset(assetPath, Music.class); + } } +