Fixed Issue#396: Display of stacking auras

This commit is contained in:
magenoxx 2014-07-11 13:14:44 +04:00
parent f8a1b327b4
commit 045a81e66a
2 changed files with 35 additions and 2 deletions

View file

@ -20,6 +20,17 @@ import java.util.UUID;
*/
public class OldCardLayoutStrategy implements CardLayoutStrategy {
/**
* This offset is used once to shift all attachments
*/
private static final int ATTACHMENTS_DX_OFFSET = 8;
/**
* This offset is used for each attachment
*/
private static final int ATTACHMENT_DX_OFFSET = 0;
private static final int ATTACHMENT_DY_OFFSET = 10;
@Override
public void doLayout(JLayeredPane jLayeredPane, int width) {
Map<UUID, MagePermanent> permanents = ((BattlefieldPanel)jLayeredPane).getPermanents();
@ -60,7 +71,11 @@ public class OldCardLayoutStrategy implements CardLayoutStrategy {
if (link != null) {
link.setBounds(r);
perm.getLinks().add(link);
r.translate(8, 10);
if (index == 1) {
r.translate(ATTACHMENTS_DX_OFFSET, ATTACHMENT_DY_OFFSET); // do it once
} else {
r.translate(ATTACHMENT_DX_OFFSET, ATTACHMENT_DY_OFFSET);
}
perm.setBounds(r);
jLayeredPane.moveToFront(link);
jLayeredPane.moveToFront(perm);

View file

@ -47,6 +47,8 @@ public class CardPluginImpl implements CardPlugin {
private static final Logger log = Logger.getLogger(CardPluginImpl.class);
private static final int ATTACHMENT_DY_OFFSET = 10;
private static final int GUTTER_Y = 15;
private static final int GUTTER_X = 5;
static final float EXTRA_CARD_SPACING_X = 0.04f;
@ -373,6 +375,9 @@ public class CardPluginImpl implements CardPlugin {
}
Stack stack = new Stack();
stack.add(panel);
if (panel.getOriginalPermanent().getAttachments() != null) {
stack.setMaxAttachedCount(panel.getOriginalPermanent().getAttachments().size());
}
add(stack);
}
}
@ -410,6 +415,11 @@ public class CardPluginImpl implements CardPlugin {
private class Stack extends ArrayList<MagePermanent> {
private static final long serialVersionUID = 1L;
/**
* Max attached object count attached to single permanent in the stack.
*/
private int maxAttachedCount = 0;
public Stack() {
super(8);
}
@ -419,7 +429,15 @@ public class CardPluginImpl implements CardPlugin {
}
private int getHeight() {
return cardHeight + (size() - 1) * stackSpacingY + cardSpacingY;
return cardHeight + (size() - 1) * stackSpacingY + cardSpacingY + ATTACHMENT_DY_OFFSET*maxAttachedCount;
}
public int getMaxAttachedCount() {
return maxAttachedCount;
}
public void setMaxAttachedCount(int maxAttachedCount) {
this.maxAttachedCount = maxAttachedCount;
}
}