mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
[UI] Some sounds
This commit is contained in:
parent
5c8ebf393b
commit
de146458a9
7 changed files with 99 additions and 5 deletions
|
@ -3,6 +3,7 @@ package mage.client.combat;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.game.PlayAreaPanel;
|
import mage.client.game.PlayAreaPanel;
|
||||||
|
import mage.client.util.AudioManager;
|
||||||
import mage.client.util.SettingsManager;
|
import mage.client.util.SettingsManager;
|
||||||
import mage.client.util.gui.ArrowBuilder;
|
import mage.client.util.gui.ArrowBuilder;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
|
@ -10,7 +11,9 @@ import mage.view.CombatGroupView;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +23,10 @@ public class CombatManager {
|
||||||
|
|
||||||
private static CombatManager combatManager;
|
private static CombatManager combatManager;
|
||||||
|
|
||||||
|
private Map<UUID, Integer> combatAttackers = new HashMap<UUID, Integer>();
|
||||||
|
private Map<UUID, Integer> combatBlockers = new HashMap<UUID, Integer>();
|
||||||
|
private int globalBlockersCount; // we need global counter as there are several combat groups
|
||||||
|
|
||||||
public static CombatManager getInstance() {
|
public static CombatManager getInstance() {
|
||||||
if (combatManager == null) {
|
if (combatManager == null) {
|
||||||
combatManager = new CombatManager();
|
combatManager = new CombatManager();
|
||||||
|
@ -34,17 +41,35 @@ public class CombatManager {
|
||||||
displayArrows(combatView, gameId);
|
displayArrows(combatView, gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideCombat() {
|
public void hideCombat(UUID gameId) {
|
||||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.COMBAT);
|
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.COMBAT);
|
||||||
|
combatAttackers.remove(gameId);
|
||||||
|
combatBlockers.remove(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayArrows(List<CombatGroupView> combatView, UUID gameId) {
|
private void displayArrows(List<CombatGroupView> combatView, UUID gameId) {
|
||||||
parentPoint = null;
|
parentPoint = null;
|
||||||
|
int count = 0;
|
||||||
|
globalBlockersCount = 0;
|
||||||
for (CombatGroupView group : combatView) {
|
for (CombatGroupView group : combatView) {
|
||||||
for (CardView attacker : group.getAttackers().values()) {
|
for (CardView attacker : group.getAttackers().values()) {
|
||||||
drawAttacker(group, attacker, gameId);
|
drawAttacker(group, attacker, gameId);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
playAddAttackersSound(gameId, count);
|
||||||
|
playAddBlockersSound(gameId, globalBlockersCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playAddAttackersSound(UUID gameId, int count) {
|
||||||
|
int prevCount = 0;
|
||||||
|
if (combatAttackers.containsKey(gameId)) {
|
||||||
|
prevCount = combatAttackers.get(gameId);
|
||||||
|
}
|
||||||
|
if (prevCount < count) {
|
||||||
|
AudioManager.playAttack();
|
||||||
|
}
|
||||||
|
combatAttackers.put(gameId, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawAttacker(CombatGroupView group, CardView attacker, UUID gameId) {
|
private void drawAttacker(CombatGroupView group, CardView attacker, UUID gameId) {
|
||||||
|
@ -99,11 +124,23 @@ public class CombatManager {
|
||||||
double xRateB = (blockerCard.getSize().width / SettingsManager.getInstance().getCardSize().width);
|
double xRateB = (blockerCard.getSize().width / SettingsManager.getInstance().getCardSize().width);
|
||||||
ArrowBuilder.addArrow((int) blockerPoint.getX() + (int)(55*xRateB), (int) blockerPoint.getY() + (int)(25*xRateB),
|
ArrowBuilder.addArrow((int) blockerPoint.getX() + (int)(55*xRateB), (int) blockerPoint.getY() + (int)(25*xRateB),
|
||||||
(int) attackerPoint.getX() + (int)(70*xRateA), (int) attackerPoint.getY() + (int)(25*yRateA), Color.blue, ArrowBuilder.Type.COMBAT);
|
(int) attackerPoint.getX() + (int)(70*xRateA), (int) attackerPoint.getY() + (int)(25*yRateA), Color.blue, ArrowBuilder.Type.COMBAT);
|
||||||
|
globalBlockersCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void playAddBlockersSound(UUID gameId, int count) {
|
||||||
|
int prevCount = 0;
|
||||||
|
if (combatBlockers.containsKey(gameId)) {
|
||||||
|
prevCount = combatBlockers.get(gameId);
|
||||||
|
}
|
||||||
|
if (prevCount < count) {
|
||||||
|
AudioManager.playBlock();
|
||||||
|
}
|
||||||
|
combatBlockers.put(gameId, count);
|
||||||
|
}
|
||||||
|
|
||||||
private Point getParentPoint(MagePermanent permanent) {
|
private Point getParentPoint(MagePermanent permanent) {
|
||||||
if (parentPoint == null) {
|
if (parentPoint == null) {
|
||||||
Component parentComponent = SwingUtilities.getRoot(permanent);
|
Component parentComponent = SwingUtilities.getRoot(permanent);
|
||||||
|
|
|
@ -34,10 +34,12 @@
|
||||||
|
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
|
import mage.Constants;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.cards.Permanent;
|
import mage.client.cards.Permanent;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
import mage.client.util.AudioManager;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
|
|
||||||
|
@ -71,6 +73,12 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
|
|
||||||
private static int i = 0;
|
private static int i = 0;
|
||||||
|
|
||||||
|
private boolean addedPermanent;
|
||||||
|
private boolean addedArtifact;
|
||||||
|
private boolean addedCreature;
|
||||||
|
|
||||||
|
private boolean removedCreature;
|
||||||
|
|
||||||
/** Creates new form BattlefieldPanel */
|
/** Creates new form BattlefieldPanel */
|
||||||
public BattlefieldPanel() {
|
public BattlefieldPanel() {
|
||||||
ui.put("battlefieldPanel", this);
|
ui.put("battlefieldPanel", this);
|
||||||
|
@ -114,11 +122,24 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
permanents.get(permanent.getId()).update(permanent);
|
permanents.get(permanent.getId()).update(permanent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addedArtifact = addedCreature = addedPermanent = false;
|
||||||
|
|
||||||
int count = permanentsToAdd.size();
|
int count = permanentsToAdd.size();
|
||||||
for (PermanentView permanent : permanentsToAdd) {
|
for (PermanentView permanent : permanentsToAdd) {
|
||||||
addPermanent(permanent, count);
|
addPermanent(permanent, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addedArtifact) {
|
||||||
|
AudioManager.playAddArtifact();
|
||||||
|
} else if (addedCreature) {
|
||||||
|
AudioManager.playSummon();
|
||||||
|
} else if (addedPermanent) {
|
||||||
|
AudioManager.playAddPermanent();
|
||||||
|
}
|
||||||
|
|
||||||
|
removedCreature = false;
|
||||||
|
|
||||||
for (Iterator<Entry<UUID, MagePermanent>> i = permanents.entrySet().iterator(); i.hasNext();) {
|
for (Iterator<Entry<UUID, MagePermanent>> i = permanents.entrySet().iterator(); i.hasNext();) {
|
||||||
Entry<UUID, MagePermanent> entry = i.next();
|
Entry<UUID, MagePermanent> entry = i.next();
|
||||||
if (!battlefield.containsKey(entry.getKey())) {
|
if (!battlefield.containsKey(entry.getKey())) {
|
||||||
|
@ -128,6 +149,10 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (removedCreature) {
|
||||||
|
AudioManager.playDiedCreature();
|
||||||
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
this.battlefield = battlefield;
|
this.battlefield = battlefield;
|
||||||
sortLayout();
|
sortLayout();
|
||||||
|
@ -183,6 +208,14 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
threads.add(t);
|
threads.add(t);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (permanent.getCardTypes().contains(Constants.CardType.ARTIFACT)) {
|
||||||
|
addedArtifact = true;
|
||||||
|
} else if (permanent.getCardTypes().contains(Constants.CardType.CREATURE)) {
|
||||||
|
addedCreature = true;
|
||||||
|
} else {
|
||||||
|
addedPermanent = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void groupAttachments(PermanentView permanent) {
|
private void groupAttachments(PermanentView permanent) {
|
||||||
|
@ -241,6 +274,9 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
if (((MagePermanent)comp).getOriginal().getCardTypes().contains(Constants.CardType.CREATURE)) {
|
||||||
|
removedCreature = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import mage.client.MageFrame;
|
||||||
import mage.client.chat.ChatPanel;
|
import mage.client.chat.ChatPanel;
|
||||||
import mage.client.components.MageTextArea;
|
import mage.client.components.MageTextArea;
|
||||||
import mage.client.dialog.MageDialog;
|
import mage.client.dialog.MageDialog;
|
||||||
|
import mage.client.util.AudioManager;
|
||||||
import mage.client.util.gui.ArrowBuilder;
|
import mage.client.util.gui.ArrowBuilder;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -378,12 +379,14 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
} else {
|
} else {
|
||||||
session.sendPlayerBoolean(gameId, false);
|
session.sendPlayerBoolean(gameId, false);
|
||||||
}
|
}
|
||||||
|
//AudioManager.playButtonOk();
|
||||||
}//GEN-LAST:event_btnRightActionPerformed
|
}//GEN-LAST:event_btnRightActionPerformed
|
||||||
|
|
||||||
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
|
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
|
||||||
this.selected = true;
|
this.selected = true;
|
||||||
// clear0();
|
// clear0();
|
||||||
session.sendPlayerBoolean(gameId, true);
|
session.sendPlayerBoolean(gameId, true);
|
||||||
|
AudioManager.playButtonCancel();
|
||||||
}//GEN-LAST:event_btnLeftActionPerformed
|
}//GEN-LAST:event_btnLeftActionPerformed
|
||||||
|
|
||||||
private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
|
private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
|
||||||
|
|
|
@ -46,6 +46,7 @@ import mage.client.dialog.*;
|
||||||
import mage.client.game.FeedbackPanel.FeedbackMode;
|
import mage.client.game.FeedbackPanel.FeedbackMode;
|
||||||
import mage.client.plugins.adapters.MageActionCallback;
|
import mage.client.plugins.adapters.MageActionCallback;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
import mage.client.util.AudioManager;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.GameManager;
|
import mage.client.util.GameManager;
|
||||||
import mage.client.util.PhaseManager;
|
import mage.client.util.PhaseManager;
|
||||||
|
@ -380,10 +381,16 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (game.getPhase() != null)
|
|
||||||
|
if (game.getPhase() != null) {
|
||||||
this.txtPhase.setText(game.getPhase().toString());
|
this.txtPhase.setText(game.getPhase().toString());
|
||||||
else
|
} else {
|
||||||
this.txtPhase.setText("");
|
this.txtPhase.setText("");
|
||||||
|
}
|
||||||
|
if (game.getPhase() != null && game.getPhase().toString().equals("End") && game.getStep().toString().equals("End Turn")) {
|
||||||
|
AudioManager.playEndTurn();
|
||||||
|
}
|
||||||
|
|
||||||
if (game.getStep() != null)
|
if (game.getStep() != null)
|
||||||
this.txtStep.setText(game.getStep().toString());
|
this.txtStep.setText(game.getStep().toString());
|
||||||
else
|
else
|
||||||
|
@ -423,7 +430,7 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
CombatManager.getInstance().showCombat(game.getCombat(), gameId);
|
CombatManager.getInstance().showCombat(game.getCombat(), gameId);
|
||||||
} else {
|
} else {
|
||||||
//combat.hideDialog();
|
//combat.hideDialog();
|
||||||
CombatManager.getInstance().hideCombat();
|
CombatManager.getInstance().hideCombat(gameId);
|
||||||
}
|
}
|
||||||
updatePhases(game.getStep());
|
updatePhases(game.getStep());
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class AudioManager {
|
||||||
audioManager.endTurnClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnEndTurn.wav");
|
audioManager.endTurnClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnEndTurn.wav");
|
||||||
audioManager.tapPermanentClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnTapPermanent.wav");
|
audioManager.tapPermanentClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnTapPermanent.wav");
|
||||||
audioManager.summonClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnSummon.wav");
|
audioManager.summonClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnSummon.wav");
|
||||||
|
audioManager.diedCreatureClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnSummon-.wav");
|
||||||
audioManager.drawClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnDraw.wav");
|
audioManager.drawClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnDraw.wav");
|
||||||
audioManager.buttonOkClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnButtonOk.wav");
|
audioManager.buttonOkClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnButtonOk.wav");
|
||||||
audioManager.buttonCancelClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnButtonCancel.wav");
|
audioManager.buttonCancelClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnButtonCancel.wav");
|
||||||
|
@ -72,6 +73,10 @@ public class AudioManager {
|
||||||
checkAndPlayClip(getManager().summonClip);
|
checkAndPlayClip(getManager().summonClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void playDiedCreature() {
|
||||||
|
checkAndPlayClip(getManager().diedCreatureClip);
|
||||||
|
}
|
||||||
|
|
||||||
public static void playDraw() {
|
public static void playDraw() {
|
||||||
checkAndPlayClip(getManager().drawClip);
|
checkAndPlayClip(getManager().drawClip);
|
||||||
}
|
}
|
||||||
|
@ -156,6 +161,7 @@ public class AudioManager {
|
||||||
private Clip endTurnClip = null;
|
private Clip endTurnClip = null;
|
||||||
private Clip tapPermanentClip = null;
|
private Clip tapPermanentClip = null;
|
||||||
private Clip summonClip = null;
|
private Clip summonClip = null;
|
||||||
|
private Clip diedCreatureClip = null;
|
||||||
private Clip drawClip = null;
|
private Clip drawClip = null;
|
||||||
private Clip buttonOkClip = null;
|
private Clip buttonOkClip = null;
|
||||||
private Clip buttonCancelClip = null;
|
private Clip buttonCancelClip = null;
|
||||||
|
|
|
@ -74,6 +74,7 @@ public class PhaseManager {
|
||||||
if (activePlayer == null) {
|
if (activePlayer == null) {
|
||||||
throw new IllegalStateException("No active player found.");
|
throw new IllegalStateException("No active player found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
if (message.equals(entry.getKey())) {
|
if (message.equals(entry.getKey())) {
|
||||||
Preferences prefs = MageFrame.getPreferences();
|
Preferences prefs = MageFrame.getPreferences();
|
||||||
|
@ -81,6 +82,6 @@ public class PhaseManager {
|
||||||
return !prop.equals(PHASE_ON);
|
return !prop.equals(PHASE_ON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import mage.cards.MagePermanent;
|
||||||
import mage.cards.TextPopup;
|
import mage.cards.TextPopup;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.cards.action.TransferData;
|
import mage.cards.action.TransferData;
|
||||||
|
import mage.client.util.AudioManager;
|
||||||
import mage.components.ImagePanel;
|
import mage.components.ImagePanel;
|
||||||
import mage.utils.CardUtil;
|
import mage.utils.CardUtil;
|
||||||
import mage.view.AbilityView;
|
import mage.view.AbilityView;
|
||||||
|
@ -631,6 +632,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
||||||
if (needsTapping || needsFlipping) {
|
if (needsTapping || needsFlipping) {
|
||||||
Animation.tapCardToggle(this, this, needsTapping, needsFlipping);
|
Animation.tapCardToggle(this, this, needsTapping, needsFlipping);
|
||||||
}
|
}
|
||||||
|
if (needsTapping && ((PermanentView) card).isTapped()) {
|
||||||
|
AudioManager.playTapPermanent();
|
||||||
|
}
|
||||||
boolean needsTranforming = isTransformed() != card.isTransformed();
|
boolean needsTranforming = isTransformed() != card.isTransformed();
|
||||||
if (needsTranforming) {
|
if (needsTranforming) {
|
||||||
Animation.transformCard(this, this, card.isTransformed());
|
Animation.transformCard(this, this, card.isTransformed());
|
||||||
|
|
Loading…
Reference in a new issue