mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* UI: added game name and seats number columns to tables list;
This commit is contained in:
parent
12b8c12d74
commit
cfff0f8116
3 changed files with 83 additions and 58 deletions
|
|
@ -56,7 +56,7 @@ import static mage.client.dialog.PreferencesDialog.*;
|
|||
public class TablesPanel extends javax.swing.JPanel {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(TablesPanel.class);
|
||||
private static final int[] DEFAULT_COLUMNS_WIDTH = {35, 150, 120, 180, 80, 120, 80, 60, 40, 40, 60};
|
||||
private static final int[] DEFAULT_COLUMNS_WIDTH = {35, 150, 100, 50, 120, 180, 80, 120, 80, 60, 40, 40, 60};
|
||||
|
||||
private final TablesTableModel tableModel;
|
||||
private final MatchesTableModel matchesModel;
|
||||
|
|
@ -163,6 +163,16 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
}
|
||||
};
|
||||
|
||||
// center text render
|
||||
TableCellRenderer centerCellRenderer = new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
label.setHorizontalAlignment(JLabel.CENTER);
|
||||
return label;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates new form TablesPanel
|
||||
*/
|
||||
|
|
@ -189,6 +199,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
tableTables.getColumnModel().getColumn(TablesTableModel.COLUMN_CREATED).setCellRenderer(timeAgoCellRenderer);
|
||||
// skill level
|
||||
tableTables.getColumnModel().getColumn(TablesTableModel.COLUMN_SKILL).setCellRenderer(skillCellRenderer);
|
||||
// seats
|
||||
tableTables.getColumnModel().getColumn(TablesTableModel.COLUMN_SEATS).setCellRenderer(centerCellRenderer);
|
||||
|
||||
/* date sorter (not need, default is good - see getColumnClass)
|
||||
activeTablesSorter.setComparator(TablesTableModel.COLUMN_CREATED, new Comparator<Date>() {
|
||||
|
|
|
|||
|
|
@ -28,24 +28,26 @@ public class TablesTableModel extends AbstractTableModel {
|
|||
|
||||
public static final int COLUMN_ICON = 0;
|
||||
public static final int COLUMN_DECK_TYPE = 1; // column the deck type is located (starting with 0) Start string is used to check for Limited
|
||||
public static final int COLUMN_OWNER = 2;
|
||||
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_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 COLUMN_MINIMUM_RATING = 11;
|
||||
public static final int ACTION_COLUMN = 12; // column the action is located (starting with 0)
|
||||
public static final int COLUMN_NAME = 2;
|
||||
public static final int COLUMN_SEATS = 3;
|
||||
public static final int COLUMN_OWNER = 4;
|
||||
public static final int COLUMN_GAME_TYPE = 5;
|
||||
public static final int COLUMN_INFO = 6;
|
||||
public static final int COLUMN_STATUS = 7;
|
||||
public static final int COLUMN_PASSWORD = 8;
|
||||
public static final int COLUMN_CREATED = 9;
|
||||
public static final int COLUMN_SKILL = 10;
|
||||
public static final int COLUMN_RATING = 11;
|
||||
public static final int COLUMN_QUIT_RATIO = 12;
|
||||
public static final int COLUMN_MINIMUM_RATING = 13;
|
||||
public static final int ACTION_COLUMN = 14; // column the action is located (starting with 0)
|
||||
|
||||
public static final String RATED_VALUE_YES = "YES";
|
||||
public static final String RATED_VALUE_NO = "";
|
||||
|
||||
public static final String PASSWORD_VALUE_YES = "YES";
|
||||
|
||||
private final String[] columnNames = new String[]{"M/T", "Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Password", "Created / Started", "Skill Level", "Rated", "Quit %", "Min Rating", "Action"};
|
||||
private final String[] columnNames = new String[]{"M/T", "Deck Type", "Name", "Seats", "Owner / Players", "Game Type", "Info", "Status", "Password", "Created / Started", "Skill Level", "Rated", "Quit %", "Min Rating", "Action"};
|
||||
|
||||
private TableView[] tables = new TableView[0];
|
||||
|
||||
|
|
@ -115,55 +117,59 @@ public class TablesTableModel extends AbstractTableModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
switch (arg1) {
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return tables[arg0].isTournament() ? tourneyIcon : matchIcon;
|
||||
return tables[rowIndex].isTournament() ? tourneyIcon : matchIcon;
|
||||
case 1:
|
||||
return tables[arg0].getDeckType();
|
||||
return tables[rowIndex].getDeckType();
|
||||
case 2:
|
||||
return tables[arg0].getControllerName();
|
||||
return tables[rowIndex].getTableName();
|
||||
case 3:
|
||||
return tables[arg0].getGameType();
|
||||
return tables[rowIndex].getSeatsInfo();
|
||||
case 4:
|
||||
return tables[arg0].getAdditionalInfo();
|
||||
return tables[rowIndex].getControllerName();
|
||||
case 5:
|
||||
return tables[arg0].getTableStateText();
|
||||
return tables[rowIndex].getGameType();
|
||||
case 6:
|
||||
return tables[arg0].isPassworded() ? PASSWORD_VALUE_YES : "";
|
||||
return tables[rowIndex].getAdditionalInfo();
|
||||
case 7:
|
||||
return tables[arg0].getCreateTime(); // use cell render, not format here
|
||||
return tables[rowIndex].getTableStateText();
|
||||
case 8:
|
||||
return this.getSkillLevelAsCode(tables[arg0].getSkillLevel(), false);
|
||||
return tables[rowIndex].isPassworded() ? PASSWORD_VALUE_YES : "";
|
||||
case 9:
|
||||
return tables[arg0].isRated() ? RATED_VALUE_YES : RATED_VALUE_NO;
|
||||
return tables[rowIndex].getCreateTime(); // use cell render, not format here
|
||||
case 10:
|
||||
return tables[arg0].getQuitRatio();
|
||||
return this.getSkillLevelAsCode(tables[rowIndex].getSkillLevel(), false);
|
||||
case 11:
|
||||
return tables[arg0].getMinimumRating();
|
||||
return tables[rowIndex].isRated() ? RATED_VALUE_YES : RATED_VALUE_NO;
|
||||
case 12:
|
||||
switch (tables[arg0].getTableState()) {
|
||||
return tables[rowIndex].getQuitRatio();
|
||||
case 13:
|
||||
return tables[rowIndex].getMinimumRating();
|
||||
case 14:
|
||||
switch (tables[rowIndex].getTableState()) {
|
||||
|
||||
case WAITING:
|
||||
String owner = tables[arg0].getControllerName();
|
||||
String owner = tables[rowIndex].getControllerName();
|
||||
if (SessionHandler.getSession() != null && owner.equals(SessionHandler.getUserName())) {
|
||||
return "";
|
||||
}
|
||||
return "Join";
|
||||
case CONSTRUCTING:
|
||||
case DRAFTING:
|
||||
if (tables[arg0].isTournament()) {
|
||||
if (tables[rowIndex].isTournament()) {
|
||||
return "Show";
|
||||
}
|
||||
case DUELING:
|
||||
if (tables[arg0].isTournament()) {
|
||||
if (tables[rowIndex].isTournament()) {
|
||||
return "Show";
|
||||
} else {
|
||||
owner = tables[arg0].getControllerName();
|
||||
owner = tables[rowIndex].getControllerName();
|
||||
if (SessionHandler.getSession() != null && owner.equals(SessionHandler.getUserName())) {
|
||||
return "";
|
||||
}
|
||||
if (tables[arg0].getSpectatorsAllowed()) {
|
||||
if (tables[rowIndex].getSpectatorsAllowed()) {
|
||||
return "Watch";
|
||||
}
|
||||
return "";
|
||||
|
|
@ -171,15 +177,15 @@ public class TablesTableModel extends AbstractTableModel {
|
|||
default:
|
||||
return "";
|
||||
}
|
||||
case 13:
|
||||
return tables[arg0].isTournament();
|
||||
case 14:
|
||||
if (!tables[arg0].getGames().isEmpty()) {
|
||||
return tables[arg0].getGames().get(0);
|
||||
case 15:
|
||||
return tables[rowIndex].isTournament();
|
||||
case 16:
|
||||
if (!tables[rowIndex].getGames().isEmpty()) {
|
||||
return tables[rowIndex].getGames().get(0);
|
||||
}
|
||||
return null;
|
||||
case 15:
|
||||
return tables[arg0].getTableId();
|
||||
case 17:
|
||||
return tables[rowIndex].getTableId();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue