forked from External/mage
GUI: added stacked feature for a same creature tokens (#12256)
This commit is contained in:
parent
199345db07
commit
f53c9da3e4
2 changed files with 66 additions and 23 deletions
|
|
@ -63,7 +63,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
|
||||
private javax.swing.Timer gameUpdateTimer; // timer for custom GUI re-drawing (example: update attack arrows)
|
||||
|
||||
//private static int iCounter = 0;
|
||||
// private static int iCounter = 0;
|
||||
private boolean addedPermanent;
|
||||
private boolean addedArtifact;
|
||||
private boolean addedCreature;
|
||||
|
|
@ -89,10 +89,10 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
}
|
||||
});
|
||||
|
||||
gameUpdateTimer = new Timer(GAME_REDRAW_TIMEOUT_MS, evt -> SwingUtilities.invokeLater(() -> {
|
||||
gameUpdateTimer = new Timer(GAME_REDRAW_TIMEOUT_MS, evt -> SwingUtilities.invokeLater(() -> {
|
||||
gameUpdateTimer.stop();
|
||||
ClientCallback updateMessage = new ClientCallback(ClientCallbackMethod.GAME_REDRAW_GUI, gameId);
|
||||
MageFrame.getInstance().onCallback(updateMessage);
|
||||
ClientCallback updateMessage = new ClientCallback(ClientCallbackMethod.GAME_REDRAW_GUI, gameId);
|
||||
MageFrame.getInstance().onCallback(updateMessage);
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
@ -151,6 +151,32 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
}
|
||||
MageCard oldFound = permanents.get(permanent.getId());
|
||||
MagePermanent oldMagePermanent = oldFound == null ? null : (MagePermanent) oldFound.getMainPanel();
|
||||
|
||||
// Check if there was a change in the power or toughness of the permanent
|
||||
int permanentPower = 0;
|
||||
int permanentToughness = 0;
|
||||
int oldMagePermanentPower = 0;
|
||||
int oldMagePermanentToughness = 0;
|
||||
if (permanent != null && oldMagePermanent != null && permanent.getOriginal() != null
|
||||
&& oldMagePermanent.getOriginal() != null) {
|
||||
permanentPower = permanent.getOriginal().getOriginalPower() != null
|
||||
? permanent.getOriginal().getOriginalPower().getValue()
|
||||
: 0;
|
||||
permanentToughness = permanent.getOriginal().getOriginalToughness() != null
|
||||
? permanent.getOriginal().getOriginalToughness().getValue()
|
||||
: 0;
|
||||
oldMagePermanentPower = oldMagePermanent.getOriginal().getOriginalPower() != null
|
||||
? oldMagePermanent.getOriginal().getOriginalPower().getValue()
|
||||
: 0;
|
||||
oldMagePermanentToughness = oldMagePermanent.getOriginal().getOriginalToughness() != null
|
||||
? oldMagePermanent.getOriginal().getOriginalToughness().getValue()
|
||||
: 0;
|
||||
|
||||
if (permanentPower != oldMagePermanentPower || permanentToughness != oldMagePermanentToughness) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldMagePermanent == null) {
|
||||
permanentsToAdd.add(permanent);
|
||||
changed = true;
|
||||
|
|
@ -182,7 +208,8 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
if (!changed) {
|
||||
UUID attachedToIdBefore = oldMagePermanent.getOriginalPermanent().getAttachedTo();
|
||||
UUID attachedToId = permanent.getAttachedTo();
|
||||
if (attachedToIdBefore == null && attachedToId != null || attachedToId == null && attachedToIdBefore != null
|
||||
if (attachedToIdBefore == null && attachedToId != null
|
||||
|| attachedToId == null && attachedToIdBefore != null
|
||||
|| (attachedToIdBefore != null && !attachedToIdBefore.equals(attachedToId))) {
|
||||
changed = true;
|
||||
}
|
||||
|
|
@ -219,7 +246,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
|
||||
removedCreature = false;
|
||||
|
||||
for (Iterator<Entry<UUID, MageCard>> iterator = permanents.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
for (Iterator<Entry<UUID, MageCard>> iterator = permanents.entrySet().iterator(); iterator.hasNext();) {
|
||||
Entry<UUID, MageCard> entry = iterator.next();
|
||||
if (!battlefield.containsKey(entry.getKey()) || !battlefield.get(entry.getKey()).isPhasedIn()) {
|
||||
removePermanent(entry.getKey(), 1);
|
||||
|
|
@ -254,13 +281,15 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
|
||||
private void addPermanent(PermanentView permanent, final int count) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
|
||||
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(),
|
||||
ClientDefaultSettings.dimensions.getFrameHeight());
|
||||
}
|
||||
final MageCard perm = Plugins.instance.getMagePermanent(permanent, bigCard, new CardIconRenderSettings(), cardDimension, gameId, true, PreferencesDialog.getRenderMode(), true);
|
||||
final MageCard perm = Plugins.instance.getMagePermanent(permanent, bigCard, new CardIconRenderSettings(),
|
||||
cardDimension, gameId, true, PreferencesDialog.getRenderMode(), true);
|
||||
perm.setCardContainerRef(jPanel);
|
||||
perm.update(permanent);
|
||||
// cards sizes changes in parent call by sortLayout
|
||||
//perm.setCardBounds
|
||||
// perm.setCardBounds
|
||||
|
||||
permanents.put(permanent.getId(), perm);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue