mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
Add ability to audit cards and card image data.
README version info fixup.
This commit is contained in:
@@ -165,7 +165,7 @@ SNAPSHOT builds can be built via the Maven integration in Eclipse.
|
||||
|
||||
2) Run forge Maven build. If everything built, you should see "BUILD SUCCESS" in the Console View.
|
||||
|
||||
The resulting snapshot will be found at: forge-gui-desktop/target/forge-gui-desktop-1.6.22-SNAPSHOT
|
||||
The resulting snapshot will be found at: forge-gui-desktop/target/forge-gui-desktop-[version]-SNAPSHOT
|
||||
|
||||
# IntelliJ
|
||||
|
||||
|
||||
@@ -53,6 +53,11 @@ public enum CSubmenuDownloaders implements ICDoc {
|
||||
VSubmenuDownloaders.SINGLETON_INSTANCE.showHowToPlay();
|
||||
}
|
||||
};
|
||||
private final UiCommand cmdListImageData = new UiCommand() {
|
||||
@Override public void run() {
|
||||
VSubmenuDownloaders.SINGLETON_INSTANCE.showCardandImageAuditData();
|
||||
}
|
||||
};
|
||||
private final UiCommand cmdImportPictures = new UiCommand() {
|
||||
@Override public void run() {
|
||||
new ImportDialog(null, null).show();
|
||||
@@ -78,6 +83,7 @@ public enum CSubmenuDownloaders implements ICDoc {
|
||||
view.setDownloadSetPicsCommand(cmdSetDownload);
|
||||
view.setDownloadQuestImagesCommand(cmdQuestImages);
|
||||
view.setDownloadAchievementImagesCommand(cmdAchievementImages);
|
||||
view.setListImageDataCommand(cmdListImageData);
|
||||
view.setReportBugCommand(cmdReportBug);
|
||||
view.setImportPicturesCommand(cmdImportPictures);
|
||||
view.setHowToPlayCommand(cmdHowToPlay);
|
||||
|
||||
@@ -1,25 +1,36 @@
|
||||
package forge.screens.home.settings;
|
||||
|
||||
import forge.ImageKeys;
|
||||
import forge.StaticData;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardEdition.CardInSet;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.item.PaperCard;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.screens.home.EMenuGroup;
|
||||
import forge.screens.home.IVSubmenu;
|
||||
import forge.screens.home.VHomeUI;
|
||||
import forge.toolbox.*;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.ImageUtil;
|
||||
import forge.util.Localizer;
|
||||
import forge.util.RuntimeVersion;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of utilities submenu singleton.
|
||||
@@ -46,6 +57,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
private final FLabel btnDownloadQuestImages = _makeButton(localizer.getMessage("btnDownloadQuestImages"));
|
||||
private final FLabel btnDownloadAchievementImages = _makeButton(localizer.getMessage("btnDownloadAchievementImages"));
|
||||
private final FLabel btnReportBug = _makeButton(localizer.getMessage("btnReportBug"));
|
||||
private final FLabel btnListImageData = _makeButton(localizer.getMessage("btnListImageData"));
|
||||
private final FLabel btnImportPictures = _makeButton(localizer.getMessage("btnImportPictures"));
|
||||
private final FLabel btnHowToPlay = _makeButton(localizer.getMessage("btnHowToPlay"));
|
||||
private final FLabel btnDownloadPrices = _makeButton(localizer.getMessage("btnDownloadPrices"));
|
||||
@@ -95,6 +107,9 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
|
||||
}
|
||||
|
||||
pnlContent.add(btnListImageData, constraintsBTN);
|
||||
pnlContent.add(_makeLabel(localizer.getMessage("lblListImageData")), constraintsLBL);
|
||||
|
||||
pnlContent.add(btnImportPictures, constraintsBTN);
|
||||
pnlContent.add(_makeLabel(localizer.getMessage("lblImportPictures")), constraintsLBL);
|
||||
|
||||
@@ -144,6 +159,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
public void setDownloadQuestImagesCommand(UiCommand command) { btnDownloadQuestImages.setCommand(command); }
|
||||
public void setDownloadAchievementImagesCommand(UiCommand command) { btnDownloadAchievementImages.setCommand(command); }
|
||||
public void setReportBugCommand(UiCommand command) { btnReportBug.setCommand(command); }
|
||||
public void setListImageDataCommand(UiCommand command) { btnListImageData.setCommand(command); }
|
||||
public void setImportPicturesCommand(UiCommand command) { btnImportPictures.setCommand(command); }
|
||||
public void setHowToPlayCommand(UiCommand command) { btnHowToPlay.setCommand(command); }
|
||||
public void setDownloadPricesCommand(UiCommand command) { btnDownloadPrices.setCommand(command); }
|
||||
@@ -181,6 +197,137 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loops through the editions and card databases, looking for missing images and unimplemented cards.
|
||||
*
|
||||
* @param tar - Text area to report info
|
||||
* @param scr
|
||||
*/
|
||||
public void auditUpdate(FTextArea tar, FScrollPane scr) {
|
||||
// Get top-level Forge objects
|
||||
CardDb cardDb = StaticData.instance().getCommonCards();
|
||||
CardEdition.Collection editions = StaticData.instance().getEditions();
|
||||
|
||||
int missingCount = 0;
|
||||
int notImplementedCount = 0;
|
||||
int internalErrorCount = 0;
|
||||
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
|
||||
for (CardEdition e : editions) {
|
||||
sb.append("Edition: " + e.getName() + "\n");
|
||||
|
||||
String lastName = null;
|
||||
int artIndex = 1;
|
||||
ArrayList<String> cis = new ArrayList<String>();
|
||||
for (CardInSet c : e.getCards()) {
|
||||
cis.add(c.name);
|
||||
}
|
||||
Collections.sort(cis.subList(1, cis.size()));
|
||||
for (String c : cis) {
|
||||
if ((lastName != null) && (c.contentEquals(lastName))) {
|
||||
artIndex++;
|
||||
} else {
|
||||
artIndex = 1;
|
||||
}
|
||||
|
||||
PaperCard cp = cardDb.getCard(c, e.getCode(), artIndex);
|
||||
if (cp != null) {
|
||||
String imagePath;
|
||||
|
||||
//
|
||||
// check the front image
|
||||
//
|
||||
imagePath = ImageUtil.getImageRelativePath(cp, false, true, false);
|
||||
if (imagePath != null) {
|
||||
File file = ImageKeys.getImageFile(imagePath);
|
||||
if (file == null) {
|
||||
sb.append(" NIF: " + imagePath + "\n");
|
||||
missingCount++;
|
||||
}
|
||||
} else {
|
||||
sb.append(" ERR: " + c + "\n");
|
||||
internalErrorCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// check the back face
|
||||
//
|
||||
if (ImageUtil.hasBackFacePicture(cp)) {
|
||||
imagePath = ImageUtil.getImageRelativePath(cp, true, true, false);
|
||||
if (imagePath != null) {
|
||||
File file = ImageKeys.getImageFile(imagePath);
|
||||
if (file == null) {
|
||||
sb.append(" NIF: " + imagePath + "\n");
|
||||
missingCount++;
|
||||
}
|
||||
} else {
|
||||
sb.append(" ERR: " + c + "\n");
|
||||
internalErrorCount++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sb.append(" CNI: " + c + "\n");
|
||||
notImplementedCount++;
|
||||
}
|
||||
lastName = c;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Audit token images here...
|
||||
|
||||
String totalStats = "NIF count: " + missingCount + "\nCNI count: " + notImplementedCount + "\nERR count: "
|
||||
+ internalErrorCount + "\n";
|
||||
|
||||
sb.append("\n-----------\n");
|
||||
sb.append(totalStats);
|
||||
sb.append("-----------\n\n");
|
||||
sb.append(
|
||||
"NIF = 'no image graphic found'\nCNI = 'card not implemented in Forge'\nERR = 'internal error detected'\n");
|
||||
|
||||
tar.setText(sb.toString());
|
||||
tar.setCaretPosition(0); // this will move scroll view to the top...
|
||||
|
||||
final FButton btnClipboardCopy = new FButton(localizer.getMessage("btnCopyToClipboard"));
|
||||
btnClipboardCopy.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent arg0) {
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(sb.toString()), null);
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
scr.getParent().add(btnClipboardCopy, "w 200!, h pref+12!, center, gaptop 10");
|
||||
|
||||
FOverlay.SINGLETON_INSTANCE.getPanel().validate();
|
||||
FOverlay.SINGLETON_INSTANCE.getPanel().repaint();
|
||||
|
||||
}
|
||||
|
||||
public void showCardandImageAuditData() {
|
||||
final FTextArea tar = new FTextArea("Auditing card and image data. Please wait...");
|
||||
tar.setOpaque(true);
|
||||
tar.setLineWrap(true);
|
||||
tar.setWrapStyleWord(true);
|
||||
tar.setEditable(false);
|
||||
tar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
tar.setFont(FSkin.getRelativeFixedFont(16));
|
||||
tar.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
tar.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||
|
||||
final FScrollPane scr = new FScrollPane(tar, true, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
_showDialog(scr, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
auditUpdate(tar, scr);
|
||||
scr.getViewport().setViewPosition(new Point(0, 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void showLicensing() {
|
||||
String license = "<html>Forge License Information<br><br>"
|
||||
+ "This program is free software : you can redistribute it and/or modify "
|
||||
|
||||
@@ -12,6 +12,7 @@ btnDeleteWorkshopUI = Reset Workshop Layout
|
||||
btnUserProfileUI = Open User Directory
|
||||
btnContentDirectoryUI = Open Content Directory
|
||||
btnResetJavaFutureCompatibilityWarnings = Reset Java Compatibility Warnings
|
||||
btnCopyToClipboard= Copy to Clipboard
|
||||
cbRemoveSmall = Remove Small Creatures
|
||||
cbCardBased = Include Card-based Deck Generation
|
||||
cbSingletons = Singleton Mode
|
||||
@@ -138,6 +139,7 @@ btnDownloadPics = Download LQ Card Pictures
|
||||
btnDownloadQuestImages = Download Quest Images
|
||||
btnDownloadAchievementImages = Download Achievement Images
|
||||
btnReportBug =Report a Bug
|
||||
btnListImageData =Audit Card and Image Data
|
||||
btnImportPictures = Import Data
|
||||
btnHowToPlay = How To Play
|
||||
btnDownloadPrices = Download Card Prices
|
||||
@@ -153,6 +155,7 @@ lblYoureRunning = You're running
|
||||
lblYouNeedAtLeastJavaVersion = You need at least version 1.8.0_101.
|
||||
lblImportPictures = Import data from a local directory.
|
||||
lblReportBug = Something broken?
|
||||
lblListImageData = Audit cards not implemented by Forge and missing card images
|
||||
lblHowToPlay = Rules of the Game.
|
||||
lblLicensing = Forge legal.
|
||||
ContentDownloaders = Content Downloaders
|
||||
|
||||
Reference in New Issue
Block a user