GUI: Improved rendering of Class cards (#11767)

This commit is contained in:
Matthew Wilson 2024-02-09 09:58:16 +02:00 committed by GitHub
parent 506e94d519
commit 41dbec4dbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 19 deletions

View file

@ -430,6 +430,15 @@ public class TestCardRenderDialog extends MageDialog {
cardViews.add(createHandCard(game, playerYou.getId(), "MKM", "155")); // Case of the Locked Hothouse
//*/
//* test case, class and saga cards in hands
cardViews.add(createHandCard(game, playerYou.getId(), "MKM", "113")); // Case of the Burning Masks
cardViews.add(createHandCard(game, playerYou.getId(), "MKM", "155")); // Case of the Locked Hothouse
cardViews.add(createHandCard(game, playerYou.getId(), "AFR", "6")); // Cleric Class
cardViews.add(createHandCard(game, playerYou.getId(), "AFR", "230")); // Rogue Class
cardViews.add(createHandCard(game, playerYou.getId(), "DOM", "90")); // The Eldest Reborn
cardViews.add(createHandCard(game, playerYou.getId(), "MH2", "259")); // Urza's Saga
//*/
/* test meld cards in hands and battlefield
cardViews.add(createHandCard(game, playerYou.getId(), "EMN", "204")); // Hanweir Battlements
cardViews.add(createHandCard(game, playerYou.getId(), "EMN", "130a")); // Hanweir Garrison

View file

@ -337,12 +337,11 @@ public class ModernCardRenderer extends CardRenderer {
rect = new Rectangle2D.Float(.079f, .11f, .84f, .84f);
} else if (isUnstableFullArtLand()) {
rect = new Rectangle2D.Float(.0f, .0f, 1.0f, 1.0f);
} else if (cardView.getArtRect() == ArtRect.FULL_LENGTH_LEFT ||
cardView.getArtRect() == ArtRect.FULL_LENGTH_RIGHT) {
rect = cardView.getArtRect().rect;
} else if (cardView.getFrameStyle().isFullArt() || (cardView.isToken())) {
rect = new Rectangle2D.Float(.079f, .11f, .84f, .63f);
} else if (cardView.getSubTypes().contains(SubType.SAGA)) {
rect = ArtRect.SAGA.rect;
} else if (cardView.getSubTypes().contains(SubType.CASE)) {
rect = ArtRect.CASE.rect;
} else {
rect = ArtRect.NORMAL.rect;
}
@ -354,8 +353,8 @@ public class ModernCardRenderer extends CardRenderer {
return TYPE_LINE_Y_FRAC_TOKEN;
} else if (cardView.getFrameStyle().isFullArt()) {
return TYPE_LINE_Y_FRAC_FULL_ART;
} else if (cardView.getSubTypes().contains(SubType.SAGA) ||
cardView.getSubTypes().contains(SubType.CASE)) {
} else if (cardView.getArtRect() == ArtRect.FULL_LENGTH_LEFT ||
cardView.getArtRect() == ArtRect.FULL_LENGTH_RIGHT) {
return TYPE_LINE_Y_FRAC_BOTTOM;
} else {
return TYPE_LINE_Y_FRAC;
@ -429,12 +428,12 @@ public class ModernCardRenderer extends CardRenderer {
contentWidth - 2, typeLineY - totalContentInset - boxHeight,
alternate_height,
sourceRect, shouldPreserveAspect);
} else if (cardView.getSubTypes().contains(SubType.SAGA)) {
} else if (cardView.getArtRect() == ArtRect.FULL_LENGTH_RIGHT) {
drawArtIntoRect(g,
contentWidth / 2 + totalContentInset + 1, totalContentInset + boxHeight,
contentWidth / 2 - 1, typeLineY - totalContentInset - boxHeight,
sourceRect, false);
} else if (cardView.getSubTypes().contains(SubType.CASE)) {
} else if (cardView.getArtRect() == ArtRect.FULL_LENGTH_LEFT) {
drawArtIntoRect(g,
totalContentInset + 1, totalContentInset + boxHeight,
contentWidth / 2 - 1, typeLineY - totalContentInset - boxHeight,
@ -489,10 +488,10 @@ public class ModernCardRenderer extends CardRenderer {
g.setPaint(textboxPaint);
}
if (cardView.getSubTypes().contains(SubType.SAGA)) {
if (cardView.getArtRect() == ArtRect.FULL_LENGTH_RIGHT) {
g.fillRect(totalContentInset + 2, totalContentInset + boxHeight,
contentWidth / 2 - 2, typeLineY - totalContentInset - boxHeight + 2);
} else if (cardView.getSubTypes().contains(SubType.CASE)) {
} else if (cardView.getArtRect() == ArtRect.FULL_LENGTH_LEFT) {
g.fillRect(contentWidth / 2 + totalContentInset + 1, totalContentInset + boxHeight,
contentWidth / 2 - 2, typeLineY - totalContentInset - boxHeight + 2);
} else if (!isZenUst) {
@ -690,11 +689,11 @@ public class ModernCardRenderer extends CardRenderer {
drawUSTCurves(g, image, x, y, w, h,
0, 0,
additionalBoxColor, borderPaint);
} else if (cardView.getSubTypes().contains(SubType.SAGA)) {
} else if (cardView.getArtRect() == ArtRect.FULL_LENGTH_RIGHT) {
drawRulesText(g, textboxKeywords, textboxRules,
totalContentInset + 4, totalContentInset + boxHeight + 2,
contentWidth / 2 - 8, typeLineY - totalContentInset - boxHeight - 6, false);
} else if (cardView.getSubTypes().contains(SubType.CASE)) {
} else if (cardView.getArtRect() == ArtRect.FULL_LENGTH_LEFT) {
drawRulesText(g, textboxKeywords, textboxRules,
contentWidth / 2 + totalContentInset + 4, totalContentInset + boxHeight + 2,
contentWidth / 2 - 8, typeLineY - totalContentInset - boxHeight - 6, false);

View file

@ -536,7 +536,6 @@ public class CardView extends SimpleCardView {
// Determine what part of the art to slice out for spells on the stack which originate
// from a split, fuse, or aftermath split card.
// Modal double faces cards draws as normal cards
// Sagas and cases have completely different layouts
SpellAbilityType ty = spell.getSpellAbility().getSpellAbilityType();
if (ty == SpellAbilityType.SPLIT_RIGHT || ty == SpellAbilityType.SPLIT_LEFT || ty == SpellAbilityType.SPLIT_FUSED) {
// Needs a special art rect
@ -557,10 +556,6 @@ public class CardView extends SimpleCardView {
artRect = ArtRect.SPLIT_LEFT;
}
}
} else if (spell.getSubtype().contains(SubType.SAGA)) {
artRect = ArtRect.SAGA;
} else if (spell.getSubtype().contains(SubType.CASE)) {
artRect = ArtRect.CASE;
}
// show for modal spell, which mode was chosen
@ -589,6 +584,14 @@ public class CardView extends SimpleCardView {
}
}
// Cases, classes and sagas have portrait art
if (card.getSubtype().contains(SubType.CASE) ||
card.getSubtype().contains(SubType.CLASS)) {
artRect = ArtRect.FULL_LENGTH_LEFT;
} else if (card.getSubtype().contains(SubType.SAGA)) {
artRect = ArtRect.FULL_LENGTH_RIGHT;
}
// Frame color
this.frameColor = card.getFrameColor(game).copy();
@ -801,6 +804,12 @@ public class CardView extends SimpleCardView {
this.rules = new ArrayList<>();
this.rules.add(stackAbility.getRule());
}
if (object.getSubtype().contains(SubType.CASE) ||
object.getSubtype().contains(SubType.CLASS)) {
artRect = ArtRect.FULL_LENGTH_LEFT;
} else if (object.getSubtype().contains(SubType.SAGA)) {
artRect = ArtRect.FULL_LENGTH_RIGHT;
}
// Frame color
this.frameColor = object.getFrameColor(game).copy();
// Frame style

View file

@ -12,8 +12,8 @@ public enum ArtRect {
SPLIT_LEFT(new Rectangle2D.Double(0.152, 0.539, 0.386, 0.400)),
SPLIT_RIGHT(new Rectangle2D.Double(0.152, 0.058, 0.386, 0.400)),
SPLIT_FUSED(null),
SAGA(new Rectangle2D.Double(0.497, 0.11, 0.426, 0.727)),
CASE(new Rectangle2D.Double(0.069, 0.11, 0.426, 0.727));
FULL_LENGTH_LEFT(new Rectangle2D.Double(0.069, 0.11, 0.426, 0.727)),
FULL_LENGTH_RIGHT(new Rectangle2D.Double(0.497, 0.11, 0.426, 0.727));
public final Rectangle2D rect;