mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Updated Stats Panel to be normal instances, as panel didn't get updated with singletons.
Signed-off-by: leriomaggio <valeriomaggio@gmail.com>
This commit is contained in:
@@ -22,18 +22,13 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class CStatisticsImporter {
|
public class CStatisticsImporter {
|
||||||
|
|
||||||
private static CStatisticsImporter instance = null;
|
|
||||||
private int totalCardsInDecklist = 0;
|
private int totalCardsInDecklist = 0;
|
||||||
private final boolean isCommanderEditor;
|
private final boolean isCommanderEditor;
|
||||||
|
private final VStatisticsImporter view;
|
||||||
|
|
||||||
private CStatisticsImporter(boolean isCommanderEditor){
|
public CStatisticsImporter(VStatisticsImporter vStatisticsImporter){
|
||||||
this.isCommanderEditor = isCommanderEditor;
|
this.view = vStatisticsImporter;
|
||||||
}
|
this.isCommanderEditor = this.view.isViewForCommanderEditor();
|
||||||
|
|
||||||
public static CStatisticsImporter instance(boolean isCommanderEditor) {
|
|
||||||
if (instance == null)
|
|
||||||
instance = new CStatisticsImporter(isCommanderEditor);
|
|
||||||
return instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateStats(Iterable<DeckRecognizer.Token> cardTokens, boolean includeBannedAndRestricted) {
|
public void updateStats(Iterable<DeckRecognizer.Token> cardTokens, boolean includeBannedAndRestricted) {
|
||||||
@@ -62,44 +57,43 @@ public class CStatisticsImporter {
|
|||||||
// Hack-ish: avoid /0 cases, but still populate labels :)
|
// Hack-ish: avoid /0 cases, but still populate labels :)
|
||||||
if (total == 0) { total = 1; }
|
if (total == 0) { total = 1; }
|
||||||
|
|
||||||
VStatisticsImporter vStatsImporter = VStatisticsImporter.instance(this.isCommanderEditor);
|
setLabelValue(this.view.getLblCreature(), deck, CardRulesPredicates.Presets.IS_CREATURE, total);
|
||||||
setLabelValue(vStatsImporter.getLblCreature(), deck, CardRulesPredicates.Presets.IS_CREATURE, total);
|
setLabelValue(this.view.getLblLand(), deck, CardRulesPredicates.Presets.IS_LAND, total);
|
||||||
setLabelValue(vStatsImporter.getLblLand(), deck, CardRulesPredicates.Presets.IS_LAND, total);
|
setLabelValue(this.view.getLblEnchantment(), deck, CardRulesPredicates.Presets.IS_ENCHANTMENT, total);
|
||||||
setLabelValue(vStatsImporter.getLblEnchantment(), deck, CardRulesPredicates.Presets.IS_ENCHANTMENT, total);
|
setLabelValue(this.view.getLblArtifact(), deck, CardRulesPredicates.Presets.IS_ARTIFACT, total);
|
||||||
setLabelValue(vStatsImporter.getLblArtifact(), deck, CardRulesPredicates.Presets.IS_ARTIFACT, total);
|
setLabelValue(this.view.getLblInstant(), deck, CardRulesPredicates.Presets.IS_INSTANT, total);
|
||||||
setLabelValue(vStatsImporter.getLblInstant(), deck, CardRulesPredicates.Presets.IS_INSTANT, total);
|
setLabelValue(this.view.getLblSorcery(), deck, CardRulesPredicates.Presets.IS_SORCERY, total);
|
||||||
setLabelValue(vStatsImporter.getLblSorcery(), deck, CardRulesPredicates.Presets.IS_SORCERY, total);
|
setLabelValue(this.view.getLblPlaneswalker(), deck, CardRulesPredicates.Presets.IS_PLANESWALKER, total);
|
||||||
setLabelValue(vStatsImporter.getLblPlaneswalker(), deck, CardRulesPredicates.Presets.IS_PLANESWALKER, total);
|
|
||||||
|
|
||||||
setLabelValue(vStatsImporter.getLblMulti(), deck, CardRulesPredicates.Presets.IS_MULTICOLOR, total);
|
setLabelValue(this.view.getLblMulti(), deck, CardRulesPredicates.Presets.IS_MULTICOLOR, total);
|
||||||
setLabelValue(vStatsImporter.getLblColorless(), deck, CardRulesPredicates.Presets.IS_COLORLESS, total);
|
setLabelValue(this.view.getLblColorless(), deck, CardRulesPredicates.Presets.IS_COLORLESS, total);
|
||||||
setLabelValue(vStatsImporter.getLblBlack(), deck, CardRulesPredicates.isMonoColor(MagicColor.BLACK), total);
|
setLabelValue(this.view.getLblBlack(), deck, CardRulesPredicates.isMonoColor(MagicColor.BLACK), total);
|
||||||
setLabelValue(vStatsImporter.getLblBlue(), deck, CardRulesPredicates.isMonoColor(MagicColor.BLUE), total);
|
setLabelValue(this.view.getLblBlue(), deck, CardRulesPredicates.isMonoColor(MagicColor.BLUE), total);
|
||||||
setLabelValue(vStatsImporter.getLblGreen(), deck, CardRulesPredicates.isMonoColor(MagicColor.GREEN), total);
|
setLabelValue(this.view.getLblGreen(), deck, CardRulesPredicates.isMonoColor(MagicColor.GREEN), total);
|
||||||
setLabelValue(vStatsImporter.getLblRed(), deck, CardRulesPredicates.isMonoColor(MagicColor.RED), total);
|
setLabelValue(this.view.getLblRed(), deck, CardRulesPredicates.isMonoColor(MagicColor.RED), total);
|
||||||
setLabelValue(vStatsImporter.getLblWhite(), deck, CardRulesPredicates.isMonoColor(MagicColor.WHITE), total);
|
setLabelValue(this.view.getLblWhite(), deck, CardRulesPredicates.isMonoColor(MagicColor.WHITE), total);
|
||||||
|
|
||||||
setLabelValue(vStatsImporter.getLblCMC0(), deck, SItemManagerUtil.StatTypes.CMC_0.predicate, total);
|
setLabelValue(this.view.getLblCMC0(), deck, SItemManagerUtil.StatTypes.CMC_0.predicate, total);
|
||||||
setLabelValue(vStatsImporter.getLblCMC1(), deck, SItemManagerUtil.StatTypes.CMC_1.predicate, total);
|
setLabelValue(this.view.getLblCMC1(), deck, SItemManagerUtil.StatTypes.CMC_1.predicate, total);
|
||||||
setLabelValue(vStatsImporter.getLblCMC2(), deck, SItemManagerUtil.StatTypes.CMC_2.predicate, total);
|
setLabelValue(this.view.getLblCMC2(), deck, SItemManagerUtil.StatTypes.CMC_2.predicate, total);
|
||||||
setLabelValue(vStatsImporter.getLblCMC3(), deck, SItemManagerUtil.StatTypes.CMC_3.predicate, total);
|
setLabelValue(this.view.getLblCMC3(), deck, SItemManagerUtil.StatTypes.CMC_3.predicate, total);
|
||||||
setLabelValue(vStatsImporter.getLblCMC4(), deck, SItemManagerUtil.StatTypes.CMC_4.predicate, total);
|
setLabelValue(this.view.getLblCMC4(), deck, SItemManagerUtil.StatTypes.CMC_4.predicate, total);
|
||||||
setLabelValue(vStatsImporter.getLblCMC5(), deck, SItemManagerUtil.StatTypes.CMC_5.predicate, total);
|
setLabelValue(this.view.getLblCMC5(), deck, SItemManagerUtil.StatTypes.CMC_5.predicate, total);
|
||||||
setLabelValue(vStatsImporter.getLblCMC6(), deck, SItemManagerUtil.StatTypes.CMC_6.predicate, total);
|
setLabelValue(this.view.getLblCMC6(), deck, SItemManagerUtil.StatTypes.CMC_6.predicate, total);
|
||||||
|
|
||||||
vStatsImporter.getLblTotalMain().setText(
|
this.view.getLblTotalMain().setText(
|
||||||
String.format("%s: %d", Localizer.getInstance().getMessage("lblTotalMain").toUpperCase(),
|
String.format("%s: %d", Localizer.getInstance().getMessage("lblTotalMain").toUpperCase(),
|
||||||
totalInMain));
|
totalInMain));
|
||||||
vStatsImporter.getLblTotalSide().setText(
|
this.view.getLblTotalSide().setText(
|
||||||
String.format("%s: %d", Localizer.getInstance().getMessage("lblTotalSide").toUpperCase(),
|
String.format("%s: %d", Localizer.getInstance().getMessage("lblTotalSide").toUpperCase(),
|
||||||
totalInSide));
|
totalInSide));
|
||||||
|
|
||||||
if (this.isCommanderEditor)
|
if (this.isCommanderEditor)
|
||||||
vStatsImporter.getLblTotalCommander().setText(
|
this.view.getLblTotalCommander().setText(
|
||||||
String.format("%s: %d", Localizer.getInstance().getMessage("lblTotalCommander").toUpperCase(),
|
String.format("%s: %d", Localizer.getInstance().getMessage("lblTotalCommander").toUpperCase(),
|
||||||
totalInCommander));
|
totalInCommander));
|
||||||
else
|
else
|
||||||
vStatsImporter.getLblTotal().setText(
|
this.view.getLblTotal().setText(
|
||||||
String.format("%s: %d", Localizer.getInstance().getMessage("lblTotalCards").toUpperCase(),
|
String.format("%s: %d", Localizer.getInstance().getMessage("lblTotalCards").toUpperCase(),
|
||||||
deck.countAll()));
|
deck.countAll()));
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import java.awt.*;
|
|||||||
|
|
||||||
public class VStatisticsImporter {
|
public class VStatisticsImporter {
|
||||||
|
|
||||||
private static VStatisticsImporter lastInstance = null;
|
|
||||||
|
|
||||||
// Global stats
|
// Global stats
|
||||||
|
|
||||||
private FLabel lblTotal = new FLabel.Builder()
|
private FLabel lblTotal = new FLabel.Builder()
|
||||||
@@ -86,7 +84,9 @@ public class VStatisticsImporter {
|
|||||||
return buildLabel(FSkin.getImage(statType.skinProp, 18, 18), zebra);
|
return buildLabel(FSkin.getImage(statType.skinProp, 18, 18), zebra);
|
||||||
}
|
}
|
||||||
|
|
||||||
private VStatisticsImporter(boolean isCommanderEditor) {
|
private final boolean isViewForCommanderEditor;
|
||||||
|
|
||||||
|
public VStatisticsImporter(boolean isCommanderEditor) {
|
||||||
scroller.getViewport().setBorder(null);
|
scroller.getViewport().setBorder(null);
|
||||||
|
|
||||||
// Color stats
|
// Color stats
|
||||||
@@ -163,17 +163,14 @@ public class VStatisticsImporter {
|
|||||||
pnlStats.add(lblTotal, constraints);
|
pnlStats.add(lblTotal, constraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
this.isViewForCommanderEditor = isCommanderEditor;
|
||||||
|
|
||||||
public static VStatisticsImporter instance(boolean isCommanderEditor) {
|
|
||||||
if (lastInstance == null)
|
|
||||||
// singleton
|
|
||||||
lastInstance = new VStatisticsImporter(isCommanderEditor);
|
|
||||||
return lastInstance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//========== Retrieval methods
|
//========== Retrieval methods
|
||||||
|
|
||||||
|
/** @return {@link boolean}*/
|
||||||
|
public boolean isViewForCommanderEditor() { return this.isViewForCommanderEditor; }
|
||||||
|
|
||||||
/** @return {@link forge.toolbox.FLabel} */
|
/** @return {@link forge.toolbox.FLabel} */
|
||||||
public FLabel getLblMulti() { return lblMulti; }
|
public FLabel getLblMulti() { return lblMulti; }
|
||||||
/** @return {@link forge.toolbox.FLabel} */
|
/** @return {@link forge.toolbox.FLabel} */
|
||||||
|
|||||||
Reference in New Issue
Block a user