Some more changes to GUI to better support high screen resolutions.

This commit is contained in:
LevelX2 2016-02-13 02:30:05 +01:00
parent 1c2faaadde
commit 7ef0a0a7f0
31 changed files with 745 additions and 518 deletions

View file

@ -67,7 +67,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private static final long serialVersionUID = -3272134219262184410L;
private static final Logger logger = Logger.getLogger(CardPanel.class);
private static final Logger LOGGER = Logger.getLogger(CardPanel.class);
private static final int WIDTH_LIMIT = 90; // card width limit to create smaller counter
public static final double TAPPED_ANGLE = Math.PI / 2;
@ -161,13 +161,14 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
this.gameCard = newGameCard;
this.callback = callback;
this.gameId = gameId;
this.setCardBounds(0, 0, dimension.width, dimension.height);
this.isPermanent = this.gameCard instanceof PermanentView;
this.isPermanent = this.gameCard instanceof PermanentView;
if (isPermanent) {
this.hasSickness = ((PermanentView) this.gameCard).hasSummoningSickness();
}
this.setCardBounds(0, 0, dimension.width, dimension.height);
//for container debug (don't remove)
//setBorder(BorderFactory.createLineBorder(Color.green));
if (this.gameCard.canTransform()) {
@ -271,9 +272,11 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
addComponentListener(this);
displayTitleAnyway = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_CARD_NAMES, "true").equals("true");
titleText = new GlowText();
setText(gameCard);
titleText.setFont(getFont().deriveFont(Font.BOLD, 13f));
int fontSize = (int) dimension.getHeight() / 11;
titleText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
titleText.setForeground(Color.white);
titleText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY);
titleText.setWrap(true);
@ -285,7 +288,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
} else if (CardUtil.isPlaneswalker(gameCard)) {
ptText.setText(gameCard.getLoyalty());
}
ptText.setFont(getFont().deriveFont(Font.BOLD, 13f));
ptText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
ptText.setForeground(Color.white);
ptText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY);
add(ptText);
@ -330,9 +333,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
}
setText(gameCard);
} catch (Exception e) {
logger.fatal("Problem during image animation", e);
LOGGER.fatal("Problem during image animation", e);
} catch (Error err) {
logger.error("Problem during image animation", err);
LOGGER.error("Problem during image animation", err);
}
}
});
@ -613,32 +616,49 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
public final void setCardBounds(int x, int y, int cardWidth, int cardHeight) {
this.cardWidth = cardWidth;
this.cardHeight = cardHeight;
int rotCenterX = Math.round(cardWidth / 2f);
int rotCenterY = cardHeight - rotCenterX;
int rotCenterToTopCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_TOP_CORNER);
int rotCenterToBottomCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_BOTTOM_CORNER);
int xOffset = getXOffset(cardWidth);
int yOffset = getYOffset(cardWidth, cardHeight);
cardXOffset = -xOffset;
cardYOffset = -yOffset;
int width = -xOffset + rotCenterX + rotCenterToTopCorner;
int height = -yOffset + rotCenterY + rotCenterToBottomCorner;
setBounds(x + xOffset, y + yOffset, width, height);
if (this.isPermanent) {
int rotCenterX = Math.round(cardWidth / 2f);
int rotCenterY = cardHeight - rotCenterX;
int rotCenterToTopCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_TOP_CORNER);
int rotCenterToBottomCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_BOTTOM_CORNER);
int xOffset = getXOffset(cardWidth);
int yOffset = getYOffset(cardWidth, cardHeight);
cardXOffset = -xOffset;
cardYOffset = -yOffset;
int width = -xOffset + rotCenterX + rotCenterToTopCorner;
int height = -yOffset + rotCenterY + rotCenterToBottomCorner;
setBounds(x + xOffset, y + yOffset, width, height);
} else {
cardXOffset = 5;
cardYOffset = 5;
int width = cardXOffset * 2 + cardWidth;
int height = cardYOffset * 2 + cardHeight;
setBounds(x - cardXOffset, y - cardYOffset, width, height);
}
}
public int getXOffset(int cardWidth) {
int rotCenterX = Math.round(cardWidth / 2f);
int rotCenterToBottomCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_BOTTOM_CORNER);
int xOffset = rotCenterX - rotCenterToBottomCorner;
return xOffset;
if (this.isPermanent) {
int rotCenterX = Math.round(cardWidth / 2f);
int rotCenterToBottomCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_BOTTOM_CORNER);
int xOffset = rotCenterX - rotCenterToBottomCorner;
return xOffset;
} else {
return cardXOffset;
}
}
public int getYOffset(int cardWidth, int cardHeight) {
int rotCenterX = Math.round(cardWidth / 2f);
int rotCenterY = cardHeight - rotCenterX;
int rotCenterToTopCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_TOP_CORNER);
int yOffset = rotCenterY - rotCenterToTopCorner;
return yOffset;
if (this.isPermanent) {
int rotCenterX = Math.round(cardWidth / 2f);
int rotCenterY = cardHeight - rotCenterX;
int rotCenterToTopCorner = Math.round(cardWidth * CardPanel.ROT_CENTER_TO_TOP_CORNER);
int yOffset = rotCenterY - rotCenterToTopCorner;
return yOffset;
} else {
return cardYOffset;
}
}
public int getCardX() {
@ -728,12 +748,10 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
} else {
return ImageCache.getManifestImage();
}
} else if (this.gameCard instanceof StackAbilityView) {
return ImageCache.getMorphImage();
} else {
if (this.gameCard instanceof StackAbilityView) {
return ImageCache.getMorphImage();
} else {
return ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));
}
return ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));
}
}
@ -1145,7 +1163,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
dayNightButton.setIcon(new ImageIcon(night));
}
if (this.gameCard.getSecondCardFace() == null) {
logger.error("no second side for card to transform!");
LOGGER.error("no second side for card to transform!");
return;
}
if (!isPermanent) { // use only for custom transformation (when pressing day-night button)

View file

@ -14,7 +14,7 @@ import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import mage.cards.repository.ExpansionRepository;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.FontSizeHelper;
import mage.client.util.GUISizeHelper;
import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
import org.apache.log4j.Logger;
@ -40,7 +40,7 @@ public class ManaSymbols {
for (String symbol : symbols) {
String resourcePath = Constants.RESOURCE_PATH_MANA_SMALL;
switch (FontSizeHelper.basicSymbolSize) {
switch (GUISizeHelper.basicSymbolSize) {
case "medium":
resourcePath = Constants.RESOURCE_PATH_MANA_SMALL;
break;
@ -50,11 +50,11 @@ public class ManaSymbols {
}
File file = new File(getSymbolsPath() + resourcePath + "/" + symbol + ".jpg");
try {
if (FontSizeHelper.symbolPaySize != 15) {
if (GUISizeHelper.symbolPaySize != 15) {
BufferedImage notResized = ImageIO.read(file);
MANA_IMAGES.put(symbol, notResized);
} else {
Rectangle r = new Rectangle(FontSizeHelper.symbolPaySize, FontSizeHelper.symbolPaySize);
Rectangle r = new Rectangle(GUISizeHelper.symbolPaySize, GUISizeHelper.symbolPaySize);
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
MANA_IMAGES.put(symbol, resized);
@ -224,23 +224,23 @@ public class ManaSymbols {
int symbolSize;
switch (type) {
case TOOLTIP:
symbolSize = FontSizeHelper.symbolTooltipSize;
symbolSize = GUISizeHelper.symbolTooltipSize;
break;
case CARD:
symbolSize = FontSizeHelper.symbolCardSize;
symbolSize = GUISizeHelper.symbolCardSize;
break;
case PAY:
symbolSize = FontSizeHelper.symbolPaySize;
symbolSize = GUISizeHelper.symbolPaySize;
break;
case EDITOR:
symbolSize = FontSizeHelper.symbolEditorSize;
symbolSize = GUISizeHelper.symbolEditorSize;
break;
default:
symbolSize = 11;
break;
}
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
+ "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' width="
+ "/symbols/" + GUISizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' width="
+ symbolSize + " height=" + symbolSize + ">");
}

View file

@ -97,9 +97,9 @@ public class CardPluginImpl implements CardPlugin {
}
@Override
public MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
CardPanel cardPanel = new CardPanel(permanent, gameId, loadImage, callback, false, dimension);
boolean implemented = permanent.getRarity() != null && !permanent.getRarity().equals(Rarity.NA);
public MagePermanent getMageCard(CardView cardView, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
CardPanel cardPanel = new CardPanel(cardView, gameId, loadImage, callback, false, dimension);
boolean implemented = cardView.getRarity() != null && !cardView.getRarity().equals(Rarity.NA);
cardPanel.setShowCastingCost(implemented);
return cardPanel;
}