add Stats export during DevMode to generate completion statistics

master
ShawnieBoy 2016-02-09 18:51:32 +00:00
parent 9e1a9aaa44
commit 86215fea55
5 changed files with 49 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

View File

@ -36,6 +36,7 @@ public enum MagicIcon {
SORCERIES_ICON("w_sorceries.png"),
PLANESWALKERS_ICON("w_planeswalkers.png"),
SPELLS_ICON("w_spells.png"),
STATS_ICON("w_stats.png"),
EDIT_ICON("w_edit.png"),
HELP_ICON("w_help.png"),
OPEN_ICON("w_open.png"),

View File

@ -1,7 +1,5 @@
package magic.ui;
import magic.translate.UiString;
import magic.translate.StringContext;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
@ -21,6 +19,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import magic.data.CardDefinitions;
import magic.data.MagicFormat;
import magic.data.MagicPredefinedFormat;
@ -32,6 +31,8 @@ import magic.model.MagicManaCost;
import magic.model.MagicRarity;
import magic.model.MagicSubType;
import magic.model.MagicType;
import magic.translate.StringContext;
import magic.translate.UiString;
import magic.ui.theme.ThemeFactory;
import magic.ui.widget.ButtonControlledPopup;
import magic.ui.widget.FontsAndBorders;
@ -101,7 +102,7 @@ public class CardFilterPanel extends TexturedPanel implements ActionListener {
private JRadioButton[] statusFilterChoices;
// sets
private ButtonControlledPopup setsPopup;
private JCheckBox[] setsCheckBoxes;
public JCheckBox[] setsCheckBoxes;
private JRadioButton[] setsFilterChoices;
// cube
private ButtonControlledPopup cubePopup;

View File

@ -33,7 +33,7 @@ public class ExplorerPanel extends JPanel implements ICardSelectionListener, ICa
private static final int FILTERS_PANEL_HEIGHT = 88; // pixels
private CardTable cardPoolTable;
private CardFilterPanel filterPanel;
public CardFilterPanel filterPanel;
private List<MagicCardDefinition> cardPoolDefs;
private ExplorerSidebarPanel sideBarPanel;
private final MigLayout migLayout = new MigLayout();
@ -87,7 +87,7 @@ public class ExplorerPanel extends JPanel implements ICardSelectionListener, ICa
}
private String generatePoolTitle() {
public String generatePoolTitle() {
final int total = filterPanel.getTotalCardCount();
return String.format("%s %s %s %s %s %s",
UiString.get(_S1),

View File

@ -10,16 +10,16 @@ import java.util.Collections;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.JPanel;
import magic.utility.MagicSystem;
import magic.data.CardDefinitions;
import magic.data.MagicIcon;
import magic.ui.MagicImages;
import magic.data.MagicSetDefinitions;
import magic.ui.explorer.ExplorerPanel;
import magic.ui.MagicFrame;
import magic.ui.ScreenOptionsOverlay;
import magic.translate.UiString;
import magic.ui.MagicFrame;
import magic.ui.MagicImages;
import magic.ui.MagicLogs;
import magic.ui.ScreenOptionsOverlay;
import magic.ui.explorer.ExplorerPanel;
import magic.ui.screen.interfaces.IActionBar;
import magic.ui.screen.interfaces.IOptionsMenu;
import magic.ui.screen.interfaces.IStatusBar;
@ -29,6 +29,7 @@ import magic.ui.screen.widget.MenuButton;
import magic.ui.screen.widget.MenuPanel;
import magic.utility.MagicFileSystem;
import magic.utility.MagicFileSystem.DataPath;
import magic.utility.MagicSystem;
@SuppressWarnings("serial")
public class CardExplorerScreen
@ -93,6 +94,21 @@ public class CardExplorerScreen
}
)
);
buttons.add(new ActionBarButton(
MagicImages.getIcon(MagicIcon.STATS_ICON),
"Save Statistics [DevMode Only]", "Creates CardStatistics.txt to view current card completion.",
new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
try {
saveCardStatistics();
} catch (IOException e1) {
throw new RuntimeException(e1);
}
}
}
)
);
}
return buttons;
}
@ -102,13 +118,31 @@ public class CardExplorerScreen
Collections.sort(missingCards);
final Path savePath = MagicFileSystem.getDataPath(DataPath.LOGS).resolve("CardsMissingInMagarena.txt");
try (final PrintWriter writer = new PrintWriter(savePath.toFile())) {
for (final String cardName : missingCards) {
writer.println(cardName);
}
missingCards.forEach(writer::println);
}
Desktop.getDesktop().open(MagicFileSystem.getDataPath(DataPath.LOGS).toFile());
}
private void saveCardStatistics() throws IOException {
ArrayList<String> allSetInfo = new ArrayList<String>();
for (int i = 0; i < content.filterPanel.setsCheckBoxes.length; i++) {
content.filterPanel.resetFilters();
content.filterPanel.setsCheckBoxes[i].setSelected(true);
content.updateCardPool();
String setText = content.filterPanel.setsCheckBoxes[i].getText()+ " " + content.generatePoolTitle();
allSetInfo.add(setText);
System.out.println(content.filterPanel.setsCheckBoxes[i].getText());
}
final Path savePath = MagicFileSystem.getDataPath(DataPath.LOGS).resolve("CardStatistics.txt");
try (final PrintWriter writer = new PrintWriter(savePath.toFile())) {
allSetInfo.forEach(writer::println);
}
Desktop.getDesktop().open(MagicFileSystem.getDataPath(DataPath.LOGS).toFile());
content.filterPanel.resetFilters();
content.updateCardPool();
}
@Override
public boolean isScreenReadyToClose(final AbstractScreen nextScreen) {
MagicSetDefinitions.clearLoadedSets();