forked from External/mage
Refactor resource paths and constants:
- delete duplicate consts; - correct paths and it uses; - fix loading icons from user defined dir;
This commit is contained in:
parent
5cda60270c
commit
f400cd5231
7 changed files with 42 additions and 47 deletions
|
|
@ -1,25 +0,0 @@
|
|||
package org.mage.plugins.card.constants;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.io.File;
|
||||
|
||||
public final class Constants {
|
||||
|
||||
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_MANA_SVG = File.separator + "symbols" + File.separator + "svg";
|
||||
|
||||
public static final String RESOURCE_PATH_SET = File.separator + "sets";
|
||||
public static final String RESOURCE_PATH_SET_SMALL = RESOURCE_PATH_SET + File.separator + "small";
|
||||
|
||||
public static final Rectangle CARD_SIZE_FULL = new Rectangle(101, 149);
|
||||
public static final Rectangle THUMBNAIL_SIZE_FULL = new Rectangle(102, 146);
|
||||
|
||||
public interface IO {
|
||||
String imageBaseDir = "plugins" + File.separator + "images";
|
||||
String IMAGE_PROPERTIES_FILE = "image.url.properties";
|
||||
}
|
||||
|
||||
public static final String CARD_IMAGE_PATH_TEMPLATE = '.' + File.separator + "plugins" + File.separator + "images/{set}/{name}.{collector}.full.jpg";
|
||||
}
|
||||
|
|
@ -31,9 +31,6 @@ import mage.client.constants.Constants;
|
|||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.sets.ConstructedFormats;
|
||||
import mage.remote.Connection;
|
||||
import static mage.remote.Connection.ProxyType.HTTP;
|
||||
import static mage.remote.Connection.ProxyType.NONE;
|
||||
import static mage.remote.Connection.ProxyType.SOCKS;
|
||||
import net.java.truevfs.access.TFile;
|
||||
import net.java.truevfs.access.TFileOutputStream;
|
||||
import net.java.truevfs.access.TVFS;
|
||||
|
|
@ -544,7 +541,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
public void run() {
|
||||
this.cardIndex = 0;
|
||||
|
||||
File base = new File(Constants.IO.imageBaseDir);
|
||||
File base = new File(Constants.IO.DEFAULT_IMAGES_DIR);
|
||||
if (!base.exists()) {
|
||||
base.mkdir();
|
||||
}
|
||||
|
|
@ -682,7 +679,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
File temporaryFile = null;
|
||||
TFile outputFile = null;
|
||||
try {
|
||||
filePath.append(Constants.IO.imageBaseDir);
|
||||
filePath.append(Constants.IO.DEFAULT_IMAGES_DIR);
|
||||
if (!useSpecifiedPaths && card != null) {
|
||||
filePath.append(card.hashCode()).append('.').append(card.getName().replace(":", "").replace("//", "-")).append(".jpg");
|
||||
temporaryFile = new File(filePath.toString());
|
||||
|
|
@ -694,7 +691,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
} else if (card != null) {
|
||||
imagePath = CardImageUtils.getImageBasePath() + actualFilename;
|
||||
} else {
|
||||
imagePath = Constants.IO.imageBaseDir;
|
||||
imagePath = Constants.IO.DEFAULT_IMAGES_DIR;
|
||||
}
|
||||
|
||||
String tmpFile = filePath + "temporary" + actualFilename;
|
||||
|
|
@ -823,7 +820,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
|
||||
iwp.setCompressionQuality(0.96f);
|
||||
|
||||
File tempFile = new File(Constants.IO.imageBaseDir + File.separator + image.hashCode() + file.getName());
|
||||
File tempFile = new File(Constants.IO.DEFAULT_IMAGES_DIR + File.separator + image.hashCode() + file.getName());
|
||||
FileImageOutputStream output = new FileImageOutputStream(tempFile);
|
||||
writer.setOutput(output);
|
||||
IIOImage image2 = new IIOImage(image, null, null);
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ import net.java.truevfs.access.TFile;
|
|||
import net.java.truevfs.access.TFileInputStream;
|
||||
import net.java.truevfs.access.TFileOutputStream;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.constants.Constants;
|
||||
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
|
||||
import org.mage.plugins.card.utils.CardImageUtils;
|
||||
import mage.client.constants.Constants;
|
||||
|
||||
/**
|
||||
* This class stores ALL card images in a cache with soft values. this means
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import org.mage.plugins.card.constants.Constants;
|
||||
import mage.client.constants.Constants;
|
||||
|
||||
public class SettingsManager {
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public final class CardImageUtils {
|
|||
return "";
|
||||
}
|
||||
String set = updateSet(card.getSet(), false).toUpperCase();
|
||||
String imagesDir = (imagesPath != null ? imagesPath : Constants.IO.imageBaseDir);
|
||||
String imagesDir = (imagesPath != null ? imagesPath : Constants.IO.DEFAULT_IMAGES_DIR);
|
||||
if (card.isToken()) {
|
||||
return buildTokenPath(imagesDir, set);
|
||||
} else {
|
||||
|
|
@ -136,7 +136,7 @@ public final class CardImageUtils {
|
|||
|
||||
public static String getImageBasePath() {
|
||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
String imagesPath = Objects.equals(useDefault, "true") ? Constants.IO.imageBaseDir : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
String imagesPath = Objects.equals(useDefault, "true") ? Constants.IO.DEFAULT_IMAGES_DIR : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
|
||||
if (imagesPath != null && !imagesPath.endsWith(TFile.separator)) {
|
||||
imagesPath += TFile.separator;
|
||||
|
|
@ -206,7 +206,7 @@ public final class CardImageUtils {
|
|||
|
||||
public static String generateFaceImagePath(String cardname, String set) {
|
||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
String imagesPath = Objects.equals(useDefault, "true") ? Constants.IO.imageBaseDir : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
String imagesPath = Objects.equals(useDefault, "true") ? Constants.IO.DEFAULT_IMAGES_DIR : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
String imageDir = imagesPath;
|
||||
String imageName = set + TFile.separator + cardname + ".jpg";
|
||||
return imageDir + TFile.separator + "FACE" + TFile.separator + imageName;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue