mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
GUI: added missing image info in card popup hint (works in any render mode, support cards, tokens, emblems, etc - can be disabled in Preferences, related to #7759, #2158);
This commit is contained in:
parent
e26445774b
commit
34816be219
7 changed files with 83 additions and 52 deletions
|
|
@ -9,9 +9,11 @@ import mage.constants.*;
|
|||
import mage.view.CardView;
|
||||
import mage.view.CounterView;
|
||||
import mage.view.PermanentView;
|
||||
import net.java.truevfs.access.TFile;
|
||||
import org.jdesktop.swingx.JXPanel;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
import org.mage.card.arcane.UI;
|
||||
import org.mage.plugins.card.utils.CardImageUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
|
@ -402,6 +404,15 @@ public final class GuiDisplayUtil {
|
|||
buffer.append("<p style='margin: 2px'><b>Card Zone:</b> ").append(zone).append("</p>");
|
||||
}
|
||||
|
||||
// missing image info in card popup
|
||||
boolean displayFullImagePath = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_FULL_IMAGE_PATH, "false").equals("true");
|
||||
if (displayFullImagePath) {
|
||||
String imageFile = CardImageUtils.buildImagePathToCardView(card);
|
||||
if (imageFile.startsWith("ERROR") || !(new TFile(imageFile).exists())) {
|
||||
buffer.append("<p style='margin: 2px'><b>Missing image:</b> ").append(imageFile).append("</p>");
|
||||
}
|
||||
}
|
||||
|
||||
buffer.append("<br></body></html>");
|
||||
return buffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ public class CardDownloadData {
|
|||
|
||||
private String name;
|
||||
private String downloadName;
|
||||
private String fileName = "";
|
||||
private String set;
|
||||
private final String collectorId;
|
||||
private final Integer imageNumber;
|
||||
|
|
@ -25,18 +24,13 @@ public class CardDownloadData {
|
|||
private String tokenClassName;
|
||||
|
||||
public CardDownloadData(String name, String setCode, String collectorId, boolean usesVariousArt, Integer imageNumber) {
|
||||
this(name, setCode, collectorId, usesVariousArt, imageNumber, false, "");
|
||||
this(name, setCode, collectorId, usesVariousArt, imageNumber, false);
|
||||
}
|
||||
|
||||
public CardDownloadData(String name, String setCode, String collectorId, boolean usesVariousArt, Integer imageNumber, boolean token) {
|
||||
this(name, setCode, collectorId, usesVariousArt, imageNumber, token, false, false, "");
|
||||
}
|
||||
|
||||
public CardDownloadData(String name, String setCode, String collectorId, boolean usesVariousArt, Integer imageNumber, boolean token, String fileName) {
|
||||
this(name, setCode, collectorId, usesVariousArt, imageNumber, token, false, false, "");
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public CardDownloadData(String name, String setCode, String collectorId, boolean usesVariousArt, Integer imageNumber, boolean token, boolean twoFacedCard, boolean secondSide) {
|
||||
this(name, setCode, collectorId, usesVariousArt, imageNumber, token, twoFacedCard, secondSide, "");
|
||||
}
|
||||
|
|
@ -56,7 +50,6 @@ public class CardDownloadData {
|
|||
public CardDownloadData(final CardDownloadData card) {
|
||||
this.name = card.name;
|
||||
this.downloadName = card.downloadName;
|
||||
this.fileName = card.fileName;
|
||||
this.set = card.set;
|
||||
this.collectorId = card.collectorId;
|
||||
this.imageNumber = card.imageNumber;
|
||||
|
|
@ -144,14 +137,6 @@ public class CardDownloadData {
|
|||
return name;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -532,8 +532,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
|||
"0",
|
||||
false,
|
||||
token.getImageNumber(),
|
||||
true,
|
||||
token.getImageFileName()
|
||||
true
|
||||
);
|
||||
allCardsUrls.add(card);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
package org.mage.plugins.card.utils;
|
||||
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.TokenRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.constants.Constants;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.Connection.ProxyType;
|
||||
import mage.view.CardView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
|
@ -113,7 +117,6 @@ public final class CardImageUtils {
|
|||
}
|
||||
|
||||
public static String buildImagePathToCardOrToken(CardDownloadData card) {
|
||||
|
||||
String setPath = buildImagePathToSet(card);
|
||||
|
||||
String prefixType = "";
|
||||
|
|
@ -121,10 +124,7 @@ public final class CardImageUtils {
|
|||
prefixType = " " + card.getImageNumber();
|
||||
}
|
||||
|
||||
String cardName = card.getFileName();
|
||||
if (cardName.isEmpty()) {
|
||||
cardName = prepareCardNameForFile(card.getName());
|
||||
}
|
||||
String cardName = prepareCardNameForFile(card.getName());
|
||||
|
||||
String finalFileName;
|
||||
if (card.getUsesVariousArt()) {
|
||||
|
|
@ -138,6 +138,49 @@ public final class CardImageUtils {
|
|||
return setPath + finalFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Special version for CardView and direct images info
|
||||
* (real card images uses image cache and key logic, see ImageCache.getKey)
|
||||
*
|
||||
* @return relative image path or "ERROR + reason"
|
||||
*/
|
||||
public static String buildImagePathToCardView(CardView card) {
|
||||
String imageFile;
|
||||
if (card.getMageObjectType().isUseTokensRepository()) {
|
||||
// token images
|
||||
CardDownloadData cardData = new CardDownloadData(
|
||||
card.getName().replace(" Token", ""),
|
||||
card.getExpansionSetCode(),
|
||||
"0",
|
||||
false,
|
||||
card.getImageNumber(),
|
||||
true);
|
||||
imageFile = CardImageUtils.buildImagePathToCardOrToken(cardData);
|
||||
} else {
|
||||
TokenRepository.instance.getAll();
|
||||
// card images
|
||||
// workaround to find various art settings first
|
||||
CardInfo cardInfo = CardRepository.instance.findCardWithPreferredSetAndNumber(
|
||||
card.getName(),
|
||||
card.getExpansionSetCode(),
|
||||
card.getCardNumber()
|
||||
);
|
||||
if (cardInfo != null) {
|
||||
CardDownloadData cardData = new CardDownloadData(
|
||||
cardInfo.getName(),
|
||||
cardInfo.getSetCode(),
|
||||
cardInfo.getCardNumber(),
|
||||
cardInfo.usesVariousArt(),
|
||||
card.getImageNumber()
|
||||
);
|
||||
imageFile = CardImageUtils.buildImagePathToCardOrToken(cardData);
|
||||
} else {
|
||||
imageFile = "ERROR: can't find card info in repository - " + card.getName();
|
||||
}
|
||||
}
|
||||
return imageFile;
|
||||
}
|
||||
|
||||
public static String generateFaceImagePath(String cardName, String setCode) {
|
||||
return getImagesDir() + File.separator + "FACE" + File.separator + fixSetNameForWindows(setCode) + File.separator + prepareCardNameForFile(cardName) + ".jpg";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue