Skip to content

Commit

Permalink
Main Menu, Help Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaganx0 committed Sep 29, 2023
1 parent 507ece0 commit 7586598
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
4 changes: 3 additions & 1 deletion source/core/src/main/com/csse3200/game/GdxGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand All @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
}
});

Expand All @@ -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();
Expand Down
17 changes: 16 additions & 1 deletion source/core/src/main/com/csse3200/game/screens/AssetLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 7586598

Please sign in to comment.