diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form index b05eb2f917c..d5c8dc49bb8 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form +++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form @@ -24,7 +24,7 @@ - + @@ -82,10 +82,10 @@ - + - + @@ -179,6 +179,7 @@ + @@ -190,7 +191,7 @@ - + @@ -198,7 +199,7 @@ - + @@ -758,10 +759,10 @@ - + - + @@ -795,7 +796,7 @@ - + @@ -835,7 +836,7 @@ - + diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java index 19e55015950..b0320f4d09d 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java @@ -80,7 +80,7 @@ public class PreferencesDialog extends javax.swing.JDialog { public static final String KEY_HAND_USE_BIG_CARDS = "handUseBigCards"; public static final String KEY_PERMANENTS_IN_ONE_PILE = "nonLandPermanentsInOnePile"; public static final String KEY_SHOW_PLAYER_NAMES_PERMANENTLY = "showPlayerNamesPermanently"; - public static final String KEY_SHOW_ABILITY_PICKER = "showAbilityPicker"; + public static final String KEY_SHOW_ABILITY_PICKER_FORCED = "showAbilityPicker"; public static final String KEY_GAME_LOG_AUTO_SAVE = "gameLogAutoSave"; public static final String KEY_CARD_IMAGES_USE_DEFAULT = "cardImagesUseDefault"; @@ -272,7 +272,7 @@ public class PreferencesDialog extends javax.swing.JDialog { main_game = new javax.swing.JPanel(); nonLandPermanentsInOnePile = new javax.swing.JCheckBox(); showPlayerNamesPermanently = new javax.swing.JCheckBox(); - showAbilityPickerForSimpleAbilities = new javax.swing.JCheckBox(); + showAbilityPickerForced = new javax.swing.JCheckBox(); main_gamelog = new javax.swing.JPanel(); cbGameLogAutoSave = new javax.swing.JCheckBox(); tabPhases = new javax.swing.JPanel(); @@ -402,6 +402,7 @@ public class PreferencesDialog extends javax.swing.JDialog { showPlayerNamesPermanently.setSelected(true); showPlayerNamesPermanently.setText("Show player names on avatar permanently"); + showPlayerNamesPermanently.setToolTipText("Instead showing the names only if you hoover over the avatar with the mouse, the name is shown all the time."); showPlayerNamesPermanently.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); showPlayerNamesPermanently.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -410,16 +411,16 @@ public class PreferencesDialog extends javax.swing.JDialog { }); main_game.add(showPlayerNamesPermanently, java.awt.BorderLayout.LINE_START); - showAbilityPickerForSimpleAbilities.setSelected(true); - showAbilityPickerForSimpleAbilities.setText("Show ability picker for abilities without costs"); - showAbilityPickerForSimpleAbilities.setToolTipText("This prevents that you accidently activate abilities without costs that e.g. tap the permanent."); - showAbilityPickerForSimpleAbilities.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); - showAbilityPickerForSimpleAbilities.addActionListener(new java.awt.event.ActionListener() { + showAbilityPickerForced.setSelected(true); + showAbilityPickerForced.setText("Show ability picker for abilities without costs"); + showAbilityPickerForced.setToolTipText("This prevents that you accidently activate abilities without costs that e.g. tap the permanent."); + showAbilityPickerForced.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + showAbilityPickerForced.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - showAbilityPickerForSimpleAbilitiesActionPerformed(evt); + showAbilityPickerForcedActionPerformed(evt); } }); - main_game.add(showAbilityPickerForSimpleAbilities, java.awt.BorderLayout.PAGE_END); + main_game.add(showAbilityPickerForced, java.awt.BorderLayout.PAGE_END); main_gamelog.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Game log")); main_gamelog.setLayout(new java.awt.BorderLayout()); @@ -451,10 +452,10 @@ public class PreferencesDialog extends javax.swing.JDialog { .addContainerGap() .addComponent(main_card, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(main_game, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(main_game, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(main_gamelog, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(153, Short.MAX_VALUE)) + .addContainerGap(171, Short.MAX_VALUE)) ); main_card.getAccessibleContext().setAccessibleName("Game panel"); @@ -791,7 +792,7 @@ public class PreferencesDialog extends javax.swing.JDialog { cbEnableGameSoundsActionPerformed(evt); } }); - sounds_clips.add(cbEnableGameSounds, java.awt.BorderLayout.CENTER); + sounds_clips.add(cbEnableGameSounds, java.awt.BorderLayout.PAGE_START); cbEnableOtherSounds.setText("Enable other sounds"); cbEnableOtherSounds.setToolTipText("Sounds that will be played for actions outside of games (e.g. whisper, player joins your game, player submits a deck ...)."); @@ -837,7 +838,7 @@ public class PreferencesDialog extends javax.swing.JDialog { .addContainerGap() .addComponent(jLabel16) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(txtBattlefieldIBGMPath, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE) + .addComponent(txtBattlefieldIBGMPath, javax.swing.GroupLayout.DEFAULT_SIZE, 332, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnBattlefieldBGMBrowse)) .addGroup(sounds_backgroundMusicLayout.createSequentialGroup() @@ -870,10 +871,10 @@ public class PreferencesDialog extends javax.swing.JDialog { tabSoundsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(tabSoundsLayout.createSequentialGroup() .addContainerGap() - .addComponent(sounds_clips, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(sounds_clips, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(sounds_backgroundMusic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(229, Short.MAX_VALUE)) + .addContainerGap(247, Short.MAX_VALUE)) ); sounds_clips.getAccessibleContext().setAccessibleDescription(""); @@ -1285,7 +1286,7 @@ public class PreferencesDialog extends javax.swing.JDialog { getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(tabsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 562, Short.MAX_VALUE) + .addComponent(tabsPanel) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(saveButton) @@ -1315,7 +1316,7 @@ public class PreferencesDialog extends javax.swing.JDialog { save(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true", "false", UPDATE_CACHE_POLICY); save(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true", "false", UPDATE_CACHE_POLICY); save(prefs, dialog.showPlayerNamesPermanently, KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true", "false", UPDATE_CACHE_POLICY); - save(prefs, dialog.showAbilityPickerForSimpleAbilities, KEY_SHOW_ABILITY_PICKER, "true", "false", UPDATE_CACHE_POLICY); + save(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true", "false", UPDATE_CACHE_POLICY); save(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY); // Phases @@ -1369,6 +1370,10 @@ public class PreferencesDialog extends javax.swing.JDialog { } try { + MageFrame.getSession().updatePreferencesForServer( + getSelectedAvatar(), + dialog.showAbilityPickerForced.isSelected()); + prefs.flush(); } catch (BackingStoreException ex) { ex.printStackTrace(); @@ -1574,9 +1579,9 @@ public class PreferencesDialog extends javax.swing.JDialog { }//GEN-LAST:event_showToolTipsInAnyZoneActionPerformed - private void showAbilityPickerForSimpleAbilitiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showAbilityPickerForSimpleAbilitiesActionPerformed + private void showAbilityPickerForcedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showAbilityPickerForcedActionPerformed // TODO add your handling code here: - }//GEN-LAST:event_showAbilityPickerForSimpleAbilitiesActionPerformed + }//GEN-LAST:event_showAbilityPickerForcedActionPerformed private void cbEnableOtherSoundsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbEnableOtherSoundsActionPerformed // TODO add your handling code here: @@ -1666,7 +1671,7 @@ public class PreferencesDialog extends javax.swing.JDialog { load(prefs, dialog.showToolTipsInAnyZone, KEY_SHOW_TOOLTIPS_ANY_ZONE, "true"); load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true"); load(prefs, dialog.showPlayerNamesPermanently, KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true"); - load(prefs, dialog.showAbilityPickerForSimpleAbilities, KEY_SHOW_ABILITY_PICKER, "true"); + load(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true"); load(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true"); } @@ -1956,7 +1961,7 @@ public class PreferencesDialog extends javax.swing.JDialog { public void mousePressed(MouseEvent e) { if (selectedAvatarId != id) { setSelectedId(id); - MageFrame.getSession().updateAvatar(id); + MageFrame.getSession().updatePreferencesForServer(id, PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true")); } } }); @@ -2040,7 +2045,7 @@ public class PreferencesDialog extends javax.swing.JDialog { private javax.swing.JPanel pnlProxySettings; private javax.swing.JCheckBox rememberPswd; private javax.swing.JButton saveButton; - private javax.swing.JCheckBox showAbilityPickerForSimpleAbilities; + private javax.swing.JCheckBox showAbilityPickerForced; private javax.swing.JCheckBox showPlayerNamesPermanently; private javax.swing.JCheckBox showToolTipsInAnyZone; private javax.swing.JPanel sounds_backgroundMusic; diff --git a/Mage.Client/src/main/java/mage/client/util/audio/AudioGroup.java b/Mage.Client/src/main/java/mage/client/util/audio/AudioGroup.java index ae90e67515d..1c01118cb03 100644 --- a/Mage.Client/src/main/java/mage/client/util/audio/AudioGroup.java +++ b/Mage.Client/src/main/java/mage/client/util/audio/AudioGroup.java @@ -1,7 +1,8 @@ package mage.client.util.audio; /** - * + * Used to dived the sound clips in different groups to make them active by group + * * @author LevelX2 */ public enum AudioGroup { diff --git a/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java b/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java index da33d4be6d7..0945953532b 100644 --- a/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java +++ b/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java @@ -46,129 +46,147 @@ public class AudioManager { /** * AudioManager singleton. */ - private static AudioManager audioManager = null; + private static final AudioManager audioManager = new AudioManager();; public static AudioManager getManager() { - if (audioManager == null) { - audioManager = new AudioManager(); - audioManager.nextPageClip = - new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav"), - AudioGroup.OtherSounds); //sounds better than OnNextPage - audioManager.prevPageClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav"), - AudioGroup.OtherSounds); - audioManager.anotherTabClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnNextPage.wav"), - AudioGroup.OtherSounds); - - audioManager.playerSubmittedDeck = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerSubmittedDeck.wav"), - AudioGroup.OtherSounds); - audioManager.playerWhispered = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerWhispered.wav"), - AudioGroup.OtherSounds); - audioManager.playerLeft = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerLeft.wav"), - AudioGroup.OtherSounds); - - // in games sounds - audioManager.nextPhaseClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnNextPhase.wav"), - AudioGroup.GameSounds); - audioManager.endTurnClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnEndTurn.wav"), - AudioGroup.GameSounds); - audioManager.tapPermanentClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnTapPermanent.wav"), - AudioGroup.GameSounds); - audioManager.summonClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnSummon.wav"), - AudioGroup.GameSounds); - audioManager.diedCreatureClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnSummon-.wav"), - AudioGroup.GameSounds); - audioManager.drawClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnDraw.wav"), - AudioGroup.GameSounds); - audioManager.buttonOkClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnButtonOk.wav"), - AudioGroup.GameSounds); - audioManager.buttonCancelClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnButtonCancel.wav"), - AudioGroup.GameSounds); - audioManager.attackClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnAttack.wav"), - AudioGroup.GameSounds); - audioManager.blockClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnBlock.wav"), - AudioGroup.GameSounds); - audioManager.addPermanentClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnAddPermanent.wav"), - AudioGroup.GameSounds); - audioManager.addArtifactClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnAddArtifact.wav"), - AudioGroup.GameSounds); - audioManager.updateStackClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnStackNew.wav"), - AudioGroup.GameSounds); - audioManager.onHover = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnHover.wav"), - AudioGroup.GameSounds); - audioManager.playerWon = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerWon.wav"), - AudioGroup.GameSounds); - audioManager.playerLost = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerLost.wav"), - AudioGroup.GameSounds); - } return audioManager; } public static void playNextPage() { + if (audioManager.nextPageClip == null) { + audioManager.nextPageClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav"), + AudioGroup.OtherSounds); + } checkAndPlayClip(getManager().nextPageClip); } public static void playPrevPage() { + if (audioManager.prevPageClip == null) { + audioManager.prevPageClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav"), + AudioGroup.OtherSounds); + } checkAndPlayClip(getManager().prevPageClip); } public static void playAnotherTab() { + if (audioManager.anotherTabClip == null) { + audioManager.anotherTabClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnNextPage.wav"), + AudioGroup.OtherSounds); + } checkAndPlayClip(getManager().anotherTabClip); } public static void playNextPhase() { + if (audioManager.nextPhaseClip == null) { + audioManager.nextPhaseClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnNextPhase.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().nextPhaseClip); } public static void playEndTurn() { + if (audioManager.endTurnClip == null) { + audioManager.endTurnClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnEndTurn.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().endTurnClip); } public static void playTapPermanent() { + if (audioManager.tapPermanentClip == null) { + audioManager.tapPermanentClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnTapPermanent.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().tapPermanentClip); } public static void playSummon() { + if (audioManager.summonClip == null) { + audioManager.summonClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnSummon.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().summonClip); } public static void playDiedCreature() { + if (audioManager.diedCreatureClip == null) { + audioManager.diedCreatureClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnSummon-.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().diedCreatureClip); } public static void playDraw() { + if (audioManager.drawClip == null) { + audioManager.drawClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnDraw.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().drawClip); } public static void playButtonOk() { + if (audioManager.buttonOkClip == null) { + audioManager.buttonOkClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnButtonOk.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().buttonOkClip); } public static void playButtonCancel() { + if (audioManager.buttonCancelClip == null) { + audioManager.buttonCancelClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnButtonCancel.wav"), + AudioGroup.GameSounds); + + } checkAndPlayClip(getManager().buttonCancelClip); } public static void playAttack() { + if (audioManager.attackClip == null) { + audioManager.attackClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnAttack.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().attackClip); } public static void playBlock() { + if (audioManager.blockClip == null) { + audioManager.blockClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnBlock.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().blockClip); } public static void playAddPermanent() { + if (audioManager.addPermanentClip == null) { + audioManager.addPermanentClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnAddPermanent.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().addPermanentClip); } public static void playAddArtifact() { + if (audioManager.addArtifactClip == null) { + audioManager.addArtifactClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnAddArtifact.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().addArtifactClip); } public static void playStackNew() { + if (audioManager.updateStackClip == null) { + audioManager.updateStackClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnStackNew.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().updateStackClip); } public static void playOnHover() { + if (audioManager.onHover == null) { + audioManager.onHover = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnHover.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().onHover); } @@ -181,22 +199,42 @@ public class AudioManager { } public static void playPlayerWhispered() { + if (audioManager.playerWhispered == null) { + audioManager.playerWhispered = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerWhispered.wav"), + AudioGroup.OtherSounds); + } checkAndPlayClip(getManager().playerWhispered); } public static void playPlayerSubmittedDeck() { + if(audioManager.playerSubmittedDeck == null) { + audioManager.playerSubmittedDeck = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerSubmittedDeck.wav"), + AudioGroup.OtherSounds); + } checkAndPlayClip(getManager().playerSubmittedDeck); } public static void playPlayerLeft() { + if(audioManager.playerLeft == null) { + audioManager.playerLeft = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerLeft.wav"), + AudioGroup.OtherSounds); + } checkAndPlayClip(getManager().playerLeft); } public static void playPlayerLost() { + if(audioManager.playerLost == null) { + audioManager.playerLost = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerLost.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().playerLost); } public static void playPlayerWon() { + if(audioManager.playerWon == null) { + audioManager.playerWon = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerWon.wav"), + AudioGroup.GameSounds); + } checkAndPlayClip(getManager().playerWon); } diff --git a/Mage.Common/src/mage/remote/Connection.java b/Mage.Common/src/mage/remote/Connection.java index 5a61c706729..bb25a6186a3 100644 --- a/Mage.Common/src/mage/remote/Connection.java +++ b/Mage.Common/src/mage/remote/Connection.java @@ -48,6 +48,7 @@ public class Connection { private String proxyPassword; private int avatarId; + private boolean showAbilityPickerForced; private static final String serialization = "?serializationtype=jboss"; private static final String transport = "bisocket"; @@ -204,4 +205,12 @@ public class Connection { this.avatarId = avatarId; } + public boolean isShowAbilityPickerForced() { + return showAbilityPickerForced; + } + + public void setShowAbilityPickerForced(boolean showAbilityPickerForced) { + this.showAbilityPickerForced = showAbilityPickerForced; + } + } diff --git a/Mage.Common/src/mage/remote/SessionImpl.java b/Mage.Common/src/mage/remote/SessionImpl.java index 3a96fc3301a..d0dfd6040fb 100644 --- a/Mage.Common/src/mage/remote/SessionImpl.java +++ b/Mage.Common/src/mage/remote/SessionImpl.java @@ -190,7 +190,7 @@ public class SessionImpl implements Session { this.sessionId = callbackClient.getSessionId(); boolean registerResult; if (connection.getPassword() == null) { - UserDataView userDataView = new UserDataView(connection.getAvatarId()); + UserDataView userDataView = new UserDataView(connection.getAvatarId(), connection.isShowAbilityPickerForced()); // for backward compatibility. don't remove twice call - first one does nothing but for version checking registerResult = server.registerClient(connection.getUsername(), sessionId, client.getVersion()); server.setUserData(connection.getUsername(), sessionId, userDataView); @@ -367,8 +367,6 @@ public class SessionImpl implements Session { } } catch (MageException ex) { handleMageException(ex); - } catch (Throwable t) { - handleThrowable(t); } return null; } @@ -381,8 +379,6 @@ public class SessionImpl implements Session { } } catch (MageException ex) { handleMageException(ex); - } catch (Throwable t) { - handleThrowable(t); } return null; } @@ -395,8 +391,6 @@ public class SessionImpl implements Session { } } catch (MageException ex) { handleMageException(ex); - } catch (Throwable t) { - handleThrowable(t); } return null; } @@ -423,8 +417,6 @@ public class SessionImpl implements Session { } } catch (MageException ex) { handleMageException(ex); - } catch (Throwable t) { - handleThrowable(t); } return null; } @@ -1243,10 +1235,10 @@ public class SessionImpl implements Session { } @Override - public boolean updateAvatar(int avatarId) { + public boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced) { try { if (isConnected()) { - UserDataView userDataView = new UserDataView(avatarId); + UserDataView userDataView = new UserDataView(avatarId, showAbilityPickerForced); server.setUserData(connection.getUsername(), sessionId, userDataView); } return true; diff --git a/Mage.Common/src/mage/remote/interfaces/ClientData.java b/Mage.Common/src/mage/remote/interfaces/ClientData.java index bb773befbc5..7a03148326e 100644 --- a/Mage.Common/src/mage/remote/interfaces/ClientData.java +++ b/Mage.Common/src/mage/remote/interfaces/ClientData.java @@ -34,5 +34,5 @@ public interface ClientData { String getUserName(); - boolean updateAvatar(int avatarId); + boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced); } diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java index 2fda2a7f547..ac1dffe5c56 100644 --- a/Mage.Common/src/mage/view/PlayerView.java +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -92,7 +92,7 @@ public class PlayerView implements Serializable { if (player.getUserData() != null) { this.userDataView = new UserDataView(player.getUserData()); } else { - this.userDataView = new UserDataView(0); + this.userDataView = new UserDataView(0, false); } for (CommandObject commandObject : game.getState().getCommand()) { diff --git a/Mage.Common/src/mage/view/UserDataView.java b/Mage.Common/src/mage/view/UserDataView.java index 037e6d4ef5a..f32a91c0616 100644 --- a/Mage.Common/src/mage/view/UserDataView.java +++ b/Mage.Common/src/mage/view/UserDataView.java @@ -13,9 +13,11 @@ public class UserDataView implements Serializable { protected int avatarId; protected int userGroup; + protected boolean showAbilityPickerForced; - public UserDataView(int avatarId) { + public UserDataView(int avatarId, boolean showAbilityPickerForced) { this.avatarId = avatarId; + this.showAbilityPickerForced = showAbilityPickerForced; } public UserDataView(UserData userData) { @@ -26,4 +28,9 @@ public class UserDataView implements Serializable { public int getAvatarId() { return avatarId; } + + public boolean isShowAbilityPickerForced() { + return showAbilityPickerForced; + } + } diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 1be6974390d..c57359e6ca4 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -104,7 +104,7 @@ public class ComputerPlayer> extends PlayerImpl i public ComputerPlayer(String name, RangeOfInfluence range) { super(name, range); human = false; - userData = new UserData(UserGroup.COMPUTER, 64); + userData = new UserData(UserGroup.COMPUTER, 64, false); } protected ComputerPlayer(UUID id) { diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 11a4e6a8995..fb3161b714d 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -30,6 +30,7 @@ package mage.player.human; import java.io.Serializable; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -41,11 +42,15 @@ import mage.abilities.Ability; import mage.abilities.ActivatedAbility; import mage.abilities.Mode; import mage.abilities.Modes; +import mage.abilities.PlayLandAbility; import mage.abilities.SpecialAction; import mage.abilities.SpellAbility; import mage.abilities.TriggeredAbility; +import mage.abilities.costs.Cost; import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCost; +import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.PhyrexianManaCost; import mage.abilities.effects.RequirementEffect; @@ -803,7 +808,7 @@ public class HumanPlayer extends PlayerImpl { protected void activateAbility(LinkedHashMap abilities, MageObject object, Game game) { updateGameStatePriority("activateAbility", game); - if (abilities.size() == 1) { + if (abilities.size() == 1 && suppressAbilityPicker(abilities.values().iterator().next())) { ActivatedAbility ability = abilities.values().iterator().next(); if (ability.getTargets().size() != 0 || !(ability.getCosts().size() == 1 && ability.getCosts().get(0) instanceof SacrificeSourceCost)) { activateAbility(ability, game); @@ -819,6 +824,24 @@ public class HumanPlayer extends PlayerImpl { } } + private boolean suppressAbilityPicker(ActivatedAbility ability) { + if (this.getUserData().isShowAbilityPickerForced()) { + if (ability instanceof PlayLandAbility) { + return true; + } + for(Cost cost : ability.getCosts() ) { + if (!(cost instanceof TapSourceCost) + || !((cost instanceof ManaCosts) && ((ManaCosts)cost).convertedManaCost() >0)) { + // if cost exists that have to be paid, pick ability dialog can be suppressed + return true; + } + } + return false; + + } + return true; + } + @Override public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { switch(ability.getSpellAbilityType()) { diff --git a/Mage.Server/src/main/java/mage/server/Session.java b/Mage.Server/src/main/java/mage/server/Session.java index 232d82c9565..bb23065c92a 100644 --- a/Mage.Server/src/main/java/mage/server/Session.java +++ b/Mage.Server/src/main/java/mage/server/Session.java @@ -113,14 +113,14 @@ public class Session { if (user == null) { user = UserManager.getInstance().findUser("Admin"); } - user.setUserData(new UserData(UserGroup.ADMIN, 0)); + user.setUserData(new UserData(UserGroup.ADMIN, 0, false)); this.userId = user.getId(); } public boolean setUserData(String userName, UserDataView userDataView) { User user = UserManager.getInstance().findUser(userName); if (user != null) { - UserData userData = new UserData(UserGroup.PLAYER, userDataView.getAvatarId()); + UserData userData = new UserData(UserGroup.PLAYER, userDataView.getAvatarId(), userDataView.isShowAbilityPickerForced()); updateAvatar(userName, userData); user.setUserData(userData); return true; diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index 78e54a92866..f42bb82d1e1 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -130,6 +130,10 @@ public interface Player extends MageItem, Copyable { Set getInRange(); boolean isTopCardRevealed(); void setTopCardRevealed(boolean topCardRevealed); + /** + * Get data from the client Preferences (e.g. avatarId or showAbilityPickerForce) + * @return + */ UserData getUserData(); void setUserData(UserData userData); boolean canLose(Game game); diff --git a/Mage/src/mage/players/net/UserData.java b/Mage/src/mage/players/net/UserData.java index e22d9aa6def..c56de0ed3a8 100644 --- a/Mage/src/mage/players/net/UserData.java +++ b/Mage/src/mage/players/net/UserData.java @@ -11,11 +11,13 @@ public class UserData implements Serializable { protected int groupId; protected int avatarId; + protected boolean showAbilityPickerForced; protected String privateKey; - public UserData(UserGroup userGroup, int avatarId) { + public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced) { this.groupId = userGroup.getGroupId(); this.avatarId = avatarId; + this.showAbilityPickerForced = showAbilityPickerForced; } public void setGroupId(int groupId) { @@ -33,4 +35,13 @@ public class UserData implements Serializable { public void setAvatarId(int avatarId) { this.avatarId = avatarId; } + + public boolean isShowAbilityPickerForced() { + return showAbilityPickerForced; + } + + public void setShowAbilityPickerForced(boolean showAbilityPickerForced) { + this.showAbilityPickerForced = showAbilityPickerForced; + } + }