rename DeckStatsPanel to DeckGamesPanel and related components.

master
lodici 2017-02-23 14:12:19 +00:00
parent e5936e1985
commit aa2358cd60
6 changed files with 28 additions and 29 deletions

View File

@ -11,7 +11,7 @@ import magic.model.player.PlayerProfile;
import magic.model.player.PlayerProfiles;
import magic.translate.MText;
class DeckGameStats {
class DeckGame {
// translatable UI text (prefix with _S).
private static final String _S1 = "version";
@ -24,7 +24,7 @@ class DeckGameStats {
private final GameStatsInfo dto;
private final MagicDeck deck;
DeckGameStats(MagicDeck deck, GameStatsInfo dto) {
DeckGame(MagicDeck deck, GameStatsInfo dto) {
this.deck = deck;
this.dto = dto;
}

View File

@ -22,7 +22,7 @@ import magic.ui.widget.cards.table.CardsTableStyle;
import magic.utility.DeckUtils;
@SuppressWarnings("serial")
class GameStatsJTable extends JTable {
class DeckGamesJTable extends JTable {
private static final int ROW_HEIGHT = 40; // pixels
@ -42,7 +42,7 @@ class GameStatsJTable extends JTable {
private Color DEFAULT_GRID_COLOR;
private final TableColumnAdjuster tca;
GameStatsJTable(TableModel dm) {
DeckGamesJTable(TableModel dm) {
super(dm);
setDefaultProperties();
setDefaultColumnProperties();
@ -60,7 +60,7 @@ class GameStatsJTable extends JTable {
int col = columnAtPoint(ev.getPoint());
if (col == 1 || col == 10) { // P1_ID, P2_ID
final TableModel dm = getModel();
MouseHelper.showBusyCursor(GameStatsJTable.this);
MouseHelper.showBusyCursor(DeckGamesJTable.this);
ScreenController.showPlayerScreen((String)dm.getValueAt(row, col));
MouseHelper.showDefaultCursor();
@ -71,7 +71,7 @@ class GameStatsJTable extends JTable {
DeckType deckType = DeckType.valueOf((String) dm.getValueAt(row, col + 2));
long fileChecksum = DeckUtils.getDeckFileChecksum(deckName, deckType);
if (fileChecksum == expectedChecksum) {
MouseHelper.showBusyCursor(GameStatsJTable.this);
MouseHelper.showBusyCursor(DeckGamesJTable.this);
ScreenController.showDeckEditor(DeckUtils.loadDeckFromFile(deckName, deckType));
MouseHelper.showDefaultCursor();
}

View File

@ -18,16 +18,16 @@ import magic.ui.widget.TexturedPanel;
import net.miginfocom.swing.MigLayout;
@SuppressWarnings("serial")
public class DeckStatsPanel extends TexturedPanel
public class DeckGamesPanel extends TexturedPanel
implements IDeckEditorView, IDeckView, IPagination {
private GameStatsTableModel tm;
private GameStatsJTable table;
private DeckGamesTableModel tm;
private DeckGamesJTable table;
private final MScrollPane scrollpane = new MScrollPane();
private final PaginationPanel paginator;
private MagicDeck deck;
public DeckStatsPanel(MagicDeck deck) {
public DeckGamesPanel(MagicDeck deck) {
this.deck = deck;
setBackground(FontsAndBorders.TRANSLUCENT_WHITE_STRONG);
scrollpane.setOpaque(false);
@ -40,11 +40,11 @@ public class DeckStatsPanel extends TexturedPanel
}
private void refreshStatsTable() {
tm = new GameStatsTableModel(deck);
tm = new DeckGamesTableModel(deck);
}
private void refreshStatsTable(int page) {
tm = new GameStatsTableModel(deck, page);
tm = new DeckGamesTableModel(deck, page);
}
@Override
@ -54,7 +54,7 @@ public class DeckStatsPanel extends TexturedPanel
refreshStatsTable();
}
if (tm != null) {
table = new GameStatsJTable(tm);
table = new DeckGamesJTable(tm);
scrollpane.setViewportView(table);
paginator.refresh();
}

View File

@ -12,7 +12,7 @@ import magic.translate.MText;
* Game statistics for a deck.
*/
@SuppressWarnings("serial")
class GameStatsTableModel extends AbstractTableModel {
class DeckGamesTableModel extends AbstractTableModel {
// translatable UI text (prefix with _S).
private static final String _S1 = "Game";
@ -24,19 +24,19 @@ class GameStatsTableModel extends AbstractTableModel {
private static final int PAGE_SIZE = 8;
private final List<DeckGameStats> gameStats;
private final List<DeckGame> gameStats;
private final int totalGames;
private final int totalPages;
private int currentPage = 1;
GameStatsTableModel(MagicDeck deck, int page) {
DeckGamesTableModel(MagicDeck deck, int page) {
this.totalGames = MagicStats.getTotalGamesPlayed(deck);
this.totalPages = ((totalGames - 1) / PAGE_SIZE) + 1;
currentPage = page;
gameStats = getDeckGameStats(deck, MagicStats.getGameStats(deck, PAGE_SIZE, getGamesToSkip()));
}
GameStatsTableModel(MagicDeck deck) {
DeckGamesTableModel(MagicDeck deck) {
this(deck, 1);
}
@ -44,9 +44,9 @@ class GameStatsTableModel extends AbstractTableModel {
return currentPage == 1 ? 0 : (currentPage - 1) * PAGE_SIZE;
}
private List<DeckGameStats> getDeckGameStats(MagicDeck deck, List<GameStatsInfo> gameStats) {
private List<DeckGame> getDeckGameStats(MagicDeck deck, List<GameStatsInfo> gameStats) {
return gameStats.stream()
.map(s -> new DeckGameStats(deck, s))
.map(s -> new DeckGame(deck, s))
.collect(Collectors.toList());
}
@ -89,7 +89,7 @@ class GameStatsTableModel extends AbstractTableModel {
@Override
public Object getValueAt(int row, int col) {
DeckGameStats stats = gameStats.get(row);
DeckGame stats = gameStats.get(row);
switch (col) {
case 0: return "<html>" + stats.getGameInfo() + "</html>";
case 1: return "<html>" + stats.getConfigInfo() + "</html>";

View File

@ -12,7 +12,7 @@ import magic.translate.MText;
import magic.ui.MagicSound;
import magic.ui.ScreenController;
import magic.ui.helpers.MouseHelper;
import magic.ui.deck.games.DeckStatsPanel;
import magic.ui.deck.games.DeckGamesPanel;
import magic.ui.widget.cards.table.CardsJTable;
import magic.ui.widget.deck.legality.LegalityPanel;
import magic.ui.widget.deck.stats.IPwlWorkerListener;
@ -41,7 +41,7 @@ class MainViewsPanel extends JPanel
private final CardPoolViewPanel cardPoolPanel;
private final CardRecallPanel recallPanel;
private final LegalityPanel legalityPanel;
private final DeckStatsPanel statsPanel;
private final DeckGamesPanel statsPanel;
private IDeckEditorView activeView;
private final CardsJTable deckTable;
@ -58,7 +58,7 @@ class MainViewsPanel extends JPanel
cardPoolPanel = new CardPoolViewPanel(this, deckActionPanel.getQuantityPanel());
recallPanel = new CardRecallPanel(this, deckActionPanel.getQuantityPanel());
legalityPanel = new LegalityPanel();
statsPanel = new DeckStatsPanel(controller.getDeck());
statsPanel = new DeckGamesPanel(controller.getDeck());
this.deckTable = deckPanel.getDeckTable();
@ -215,9 +215,8 @@ class MainViewsPanel extends JPanel
activeView.setVisible(false);
}
aView.setVisible(true);
deckActionPanel.setVisible(
aView instanceof LegalityPanel == false
&& aView instanceof DeckStatsPanel == false
deckActionPanel.setVisible(aView instanceof LegalityPanel == false
&& aView instanceof DeckGamesPanel == false
);
activeView = aView;
refreshLayout();

View File

@ -10,7 +10,7 @@ import magic.model.MagicCardDefinition;
import magic.model.MagicDeck;
import magic.translate.MText;
import magic.ui.helpers.MouseHelper;
import magic.ui.deck.games.DeckStatsPanel;
import magic.ui.deck.games.DeckGamesPanel;
import magic.ui.widget.deck.legality.LegalityPanel;
import magic.ui.widget.deck.stats.IPwlWorkerListener;
import net.miginfocom.swing.MigLayout;
@ -29,7 +29,7 @@ public class DeckViewsPanel extends JPanel implements IPwlWorkerListener {
private final ToggleButtonsPanel toggleButtonsPanel = new ToggleButtonsPanel();
private final DeckPanel deckPanel;
private final LegalityPanel legalityPanel;
private final DeckStatsPanel statsPanel;
private final DeckGamesPanel statsPanel;
private JToggleButton statsToggleButton;
private IDeckView activeView;
@ -39,7 +39,7 @@ public class DeckViewsPanel extends JPanel implements IPwlWorkerListener {
deckPanel = new DeckPanel();
legalityPanel = new LegalityPanel();
statsPanel = new DeckStatsPanel(new MagicDeck());
statsPanel = new DeckGamesPanel(new MagicDeck());
legalityPanel.setVisible(false);
statsPanel.setVisible(false);