forked from External/mage
Some more changes to GUI to better support high screen resolutions.
This commit is contained in:
parent
2ce5e00c6d
commit
706d319f81
25 changed files with 376 additions and 229 deletions
|
|
@ -24,7 +24,6 @@ public class ManaSymbols {
|
|||
|
||||
private static final Logger LOGGER = Logger.getLogger(ManaSymbols.class);
|
||||
private static final Map<String, BufferedImage> MANA_IMAGES = new HashMap<>();
|
||||
private static final Map<String, Image> MANA_IMAGES_ORIGINAL = new HashMap<>();
|
||||
private static final Map<String, Image> SET_IMAGES = new HashMap<>();
|
||||
private static final Map<String, Dimension> SET_IMAGES_EXIST = new HashMap<>();
|
||||
private static final Pattern REPLACE_SYMBOLS_PATTERN = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}");
|
||||
|
|
@ -35,23 +34,36 @@ public class ManaSymbols {
|
|||
"BR", "G", "GU", "GW", "R", "RG", "RW", "S", "T", "U", "UB", "UR", "W", "WB", "WU",
|
||||
"WP", "UP", "BP", "RP", "GP", "X", "C" /*, "Y", "Z", "slash"*/};
|
||||
|
||||
MANA_IMAGES.clear();
|
||||
SET_IMAGES.clear();
|
||||
SET_IMAGES_EXIST.clear();
|
||||
|
||||
for (String symbol : symbols) {
|
||||
File file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_MANA_MEDIUM + "/" + symbol + ".jpg");
|
||||
Rectangle r = new Rectangle(11, 11);
|
||||
String resourcePath = Constants.RESOURCE_PATH_MANA_SMALL;
|
||||
switch (FontSizeHelper.basicSymbolSize) {
|
||||
case "medium":
|
||||
resourcePath = Constants.RESOURCE_PATH_MANA_SMALL;
|
||||
break;
|
||||
case "large":
|
||||
resourcePath = Constants.RESOURCE_PATH_MANA_LARGE;
|
||||
break;
|
||||
}
|
||||
File file = new File(getSymbolsPath() + resourcePath + "/" + symbol + ".jpg");
|
||||
try {
|
||||
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
|
||||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
MANA_IMAGES.put(symbol, resized);
|
||||
if (FontSizeHelper.symbolPaySize != 15) {
|
||||
BufferedImage notResized = ImageIO.read(file);
|
||||
MANA_IMAGES.put(symbol, notResized);
|
||||
} else {
|
||||
Rectangle r = new Rectangle(FontSizeHelper.symbolPaySize, FontSizeHelper.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);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error for symbol:" + symbol);
|
||||
}
|
||||
file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_MANA_MEDIUM + "/" + symbol + ".jpg");
|
||||
try {
|
||||
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
|
||||
MANA_IMAGES_ORIGINAL.put(symbol, image);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> setCodes = ExpansionRepository.instance.getSetCodes();
|
||||
if (setCodes == null) {
|
||||
// the cards db file is probaly not included in the client. It will be created after the first connect to a server.
|
||||
|
|
@ -158,10 +170,6 @@ public class ManaSymbols {
|
|||
return path;
|
||||
}
|
||||
|
||||
public static Image getManaSymbolImage(String symbol) {
|
||||
return MANA_IMAGES_ORIGINAL.get(symbol);
|
||||
}
|
||||
|
||||
public static void draw(Graphics g, String manaCost, int x, int y) {
|
||||
if (manaCost.length() == 0) {
|
||||
return;
|
||||
|
|
@ -201,9 +209,9 @@ public class ManaSymbols {
|
|||
}
|
||||
|
||||
public enum Type {
|
||||
|
||||
CARD,
|
||||
TOOLTIP,
|
||||
EDITOR,
|
||||
PAY
|
||||
}
|
||||
|
||||
|
|
@ -213,28 +221,28 @@ public class ManaSymbols {
|
|||
String replaced = value;
|
||||
|
||||
if (!MANA_IMAGES.isEmpty()) {
|
||||
int symbolSize;
|
||||
switch (type) {
|
||||
case TOOLTIP:
|
||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true) + "/symbols/small/$1$2.jpg' alt='$1$2' width=11 height=11>");
|
||||
// replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
|
||||
// + "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' width="
|
||||
// + FontSizeHelper.symbolTooltipSize + " height=" + FontSizeHelper.symbolTooltipSize + ">");
|
||||
symbolSize = FontSizeHelper.symbolTooltipSize;
|
||||
break;
|
||||
case CARD:
|
||||
value = value.replace("{slash}", "<img src='file:" + getSymbolsPath() + "/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
|
||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
|
||||
+ "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' width="
|
||||
+ FontSizeHelper.symbolCardSize + " height=" + FontSizeHelper.symbolCardSize + ">");
|
||||
symbolSize = FontSizeHelper.symbolCardSize;
|
||||
break;
|
||||
case PAY:
|
||||
value = value.replace("{slash}", "<img src='file:" + getSymbolsPath() + "/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
|
||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
|
||||
+ "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' "
|
||||
+ "width=" + FontSizeHelper.symbolPaySize + " height=" + FontSizeHelper.symbolPaySize + ">");
|
||||
symbolSize = FontSizeHelper.symbolPaySize;
|
||||
break;
|
||||
case EDITOR:
|
||||
symbolSize = FontSizeHelper.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="
|
||||
+ symbolSize + " height=" + symbolSize + ">");
|
||||
|
||||
}
|
||||
replaced = replaced.replace("|source|", "{source}");
|
||||
replaced = replaced.replace("|this|", "{this}");
|
||||
|
|
@ -256,7 +264,7 @@ public class ManaSymbols {
|
|||
return SET_IMAGES.get(set);
|
||||
}
|
||||
|
||||
public static BufferedImage getManaSymbolImageSmall(String symbol) {
|
||||
public static BufferedImage getSizedManaSymbol(String symbol) {
|
||||
return MANA_IMAGES.get(symbol);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package org.mage.plugins.card;
|
|||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
|
@ -31,7 +30,6 @@ import net.xeoh.plugins.base.annotations.meta.Author;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.Animation;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
import org.mage.plugins.card.constants.Constants;
|
||||
import org.mage.plugins.card.dl.DownloadGui;
|
||||
import org.mage.plugins.card.dl.DownloadJob;
|
||||
|
|
@ -48,14 +46,15 @@ import org.mage.plugins.card.info.CardInfoPaneImpl;
|
|||
*
|
||||
* @author nantuko
|
||||
* @version 0.1 01.11.2010 Mage permanents. Sorting card layout.
|
||||
* @version 0.6 17.07.2011 #sortPermanents got option to display non-land permanents in one pile
|
||||
* @version 0.6 17.07.2011 #sortPermanents got option to display non-land
|
||||
* permanents in one pile
|
||||
* @version 0.7 29.07.2011 face down cards support
|
||||
*/
|
||||
@PluginImplementation
|
||||
@Author(name = "nantuko")
|
||||
public class CardPluginImpl implements CardPlugin {
|
||||
|
||||
private static final Logger log = Logger.getLogger(CardPluginImpl.class);
|
||||
private static final Logger LOGGER = Logger.getLogger(CardPluginImpl.class);
|
||||
|
||||
private static final int GUTTER_Y = 15;
|
||||
private static final int GUTTER_X = 5;
|
||||
|
|
@ -81,7 +80,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
|
||||
@PluginLoaded
|
||||
public void newPlugin(CardPlugin plugin) {
|
||||
log.info(plugin.toString() + " has been loaded.");
|
||||
LOGGER.info(plugin.toString() + " has been loaded.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -398,6 +397,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
private class Row extends ArrayList<Stack> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Row() {
|
||||
|
|
@ -458,6 +458,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
private class Stack extends ArrayList<MagePermanent> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
|
@ -474,7 +475,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
private int getHeight() {
|
||||
return cardHeight + (size() - 1) * stackSpacingY + cardSpacingY + attachmentSpacingY*maxAttachedCount;
|
||||
return cardHeight + (size() - 1) * stackSpacingY + cardSpacingY + attachmentSpacingY * maxAttachedCount;
|
||||
}
|
||||
|
||||
public int getMaxAttachedCount() {
|
||||
|
|
@ -489,7 +490,8 @@ public class CardPluginImpl implements CardPlugin {
|
|||
/**
|
||||
* Download various symbols (mana, tap, set).
|
||||
*
|
||||
* @param imagesPath Path to check in and store symbols to. Can be null, in such case default path should be used.
|
||||
* @param imagesPath Path to check in and store symbols to. Can be null, in
|
||||
* such case default path should be used.
|
||||
*/
|
||||
@Override
|
||||
public void downloadSymbols(String imagesPath) {
|
||||
|
|
@ -502,17 +504,17 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
it = new GathererSets(imagesPath);
|
||||
for(DownloadJob job:it) {
|
||||
g.getDownloader().add(job);
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
}
|
||||
|
||||
it = new CardFrames(imagesPath);
|
||||
for(DownloadJob job:it) {
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
}
|
||||
|
||||
it = new DirectLinksForDownload(imagesPath);
|
||||
for(DownloadJob job:it) {
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
}
|
||||
|
||||
|
|
@ -530,11 +532,6 @@ public class CardPluginImpl implements CardPlugin {
|
|||
d.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getManaSymbolImage(String symbol) {
|
||||
return ManaSymbols.getManaSymbolImage(symbol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddCard(MagePermanent card, int count) {
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -4,22 +4,26 @@ import java.awt.Rectangle;
|
|||
import java.io.File;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String RESOURCE_PATH_SET = File.separator + "sets" + File.separator;
|
||||
|
||||
public static final String RESOURCE_PATH_MANA_SMALL = File.separator + "symbols" + File.separator + "small";
|
||||
public static final String RESOURCE_PATH_MANA_LARGE = File.separator + "symbols" + File.separator + "large";
|
||||
public static final String RESOURCE_PATH_MANA_MEDIUM = File.separator + "symbols" + File.separator + "medium";
|
||||
|
||||
public static final String RESOURCE_PATH_SET = File.separator + "sets" + File.separator;
|
||||
public static final String RESOURCE_PATH_SET_SMALL = RESOURCE_PATH_SET + File.separator + "small" + File.separator;
|
||||
|
||||
public static final Rectangle CARD_SIZE_FULL = new Rectangle(101, 149);
|
||||
public static final Rectangle THUMBNAIL_SIZE_FULL = new Rectangle(102, 146);
|
||||
|
||||
|
||||
public static final int TOOLTIP_WIDTH_MIN = 320;
|
||||
public static final int TOOLTIP_HEIGHT_MIN = 201;
|
||||
|
||||
public static final int TOOLTIP_HEIGHT_MAX = 401;
|
||||
public static final int TOOLTIP_BORDER_WIDTH = 80;
|
||||
|
||||
public interface IO {
|
||||
public interface IO {
|
||||
|
||||
String imageBaseDir = "plugins" + File.separator + "images";
|
||||
String IMAGE_PROPERTIES_FILE = "image.url.properties";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue