diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.form b/Mage.Client/src/main/java/mage/client/table/TablesPanel.form index 6080002708..30e1a8e228 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.form +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.form @@ -418,6 +418,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java index e03aaad781..0e08570077 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java @@ -158,7 +158,7 @@ public class TablesPanel extends javax.swing.JPanel { filterButtons = new JToggleButton[]{btnStateWaiting, btnStateActive, btnStateFinished, btnTypeMatch, btnTypeTourneyConstructed, btnTypeTourneyLimited, btnFormatBlock, btnFormatStandard, btnFormatModern, btnFormatLegacy, btnFormatVintage, btnFormatCommander, btnFormatTinyLeader, btnFormatLimited, btnFormatOther, - btnSkillBeginner, btnSkillCasual, btnSkillSerious, btnRated, btnUnrated}; + btnSkillBeginner, btnSkillCasual, btnSkillSerious, btnRated, btnUnrated, btnOpen, btnPassword}; JComponent[] components = new JComponent[]{chatPanelMain, jSplitPane1, jScrollPaneTablesActive, jScrollPaneTablesFinished, jPanelTop, jPanelTables}; for (JComponent component : components) { @@ -625,9 +625,19 @@ public class TablesPanel extends javax.swing.JPanel { if (btnUnrated.isSelected()){ ratingFilterList.add(RowFilter.regexFilter("^Unrated", TableTableModel.COLUMN_RATING)); } + + // Password + List> passwordFilterList = new ArrayList<>(); + if (btnOpen.isSelected()) { + passwordFilterList.add(RowFilter.regexFilter("^$", TableTableModel.COLUMN_PASSWORD)); + } + if (btnPassword.isSelected()) { + passwordFilterList.add(RowFilter.regexFilter("^\\*\\*\\*$", TableTableModel.COLUMN_PASSWORD)); + } if (stateFilterList.isEmpty() || typeFilterList.isEmpty() || formatFilterList.isEmpty() - || skillFilterList.isEmpty() || ratingFilterList.isEmpty()) { // no selection + || skillFilterList.isEmpty() || ratingFilterList.isEmpty() + || passwordFilterList.isEmpty()) { // no selection activeTablesSorter.setRowFilter(RowFilter.regexFilter("Nothing", TableTableModel.COLUMN_SKILL)); } else { List> filterList = new ArrayList<>(); @@ -661,6 +671,12 @@ public class TablesPanel extends javax.swing.JPanel { } else if (ratingFilterList.size() == 1) { filterList.addAll(ratingFilterList); } + + if (passwordFilterList.size() > 1) { + filterList.add(RowFilter.orFilter(passwordFilterList)); + } else if (passwordFilterList.size() == 1) { + filterList.addAll(passwordFilterList); + } if (filterList.size() == 1) { activeTablesSorter.setRowFilter(filterList.get(0)); @@ -710,6 +726,9 @@ public class TablesPanel extends javax.swing.JPanel { jSeparator2 = new javax.swing.JToolBar.Separator(); btnFormatLimited = new javax.swing.JToggleButton(); btnFormatOther = new javax.swing.JToggleButton(); + jSeparator5 = new javax.swing.JToolBar.Separator(); + btnOpen = new javax.swing.JToggleButton(); + btnPassword = new javax.swing.JToggleButton(); btnQuickStart = new javax.swing.JButton(); jSplitPane1 = new javax.swing.JSplitPane(); jPanelTables = new javax.swing.JPanel(); @@ -1079,6 +1098,39 @@ public class TablesPanel extends javax.swing.JPanel { } }); filterBar2.add(btnFormatOther); + filterBar2.add(jSeparator5); + + btnOpen.setSelected(true); + btnOpen.setText("Open"); + btnOpen.setToolTipText("Show open games"); + btnOpen.setFocusPainted(false); + btnOpen.setFocusable(false); + btnOpen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnOpen.setRequestFocusEnabled(false); + btnOpen.setVerifyInputWhenFocusTarget(false); + btnOpen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + btnOpen.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnFilterActionPerformed(evt); + } + }); + filterBar2.add(btnOpen); + + btnPassword.setSelected(true); + btnPassword.setText("PW"); + btnPassword.setToolTipText("Show passworded games"); + btnPassword.setFocusPainted(false); + btnPassword.setFocusable(false); + btnPassword.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnPassword.setRequestFocusEnabled(false); + btnPassword.setVerifyInputWhenFocusTarget(false); + btnPassword.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + btnPassword.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnFilterActionPerformed(evt); + } + }); + filterBar2.add(btnPassword); btnQuickStart.setText("Quick Start"); btnQuickStart.setFocusable(false); @@ -1290,6 +1342,8 @@ public class TablesPanel extends javax.swing.JPanel { private javax.swing.JToggleButton btnFormatVintage; private javax.swing.JButton btnNewTable; private javax.swing.JButton btnNewTournament; + private javax.swing.JToggleButton btnOpen; + private javax.swing.JToggleButton btnPassword; private javax.swing.JButton btnQuickStart; private javax.swing.JToggleButton btnSkillBeginner; private javax.swing.JToggleButton btnSkillCasual; @@ -1337,12 +1391,14 @@ class TableTableModel extends AbstractTableModel { public static final int COLUMN_GAME_TYPE = 3; public static final int COLUMN_INFO = 4; public static final int COLUMN_STATUS = 5; - public static final int COLUMN_SKILL = 7; - public static final int COLUMN_RATING = 8; - public static final int COLUMN_QUIT_RATIO = 9; - public static final int ACTION_COLUMN = 10; // column the action is located (starting with 0) + public static final int COLUMN_PASSWORD = 6; + public static final int COLUMN_CREATED = 7; + public static final int COLUMN_SKILL = 8; + public static final int COLUMN_RATING = 9; + public static final int COLUMN_QUIT_RATIO = 10; + public static final int ACTION_COLUMN = 11; // column the action is located (starting with 0) - private final String[] columnNames = new String[]{"M/T", "Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Created / Started", "Skill Level", "Rating", "Quit %", "Action"}; + private final String[] columnNames = new String[]{"M/T", "Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Password", "Created / Started", "Skill Level", "Rating", "Quit %", "Action"}; private TableView[] tables = new TableView[0]; private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss"); @@ -1385,14 +1441,16 @@ class TableTableModel extends AbstractTableModel { case 5: return tables[arg0].getTableStateText(); case 6: - return timeFormatter.format(tables[arg0].getCreateTime()); + return tables[arg0].isPassworded() ? "***" : ""; case 7: - return tables[arg0].getSkillLevel(); + return timeFormatter.format(tables[arg0].getCreateTime()); case 8: - return tables[arg0].isRated() ? "Rated" : "Unrated"; + return tables[arg0].getSkillLevel(); case 9: - return tables[arg0].getQuitRatio(); + return tables[arg0].isRated() ? "Rated" : "Unrated"; case 10: + return tables[arg0].getQuitRatio(); + case 11: switch (tables[arg0].getTableState()) { case WAITING: @@ -1419,14 +1477,14 @@ class TableTableModel extends AbstractTableModel { default: return ""; } - case 11: - return tables[arg0].isTournament(); case 12: + return tables[arg0].isTournament(); + case 13: if (!tables[arg0].getGames().isEmpty()) { return tables[arg0].getGames().get(0); } return null; - case 13: + case 14: return tables[arg0].getTableId(); } return ""; diff --git a/Mage.Common/src/mage/view/TableView.java b/Mage.Common/src/mage/view/TableView.java index 2b7c711b95..4d4f7373dd 100644 --- a/Mage.Common/src/mage/view/TableView.java +++ b/Mage.Common/src/mage/view/TableView.java @@ -65,6 +65,7 @@ public class TableView implements Serializable { private final String quitRatio; private final boolean limited; private final boolean rated; + private final boolean passworded; public TableView(Table table) { this.tableId = table.getId(); @@ -94,8 +95,7 @@ public class TableView implements Serializable { if (!table.isTournament()) { // MATCH if (table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.READY_TO_START)) { - tableStateText = table.getState().toString() + " (" + table.getMatch().getPlayers().size() + "/"+ table.getSeats().length + ")" + - (table.getMatch().getOptions().getPassword().isEmpty() ? "":" PW"); + tableStateText = table.getState().toString() + " (" + table.getMatch().getPlayers().size() + "/"+ table.getSeats().length + ")"; } else { tableStateText = table.getState().toString(); } @@ -136,6 +136,7 @@ public class TableView implements Serializable { this.quitRatio = Integer.toString(table.getMatch().getOptions().getQuitRatio()); this.limited = table.getMatch().getOptions().isLimited(); this.rated = table.getMatch().getOptions().isRated(); + this.passworded = !table.getMatch().getOptions().getPassword().isEmpty(); } else { // TOURNAMENT if (table.getTournament().getOptions().getNumberRounds() > 0) { @@ -155,9 +156,6 @@ public class TableView implements Serializable { switch (table.getState()) { case WAITING: stateText.append(" (").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats()).append(")"); - if (!table.getTournament().getOptions().getPassword().isEmpty()) { - stateText.append(" PW"); - } case READY_TO_START: case STARTING: infoText.append(" Time: ").append(table.getTournament().getOptions().getMatchOptions().getMatchTimeLimit().toString()); @@ -185,6 +183,7 @@ public class TableView implements Serializable { this.quitRatio = Integer.toString(table.getTournament().getOptions().getQuitRatio()); this.limited = table.getTournament().getOptions().getMatchOptions().isLimited(); this.rated = table.getTournament().getOptions().getMatchOptions().isRated(); + this.passworded = !table.getTournament().getOptions().getPassword().isEmpty(); } } @@ -250,4 +249,8 @@ public class TableView implements Serializable { public boolean isRated() { return rated; } + + public boolean isPassworded() { + return passworded; + } }