GUI: improved rendering of Saga and Case cards (#11762)

Co-authored-by: Matthew Wilson <matthew_w@vaadin.com>
This commit is contained in:
Matthew Wilson 2024-02-06 10:33:11 +02:00 committed by GitHub
parent c4e0d64428
commit e1968a6b5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 41 additions and 2 deletions

View file

@ -171,6 +171,7 @@ public class ModernCardRenderer extends CardRenderer {
protected static final float TYPE_LINE_Y_FRAC = 0.57f; // x cardHeight
protected static final float TYPE_LINE_Y_FRAC_TOKEN = 0.70f;
protected static final float TYPE_LINE_Y_FRAC_FULL_ART = 0.74f;
protected static final float TYPE_LINE_Y_FRAC_BOTTOM = 0.89f;
protected int typeLineY;
// Possible sizes of rules text font
@ -329,6 +330,10 @@ public class ModernCardRenderer extends CardRenderer {
rect = new Rectangle2D.Float(.0f, .0f, 1.0f, 1.0f);
} 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;
}
@ -340,6 +345,9 @@ 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)) {
return TYPE_LINE_Y_FRAC_BOTTOM;
} else {
return TYPE_LINE_Y_FRAC;
}
@ -424,6 +432,16 @@ public class ModernCardRenderer extends CardRenderer {
contentWidth - 2, typeLineY - totalContentInset - boxHeight,
alternate_height,
sourceRect, shouldPreserveAspect);
} else if (cardView.getSubTypes().contains(SubType.SAGA)) {
drawArtIntoRect(g,
contentWidth / 2 + totalContentInset + 1, totalContentInset + boxHeight,
contentWidth / 2 - 1, typeLineY - totalContentInset - boxHeight,
sourceRect, false);
} else if (cardView.getSubTypes().contains(SubType.CASE)) {
drawArtIntoRect(g,
totalContentInset + 1, totalContentInset + boxHeight,
contentWidth / 2 - 1, typeLineY - totalContentInset - boxHeight,
sourceRect, false);
} else if (!isZendikarFullArtLand()) {
drawArtIntoRect(g,
totalContentInset + 1, totalContentInset + boxHeight,
@ -474,7 +492,13 @@ public class ModernCardRenderer extends CardRenderer {
g.setPaint(textboxPaint);
}
if (!isZenUst) {
if (cardView.getSubTypes().contains(SubType.SAGA)) {
g.fillRect(totalContentInset + 2, totalContentInset + boxHeight,
contentWidth / 2 - 2, typeLineY - totalContentInset - boxHeight + 2);
} else if (cardView.getSubTypes().contains(SubType.CASE)) {
g.fillRect(contentWidth / 2 + totalContentInset + 1, totalContentInset + boxHeight,
contentWidth / 2 - 2, typeLineY - totalContentInset - boxHeight + 2);
} else if (!isZenUst) {
if (cardView.getCardTypes().contains(CardType.LAND)) {
int total_height_of_box = cardHeight - borderWidth * 3 - typeLineY - 2 - boxHeight;
@ -669,6 +693,14 @@ public class ModernCardRenderer extends CardRenderer {
drawUSTCurves(g, image, x, y, w, h,
0, 0,
additionalBoxColor, borderPaint);
} else if (cardView.getSubTypes().contains(SubType.SAGA)) {
drawRulesText(g, textboxKeywords, textboxRules,
totalContentInset + 4, totalContentInset + boxHeight + 2,
contentWidth / 2 - 8, typeLineY - totalContentInset - boxHeight - 6, false);
} else if (cardView.getSubTypes().contains(SubType.CASE)) {
drawRulesText(g, textboxKeywords, textboxRules,
contentWidth / 2 + totalContentInset + 4, totalContentInset + boxHeight + 2,
contentWidth / 2 - 8, typeLineY - totalContentInset - boxHeight - 6, false);
} else if (!isZenUst) {
drawRulesText(g, textboxKeywords, textboxRules,
totalContentInset + 2, typeLineY + boxHeight + 2,