GUI: added info about combat arrows bug on re-connect

This commit is contained in:
Oleg Agafonov 2020-08-02 14:22:59 +04:00
parent 00411b4a9b
commit c9c1bc2b90
2 changed files with 277 additions and 269 deletions

View file

@ -1,10 +1,3 @@
/*
* BattlefieldPanel.java
*
* Created on 10-Jan-2010, 10:43:14 PM
*/
package mage.client.game; package mage.client.game;
import mage.cards.MagePermanent; import mage.cards.MagePermanent;
@ -45,7 +38,6 @@
private JLayeredPane jPanel; private JLayeredPane jPanel;
private JScrollPane jScrollPane; private JScrollPane jScrollPane;
private int width;
private final CardLayoutStrategy layoutStrategy = new OldCardLayoutStrategy(); private final CardLayoutStrategy layoutStrategy = new OldCardLayoutStrategy();
@ -70,15 +62,16 @@
addComponentListener(new ComponentAdapter() { addComponentListener(new ComponentAdapter() {
@Override @Override
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
int width = e.getComponent().getWidth(); updateSize();
int height = e.getComponent().getHeight();
BattlefieldPanel.this.jScrollPane.setSize(width, height);
BattlefieldPanel.this.width = width;
sortLayout();
} }
}); });
} }
public void updateSize() {
this.jScrollPane.setSize(this.getWidth(), this.getHeight());
sortLayout();
}
public void init(UUID gameId, BigCard bigCard) { public void init(UUID gameId, BigCard bigCard) {
this.gameId = gameId; this.gameId = gameId;
this.bigCard = bigCard; this.bigCard = bigCard;
@ -215,7 +208,7 @@
return; return;
} }
layoutStrategy.doLayout(this, width); layoutStrategy.doLayout(this, this.getWidth());
this.jScrollPane.repaint(); this.jScrollPane.repaint();
this.jScrollPane.revalidate(); this.jScrollPane.revalidate();

View file

@ -611,6 +611,21 @@ public final class GamePanel extends javax.swing.JPanel {
this.pnlBattlefield.add(topPanel, panelC); this.pnlBattlefield.add(topPanel, panelC);
panelC.gridy = 1; panelC.gridy = 1;
this.pnlBattlefield.add(bottomPanel, panelC); this.pnlBattlefield.add(bottomPanel, panelC);
// TODO: combat arrows aren't visible on re-connect, must click on avatar to update correctrly
// reason: panels aren't visible/located here, so battlefieldpanel see wrong sizes
// recalc all component sizes and update permanents/arrows positions
// if you don't do it here then will catch wrong arrows drawing on re-connect (no sortLayout calls)
/*
this.validate();
for (Map.Entry<UUID, PlayAreaPanel> p : players.entrySet()) {
PlayerView playerView = game.getPlayers().stream().filter(view -> view.getPlayerId().equals(p.getKey())).findFirst().orElse(null);
if (playerView != null) {
p.getValue().getBattlefieldPanel().updateSize();
p.getValue().update(null, playerView, null);
}
}
*/
} }
public synchronized void updateGame(GameView game) { public synchronized void updateGame(GameView game) {