mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
update SFX, handle missing JSON deck definition
- add button_press, coins_drop, take_shard sfx - update music timing - adjust secondary audio volume - adjust flipprocess prior to its sfx - handle crash for missing deck/json definition
This commit is contained in:
@@ -18,6 +18,8 @@ import forge.deck.DeckProxy;
|
|||||||
import forge.deck.DeckSection;
|
import forge.deck.DeckSection;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
|
import forge.sound.SoundEffectType;
|
||||||
|
import forge.sound.SoundSystem;
|
||||||
import forge.util.ItemPool;
|
import forge.util.ItemPool;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -516,6 +518,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
public void takeGold(int price) {
|
public void takeGold(int price) {
|
||||||
gold -= price;
|
gold -= price;
|
||||||
onGoldChangeList.emit();
|
onGoldChangeList.emit();
|
||||||
|
//play sfx
|
||||||
|
SoundSystem.instance.play(SoundEffectType.CoinsDrop, false);
|
||||||
}
|
}
|
||||||
public void addShards(int number) {
|
public void addShards(int number) {
|
||||||
takeShards(-number);
|
takeShards(-number);
|
||||||
@@ -523,6 +527,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
public void takeShards(int number) {
|
public void takeShards(int number) {
|
||||||
shards -= number;
|
shards -= number;
|
||||||
onShardsChangeList.emit();
|
onShardsChangeList.emit();
|
||||||
|
//play sfx
|
||||||
|
SoundSystem.instance.play(SoundEffectType.TakeShard, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShards(int number) {
|
public void setShards(int number) {
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class DuelScene extends ForgeScene {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
GameHUD.getInstance().stopAudio();
|
GameHUD.getInstance().unloadAudio();
|
||||||
Set<GameType> appliedVariants = new HashSet<>();
|
Set<GameType> appliedVariants = new HashSet<>();
|
||||||
appliedVariants.add(GameType.Constructed);
|
appliedVariants.add(GameType.Constructed);
|
||||||
AdventurePlayer advPlayer = Current.player();
|
AdventurePlayer advPlayer = Current.player();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import forge.localinstance.properties.ForgePreferences;
|
|||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.player.GamePlayerUtil;
|
import forge.player.GamePlayerUtil;
|
||||||
import forge.screens.TransitionScreen;
|
import forge.screens.TransitionScreen;
|
||||||
|
import forge.sound.SoundSystem;
|
||||||
import forge.util.NameGenerator;
|
import forge.util.NameGenerator;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@@ -190,7 +191,7 @@ public class NewGameScene extends UIScene {
|
|||||||
}
|
}
|
||||||
Runnable runnable = () -> {
|
Runnable runnable = () -> {
|
||||||
started = false;
|
started = false;
|
||||||
FModel.getPreferences().setPref(ForgePreferences.FPref.UI_ENABLE_MUSIC, false);
|
//FModel.getPreferences().setPref(ForgePreferences.FPref.UI_ENABLE_MUSIC, false);
|
||||||
WorldSave.generateNewWorld(selectedName.getText(),
|
WorldSave.generateNewWorld(selectedName.getText(),
|
||||||
gender.getCurrentIndex() == 0,
|
gender.getCurrentIndex() == 0,
|
||||||
race.getCurrentIndex(),
|
race.getCurrentIndex(),
|
||||||
@@ -200,6 +201,7 @@ public class NewGameScene extends UIScene {
|
|||||||
modes.get(mode.getCurrentIndex()), colorId.getCurrentIndex(),
|
modes.get(mode.getCurrentIndex()), colorId.getCurrentIndex(),
|
||||||
editionIds[starterEdition.getCurrentIndex()], 0);//maybe replace with enum
|
editionIds[starterEdition.getCurrentIndex()], 0);//maybe replace with enum
|
||||||
GamePlayerUtil.getGuiPlayer().setName(selectedName.getText());
|
GamePlayerUtil.getGuiPlayer().setName(selectedName.getText());
|
||||||
|
SoundSystem.instance.changeBackgroundTrack();
|
||||||
Forge.switchScene(GameScene.instance());
|
Forge.switchScene(GameScene.instance());
|
||||||
};
|
};
|
||||||
Forge.setTransitionScreen(new TransitionScreen(runnable, null, false, true, "Generating World..."));
|
Forge.setTransitionScreen(new TransitionScreen(runnable, null, false, true, "Generating World..."));
|
||||||
|
|||||||
@@ -146,13 +146,15 @@ public class RewardScene extends UIScene {
|
|||||||
showLootOrDone();
|
showLootOrDone();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
switch (type) {
|
if (type != null) {
|
||||||
case Shop:
|
switch (type) {
|
||||||
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
case Shop:
|
||||||
break;
|
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||||
case Loot:
|
break;
|
||||||
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
case Loot:
|
||||||
break;
|
doneButton.setText(Forge.getLocalizer().getMessage("lblDone"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
shown = false;
|
shown = false;
|
||||||
clearGenerated();
|
clearGenerated();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import forge.adventure.util.Current;
|
|||||||
import forge.adventure.world.WorldSave;
|
import forge.adventure.world.WorldSave;
|
||||||
import forge.adventure.world.WorldSaveHeader;
|
import forge.adventure.world.WorldSaveHeader;
|
||||||
import forge.screens.TransitionScreen;
|
import forge.screens.TransitionScreen;
|
||||||
|
import forge.sound.SoundSystem;
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -217,6 +218,7 @@ public class SaveLoadScene extends UIScene {
|
|||||||
try {
|
try {
|
||||||
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||||
if (WorldSave.load(currentSlot)) {
|
if (WorldSave.load(currentSlot)) {
|
||||||
|
SoundSystem.instance.changeBackgroundTrack();
|
||||||
Forge.switchScene(GameScene.instance());
|
Forge.switchScene(GameScene.instance());
|
||||||
} else {
|
} else {
|
||||||
Forge.clearTransitionScreen();
|
Forge.clearTransitionScreen();
|
||||||
@@ -236,6 +238,7 @@ public class SaveLoadScene extends UIScene {
|
|||||||
Current.player().updateDifficulty(Config.instance().getConfigData().difficulties[difficulty.getSelectedIndex()]);
|
Current.player().updateDifficulty(Config.instance().getConfigData().difficulties[difficulty.getSelectedIndex()]);
|
||||||
Current.player().setWorldPosY((int) (WorldSave.getCurrentSave().getWorld().getData().playerStartPosY * WorldSave.getCurrentSave().getWorld().getData().height * WorldSave.getCurrentSave().getWorld().getTileSize()));
|
Current.player().setWorldPosY((int) (WorldSave.getCurrentSave().getWorld().getData().playerStartPosY * WorldSave.getCurrentSave().getWorld().getData().height * WorldSave.getCurrentSave().getWorld().getTileSize()));
|
||||||
Current.player().setWorldPosX((int) (WorldSave.getCurrentSave().getWorld().getData().playerStartPosX * WorldSave.getCurrentSave().getWorld().getData().width * WorldSave.getCurrentSave().getWorld().getTileSize()));
|
Current.player().setWorldPosX((int) (WorldSave.getCurrentSave().getWorld().getData().playerStartPosX * WorldSave.getCurrentSave().getWorld().getData().width * WorldSave.getCurrentSave().getWorld().getTileSize()));
|
||||||
|
SoundSystem.instance.changeBackgroundTrack();
|
||||||
Forge.switchScene(GameScene.instance());
|
Forge.switchScene(GameScene.instance());
|
||||||
} else {
|
} else {
|
||||||
Forge.clearTransitionScreen();
|
Forge.clearTransitionScreen();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import forge.adventure.util.Config;
|
|||||||
import forge.adventure.util.Controls;
|
import forge.adventure.util.Controls;
|
||||||
import forge.adventure.world.WorldSave;
|
import forge.adventure.world.WorldSave;
|
||||||
import forge.screens.TransitionScreen;
|
import forge.screens.TransitionScreen;
|
||||||
|
import forge.sound.SoundSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First scene after the splash screen
|
* First scene after the splash screen
|
||||||
@@ -81,6 +82,7 @@ public class StartScene extends UIScene {
|
|||||||
try {
|
try {
|
||||||
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
Forge.setTransitionScreen(new TransitionScreen(() -> {
|
||||||
if (WorldSave.load(WorldSave.filenameToSlot(lastActiveSave))) {
|
if (WorldSave.load(WorldSave.filenameToSlot(lastActiveSave))) {
|
||||||
|
SoundSystem.instance.changeBackgroundTrack();
|
||||||
Forge.switchScene(GameScene.instance());
|
Forge.switchScene(GameScene.instance());
|
||||||
} else {
|
} else {
|
||||||
Forge.clearTransitionScreen();
|
Forge.clearTransitionScreen();
|
||||||
|
|||||||
@@ -35,6 +35,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.localinstance.properties.ForgePreferences;
|
||||||
|
import forge.model.FModel;
|
||||||
import forge.sound.MusicPlaylist;
|
import forge.sound.MusicPlaylist;
|
||||||
import forge.sound.SoundSystem;
|
import forge.sound.SoundSystem;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
@@ -311,7 +313,7 @@ public class GameHUD extends Stage {
|
|||||||
SoundSystem.instance.pause();
|
SoundSystem.instance.pause();
|
||||||
playAudio();
|
playAudio();
|
||||||
} else {
|
} else {
|
||||||
stopAudio();
|
unloadAudio();
|
||||||
SoundSystem.instance.resume(); // resume World BGM
|
SoundSystem.instance.resume(); // resume World BGM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -337,26 +339,63 @@ public class GameHUD extends Stage {
|
|||||||
if (audio != null) {
|
if (audio != null) {
|
||||||
audio.getRight().setLooping(true);
|
audio.getRight().setLooping(true);
|
||||||
audio.getRight().play();
|
audio.getRight().play();
|
||||||
|
audio.getRight().setVolume(FModel.getPreferences().getPrefInt(ForgePreferences.FPref.UI_VOL_MUSIC)/100f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void fadeAudio(float v) {
|
public void fadeAudio(float value) {
|
||||||
if (audio != null) {
|
if (audio != null) {
|
||||||
audio.getRight().setVolume(v);
|
audio.getRight().setVolume((FModel.getPreferences().getPrefInt(ForgePreferences.FPref.UI_VOL_MUSIC)*value)/100f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopAudio() {
|
float fade = 1f;
|
||||||
if (audio != null) {
|
void fadeIn() {
|
||||||
audio.getRight().stop();
|
if (fade >= 1f)
|
||||||
|
return;
|
||||||
|
for (int i = 10; i > 1; i--) {
|
||||||
|
float delay = i * 0.1f;
|
||||||
|
Timer.schedule(new Timer.Task() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fade += 0.1f;
|
||||||
|
if (fade > 1f)
|
||||||
|
fade = 1f;
|
||||||
|
fadeAudio(fade);
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void fadeOut() {
|
||||||
|
for (int i = 10; i > 1; i--) {
|
||||||
|
float delay = i * 0.1f;
|
||||||
|
Timer.schedule(new Timer.Task() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fade -= 0.1f;
|
||||||
|
if (fade < 0.1f)
|
||||||
|
fade = 0.1f;
|
||||||
|
fadeAudio(fade);
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unloadAudio() {
|
||||||
|
if (audio != null) {
|
||||||
|
audio.getRight().setOnCompletionListener(null);
|
||||||
|
audio.getRight().stop();
|
||||||
|
Forge.getAssets().manager().unload(audio.getLeft().path());
|
||||||
|
}
|
||||||
|
audio = null;
|
||||||
|
currentAudioPlaylist = null;
|
||||||
|
}
|
||||||
|
|
||||||
private MusicPlaylist currentAudioPlaylist = null;
|
private MusicPlaylist currentAudioPlaylist = null;
|
||||||
|
|
||||||
private void setAudio(MusicPlaylist playlist) {
|
private void setAudio(MusicPlaylist playlist) {
|
||||||
if (playlist.equals(currentAudioPlaylist))
|
if (playlist.equals(currentAudioPlaylist))
|
||||||
return;
|
return;
|
||||||
stopAudio();
|
unloadAudio();
|
||||||
audio = getMusic(playlist);
|
audio = getMusic(playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,6 +438,12 @@ public class GameHUD extends Stage {
|
|||||||
showDialog();
|
showDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void pauseMusic() {
|
||||||
|
if (audio != null) {
|
||||||
|
audio.getRight().pause();
|
||||||
|
}
|
||||||
|
SoundSystem.instance.pause();
|
||||||
|
}
|
||||||
private void exitDungeonCallback() {
|
private void exitDungeonCallback() {
|
||||||
hideDialog(true);
|
hideDialog(true);
|
||||||
}
|
}
|
||||||
@@ -656,8 +701,6 @@ public class GameHUD extends Stage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float fade = 1f;
|
|
||||||
|
|
||||||
void changeBGM(MusicPlaylist playlist) {
|
void changeBGM(MusicPlaylist playlist) {
|
||||||
if (!playlist.equals(SoundSystem.instance.getCurrentPlaylist())) {
|
if (!playlist.equals(SoundSystem.instance.getCurrentPlaylist())) {
|
||||||
SoundSystem.instance.setBackgroundMusic(playlist);
|
SoundSystem.instance.setBackgroundMusic(playlist);
|
||||||
|
|||||||
@@ -648,7 +648,9 @@ public class CardUtil {
|
|||||||
FileHandle handle = Config.instance().getFile(path);
|
FileHandle handle = Config.instance().getFile(path);
|
||||||
if (handle.exists())
|
if (handle.exists())
|
||||||
return generateDeck(json.fromJson(GeneratedDeckData.class, handle), starterEdition, discourageDuplicates);
|
return generateDeck(json.fromJson(GeneratedDeckData.class, handle), starterEdition, discourageDuplicates);
|
||||||
return null;
|
Deck deck = DeckgenUtil.getRandomOrPreconOrThemeDeck(colors, true, false, true);
|
||||||
|
System.err.println("Error loading JSON: " + handle.path() + "\nGenerating random deck: "+deck.getName());
|
||||||
|
return deck;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import com.github.tommyettinger.textra.TypingLabel;
|
|||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.adventure.player.AdventurePlayer;
|
import forge.adventure.player.AdventurePlayer;
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
|
import forge.sound.SoundEffectType;
|
||||||
|
import forge.sound.SoundSystem;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@@ -52,6 +54,13 @@ public class Controls {
|
|||||||
static class TextButtonFix extends TextraButton {
|
static class TextButtonFix extends TextraButton {
|
||||||
public TextButtonFix(@Null String text) {
|
public TextButtonFix(@Null String text) {
|
||||||
super(text == null ? "NULL" : text, Controls.getSkin(), Controls.getTextraFont());
|
super(text == null ? "NULL" : text, Controls.getSkin(), Controls.getTextraFont());
|
||||||
|
addListener(new ClickListener(){
|
||||||
|
@Override
|
||||||
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
|
super.clicked(event, x, y);
|
||||||
|
SoundSystem.instance.play(SoundEffectType.ButtonPress, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,6 +83,7 @@ public class Controls {
|
|||||||
getTextraLabel().setWidth(getTextraLabel().layout.getWidth() + (getTextraLabel().style != null && getTextraLabel().style.background != null ? getTextraLabel().style.background.getLeftWidth() + getTextraLabel().style.background.getRightWidth() : 0.0F));
|
getTextraLabel().setWidth(getTextraLabel().layout.getWidth() + (getTextraLabel().style != null && getTextraLabel().style.background != null ? getTextraLabel().style.background.getLeftWidth() + getTextraLabel().style.background.getRightWidth() : 0.0F));
|
||||||
layout();
|
layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public TextraButton newTextButton(String text) {
|
static public TextraButton newTextButton(String text) {
|
||||||
|
|||||||
@@ -611,7 +611,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
super.act(delta);
|
super.act(delta);
|
||||||
if (clicked) {
|
if (clicked) {
|
||||||
if (flipProcess < 1)
|
if (flipProcess < 1)
|
||||||
flipProcess += delta * 1.5;
|
flipProcess += delta * 2.4;
|
||||||
else
|
else
|
||||||
flipProcess = 1;
|
flipProcess = 1;
|
||||||
|
|
||||||
|
|||||||
BIN
forge-gui/res/sound/button_press.mp3
Normal file
BIN
forge-gui/res/sound/button_press.mp3
Normal file
Binary file not shown.
BIN
forge-gui/res/sound/coins_drop.mp3
Normal file
BIN
forge-gui/res/sound/coins_drop.mp3
Normal file
Binary file not shown.
BIN
forge-gui/res/sound/take_shard.mp3
Normal file
BIN
forge-gui/res/sound/take_shard.mp3
Normal file
Binary file not shown.
@@ -48,6 +48,8 @@ public enum SoundEffectType {
|
|||||||
BlueBlackLand("blue_black_land.mp3", false),
|
BlueBlackLand("blue_black_land.mp3", false),
|
||||||
BlueBlackRedLand("blue_black_red_land.mp3", false),
|
BlueBlackRedLand("blue_black_red_land.mp3", false),
|
||||||
BlueLand("blue_land.mp3", false),
|
BlueLand("blue_land.mp3", false),
|
||||||
|
ButtonPress("button_press.mp3", false),
|
||||||
|
CoinsDrop("coins_drop.mp3", false),
|
||||||
Creature("creature.mp3", false),
|
Creature("creature.mp3", false),
|
||||||
Damage("damage.mp3", true),
|
Damage("damage.mp3", true),
|
||||||
Daytime("daytime.mp3", true),
|
Daytime("daytime.mp3", true),
|
||||||
@@ -58,8 +60,8 @@ public enum SoundEffectType {
|
|||||||
EndOfTurn("end_of_turn.mp3", false),
|
EndOfTurn("end_of_turn.mp3", false),
|
||||||
Equip("equip.mp3", false),
|
Equip("equip.mp3", false),
|
||||||
Exile("exile.mp3", false),
|
Exile("exile.mp3", false),
|
||||||
FlipCoin("flip_coin.mp3", false),
|
|
||||||
FlipCard("flip_card.mp3", false),
|
FlipCard("flip_card.mp3", false),
|
||||||
|
FlipCoin("flip_coin.mp3", false),
|
||||||
GreenBlackBlueLand("green_black_blue_land.mp3", false),
|
GreenBlackBlueLand("green_black_blue_land.mp3", false),
|
||||||
GreenBlackLand("green_black_land.mp3", false),
|
GreenBlackLand("green_black_land.mp3", false),
|
||||||
GreenBlueLand("green_blue_land.mp3", false),
|
GreenBlueLand("green_blue_land.mp3", false),
|
||||||
@@ -87,6 +89,7 @@ public enum SoundEffectType {
|
|||||||
ScriptedEffect("", false), // Plays the effect defined by SVar:SoundEffect
|
ScriptedEffect("", false), // Plays the effect defined by SVar:SoundEffect
|
||||||
Shuffle("shuffle.mp3", false),
|
Shuffle("shuffle.mp3", false),
|
||||||
Sorcery("sorcery.mp3", false),
|
Sorcery("sorcery.mp3", false),
|
||||||
|
TakeShard("take_shard.mp3", false),
|
||||||
StartDuel("start_duel.mp3",false),
|
StartDuel("start_duel.mp3",false),
|
||||||
Tap("tap.mp3", false),
|
Tap("tap.mp3", false),
|
||||||
Token("token.mp3", true),
|
Token("token.mp3", true),
|
||||||
|
|||||||
Reference in New Issue
Block a user