mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
Merge branch 'custom-sound-fx' into 'master'
Auto-detect custom sound files for cards if they exist See merge request core-developers/forge!5468
This commit is contained in:
@@ -315,14 +315,18 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
|
||||
// Implement sound effects for specific cards here, if necessary.
|
||||
String effect = "";
|
||||
if (null != c) {
|
||||
effect = c.getSVar("SoundEffect");
|
||||
}
|
||||
if (!effect.isEmpty()) {
|
||||
// Only proceed if the file actually exists
|
||||
return new File(ForgeConstants.SOUND_DIR, effect).exists();
|
||||
if (c.hasSVar("SoundEffect")) {
|
||||
effect = c.getSVar("SoundEffect");
|
||||
} else {
|
||||
effect = TextUtil.fastReplace(TextUtil.fastReplace(
|
||||
TextUtil.fastReplace(c.getName(), ",", ""),
|
||||
" ", "_"), "'", "").toLowerCase() + ".mp3";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
// Only proceed if the file actually exists
|
||||
return new File(ForgeConstants.SOUND_DIR, effect).exists();
|
||||
}
|
||||
|
||||
|
||||
@@ -339,11 +343,24 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
|
||||
|
||||
if (evt instanceof GameEventSpellResolved) {
|
||||
c = ((GameEventSpellResolved) evt).spell.getHostCard();
|
||||
} else if (evt instanceof GameEventLandPlayed) {
|
||||
c = ((GameEventLandPlayed) evt).land;
|
||||
} else if (evt instanceof GameEventZone) {
|
||||
GameEventZone evZone = (GameEventZone)evt;
|
||||
if (evZone.zoneType == ZoneType.Battlefield && evZone.mode == EventValueChangeType.Added && evZone.card.isLand()) {
|
||||
c = evZone.card; // assuming a land is played or otherwise put on the battlefield
|
||||
}
|
||||
}
|
||||
|
||||
return c != null ? c.getSVar("SoundEffect") : "";
|
||||
if (c == null) {
|
||||
return "";
|
||||
} else {
|
||||
if (c.hasSVar("SoundEffect")) {
|
||||
return c.getSVar("SoundEffect");
|
||||
} else {
|
||||
return TextUtil.fastReplace(TextUtil.fastReplace(
|
||||
TextUtil.fastReplace(c.getName(), ",", ""),
|
||||
" ", "_"), "'", "").toLowerCase() + ".mp3";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user