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);
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));

View File

@@ -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;

View File

@@ -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> 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<String> locationTypes = Sets.newHashSet("capital", "castle", "cave", "dungeon", "town");
return locationTypes.contains(location);
}

View File

@@ -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;
}
}

View File

@@ -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)

View File

@@ -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

View File

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

View File

@@ -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":

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 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;

View File

@@ -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;

View File

@@ -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;