diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java index 6e93c9a9c01..a00fb6247bc 100644 --- a/forge-gui-mobile/src/forge/Forge.java +++ b/forge-gui-mobile/src/forge/Forge.java @@ -312,6 +312,8 @@ public class Forge implements ApplicationListener { GuiBase.setIsAdventureMode(false); openHomeScreen(-1, null); //default for startup isMobileAdventureMode = false; + MusicPlaylist.invalidateMusicPlaylist(); + SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); if (isLandscapeMode()) { //open preferred new game screen by default if landscape mode NewGameMenu.getPreferredScreen().open(); } @@ -338,8 +340,11 @@ public class Forge implements ApplicationListener { try { Config.instance().loadResources(); SpellSmithScene.instance().loadEditions(); - if (startScene) + if (startScene) { + MusicPlaylist.invalidateMusicPlaylist(); + SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); switchScene(StartScene.instance()); + } } catch (Exception e) { e.printStackTrace(); } @@ -404,8 +409,6 @@ public class Forge implements ApplicationListener { clearSplashScreen(); } } - //start background music - SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); safeToClose = true; clearTransitionScreen(); }, takeScreenshot(), false, false, true, false)); diff --git a/forge-gui-mobile/src/forge/adventure/scene/ArenaScene.java b/forge-gui-mobile/src/forge/adventure/scene/ArenaScene.java index 218449d4afe..e5c6a6233a8 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/ArenaScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/ArenaScene.java @@ -327,12 +327,12 @@ public class ArenaScene extends UIScene implements IAfterMatch { pane.clear(); arenaTable.clear(); 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.add(arenaPlane).width(arenaPlane.getWidth()).height(arenaPlane.getHeight()); pane.setActor(arenaTable); } 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(); int size = fighters.size; int pv = 0; diff --git a/forge-gui-mobile/src/forge/adventure/scene/GameScene.java b/forge-gui-mobile/src/forge/adventure/scene/GameScene.java index 07058ef66a4..eabe69d509a 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/GameScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/GameScene.java @@ -24,6 +24,7 @@ public class GameScene extends HudScene { } private static GameScene object; + private String location = ""; public static GameScene instance() { if (object == null) @@ -57,27 +58,31 @@ public class GameScene extends HudScene { WorldStage.getInstance().handlePointsOfInterestCollision(); } - public String getAdventurePlayerLocation(boolean forHeader) { - String location = ""; + public String getAdventurePlayerLocation(boolean forHeader, boolean skipRoads) { if (MapStage.getInstance().isInMap()) { location = forHeader ? TileMapScene.instance().rootPoint.getData().name : TileMapScene.instance().rootPoint.getData().type; } else { 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 = 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); location = forHeader ? TextUtil.capitalize(data.name) + " Map" : data.name; - } catch (Exception e) { - //e.printStackTrace(); - location = forHeader ? "Waste Map" : "waste"; } } return location; } public boolean isNotInWorldMap() { - String location = getAdventurePlayerLocation(false); + String location = getAdventurePlayerLocation(false, true); Set locationTypes = Sets.newHashSet("capital", "castle", "cave", "dungeon", "town"); return locationTypes.contains(location); } diff --git a/forge-gui-mobile/src/forge/adventure/scene/HudScene.java b/forge-gui-mobile/src/forge/adventure/scene/HudScene.java index 6bcb72a2a17..98b4abf94ea 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/HudScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/HudScene.java @@ -13,7 +13,7 @@ import forge.adventure.util.KeyBinding; /** * Hud base scene */ -public abstract class HudScene extends Scene implements InputProcessor, IAfterMatch { +public abstract class HudScene extends Scene implements InputProcessor, IAfterMatch { GameHUD hud; GameStage stage; @@ -27,10 +27,12 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa public void connected(final Controller controller) { hud.ui.controllerConnected(); } + @Override public void disconnected(final Controller controller) { hud.ui.controllerDisconnected(); } + @Override public boolean leave() { stage.leave(); @@ -51,18 +53,16 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa } @Override - public void act(float delta) - { + public void act(float delta) { stage.act(delta); hud.act(delta); } + @Override public void render() { - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.draw(); hud.draw(); - } @Override @@ -72,38 +72,38 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa } if (hud.keyDown(keycode)) return true; - if(isInHudOnlyMode()) + if (isInHudOnlyMode()) return false; return stage.keyDown(keycode); } @Override public boolean keyUp(int keycode) { - if (MapStage.getInstance().isDialogOnlyInput()) { return true; } if (hud.keyUp(keycode)) return true; - if(isInHudOnlyMode()) + if (isInHudOnlyMode()) return false; return stage.keyUp(keycode); } + @Override public boolean buttonDown(Controller var1, int var2) { - return keyDown(KeyBinding.controllerButtonToKey(var1,var2)); + return keyDown(KeyBinding.controllerButtonToKey(var1, var2)); } + @Override public boolean buttonUp(Controller var1, int var2) { - return keyUp(KeyBinding.controllerButtonToKey(var1,var2)); + return keyUp(KeyBinding.controllerButtonToKey(var1, var2)); } @Override public boolean keyTyped(char character) { - if (hud.keyTyped(character)) return true; - if(isInHudOnlyMode()) + if (isInHudOnlyMode()) return false; return stage.keyTyped(character); } @@ -112,7 +112,7 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa public boolean touchDown(int screenX, int screenY, int pointer, int button) { if (hud.touchDown(screenX, screenY, pointer, button)) return true; - if(isInHudOnlyMode()) + if (isInHudOnlyMode()) return false; return stage.touchDown(screenX, screenY, pointer, button); } @@ -121,7 +121,7 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa public boolean touchUp(int screenX, int screenY, int pointer, int button) { if (hud.touchUp(screenX, screenY, pointer, button)) return true; - if(isInHudOnlyMode()) + if (isInHudOnlyMode()) return false; return stage.touchUp(screenX, screenY, pointer, button); } @@ -130,7 +130,7 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa public boolean touchDragged(int screenX, int screenY, int pointer) { if (hud.touchDragged(screenX, screenY, pointer)) return true; - if(isInHudOnlyMode()) + if (isInHudOnlyMode()) return false; return stage.touchDragged(screenX, screenY, pointer); } @@ -139,7 +139,7 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa public boolean mouseMoved(int screenX, int screenY) { if (hud.mouseMoved(screenX, screenY)) return true; - if(isInHudOnlyMode()) + if (isInHudOnlyMode()) return false; return stage.mouseMoved(screenX, screenY); } @@ -148,22 +148,22 @@ public abstract class HudScene extends Scene implements InputProcessor, IAfterMa public boolean scrolled(float amountX, float amountY) { if (hud.scrolled(amountX, amountY)) return true; - if(isInHudOnlyMode()) + if (isInHudOnlyMode()) return false; return stage.scrolled(amountX, amountY); } @Override public boolean axisMoved(Controller controller, int axisIndex, float value) { - return stage.axisMoved(controller, axisIndex, value); } + @Override public void setWinner(boolean winner) { stage.setWinner(winner); } - public boolean isInHudOnlyMode() - { + + public boolean isInHudOnlyMode() { return false; } } \ No newline at end of file diff --git a/forge-gui-mobile/src/forge/adventure/scene/InventoryScene.java b/forge-gui-mobile/src/forge/adventure/scene/InventoryScene.java index cebf22a5b30..af7c74d07c7 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/InventoryScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/InventoryScene.java @@ -218,6 +218,7 @@ public class InventoryScene extends UIScene { clearSelectable(); inventoryButtons.clear(); inventory.clear(); + Current.player().getItems().sort(); for (int i = 0; i < Current.player().getItems().size; i++) { if (i % columns == 0) diff --git a/forge-gui-mobile/src/forge/adventure/scene/SaveLoadScene.java b/forge-gui-mobile/src/forge/adventure/scene/SaveLoadScene.java index a020e37080a..cbb7ad68221 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/SaveLoadScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/SaveLoadScene.java @@ -250,7 +250,7 @@ public class SaveLoadScene extends UIScene { 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(); //ensure the dialog is hidden before switching diff --git a/forge-gui-mobile/src/forge/adventure/stage/GameHUD.java b/forge-gui-mobile/src/forge/adventure/stage/GameHUD.java index 35b37e4f34a..ab9021c188f 100644 --- a/forge-gui-mobile/src/forge/adventure/stage/GameHUD.java +++ b/forge-gui-mobile/src/forge/adventure/stage/GameHUD.java @@ -33,6 +33,8 @@ import forge.adventure.world.WorldSave; import forge.deck.Deck; import forge.gui.FThreads; import forge.gui.GuiBase; +import forge.sound.MusicPlaylist; +import forge.sound.SoundSystem; /** * Stage to handle everything rendered in the HUD @@ -238,7 +240,6 @@ public class GameHUD extends Stage { return super.touchDown(screenX, screenY, pointer, button); } - @Override public void draw() { updatelife = false; @@ -274,6 +275,7 @@ public class GameHUD extends Stage { updatelife = false; lifePoints.setText("[%95][+Life]" + lifepointsTextColor + " " + AdventurePlayer.current().getLife() + "/" + AdventurePlayer.current().getMaxLife()); } + updateMusic(); } Texture miniMapTexture; @@ -299,6 +301,7 @@ public class GameHUD extends Stage { } else { deckActor.setColor(menuActor.getColor()); } + updateMusic(); } private void openDeck() { @@ -326,7 +329,6 @@ public class GameHUD extends Stage { dialog.getContentTable().add(L).width(120f); dialog.setKeepWithinStage(true); showDialog(); - } private void exitDungeonCallback() { @@ -475,7 +477,6 @@ public class GameHUD extends Stage { } private void showDialog() { - dialogButtonMap.clear(); for (int i = 0; i < dialog.getButtonTable().getCells().size; i++) { dialogButtonMap.add((TextraButton) dialog.getButtonTable().getCells().get(i).getActor()); @@ -560,7 +561,47 @@ public class GameHUD extends Stage { if (count > 1) 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); + } } } diff --git a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java index 04d1abf5be0..54fddb4afbc 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java @@ -818,7 +818,7 @@ public class MatchScreen extends FScreen { FSkinTexture getBG() { if (Forge.isMobileAdventureMode) { - switch (GameScene.instance().getAdventurePlayerLocation(false)) { + switch (GameScene.instance().getAdventurePlayerLocation(false, true)) { case "green": return FSkinTexture.ADV_BG_FOREST; case "black": diff --git a/forge-gui/res/adventure/music/black/black1.mp3 b/forge-gui/res/adventure/music/black/black1.mp3 new file mode 100644 index 00000000000..63da592e852 Binary files /dev/null and b/forge-gui/res/adventure/music/black/black1.mp3 differ diff --git a/forge-gui/res/adventure/music/blue/blue1.mp3 b/forge-gui/res/adventure/music/blue/blue1.mp3 new file mode 100644 index 00000000000..b6206b287f3 Binary files /dev/null and b/forge-gui/res/adventure/music/blue/blue1.mp3 differ diff --git a/forge-gui/res/adventure/music/cave/cave1.mp3 b/forge-gui/res/adventure/music/cave/cave1.mp3 new file mode 100644 index 00000000000..53b3981a448 Binary files /dev/null and b/forge-gui/res/adventure/music/cave/cave1.mp3 differ diff --git a/forge-gui/res/adventure/music/green/green1.mp3 b/forge-gui/res/adventure/music/green/green1.mp3 new file mode 100644 index 00000000000..2d1045adf6d Binary files /dev/null and b/forge-gui/res/adventure/music/green/green1.mp3 differ diff --git a/forge-gui/res/adventure/music/match/match1.mp3 b/forge-gui/res/adventure/music/match/match1.mp3 new file mode 100644 index 00000000000..c008420120a Binary files /dev/null and b/forge-gui/res/adventure/music/match/match1.mp3 differ diff --git a/forge-gui/res/adventure/music/match/match2.mp3 b/forge-gui/res/adventure/music/match/match2.mp3 new file mode 100644 index 00000000000..8935336ba9a Binary files /dev/null and b/forge-gui/res/adventure/music/match/match2.mp3 differ diff --git a/forge-gui/res/adventure/music/match/match3.mp3 b/forge-gui/res/adventure/music/match/match3.mp3 new file mode 100644 index 00000000000..6f832031214 Binary files /dev/null and b/forge-gui/res/adventure/music/match/match3.mp3 differ diff --git a/forge-gui/res/adventure/music/menus/menu1.mp3 b/forge-gui/res/adventure/music/menus/menu1.mp3 new file mode 100644 index 00000000000..539fe0131af Binary files /dev/null and b/forge-gui/res/adventure/music/menus/menu1.mp3 differ diff --git a/forge-gui/res/adventure/music/red/red1.mp3 b/forge-gui/res/adventure/music/red/red1.mp3 new file mode 100644 index 00000000000..5352aac7c8d Binary files /dev/null and b/forge-gui/res/adventure/music/red/red1.mp3 differ diff --git a/forge-gui/res/adventure/music/town/town1.mp3 b/forge-gui/res/adventure/music/town/town1.mp3 new file mode 100644 index 00000000000..a779f96bff5 Binary files /dev/null and b/forge-gui/res/adventure/music/town/town1.mp3 differ diff --git a/forge-gui/res/adventure/music/white/white1.mp3 b/forge-gui/res/adventure/music/white/white1.mp3 new file mode 100644 index 00000000000..65b7be8fcd6 Binary files /dev/null and b/forge-gui/res/adventure/music/white/white1.mp3 differ diff --git a/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java b/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java index a3470a9353c..d98b1516eb8 100644 --- a/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java +++ b/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java @@ -84,6 +84,7 @@ public final class ForgeConstants { 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 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 EFFECTS_DIR = RES_DIR + "effects" + PATH_SEPARATOR; public static final String PUZZLE_DIR = RES_DIR + "puzzle" + PATH_SEPARATOR; diff --git a/forge-gui/src/main/java/forge/sound/MusicPlaylist.java b/forge-gui/src/main/java/forge/sound/MusicPlaylist.java index 48cf6f958ca..5b6657bf28f 100644 --- a/forge-gui/src/main/java/forge/sound/MusicPlaylist.java +++ b/forge-gui/src/main/java/forge/sound/MusicPlaylist.java @@ -6,8 +6,16 @@ import java.io.FilenameFilter; import forge.util.MyRandom; public enum MusicPlaylist { - MENUS("menus/"), - MATCH("match/"); + BLACK ("black/"), + BLUE ("blue/"), + RED ("red/"), + GREEN ("green/"), + WHITE ("white/"), + CASTLE ("castle/"), + CAVE ("cave/"), + TOWN ("town/"), + MENUS ("menus/"), + MATCH ("match/"); private final String subDir; private int mostRecentTrackIdx = -1; diff --git a/forge-gui/src/main/java/forge/sound/SoundSystem.java b/forge-gui/src/main/java/forge/sound/SoundSystem.java index 9720da4b113..f6c892583b6 100644 --- a/forge-gui/src/main/java/forge/sound/SoundSystem.java +++ b/forge-gui/src/main/java/forge/sound/SoundSystem.java @@ -192,6 +192,10 @@ public class SoundSystem { changeBackgroundTrack(); } + public MusicPlaylist getCurrentPlaylist() { + return currentPlaylist; + } + public void changeBackgroundTrack() { //ensure old track stopped and disposed of if needed if (currentTrack != null) { @@ -300,6 +304,8 @@ public class SoundSystem { } public String getMusicDirectory() { + if (GuiBase.isAdventureMode()) + return ForgeConstants.ADVENTURE_MUSIC_DIR; String profileName = FModel.getPreferences().getPref(ForgePreferences.FPref.UI_CURRENT_MUSIC_SET); if (profileName.equals("Default")) { return ForgeConstants.MUSIC_DIR;