diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-22 18:23:02 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-22 18:23:02 +0100 |
commit | 18db2f47e4808eda33f24e1a8571f62344524f71 (patch) | |
tree | 8a25ed7261dedb9ded9b7f77dc91e5365f50efba /core | |
parent | 6ec6e479d1fb91c51c65fecee9045c07fa92300d (diff) | |
download | RustAndDust-18db2f47e4808eda33f24e1a8571f62344524f71.zip RustAndDust-18db2f47e4808eda33f24e1a8571f62344524f71.tar.gz |
Sound type/enter: nicer, better
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/rustanddust/RustAndDust.java | 8 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/Hud.java | 20 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/hud/OptionsPanel.java | 10 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/menu/MainMenu.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/menu/MenuCtrl.java | 9 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/menu/NewGameMenu.java | 12 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/menu/OptionsMenu.java | 10 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/menu/PlayMenu.java | 12 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/ui/OkCancel.java | 8 |
10 files changed, 54 insertions, 39 deletions
diff --git a/core/src/ch/asynk/rustanddust/RustAndDust.java b/core/src/ch/asynk/rustanddust/RustAndDust.java index 759f72c..ef16bc5 100644 --- a/core/src/ch/asynk/rustanddust/RustAndDust.java +++ b/core/src/ch/asynk/rustanddust/RustAndDust.java @@ -76,8 +76,12 @@ public class RustAndDust extends Game public BitmapFont font; public NinePatch bgPatch; public NinePatch framePatch; - public Sound typeSnd; - public Sound enterSnd; + private Sound typeSnd; + private Sound enterSnd; + + public void playType() { typeSnd.play(config.fxVolume); } + public void playType(float v) { typeSnd.play(v); } + public void playEnter() { enterSnd.play(config.fxVolume); } public enum State { diff --git a/core/src/ch/asynk/rustanddust/game/Hud.java b/core/src/ch/asynk/rustanddust/game/Hud.java index e59cae2..56b76dd 100644 --- a/core/src/ch/asynk/rustanddust/game/Hud.java +++ b/core/src/ch/asynk/rustanddust/game/Hud.java @@ -67,7 +67,7 @@ public class Hud implements Disposable, Animation actionButtons = new ActionButtons(game); actionButtons.hide(); msg = new Msg(game.font, game.bgPatch, 20f); - okCancel = new OkCancel(game.font, game.bgPatch, game.factory.getHudRegion(game.factory.ACT_DONE), game.factory.getHudRegion(game.factory.ACT_ABORT), game.typeSnd); + okCancel = new OkCancel(game.font, game.bgPatch, game.factory.getHudRegion(game.factory.ACT_DONE), game.factory.getHudRegion(game.factory.ACT_ABORT)); optionsBtn = new Bg(game.factory.getHudRegion(game.factory.ACT_OPTIONS)); optionsPanel = new OptionsPanel(game); stats = new StatisticsPanel(game); @@ -185,7 +185,7 @@ public class Hud implements Disposable, Animation public boolean hit(float x, float y, boolean isInAnimation) { if (optionsBtn.hit(x, y)) { - game.typeSnd.play(); + game.playType(); toggleOptionsPanel(); return true; } @@ -202,10 +202,13 @@ public class Hud implements Disposable, Animation if (isInAnimation) return false; - if (actionButtons.hit(x, y)) + if (actionButtons.hit(x, y)) { + game.playType(); return true; - else if (playerInfo.hit(x, y)) + } else if (playerInfo.hit(x, y)) { + game.playType(); return true; + } return false; } @@ -217,7 +220,10 @@ public class Hud implements Disposable, Animation if (dialog == okCancel) closeOkCancel(); - else if (dialog == stats) + else + game.playType(); + + if (dialog == stats) ctrl.endGame(); if (dialogs.size() > 0) @@ -229,6 +235,10 @@ public class Hud implements Disposable, Animation private void closeOkCancel() { boolean ok = okCancel.ok; + if (ok) + game.playEnter(); + else + game.playType(); switch(okCancelAction) { case EXIT_BOARD: diff --git a/core/src/ch/asynk/rustanddust/game/hud/OptionsPanel.java b/core/src/ch/asynk/rustanddust/game/hud/OptionsPanel.java index ea175c9..ba0f395 100644 --- a/core/src/ch/asynk/rustanddust/game/hud/OptionsPanel.java +++ b/core/src/ch/asynk/rustanddust/game/hud/OptionsPanel.java @@ -139,7 +139,7 @@ public class OptionsPanel extends Patch public boolean hit(float x, float y) { if (objectivesPanel.hit(x, y)) { - game.typeSnd.play(); + game.playType(); objectivesPanel.visible = false; this.visible = true; return false; @@ -148,21 +148,21 @@ public class OptionsPanel extends Patch if (!visible) return false; if (fxVolume.hit(x, y) || fxVolumeValue.hit(x, y)) { - game.typeSnd.play(); cycleFxVolume(); + game.playType((fxVolumeIdx / 10.0f)); } else if (quit.hit(x, y)) { - game.typeSnd.play(); + game.playType(); game.ctrl.hud.askQuitBattle(); return false; } else if (objectives.hit(x, y)) { - game.typeSnd.play(); + game.playType(); this.visible = false; objectivesPanel.show(game.config.battle); return false; } else { for (int i = 0; i < checkLabels.length; i++) { if (checkLabels[i].hit(x, y)) { - game.typeSnd.play(); + game.playType(); checkValues[i] =! checkValues[i]; } } diff --git a/core/src/ch/asynk/rustanddust/menu/MainMenu.java b/core/src/ch/asynk/rustanddust/menu/MainMenu.java index c51f73e..6d7016a 100644 --- a/core/src/ch/asynk/rustanddust/menu/MainMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/MainMenu.java @@ -102,7 +102,7 @@ public class MainMenu extends Patch implements MenuCtrl.Panel int idx = -1; for (int i = 0; i< Item.NONE.i; i ++) { if (labels[i].hit(x, y)) { - game.typeSnd.play(); + game.playType(); return Item.get(i).t; } } diff --git a/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java b/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java index 49a959c..b793d9a 100644 --- a/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java +++ b/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java @@ -37,6 +37,8 @@ public class MenuCtrl implements Disposable, Drawable public boolean drag(float x, float y, int dx, int dy); } + private final RustAndDust game; + public boolean visible; private Panel []panels; private MenuType current; @@ -44,13 +46,14 @@ public class MenuCtrl implements Disposable, Drawable public MenuCtrl(final RustAndDust game) { + this.game = game; this.panels = new Panel[MenuType.NONE.i]; this.panels[MenuType.MAIN.i] = new MainMenu(game); this.panels[MenuType.OPTIONS.i] = new OptionsMenu(game); this.panels[MenuType.TUTORIALS.i] = new TutorialsMenu(game); this.panels[MenuType.PLAY.i] = new PlayMenu(game); this.panels[MenuType.NEW_GAME.i] = new NewGameMenu(game); - this.okCancel = new OkCancel(game.font, game.bgPatch, game.getUiRegion(game.UI_OK), game.getUiRegion(game.UI_CANCEL), game.typeSnd); + this.okCancel = new OkCancel(game.font, game.bgPatch, game.getUiRegion(game.UI_OK), game.getUiRegion(game.UI_CANCEL)); this.current = MenuType.MAIN; @@ -68,6 +71,10 @@ public class MenuCtrl implements Disposable, Drawable public boolean touch(float x, float y) { if (okCancel.hit(x, y)) { + if (okCancel.ok) + game.playEnter(); + else + game.playType(); visible = true; okCancel.visible = false; panels[current.i].postAnswer(okCancel.ok); diff --git a/core/src/ch/asynk/rustanddust/menu/NewGameMenu.java b/core/src/ch/asynk/rustanddust/menu/NewGameMenu.java index f91ed93..4a4f3c7 100644 --- a/core/src/ch/asynk/rustanddust/menu/NewGameMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/NewGameMenu.java @@ -121,7 +121,7 @@ public class NewGameMenu extends Patch implements MenuCtrl.Panel public MenuCtrl.MenuType touch(float x, float y) { if (objectivesPanel.hit(x, y)) { - game.typeSnd.play(); + game.playType(); this.visible = true; objectivesPanel.visible = false; return MenuCtrl.MenuType.NONE; @@ -130,19 +130,19 @@ public class NewGameMenu extends Patch implements MenuCtrl.Panel if (!visible) return MenuCtrl.MenuType.NONE; if (okBtn.hit(x, y)) { - game.enterSnd.play(); + game.playEnter(); return apply(); } else if (cancelBtn.hit(x, y)) { - game.typeSnd.play(); + game.playType(); return MenuCtrl.MenuType.MAIN; } else if (gameMode.hit(x, y) || gameModeValue.hit(x, y)) { - game.typeSnd.play(); + game.playType(); cycleGameMode(); } else if (battle.hit(x, y) || battleValue.hit(x, y)) { - game.typeSnd.play(); + game.playType(); cycleBattle(); } else if (objectives.hit(x, y)) { - game.typeSnd.play(); + game.playType(); this.visible = false; objectivesPanel.show(game.config.battle); } diff --git a/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java b/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java index 8ec9b10..c1b5603 100644 --- a/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java @@ -164,23 +164,23 @@ public class OptionsMenu extends Patch implements MenuCtrl.Panel public MenuCtrl.MenuType touch(float x, float y) { if (okBtn.hit(x, y)) { - game.enterSnd.play(); + game.playEnter(); apply(); return MenuCtrl.MenuType.MAIN; } else if (cancelBtn.hit(x, y)) { - game.typeSnd.play(); + game.playType(); getValues(); return MenuCtrl.MenuType.MAIN; } else if (fxVolume.hit(x, y) || fxVolumeValue.hit(x, y)) { - game.typeSnd.play(); cycleFxVolume(); + game.playType((fxVolumeIdx / 10.0f)); } else if (graphics.hit(x, y) || graphicsValue.hit(x, y)) { - game.typeSnd.play(); + game.playType(); cycleGraphics(); } else { for (int i = 0; i < checkLabels.length; i++) { if (checkLabels[i].hit(x, y)) { - game.typeSnd.play(); + game.playType(); checkValues[i] =! checkValues[i]; } } diff --git a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java index fb1c9ef..c442cd6 100644 --- a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java @@ -119,24 +119,24 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel Integer i = getList().getIdx(); if (newBtn.hit(x, y)) { - game.enterSnd.play(); + game.playEnter(); return MenuCtrl.MenuType.NEW_GAME; } else if (cancelBtn.hit(x, y)) { - game.typeSnd.play(); + game.playType(); return MenuCtrl.MenuType.MAIN; } else if (newBtn.hit(x, y)) { - game.enterSnd.play(); + game.playEnter(); return MenuCtrl.MenuType.NEW_GAME; } else if (deleteBtn.hit(x, y)) { - game.typeSnd.play(); + game.playType(); return MenuCtrl.MenuType.OKKO; } else if (joinBtn.hit(x, y)) { - game.typeSnd.play(); + game.playType(); game.config.gameId = GameRecord.get(getList().getIdx()).g; return MenuCtrl.MenuType.BEGIN; } else if (list.hit(x, y)) { if (i != getList().getIdx()) - game.typeSnd.play(); + game.playType(); if(getList().getIdx() == null) { deleteBtn.visible = false; joinBtn.visible = false; diff --git a/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java b/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java index e397660..02b65c3 100644 --- a/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java @@ -69,7 +69,7 @@ public class TutorialsMenu extends Patch implements MenuCtrl.Panel public MenuCtrl.MenuType touch(float x, float y) { if (rect.contains(x, y) || okBtn.hit(x, y)) { - game.enterSnd.play(); + game.playEnter(); return MenuCtrl.MenuType.MAIN; } diff --git a/core/src/ch/asynk/rustanddust/ui/OkCancel.java b/core/src/ch/asynk/rustanddust/ui/OkCancel.java index 8bbceef..5036995 100644 --- a/core/src/ch/asynk/rustanddust/ui/OkCancel.java +++ b/core/src/ch/asynk/rustanddust/ui/OkCancel.java @@ -1,6 +1,5 @@ package ch.asynk.rustanddust.ui; -import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.BitmapFont; @@ -17,15 +16,13 @@ public class OkCancel extends Patch protected Label label; protected Bg okBtn; protected Bg cancelBtn; - protected Sound snd; - public OkCancel(BitmapFont font, NinePatch patch, AtlasRegion okRegion, AtlasRegion cancelRegion, Sound snd) + public OkCancel(BitmapFont font, NinePatch patch, AtlasRegion okRegion, AtlasRegion cancelRegion) { super(patch); this.label = new Label(font); this.okBtn = new Bg(okRegion); this.cancelBtn = new Bg(cancelRegion); - this.snd = snd; this.visible = false; } @@ -75,16 +72,13 @@ public class OkCancel extends Patch public boolean hit(float x, float y) { if (!cancelBtn.visible && super.hit(x, y)) { - snd.play(); ok = true; return true; } if (okBtn.hit(x, y)) { - snd.play(); ok = true; return true; } else if (cancelBtn.hit(x, y)) { - snd.play(); ok = false; return true; } |