mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Fixed arrows displayed under dialogs. Since now card.plugin is used in ShowCardsDialog. Added sourceCard to AbilityView (required for source arrows).
This commit is contained in:
parent
be707b3b52
commit
0211787433
7 changed files with 56 additions and 22 deletions
|
|
@ -164,12 +164,16 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
desktopPane.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.DRAG_LAYER);
|
||||
|
||||
desktopPane.addComponentListener(new ComponentAdapter(){
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
int width = ((JComponent)e.getSource()).getWidth();
|
||||
int height = ((JComponent)e.getSource()).getHeight();
|
||||
backgroundPane.setSize(width, height);
|
||||
JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef();
|
||||
if (arrowsPanel != null) arrowsPanel.setSize(width, height);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,12 @@ import java.util.UUID;
|
|||
import javax.swing.JLayeredPane;
|
||||
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.Card;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Config;
|
||||
import mage.view.AbilityView;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
|
||||
|
|
@ -82,16 +84,29 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
private void loadCardsFew(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
for (CardView card: showCards.values()) {
|
||||
Card cardImg = new Card(card, bigCard, dimension, gameId);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
cardImg.update(card);
|
||||
cardImg.addMouseListener(this);
|
||||
addCard(card, bigCard, gameId, rectangle, dimension);
|
||||
rectangle.translate(Config.dimensions.frameWidth, 0);
|
||||
}
|
||||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * showCards.size(), Config.dimensions.frameHeight));
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, CardDimensions dimension) {
|
||||
if (card instanceof AbilityView) {
|
||||
CardView tmp = ((AbilityView)card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
tmp.setIsAbility(true);
|
||||
tmp.overrideTargets(card.getTargets());
|
||||
tmp.setAbility(card); // cross-reference, required for ability picker
|
||||
card = tmp;
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, gameId);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
cardImg.update(card);
|
||||
cardImg.addMouseListener(this);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
|
||||
private void loadCardsMany(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
int columns = 1;
|
||||
|
|
@ -99,12 +114,7 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
int count = 0;
|
||||
for (CardView card: showCards.values()) {
|
||||
Card cardImg = new Card(card, bigCard, dimension, gameId);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
cardImg.update(card);
|
||||
cardImg.addMouseListener(this);
|
||||
addCard(card, bigCard, gameId, rectangle, dimension);
|
||||
if (count >= 20) {
|
||||
rectangle.translate(Config.dimensions.frameWidth, -400);
|
||||
columns++;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import java.awt.event.ComponentEvent;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
|
@ -87,7 +88,6 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
// Override layout (I can't edit generated code)
|
||||
this.setLayout(new BorderLayout());
|
||||
final JLayeredPane j = new JLayeredPane();
|
||||
j.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.MODAL_LAYER);
|
||||
j.setSize(1024,768);
|
||||
this.add(j);
|
||||
j.add(jSplitPane1, JLayeredPane.DEFAULT_LAYER);
|
||||
|
|
@ -102,8 +102,6 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
int width = ((JComponent)e.getSource()).getWidth();
|
||||
int height = ((JComponent)e.getSource()).getHeight();
|
||||
j.setSize(width, height);
|
||||
JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef();
|
||||
if (arrowsPanel != null) arrowsPanel.setSize(width, height);
|
||||
jSplitPane1.setSize(width, height);
|
||||
}
|
||||
});
|
||||
|
|
@ -188,15 +186,18 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
public void hideGame() {
|
||||
this.chatPanel.disconnect();
|
||||
this.players.clear();
|
||||
logger.log(Level.FINE, "players clear.");
|
||||
this.pnlBattlefield.removeAll();
|
||||
MageFrame.getCombatDialog().hideDialog();
|
||||
this.setVisible(false);
|
||||
}
|
||||
|
||||
public synchronized void init(GameView game) {
|
||||
logger.log(Level.FINE, "init.");
|
||||
MageFrame.getCombatDialog().init(gameId, bigCard);
|
||||
MageFrame.getCombatDialog().setLocation(500, 300);
|
||||
addPlayers(game);
|
||||
logger.log(Level.FINE, "added players.");
|
||||
updateGame(game);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,12 @@ public class DefaultActionCallback {
|
|||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e, UUID gameId, Session session, CardView card) {
|
||||
if (gameId != null)
|
||||
session.sendPlayerUUID(gameId, card.getId());
|
||||
if (gameId != null) {
|
||||
if (card.isAbility() && card.getAbility() != null) {
|
||||
session.sendPlayerUUID(gameId, card.getAbility().getId());
|
||||
} else {
|
||||
session.sendPlayerUUID(gameId, card.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue