forked from External/mage
Fixed Issue#84: Arrows that show the targets are always on top
This commit is contained in:
parent
cdcc24a159
commit
ec5b5845ef
8 changed files with 165 additions and 88 deletions
|
|
@ -245,7 +245,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
setAppIcon();
|
setAppIcon();
|
||||||
MageTray.getInstance().install();
|
MageTray.getInstance().install();
|
||||||
|
|
||||||
desktopPane.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.DRAG_LAYER);
|
desktopPane.add(ArrowBuilder.getBuilder().getArrowsManagerPanel(), JLayeredPane.DRAG_LAYER);
|
||||||
|
|
||||||
desktopPane.addComponentListener(new ComponentAdapter() {
|
desktopPane.addComponentListener(new ComponentAdapter() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -256,10 +256,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
if (!liteMode && !grayMode) {
|
if (!liteMode && !grayMode) {
|
||||||
backgroundPane.setSize(width, height);
|
backgroundPane.setSize(width, height);
|
||||||
}
|
}
|
||||||
JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef();
|
|
||||||
if (arrowsPanel != null) {
|
ArrowBuilder.getBuilder().setSize(width, height);
|
||||||
arrowsPanel.setSize(width, height);
|
|
||||||
}
|
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
title.setBounds((int) (width - titleRectangle.getWidth()) / 2, (int) (height - titleRectangle.getHeight()) / 2, titleRectangle.width, titleRectangle.height);
|
title.setBounds((int) (width - titleRectangle.getWidth()) / 2, (int) (height - titleRectangle.getHeight()) / 2, titleRectangle.width, titleRectangle.height);
|
||||||
}
|
}
|
||||||
|
|
@ -534,6 +533,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
logger.error("Error setting " + frame.getTitle() + " active");
|
logger.error("Error setting " + frame.getTitle() + " active");
|
||||||
}
|
}
|
||||||
activeFrame.activated();
|
activeFrame.activated();
|
||||||
|
ArrowBuilder.getBuilder().hideAllPanels();
|
||||||
|
if (frame instanceof GamePane) {
|
||||||
|
ArrowBuilder.getBuilder().showPanel(((GamePane) frame).getGameId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deactivate(MagePane frame) {
|
public static void deactivate(MagePane frame) {
|
||||||
|
|
|
||||||
|
|
@ -361,14 +361,14 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
Point target = p.getLocationOnScreen();
|
Point target = p.getLocationOnScreen();
|
||||||
Point me = this.getLocationOnScreen();
|
Point me = this.getLocationOnScreen();
|
||||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
ArrowBuilder.getBuilder().addArrow(gameId, (int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
||||||
} else {
|
} else {
|
||||||
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) {
|
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) {
|
||||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Point target = permanent.getLocationOnScreen();
|
Point target = permanent.getLocationOnScreen();
|
||||||
Point me = this.getLocationOnScreen();
|
Point me = this.getLocationOnScreen();
|
||||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
ArrowBuilder.getBuilder().addArrow(gameId, (int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -383,10 +383,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
||||||
if (popup != null) {
|
if (popup != null) {
|
||||||
popup.hide();
|
popup.hide();
|
||||||
popupShowing = false;
|
popupShowing = false;
|
||||||
//ArrowBuilder.removeAllArrows();
|
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.TARGET);
|
||||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.TARGET);
|
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.PAIRED);
|
||||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.PAIRED);
|
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.SOURCE);
|
||||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.SOURCE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,12 @@ public class CombatManager {
|
||||||
private Point parentPoint;
|
private Point parentPoint;
|
||||||
|
|
||||||
public void showCombat(List<CombatGroupView> combatView, UUID gameId) {
|
public void showCombat(List<CombatGroupView> combatView, UUID gameId) {
|
||||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.COMBAT);
|
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.COMBAT);
|
||||||
displayArrows(combatView, gameId);
|
displayArrows(combatView, gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideCombat(UUID gameId) {
|
public void hideCombat(UUID gameId) {
|
||||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.COMBAT);
|
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.COMBAT);
|
||||||
combatAttackers.remove(gameId);
|
combatAttackers.remove(gameId);
|
||||||
combatBlockers.remove(gameId);
|
combatBlockers.remove(gameId);
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +92,7 @@ public class CombatManager {
|
||||||
target.translate(-parentPoint.x, -parentPoint.y);
|
target.translate(-parentPoint.x, -parentPoint.y);
|
||||||
Point attackerPoint = attackerCard.getLocationOnScreen();
|
Point attackerPoint = attackerCard.getLocationOnScreen();
|
||||||
attackerPoint.translate(-parentPoint.x, -parentPoint.y);
|
attackerPoint.translate(-parentPoint.x, -parentPoint.y);
|
||||||
ArrowBuilder.addArrow((int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() - 20, Color.red, ArrowBuilder.Type.COMBAT);
|
ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() - 20, Color.red, ArrowBuilder.Type.COMBAT);
|
||||||
} else {
|
} else {
|
||||||
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) {
|
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) {
|
||||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(defenderId);
|
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(defenderId);
|
||||||
|
|
@ -101,7 +101,7 @@ public class CombatManager {
|
||||||
target.translate(-parentPoint.x, -parentPoint.y);
|
target.translate(-parentPoint.x, -parentPoint.y);
|
||||||
Point attackerPoint = attackerCard.getLocationOnScreen();
|
Point attackerPoint = attackerCard.getLocationOnScreen();
|
||||||
attackerPoint.translate(-parentPoint.x, -parentPoint.y);
|
attackerPoint.translate(-parentPoint.x, -parentPoint.y);
|
||||||
ArrowBuilder.addArrow((int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.COMBAT);
|
ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.COMBAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ public class CombatManager {
|
||||||
double xRateA = (attackerCard.getSize().width / SettingsManager.getInstance().getCardSize().width);
|
double xRateA = (attackerCard.getSize().width / SettingsManager.getInstance().getCardSize().width);
|
||||||
double yRateB = (blockerCard.getSize().height / SettingsManager.getInstance().getCardSize().height);
|
double yRateB = (blockerCard.getSize().height / SettingsManager.getInstance().getCardSize().height);
|
||||||
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.getBuilder().addArrow(gameId, (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++;
|
globalBlockersCount++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
this.btnRight.setVisible(true);
|
this.btnRight.setVisible(true);
|
||||||
this.btnRight.setText("OK");
|
this.btnRight.setText("OK");
|
||||||
this.helper.setState("", false, "OK", true);
|
this.helper.setState("", false, "OK", true);
|
||||||
ArrowBuilder.removeAllArrows();
|
ArrowBuilder.getBuilder().removeAllArrows(gameId);
|
||||||
endWithTimeout();
|
endWithTimeout();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ public class GamePane extends MagePane {
|
||||||
|
|
||||||
public void showGame(UUID gameId, UUID playerId) {
|
public void showGame(UUID gameId, UUID playerId) {
|
||||||
this.setTitle("Game " + gameId);
|
this.setTitle("Game " + gameId);
|
||||||
|
this.gameId = gameId;
|
||||||
gamePanel.showGame(gameId, playerId);
|
gamePanel.showGame(gameId, playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,11 +70,13 @@ public class GamePane extends MagePane {
|
||||||
|
|
||||||
public void watchGame(UUID gameId) {
|
public void watchGame(UUID gameId) {
|
||||||
this.setTitle("Watching " + gameId);
|
this.setTitle("Watching " + gameId);
|
||||||
|
this.gameId = gameId;
|
||||||
gamePanel.watchGame(gameId);
|
gamePanel.watchGame(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replayGame(UUID gameId) {
|
public void replayGame(UUID gameId) {
|
||||||
this.setTitle("Replaying " + gameId);
|
this.setTitle("Replaying " + gameId);
|
||||||
|
this.gameId = gameId;
|
||||||
gamePanel.replayGame(gameId);
|
gamePanel.replayGame(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,8 +104,12 @@ public class GamePane extends MagePane {
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getGameId() {
|
||||||
|
return gameId;
|
||||||
|
}
|
||||||
|
|
||||||
private mage.client.game.GamePanel gamePanel;
|
private mage.client.game.GamePanel gamePanel;
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
|
private UUID gameId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ import mage.client.plugins.impl.Plugins;
|
||||||
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;
|
||||||
|
import mage.client.util.gui.ArrowBuilder;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.view.*;
|
import mage.view.*;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
@ -265,6 +266,8 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
//int height = pnlBattlefield.getHeight();
|
//int height = pnlBattlefield.getHeight();
|
||||||
//phasesContainer.setPreferredSize(new Dimension(X_PHASE_WIDTH, X_PHASE_HEIGHT));
|
//phasesContainer.setPreferredSize(new Dimension(X_PHASE_WIDTH, X_PHASE_HEIGHT));
|
||||||
|
|
||||||
|
ArrowBuilder.getBuilder().setSize(rect.width, rect.height);
|
||||||
|
|
||||||
DialogManager.getManager(gameId).setScreenWidth(rect.width);
|
DialogManager.getManager(gameId).setScreenWidth(rect.width);
|
||||||
DialogManager.getManager(gameId).setScreenHeight(rect.height);
|
DialogManager.getManager(gameId).setScreenHeight(rect.height);
|
||||||
DialogManager.getManager(gameId).setBounds(0, 0, rect.width, rect.height);
|
DialogManager.getManager(gameId).setBounds(0, 0, rect.width, rect.height);
|
||||||
|
|
@ -441,7 +444,7 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
handContainer.loadCards(handCards.get(chosenHandKey), bigCard, gameId);
|
handContainer.loadCards(handCards.get(chosenHandKey), bigCard, gameId);
|
||||||
|
|
||||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||||
((MageActionCallback)callback).hideAll();
|
((MageActionCallback)callback).hideAll(gameId);
|
||||||
|
|
||||||
// set visible only if we have any other hand visible than ours
|
// set visible only if we have any other hand visible than ours
|
||||||
boolean previous = btnSwitchHands.isVisible();
|
boolean previous = btnSwitchHands.isVisible();
|
||||||
|
|
@ -623,16 +626,13 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public void endMessage(String message) {
|
public void endMessage(String message) {
|
||||||
this.feedbackPanel.getFeedback(FeedbackMode.END, message, false, null);
|
this.feedbackPanel.getFeedback(FeedbackMode.END, message, false, null);
|
||||||
|
ArrowBuilder.getBuilder().removeAllArrows(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int modalQuestion(String message, String title) {
|
public int modalQuestion(String message, String title) {
|
||||||
return JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION);
|
return JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public JPanel getHand() {
|
|
||||||
return hand;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public void select(String message, GameView gameView) {
|
public void select(String message, GameView gameView) {
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
String messageToDisplay = message;
|
String messageToDisplay = message;
|
||||||
|
|
@ -1074,23 +1074,23 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
gl_jPanel3.setHorizontalGroup(
|
gl_jPanel3.setHorizontalGroup(
|
||||||
gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
//.addComponent(pnlGameInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
//.addComponent(pnlGameInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
//.addGap(0)
|
//.addGap(0)
|
||||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
)
|
)
|
||||||
.addComponent(stack, 400, 400, 400)
|
.addComponent(stack, 400, 400, 400)
|
||||||
|
|
||||||
)
|
)
|
||||||
.addGap(0)
|
.addGap(0)
|
||||||
//.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
//.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
||||||
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
)))
|
)))
|
||||||
);
|
);
|
||||||
gl_jPanel3.setVerticalGroup(
|
gl_jPanel3.setVerticalGroup(
|
||||||
gl_jPanel3.createParallelGroup(Alignment.TRAILING)
|
gl_jPanel3.createParallelGroup(Alignment.TRAILING)
|
||||||
|
|
@ -1099,7 +1099,7 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
||||||
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
)
|
)
|
||||||
//.addPreferredGap(ComponentPlacement.RELATED)
|
//.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
.addGap(85)
|
.addGap(85)
|
||||||
|
|
@ -1320,9 +1320,9 @@ class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
try {
|
try {
|
||||||
get();
|
get();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
logger.fatal("Update Matches Task error", ex);
|
logger.fatal("Replay Match Task error", ex);
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
logger.fatal("Update Matches Task error", ex);
|
logger.fatal("Replay Match Task error", ex);
|
||||||
} catch (CancellationException ex) {}
|
} catch (CancellationException ex) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Point target = permanent.getLocationOnScreen();
|
Point target = permanent.getLocationOnScreen();
|
||||||
target.translate(-parentPoint.x, -parentPoint.y);
|
target.translate(-parentPoint.x, -parentPoint.y);
|
||||||
ArrowBuilder.addArrow((int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.green, ArrowBuilder.Type.PAIRED);
|
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.green, ArrowBuilder.Type.PAIRED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Point source = permanent.getLocationOnScreen();
|
Point source = permanent.getLocationOnScreen();
|
||||||
source.translate(-parentPoint.x, -parentPoint.y);
|
source.translate(-parentPoint.x, -parentPoint.y);
|
||||||
ArrowBuilder.addArrow((int) source.getX() + 40, (int) source.getY() + 10, (int) me.getX() + 35, (int) me.getY() + 20, Color.blue, ArrowBuilder.Type.SOURCE);
|
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) source.getX() + 40, (int) source.getY() + 10, (int) me.getX() + 35, (int) me.getY() + 20, Color.blue, ArrowBuilder.Type.SOURCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -136,14 +136,14 @@ public class MageActionCallback implements ActionCallback {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
Point target = p.getLocationOnScreen();
|
Point target = p.getLocationOnScreen();
|
||||||
target.translate(-parentPoint.x, -parentPoint.y);
|
target.translate(-parentPoint.x, -parentPoint.y);
|
||||||
ArrowBuilder.addArrow((int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
ArrowBuilder.getBuilder().addArrow(data.gameId,(int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
||||||
} else {
|
} else {
|
||||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Point target = permanent.getLocationOnScreen();
|
Point target = permanent.getLocationOnScreen();
|
||||||
target.translate(-parentPoint.x, -parentPoint.y);
|
target.translate(-parentPoint.x, -parentPoint.y);
|
||||||
ArrowBuilder.addArrow((int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -276,17 +276,16 @@ public class MageActionCallback implements ActionCallback {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e, final TransferData data) {
|
public void mouseExited(MouseEvent e, final TransferData data) {
|
||||||
hideAll();
|
hideAll(data.gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideAll() {
|
public void hideAll(UUID gameId) {
|
||||||
hidePopup();
|
hidePopup();
|
||||||
startHideTimeout();
|
startHideTimeout();
|
||||||
this.state = false;
|
this.state = false;
|
||||||
//ArrowBuilder.removeAllArrows();
|
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.TARGET);
|
||||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.TARGET);
|
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.PAIRED);
|
||||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.PAIRED);
|
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.SOURCE);
|
||||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.SOURCE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enlargeCard() {
|
public void enlargeCard() {
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,40 @@ package mage.client.util.gui;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for dealing with arrows in the game.
|
* Class for dealing with arrows in the game.
|
||||||
*
|
*
|
||||||
* @author nantuko
|
* @author nantuko, noxx
|
||||||
*/
|
*/
|
||||||
public class ArrowBuilder {
|
public class ArrowBuilder {
|
||||||
|
|
||||||
private static JPanel arrowsPanel;
|
private static ArrowBuilder instance;
|
||||||
|
|
||||||
private final static Map<Type, java.util.List<Arrow>> map = new HashMap<Type, java.util.List<Arrow>>();
|
static {
|
||||||
|
instance = new ArrowBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrowBuilder getBuilder() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The top panel where arrow panels are added to.
|
||||||
|
*/
|
||||||
|
private JPanel arrowsManagerPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores arrow panels per game
|
||||||
|
*/
|
||||||
|
private final Map<UUID, JPanel> arrowPanels = new HashMap<UUID, JPanel>();
|
||||||
|
|
||||||
|
private final Map<UUID, Map<Type, List<Arrow>>> map = new HashMap<UUID, Map<Type, java.util.List<Arrow>>>();
|
||||||
|
|
||||||
|
private int currentWidth;
|
||||||
|
private int currentHeight;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
PAIRED, SOURCE, TARGET, COMBAT;
|
PAIRED, SOURCE, TARGET, COMBAT;
|
||||||
|
|
@ -25,20 +45,33 @@ public class ArrowBuilder {
|
||||||
* Get the panel where all arrows are being drawn.
|
* Get the panel where all arrows are being drawn.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static JPanel getArrowsPanel() {
|
public JPanel getArrowsManagerPanel() {
|
||||||
if (arrowsPanel == null) {
|
if (arrowsManagerPanel == null) {
|
||||||
synchronized (ArrowBuilder.class) {
|
synchronized (ArrowBuilder.class) {
|
||||||
if (arrowsPanel == null) {
|
if (arrowsManagerPanel == null) {
|
||||||
arrowsPanel = new JPanel();
|
arrowsManagerPanel = new JPanel();
|
||||||
arrowsPanel.setVisible(true);
|
arrowsManagerPanel.setVisible(true);
|
||||||
arrowsPanel.setOpaque(false);
|
arrowsManagerPanel.setOpaque(false);
|
||||||
//arrowsPanel.setLayout(new BorderLayout());
|
arrowsManagerPanel.setLayout(null);
|
||||||
arrowsPanel.setLayout(null);
|
|
||||||
//arrowsPanel.setBorder(BorderFactory.createLineBorder(Color.red));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arrowsPanel;
|
return arrowsManagerPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JPanel getArrowsPanel(UUID gameId) {
|
||||||
|
if (!arrowPanels.containsKey(gameId)) {
|
||||||
|
JPanel arrowPanel = new JPanel();
|
||||||
|
arrowPanel.setVisible(true);
|
||||||
|
arrowPanel.setOpaque(false);
|
||||||
|
arrowPanel.setLayout(null);
|
||||||
|
arrowPanel.setBorder(BorderFactory.createLineBorder(Color.blue));
|
||||||
|
arrowPanel.setSize(currentWidth, currentHeight);
|
||||||
|
arrowPanels.put(gameId, arrowPanel);
|
||||||
|
getArrowsManagerPanel().add(arrowPanel);
|
||||||
|
return arrowPanel;
|
||||||
|
}
|
||||||
|
return arrowPanels.get(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,9 +81,9 @@ public class ArrowBuilder {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static JPanel getArrowsPanelRef() {
|
/*public JPanel getPanelRef() {
|
||||||
return arrowsPanel;
|
return arrowsManagerPanel;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds new arrow.
|
* Adds new arrow.
|
||||||
|
|
@ -61,21 +94,29 @@ public class ArrowBuilder {
|
||||||
* @param endY
|
* @param endY
|
||||||
* @param color
|
* @param color
|
||||||
*/
|
*/
|
||||||
public static void addArrow(int startX, int startY, int endX, int endY, Color color, Type type) {
|
public void addArrow(UUID gameId, int startX, int startY, int endX, int endY, Color color, Type type) {
|
||||||
JPanel p = getArrowsPanel();
|
JPanel p = getArrowsPanel(gameId);
|
||||||
|
|
||||||
Arrow arrow = new Arrow();
|
Arrow arrow = new Arrow();
|
||||||
arrow.setColor(color);
|
arrow.setColor(color);
|
||||||
arrow.setArrowLocation(startX, startY, endX, endY);
|
arrow.setArrowLocation(startX, startY, endX, endY);
|
||||||
arrow.setBounds(0, 0, Math.max(startX, endX) + 40, Math.max(startY, endY) + 30); // 30 is offset for arrow heads (being cut otherwise)
|
arrow.setBounds(0, 0, Math.max(startX, endX) + 40, Math.max(startY, endY) + 30); // 30 is offset for arrow heads (being cut otherwise)
|
||||||
|
|
||||||
synchronized (map) {
|
synchronized (map) {
|
||||||
p.add(arrow);
|
p.add(arrow);
|
||||||
java.util.List<Arrow> arrows = map.get(type);
|
Map<Type, java.util.List<Arrow>> innerMap = map.get(gameId);
|
||||||
|
if (innerMap == null) {
|
||||||
|
innerMap = new HashMap<Type, List<Arrow>>();
|
||||||
|
map.put(gameId, innerMap);
|
||||||
|
}
|
||||||
|
java.util.List<Arrow> arrows = innerMap.get(type);
|
||||||
if (arrows == null) {
|
if (arrows == null) {
|
||||||
arrows = new ArrayList<Arrow>();
|
arrows = new ArrayList<Arrow>();
|
||||||
map.put(type, arrows);
|
innerMap.put(type, arrows);
|
||||||
}
|
}
|
||||||
arrows.add(arrow);
|
arrows.add(arrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.revalidate();
|
p.revalidate();
|
||||||
p.repaint();
|
p.repaint();
|
||||||
}
|
}
|
||||||
|
|
@ -83,33 +124,61 @@ public class ArrowBuilder {
|
||||||
/**
|
/**
|
||||||
* Removes all arrows from the screen.
|
* Removes all arrows from the screen.
|
||||||
*/
|
*/
|
||||||
public static void removeAllArrows() {
|
public void removeAllArrows(UUID gameId) {
|
||||||
JPanel p = getArrowsPanel();
|
if (map.containsKey(gameId)) {
|
||||||
synchronized (map) {
|
Map<Type, List<Arrow>> innerMap = map.get(gameId);
|
||||||
if (p.getComponentCount() > 0) {
|
JPanel p = getArrowsPanel(gameId);
|
||||||
p.removeAll();
|
synchronized (map) {
|
||||||
p.revalidate();
|
if (p != null && p.getComponentCount() > 0) {
|
||||||
p.repaint();
|
p.removeAll();
|
||||||
|
p.revalidate();
|
||||||
|
p.repaint();
|
||||||
|
}
|
||||||
|
innerMap.clear();
|
||||||
|
map.remove(gameId);
|
||||||
}
|
}
|
||||||
map.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeArrowsByType(Type type) {
|
public void removeArrowsByType(UUID gameId, Type type) {
|
||||||
java.util.List<Arrow> arrows = map.get(type);
|
if (map.containsKey(gameId)) {
|
||||||
if (arrows != null) {
|
Map<Type, List<Arrow>> innerMap = map.get(gameId);
|
||||||
JPanel p = getArrowsPanel();
|
java.util.List<Arrow> arrows = innerMap.get(type);
|
||||||
if (arrows.size() > 0) {
|
if (arrows != null && arrows.size() > 0) {
|
||||||
|
JPanel p = getArrowsPanel(gameId);
|
||||||
synchronized (map) {
|
synchronized (map) {
|
||||||
for (Arrow arrow : arrows) {
|
for (Arrow arrow : arrows) {
|
||||||
p.remove(arrow);
|
p.remove(arrow);
|
||||||
}
|
}
|
||||||
map.put(type, new ArrayList<Arrow>());
|
innerMap.put(type, new ArrayList<Arrow>());
|
||||||
}
|
}
|
||||||
p.revalidate();
|
p.revalidate();
|
||||||
p.repaint();
|
p.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSize(int width, int height) {
|
||||||
|
this.currentWidth = width;
|
||||||
|
this.currentHeight = height;
|
||||||
|
if (arrowsManagerPanel != null) {
|
||||||
|
arrowsManagerPanel.setSize(width, height);
|
||||||
|
}
|
||||||
|
for (JPanel arrowPanel : arrowPanels.values()) {
|
||||||
|
arrowPanel.setSize(width, height);
|
||||||
|
arrowPanel.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideAllPanels() {
|
||||||
|
for (JPanel arrowPanel : arrowPanels.values()) {
|
||||||
|
arrowPanel.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showPanel(UUID gameId) {
|
||||||
|
if (arrowPanels.containsKey(gameId)) {
|
||||||
|
arrowPanels.get(gameId).setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue