- Sound system: added an option to toggle the sound effects on/off in the game (currently not linked to any code).

This commit is contained in:
Agetian
2012-11-12 04:56:43 +00:00
parent a7e0449b0e
commit 4f8cec38b1
4 changed files with 26 additions and 2 deletions

View File

@@ -141,6 +141,14 @@ public enum CSubmenuPreferences implements ICDoc {
}
});
view.getCbEnableSounds().addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent arg0) {
prefs.setPref(FPref.UI_ENABLE_SOUNDS, view.getCbEnableSounds().isSelected());
prefs.save();
}
});
view.getBtnReset().setCommand(new Command() {
@Override
public void execute() {
@@ -170,6 +178,7 @@ public enum CSubmenuPreferences implements ICDoc {
view.getCbRandomFoil().setSelected(prefs.getPrefBoolean(FPref.UI_RANDOM_FOIL));
view.getCbScaleLarger().setSelected(prefs.getPrefBoolean(FPref.UI_SCALE_LARGER));
view.getCbTextMana().setSelected(prefs.getPrefBoolean(FPref.UI_CARD_OVERLAY));
view.getCbEnableSounds().setSelected(prefs.getPrefBoolean(FPref.UI_ENABLE_SOUNDS));
}
private void updateSkinNames() {

View File

@@ -83,6 +83,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final JCheckBox cbTextMana = new OptionsCheckBox("Text / Mana Overlay");
private final JCheckBox cbScaleLarger = new OptionsCheckBox("Scale Image Larger");
private final JCheckBox cbRandomFoil = new OptionsCheckBox("Random Foil");
private final JCheckBox cbEnableSounds = new OptionsCheckBox("Enable Sounds");
/**
* Constructor.
@@ -141,6 +142,12 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbTextMana, regularConstraints);
pnlPrefs.add(new NoteLabel("Overlays each card with basic card-specific information."), regularConstraints);
// Sound options
pnlPrefs.add(new SectionLabel("Sound Options"), sectionConstraints);
pnlPrefs.add(cbEnableSounds, regularConstraints);
pnlPrefs.add(new NoteLabel("Enable sound effects during the game."), regularConstraints);
// Keyboard shortcuts
final JLabel lblShortcuts = new SectionLabel("Keyboard Shortcuts");
pnlPrefs.add(lblShortcuts, sectionConstraints);
@@ -396,6 +403,11 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbDevMode;
}
/** @return {@link javax.swing.JCheckBox} */
public JCheckBox getCbEnableSounds() {
return cbEnableSounds;
}
/** @return {@link forge.gui.toolbox.FLabel} */
public FLabel getBtnReset() {
return btnReset;

View File

@@ -71,6 +71,7 @@ public class ForgePreferences {
UI_SKIN ("default"), /** */
UI_PREFERRED_AVATARS_ONLY ("false"), /** */
UI_TARGETING_OVERLAY ("false"), /** */
UI_ENABLE_SOUNDS ("false"), /** */
SUBMENU_CURRENTMENU (EMenuItem.CONSTRUCTED.toString()), /** */
SUBMENU_SANCTIONED ("false"), /** */

View File

@@ -31,7 +31,9 @@ package forge.sound;
* @author Agetian
*/
public enum Sounds {
Tap("res/sound/tap.wav");
LoseDuel("res/sound/lose_duel.wav"),
Tap("res/sound/tap.wav"),
WinDuel("res/sound/win_duel.wav");
SoundSystem snd = null;