update adventure BGM..

This commit is contained in:
Anthony Calosa
2023-03-19 19:16:51 +08:00
parent 0cf8fe9683
commit 1bc8abf7e1
22 changed files with 105 additions and 40 deletions

View File

@@ -312,6 +312,8 @@ public class Forge implements ApplicationListener {
GuiBase.setIsAdventureMode(false); GuiBase.setIsAdventureMode(false);
openHomeScreen(-1, null); //default for startup openHomeScreen(-1, null); //default for startup
isMobileAdventureMode = false; isMobileAdventureMode = false;
MusicPlaylist.invalidateMusicPlaylist();
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
if (isLandscapeMode()) { //open preferred new game screen by default if landscape mode if (isLandscapeMode()) { //open preferred new game screen by default if landscape mode
NewGameMenu.getPreferredScreen().open(); NewGameMenu.getPreferredScreen().open();
} }
@@ -338,8 +340,11 @@ public class Forge implements ApplicationListener {
try { try {
Config.instance().loadResources(); Config.instance().loadResources();
SpellSmithScene.instance().loadEditions(); SpellSmithScene.instance().loadEditions();
if (startScene) if (startScene) {
MusicPlaylist.invalidateMusicPlaylist();
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
switchScene(StartScene.instance()); switchScene(StartScene.instance());
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -404,8 +409,6 @@ public class Forge implements ApplicationListener {
clearSplashScreen(); clearSplashScreen();
} }
} }
//start background music
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
safeToClose = true; safeToClose = true;
clearTransitionScreen(); clearTransitionScreen();
}, takeScreenshot(), false, false, true, false)); }, takeScreenshot(), false, false, true, false));

View File

@@ -327,12 +327,12 @@ public class ArenaScene extends UIScene implements IAfterMatch {
pane.clear(); pane.clear();
arenaTable.clear(); arenaTable.clear();
if (Forge.isLandscapeMode()) { if (Forge.isLandscapeMode()) {
arenaTable.add(Controls.newTextraLabel("[;][%150]" + GameScene.instance().getAdventurePlayerLocation(true) + " Arena")).top(); arenaTable.add(Controls.newTextraLabel("[;][%150]" + GameScene.instance().getAdventurePlayerLocation(true, true) + " Arena")).top();
arenaTable.row(); arenaTable.row();
arenaTable.add(arenaPlane).width(arenaPlane.getWidth()).height(arenaPlane.getHeight()); arenaTable.add(arenaPlane).width(arenaPlane.getWidth()).height(arenaPlane.getHeight());
pane.setActor(arenaTable); pane.setActor(arenaTable);
} else { } else {
arenaTable.add(Controls.newTextraLabel("[;][%150]" + GameScene.instance().getAdventurePlayerLocation(true) + " Arena")).colspan(3).top(); arenaTable.add(Controls.newTextraLabel("[;][%150]" + GameScene.instance().getAdventurePlayerLocation(true, true) + " Arena")).colspan(3).top();
arenaTable.row(); arenaTable.row();
int size = fighters.size; int size = fighters.size;
int pv = 0; int pv = 0;

View File

@@ -24,6 +24,7 @@ public class GameScene extends HudScene {
} }
private static GameScene object; private static GameScene object;
private String location = "";
public static GameScene instance() { public static GameScene instance() {
if (object == null) if (object == null)
@@ -57,27 +58,31 @@ public class GameScene extends HudScene {
WorldStage.getInstance().handlePointsOfInterestCollision(); WorldStage.getInstance().handlePointsOfInterestCollision();
} }
public String getAdventurePlayerLocation(boolean forHeader) { public String getAdventurePlayerLocation(boolean forHeader, boolean skipRoads) {
String location = "";
if (MapStage.getInstance().isInMap()) { if (MapStage.getInstance().isInMap()) {
location = forHeader ? TileMapScene.instance().rootPoint.getData().name : TileMapScene.instance().rootPoint.getData().type; location = forHeader ? TileMapScene.instance().rootPoint.getData().name : TileMapScene.instance().rootPoint.getData().type;
} else { } else {
World world = Current.world(); World world = Current.world();
int currentBiome = World.highestBiome(world.getBiome((int) Current.player().getWorldPosX() / world.getTileSize(), (int) Current.player().getWorldPosY() / world.getTileSize())); //this gets the name of the layer... this shoud be based on boundaries...
int currentBiome = World.highestBiome(world.getBiome((int) stage.getPlayerSprite().getX() / world.getTileSize(), (int) stage.getPlayerSprite().getY() / world.getTileSize()));
List<BiomeData> biomeData = world.getData().GetBiomes(); List<BiomeData> biomeData = world.getData().GetBiomes();
try { if (biomeData.size() <= currentBiome) //on roads....
if (skipRoads) {
location = forHeader ? "Waste Map" : "waste";
} else {
//should load while walking on "road"
location = "";
}
else {
BiomeData data = biomeData.get(currentBiome); BiomeData data = biomeData.get(currentBiome);
location = forHeader ? TextUtil.capitalize(data.name) + " Map" : data.name; location = forHeader ? TextUtil.capitalize(data.name) + " Map" : data.name;
} catch (Exception e) {
//e.printStackTrace();
location = forHeader ? "Waste Map" : "waste";
} }
} }
return location; return location;
} }
public boolean isNotInWorldMap() { public boolean isNotInWorldMap() {
String location = getAdventurePlayerLocation(false); String location = getAdventurePlayerLocation(false, true);
Set<String> locationTypes = Sets.newHashSet("capital", "castle", "cave", "dungeon", "town"); Set<String> locationTypes = Sets.newHashSet("capital", "castle", "cave", "dungeon", "town");
return locationTypes.contains(location); return locationTypes.contains(location);
} }

View File

@@ -27,10 +27,12 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa
public void connected(final Controller controller) { public void connected(final Controller controller) {
hud.ui.controllerConnected(); hud.ui.controllerConnected();
} }
@Override @Override
public void disconnected(final Controller controller) { public void disconnected(final Controller controller) {
hud.ui.controllerDisconnected(); hud.ui.controllerDisconnected();
} }
@Override @Override
public boolean leave() { public boolean leave() {
stage.leave(); stage.leave();
@@ -51,18 +53,16 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa
} }
@Override @Override
public void act(float delta) public void act(float delta) {
{
stage.act(delta); stage.act(delta);
hud.act(delta); hud.act(delta);
} }
@Override @Override
public void render() { public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw(); stage.draw();
hud.draw(); hud.draw();
} }
@Override @Override
@@ -79,7 +79,6 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa
@Override @Override
public boolean keyUp(int keycode) { public boolean keyUp(int keycode) {
if (MapStage.getInstance().isDialogOnlyInput()) { if (MapStage.getInstance().isDialogOnlyInput()) {
return true; return true;
} }
@@ -89,10 +88,12 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa
return false; return false;
return stage.keyUp(keycode); return stage.keyUp(keycode);
} }
@Override @Override
public boolean buttonDown(Controller var1, int var2) { public boolean buttonDown(Controller var1, int var2) {
return keyDown(KeyBinding.controllerButtonToKey(var1, var2)); return keyDown(KeyBinding.controllerButtonToKey(var1, var2));
} }
@Override @Override
public boolean buttonUp(Controller var1, int var2) { public boolean buttonUp(Controller var1, int var2) {
return keyUp(KeyBinding.controllerButtonToKey(var1, var2)); return keyUp(KeyBinding.controllerButtonToKey(var1, var2));
@@ -100,7 +101,6 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa
@Override @Override
public boolean keyTyped(char character) { public boolean keyTyped(char character) {
if (hud.keyTyped(character)) if (hud.keyTyped(character))
return true; return true;
if (isInHudOnlyMode()) if (isInHudOnlyMode())
@@ -155,15 +155,15 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa
@Override @Override
public boolean axisMoved(Controller controller, int axisIndex, float value) { public boolean axisMoved(Controller controller, int axisIndex, float value) {
return stage.axisMoved(controller, axisIndex, value); return stage.axisMoved(controller, axisIndex, value);
} }
@Override @Override
public void setWinner(boolean winner) { public void setWinner(boolean winner) {
stage.setWinner(winner); stage.setWinner(winner);
} }
public boolean isInHudOnlyMode()
{ public boolean isInHudOnlyMode() {
return false; return false;
} }
} }

View File

@@ -218,6 +218,7 @@ public class InventoryScene extends UIScene {
clearSelectable(); clearSelectable();
inventoryButtons.clear(); inventoryButtons.clear();
inventory.clear(); inventory.clear();
Current.player().getItems().sort();
for (int i = 0; i < Current.player().getItems().size; i++) { for (int i = 0; i < Current.player().getItems().size; i++) {
if (i % columns == 0) if (i % columns == 0)

View File

@@ -250,7 +250,7 @@ public class SaveLoadScene extends UIScene {
public void save() { public void save() {
if (WorldSave.getCurrentSave().save(textInput.getText() + ASCII_179 + GameScene.instance().getAdventurePlayerLocation(true), currentSlot)) { if (WorldSave.getCurrentSave().save(textInput.getText() + ASCII_179 + GameScene.instance().getAdventurePlayerLocation(true, true), currentSlot)) {
updateFiles(); updateFiles();
//ensure the dialog is hidden before switching //ensure the dialog is hidden before switching

View File

@@ -33,6 +33,8 @@ import forge.adventure.world.WorldSave;
import forge.deck.Deck; import forge.deck.Deck;
import forge.gui.FThreads; import forge.gui.FThreads;
import forge.gui.GuiBase; import forge.gui.GuiBase;
import forge.sound.MusicPlaylist;
import forge.sound.SoundSystem;
/** /**
* Stage to handle everything rendered in the HUD * Stage to handle everything rendered in the HUD
@@ -238,7 +240,6 @@ public class GameHUD extends Stage {
return super.touchDown(screenX, screenY, pointer, button); return super.touchDown(screenX, screenY, pointer, button);
} }
@Override @Override
public void draw() { public void draw() {
updatelife = false; updatelife = false;
@@ -274,6 +275,7 @@ public class GameHUD extends Stage {
updatelife = false; updatelife = false;
lifePoints.setText("[%95][+Life]" + lifepointsTextColor + " " + AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife()); lifePoints.setText("[%95][+Life]" + lifepointsTextColor + " " + AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife());
} }
updateMusic();
} }
Texture miniMapTexture; Texture miniMapTexture;
@@ -299,6 +301,7 @@ public class GameHUD extends Stage {
} else { } else {
deckActor.setColor(menuActor.getColor()); deckActor.setColor(menuActor.getColor());
} }
updateMusic();
} }
private void openDeck() { private void openDeck() {
@@ -326,7 +329,6 @@ public class GameHUD extends Stage {
dialog.getContentTable().add(L).width(120f); dialog.getContentTable().add(L).width(120f);
dialog.setKeepWithinStage(true); dialog.setKeepWithinStage(true);
showDialog(); showDialog();
} }
private void exitDungeonCallback() { private void exitDungeonCallback() {
@@ -475,7 +477,6 @@ public class GameHUD extends Stage {
} }
private void showDialog() { private void showDialog() {
dialogButtonMap.clear(); dialogButtonMap.clear();
for (int i = 0; i < dialog.getButtonTable().getCells().size; i++) { for (int i = 0; i < dialog.getButtonTable().getCells().size; i++) {
dialogButtonMap.add((TextraButton) dialog.getButtonTable().getCells().get(i).getActor()); dialogButtonMap.add((TextraButton) dialog.getButtonTable().getCells().get(i).getActor());
@@ -560,7 +561,47 @@ public class GameHUD extends Stage {
if (count > 1) if (count > 1)
showButtons(); showButtons();
} }
}
public void updateMusic() {
switch (GameScene.instance().getAdventurePlayerLocation(false, false)) {
case "green":
changeBGM(MusicPlaylist.GREEN);
break;
case "red":
changeBGM(MusicPlaylist.RED);
break;
case "blue":
changeBGM(MusicPlaylist.BLUE);
break;
case "black":
changeBGM(MusicPlaylist.BLACK);
break;
case "white":
changeBGM(MusicPlaylist.WHITE);
break;
case "capital":
case "town":
changeBGM(MusicPlaylist.TOWN);
break;
case "cave":
changeBGM(MusicPlaylist.CAVE);
break;
case "castle":
changeBGM(MusicPlaylist.CASTLE);
break;
case "waste":
changeBGM(MusicPlaylist.MENUS);
break;
default:
break;
}
}
float fade = 1f;
void changeBGM(MusicPlaylist playlist) {
if (!playlist.equals(SoundSystem.instance.getCurrentPlaylist())) {
SoundSystem.instance.setBackgroundMusic(playlist);
}
} }
} }

View File

@@ -818,7 +818,7 @@ public class MatchScreen extends FScreen {
FSkinTexture getBG() { FSkinTexture getBG() {
if (Forge.isMobileAdventureMode) { if (Forge.isMobileAdventureMode) {
switch (GameScene.instance().getAdventurePlayerLocation(false)) { switch (GameScene.instance().getAdventurePlayerLocation(false, true)) {
case "green": case "green":
return FSkinTexture.ADV_BG_FOREST; return FSkinTexture.ADV_BG_FOREST;
case "black": case "black":

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -84,6 +84,7 @@ public final class ForgeConstants {
public static final String AI_PROFILE_DIR = RES_DIR + "ai" + PATH_SEPARATOR; public static final String AI_PROFILE_DIR = RES_DIR + "ai" + PATH_SEPARATOR;
public static final String SOUND_DIR = RES_DIR + "sound" + PATH_SEPARATOR; public static final String SOUND_DIR = RES_DIR + "sound" + PATH_SEPARATOR;
public static final String MUSIC_DIR = RES_DIR + "music" + PATH_SEPARATOR; public static final String MUSIC_DIR = RES_DIR + "music" + PATH_SEPARATOR;
public static final String ADVENTURE_MUSIC_DIR = ADVENTURE_DIR + "music" + PATH_SEPARATOR;
public static final String LANG_DIR = RES_DIR + "languages" + PATH_SEPARATOR; public static final String LANG_DIR = RES_DIR + "languages" + PATH_SEPARATOR;
public static final String EFFECTS_DIR = RES_DIR + "effects" + PATH_SEPARATOR; public static final String EFFECTS_DIR = RES_DIR + "effects" + PATH_SEPARATOR;
public static final String PUZZLE_DIR = RES_DIR + "puzzle" + PATH_SEPARATOR; public static final String PUZZLE_DIR = RES_DIR + "puzzle" + PATH_SEPARATOR;

View File

@@ -6,6 +6,14 @@ import java.io.FilenameFilter;
import forge.util.MyRandom; import forge.util.MyRandom;
public enum MusicPlaylist { public enum MusicPlaylist {
BLACK ("black/"),
BLUE ("blue/"),
RED ("red/"),
GREEN ("green/"),
WHITE ("white/"),
CASTLE ("castle/"),
CAVE ("cave/"),
TOWN ("town/"),
MENUS ("menus/"), MENUS ("menus/"),
MATCH ("match/"); MATCH ("match/");

View File

@@ -192,6 +192,10 @@ public class SoundSystem {
changeBackgroundTrack(); changeBackgroundTrack();
} }
public MusicPlaylist getCurrentPlaylist() {
return currentPlaylist;
}
public void changeBackgroundTrack() { public void changeBackgroundTrack() {
//ensure old track stopped and disposed of if needed //ensure old track stopped and disposed of if needed
if (currentTrack != null) { if (currentTrack != null) {
@@ -300,6 +304,8 @@ public class SoundSystem {
} }
public String getMusicDirectory() { public String getMusicDirectory() {
if (GuiBase.isAdventureMode())
return ForgeConstants.ADVENTURE_MUSIC_DIR;
String profileName = FModel.getPreferences().getPref(ForgePreferences.FPref.UI_CURRENT_MUSIC_SET); String profileName = FModel.getPreferences().getPref(ForgePreferences.FPref.UI_CURRENT_MUSIC_SET);
if (profileName.equals("Default")) { if (profileName.equals("Default")) {
return ForgeConstants.MUSIC_DIR; return ForgeConstants.MUSIC_DIR;