mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Merge branch 'card-and-image-audit-menu' into 'master'
Card and image audit menu See merge request core-developers/forge!1451
This commit is contained in:
@@ -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"));
|
||||
@@ -94,6 +106,9 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
|
||||
pnlContent.add(label, "w 90%!, h 25px!, center, gap 0 0 0 36px");
|
||||
|
||||
}
|
||||
|
||||
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); }
|
||||
@@ -180,6 +196,148 @@ 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;
|
||||
|
||||
final StringBuffer nifSB = new StringBuffer(); // NO IMAGE FOUND BUFFER
|
||||
final StringBuffer cniSB = new StringBuffer(); // CARD NOT IMPLEMENTED BUFFER
|
||||
|
||||
nifSB.append("\n\n-------------------\n");
|
||||
nifSB.append("NO IMAGE FOUND LIST\n");
|
||||
nifSB.append("-------------------\n\n");
|
||||
|
||||
cniSB.append("\n\n-------------------\n");
|
||||
cniSB.append("UNIMPLEMENTED CARD LIST\n");
|
||||
cniSB.append("-------------------\n\n");
|
||||
|
||||
for (CardEdition e : editions) {
|
||||
nifSB.append("Edition: " + e.getName() + " " + "(" + e.getCode() + "/" + e.getCode2() + ")\n");
|
||||
cniSB.append("Edition: " + e.getName() + " " + "(" + e.getCode() + "/" + e.getCode2() + ")\n");
|
||||
|
||||
// perform sorting on the cards for this edition...
|
||||
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()));
|
||||
|
||||
// loop through the cards in this edition, considering art variations...
|
||||
for (String c : cis) {
|
||||
// if the same card name is set and this card has the same name as the previous...
|
||||
if ((lastName != null) && (c.contentEquals(lastName))) {
|
||||
// must be a card with multiple art representations...
|
||||
artIndex++;
|
||||
} else {
|
||||
// else this is a unique card or first of a multiple art set...
|
||||
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) {
|
||||
nifSB.append(" " + imagePath + "\n");
|
||||
missingCount++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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) {
|
||||
nifSB.append(" " + imagePath + "\n");
|
||||
missingCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cniSB.append(" " + c + "\n");
|
||||
notImplementedCount++;
|
||||
}
|
||||
lastName = c;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Audit token images here...
|
||||
|
||||
String totalStats = "Missing images: " + missingCount + "\nUnimplemented cards: " + notImplementedCount + "\n";
|
||||
cniSB.append("\n-----------\n");
|
||||
cniSB.append(totalStats);
|
||||
cniSB.append("-----------\n\n");
|
||||
|
||||
nifSB.append(cniSB); // combine things together...
|
||||
|
||||
tar.setText(nifSB.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(nifSB.toString()), null);
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
});
|
||||
scr.getParent().add(btnClipboardCopy, "w 200!, h pref+12!, center, gaptop 10");
|
||||
|
||||
String labelText = "<html>Missing images: " + missingCount + "<br>Unimplemented cards: " + notImplementedCount + "<br>";
|
||||
final FLabel statsLabel = new FLabel.Builder().text(labelText).fontSize(15).build();
|
||||
scr.getParent().add(statsLabel);
|
||||
|
||||
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(false);
|
||||
tar.setWrapStyleWord(false);
|
||||
tar.setEditable(false);
|
||||
tar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
tar.setFont(FSkin.getRelativeFixedFont(12));
|
||||
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_ALWAYS);
|
||||
|
||||
_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>"
|
||||
|
||||
Reference in New Issue
Block a user