From: Frederick W. <fre...@us...> - 2012-01-29 06:13:07
|
LocalisedText.properties | 2 ++ data/Properties.xml | 2 ++ rails/sound/SoundConfig.java | 2 ++ rails/sound/SoundEventInterpreter.java | 18 +++++++++++++++++- rails/sound/SoundManager.java | 3 +++ rails/sound/SoundPlayer.java | 28 +++++++++++++++++++++------- rails/ui/swing/ORUIManager.java | 5 +++++ 7 files changed, 52 insertions(+), 8 deletions(-) New commits: commit b001a3100117b2591ec1eeb2ad52d863e9c37640 Author: Frederick Weld <fre...@gm...> Date: Sun Jan 29 07:10:57 2012 +0100 Added new sfx options (pass, rotate tile) Sound framework is notified of Rotate tile by ORUIManager (neither action nor model change). Design decision here is to put all such non-standard notification calls to the UI Managers (Game, OR) instead of the UI elements (GUIHex...) so that they do not spread over the complete UI layer. diff --git a/LocalisedText.properties b/LocalisedText.properties index df07a3b..8ef0a7f 100644 --- a/LocalisedText.properties +++ b/LocalisedText.properties @@ -213,6 +213,7 @@ Config.label.sound.backgroundMusic.startRound=Start Round Config.label.sound.backgroundMusic.stockRound=Stock Round (several files) Config.label.sound.backgroundMusic.operatingRound=Operating Round (several files) Config.label.sound.sfx=Sound Effects +Config.label.sound.sfx.gen.pass=Pass Config.label.sound.sfx.str.bidStartItem=Bid on Start Item Config.label.sound.sfx.str.buyStartItem=Buy Start Item Config.label.sound.sfx.or.buyPrivate=Buy Private (as a company) @@ -222,6 +223,7 @@ Config.label.sound.sfx.or.decision.split=Split Revenue Config.label.sound.sfx.or.decision.withhold=Withhold Revenue Config.label.sound.sfx.or.layTile=Lay Tile Config.label.sound.sfx.or.layToken=Lay Token +Config.label.sound.sfx.or.rotateTile=Rotate Tile Config.label.sound.sfx.or.setRevenue=Set Revenue Config.label.sound.sfx.sr.buyShare.president=Buy Share (of presided company) Config.label.sound.sfx.sr.buyShare.nonPresident=Buy Share (of other company) diff --git a/data/Properties.xml b/data/Properties.xml index ac703c0..d2a9153 100644 --- a/data/Properties.xml +++ b/data/Properties.xml @@ -73,6 +73,7 @@ </Section> <Section name="SFX"> <Property name="sound.sfx" type="LIST" values="disabled,enabled" /> + <Property name="sound.sfx.gen.pass" type="FILE" /> <Property name="sound.sfx.str.bidStartItem" type="FILE" /> <Property name="sound.sfx.str.buyStartItem" type="FILE" /> <Property name="sound.sfx.sr.openingBell" type="FILE" /> @@ -82,6 +83,7 @@ <Property name="sound.sfx.sr.sellShare.president" type="FILE" /> <Property name="sound.sfx.sr.sellShare.nonPresident" type="FILE" /> <Property name="sound.sfx.sr.companyFloats" type="FILE" /> + <Property name="sound.sfx.or.rotateTile" type="FILE" /> <Property name="sound.sfx.or.layTile" type="FILE" /> <Property name="sound.sfx.or.layToken" type="FILE" /> <Property name="sound.sfx.or.setRevenue" type="FILE" /> diff --git a/rails/sound/SoundConfig.java b/rails/sound/SoundConfig.java index c9ea6c5..14adb30 100644 --- a/rails/sound/SoundConfig.java +++ b/rails/sound/SoundConfig.java @@ -20,6 +20,7 @@ public class SoundConfig { public static final String KEY_BGM_OperatingRound = "sound.backgroundMusic.operatingRound"; public static final String KEY_BGM_EndOfGameRound = "sound.backgroundMusic.endOfGameRound"; public static final String KEY_SFX_Enabled = "sound.sfx"; + public static final String KEY_SFX_GEN_Pass = "sound.sfx.gen.pass"; public static final String KEY_SFX_STR_BidStartItem = "sound.sfx.str.bidStartItem"; public static final String KEY_SFX_STR_BuyStartItem = "sound.sfx.str.buyStartItem"; public static final String KEY_SFX_SR_OpeningBell = "sound.sfx.sr.openingBell"; @@ -29,6 +30,7 @@ public class SoundConfig { public static final String KEY_SFX_SR_SellShare_President = "sound.sfx.sr.sellShare.president"; public static final String KEY_SFX_SR_SellShare_NonPresident = "sound.sfx.sr.sellShare.nonPresident"; public static final String KEY_SFX_SR_CompanyFloats = "sound.sfx.sr.companyFloats"; + public static final String KEY_SFX_OR_RotateTile = "sound.sfx.or.rotateTile"; public static final String KEY_SFX_OR_LayTile = "sound.sfx.or.layTile"; public static final String KEY_SFX_OR_LayToken = "sound.sfx.or.layToken"; public static final String KEY_SFX_OR_SetRevenue = "sound.sfx.or.setRevenue"; diff --git a/rails/sound/SoundEventInterpreter.java b/rails/sound/SoundEventInterpreter.java index f494655..1f5590c 100644 --- a/rails/sound/SoundEventInterpreter.java +++ b/rails/sound/SoundEventInterpreter.java @@ -69,9 +69,18 @@ public class SoundEventInterpreter { if (SoundConfig.isSFXEnabled()) { + //General actions + + if (action instanceof NullAction) { + if (((NullAction)action).getMode() == NullAction.PASS) { + player.playSFXByConfigKey (SoundConfig.KEY_SFX_GEN_Pass); + } + + } + //OR actions - if (action instanceof LayTile) { + else if (action instanceof LayTile) { player.playSFXByConfigKey (SoundConfig.KEY_SFX_OR_LayTile); } else if (action instanceof LayToken) { @@ -177,4 +186,11 @@ public class SoundEventInterpreter { public void notifyOfTimeWarp(boolean timeWarpMode) { SoundConfig.setSFXDisabled(timeWarpMode); } + public void notifyOfRotateTile() { + if (SoundConfig.isSFXEnabled()) { + //don't wait for prior SFX playing end, otherwise quickly repeated + //rotations would lead to a long queue of sequentially played sfx + player.playSFXByConfigKey(SoundConfig.KEY_SFX_OR_RotateTile,false); + } + } } diff --git a/rails/sound/SoundManager.java b/rails/sound/SoundManager.java index 0e04c4f..d3a9e33 100644 --- a/rails/sound/SoundManager.java +++ b/rails/sound/SoundManager.java @@ -58,4 +58,7 @@ public class SoundManager { public static void notifyOfTimeWarp(boolean timeWarpMode) { getInstance().eventInterpreter.notifyOfTimeWarp(timeWarpMode); } + public static void notifyOfRotateTile() { + getInstance().eventInterpreter.notifyOfRotateTile(); + } } diff --git a/rails/sound/SoundPlayer.java b/rails/sound/SoundPlayer.java index 2e53c03..45fbf8f 100644 --- a/rails/sound/SoundPlayer.java +++ b/rails/sound/SoundPlayer.java @@ -187,24 +187,38 @@ public class SoundPlayer { return pt; } - private void playSFX(PlayerThread newPlayerThread) { + private void playSFX(PlayerThread newPlayerThread,boolean waitForEndOfPriorSFX) { PlayerThread oldPlayerThread = adjustLastSFXThread(newPlayerThread); - newPlayerThread.setPriorThread(oldPlayerThread); + if (waitForEndOfPriorSFX) { + newPlayerThread.setPriorThread(oldPlayerThread); + } newPlayerThread.start(); } + /** + * SFX played after prior SFX playing has been completed + */ public void playSFX(String fileName) { - playSFX(new PlayerThread (fileName)); + playSFX(fileName,true); } + public void playSFX(String fileName, boolean waitForEndOfPriorSFX) { + playSFX(new PlayerThread (fileName),waitForEndOfPriorSFX); + } + /** + * SFX played after prior SFX playing has been completed + */ public void playSFXByConfigKey(String configKey) { - playSFX(SoundConfig.get(configKey)); + playSFXByConfigKey(configKey, true); + } + public void playSFXByConfigKey(String configKey, boolean waitForEndOfPriorSFX) { + playSFX(SoundConfig.get(configKey), waitForEndOfPriorSFX); } public void playSFXByConfigKey(String configKey,String parameter) { playSFX(SoundConfig.get(configKey,parameter)); } public void playSFX(String fileName, double playSoundProportion) { - playSFX(new PortionPlayerThread (fileName, 1 - playSoundProportion, 1)); + playSFX(new PortionPlayerThread (fileName, 1 - playSoundProportion, 1),true); } /** @@ -216,7 +230,7 @@ public class SoundPlayer { } public void playSFXWithFollowupBGM(String sfxFileName,String bgmFileName) { - playSFX(new PlayerThreadWithFollowupBGM (sfxFileName,bgmFileName)); + playSFX(new PlayerThreadWithFollowupBGM (sfxFileName,bgmFileName),true); } /** @@ -227,7 +241,7 @@ public class SoundPlayer { playSFXWithFollowupBGM( SoundConfig.get(sfxConfigKey),SoundConfig.get(bgmConfigKey)); } - + public void playBGM(String backgroundMusicFileName) { LoopPlayerThread newPlayerThread = new LoopPlayerThread(backgroundMusicFileName); LoopPlayerThread oldPlayerThread = adjustLastBGMThread(newPlayerThread); diff --git a/rails/ui/swing/ORUIManager.java b/rails/ui/swing/ORUIManager.java index f10d2a4..89ef997 100644 --- a/rails/ui/swing/ORUIManager.java +++ b/rails/ui/swing/ORUIManager.java @@ -663,6 +663,11 @@ public class ORUIManager implements DialogOwner { if (localStep == ROTATE_OR_CONFIRM_TILE && clickedHex == selectedHex) { selectedHex.rotateTile(); + //directly inform sound framework of "rotate tile" as this is + //neither an action nor a model change + //call not put to GUIHex so that sound notification calls are + //centrally done by UIManagers (Game, OR) + SoundManager.notifyOfRotateTile(); return true; } else { |