Added option that AbilityPicker is forced to show if ability or spell has no or only tap cost (not finished yet).

This commit is contained in:
LevelX2 2014-02-12 17:18:06 +01:00
parent 81eaac46c7
commit ee76ccfee4
14 changed files with 194 additions and 103 deletions

View file

@ -24,7 +24,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="tabsPanel" alignment="0" pref="562" max="32767" attributes="0"/>
<Component id="tabsPanel" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="saveButton" min="-2" max="-2" attributes="0"/>
@ -82,10 +82,10 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="main_card" min="-2" pref="68" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="main_game" min="-2" pref="103" max="-2" attributes="0"/>
<Component id="main_game" min="-2" pref="91" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="main_gamelog" min="-2" pref="49" max="-2" attributes="0"/>
<EmptySpace pref="153" max="32767" attributes="0"/>
<EmptySpace pref="171" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -179,6 +179,7 @@
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Show player names on avatar permanently"/>
<Property name="toolTipText" type="java.lang.String" value="Instead showing the names only if you hoover over the avatar with the mouse, the name is shown all the time."/>
<Property name="horizontalAlignment" type="int" value="2"/>
</Properties>
<Events>
@ -190,7 +191,7 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="showAbilityPickerForSimpleAbilities">
<Component class="javax.swing.JCheckBox" name="showAbilityPickerForced">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Show ability picker for abilities without costs"/>
@ -198,7 +199,7 @@
<Property name="horizontalAlignment" type="int" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="showAbilityPickerForSimpleAbilitiesActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="showAbilityPickerForcedActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
@ -758,10 +759,10 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="sounds_clips" min="-2" max="-2" attributes="0"/>
<Component id="sounds_clips" min="-2" pref="68" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="sounds_backgroundMusic" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="229" max="32767" attributes="0"/>
<EmptySpace pref="247" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -795,7 +796,7 @@
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
<BorderConstraints direction="First"/>
</Constraint>
</Constraints>
</Component>
@ -835,7 +836,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel16" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtBattlefieldIBGMPath" pref="297" max="32767" attributes="0"/>
<Component id="txtBattlefieldIBGMPath" pref="332" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnBattlefieldBGMBrowse" min="-2" max="-2" attributes="0"/>
</Group>

View file

@ -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;

View file

@ -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 {

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -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;

View file

@ -34,5 +34,5 @@ public interface ClientData {
String getUserName();
boolean updateAvatar(int avatarId);
boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced);
}

View file

@ -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()) {

View file

@ -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;
}
}

View file

@ -104,7 +104,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> 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) {

View file

@ -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<HumanPlayer> {
protected void activateAbility(LinkedHashMap<UUID, ? extends ActivatedAbility> 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<HumanPlayer> {
}
}
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()) {

View file

@ -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;

View file

@ -130,6 +130,10 @@ public interface Player extends MageItem, Copyable<Player> {
Set<UUID> 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);

View file

@ -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;
}
}