mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Merge pull request #1505 from menocar/user-pane
Split History column into Matches and Tourneys columns.
This commit is contained in:
commit
75f5a17135
5 changed files with 91 additions and 90 deletions
|
@ -61,7 +61,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
private final List<String> players = new ArrayList<>();
|
private final List<String> players = new ArrayList<>();
|
||||||
private final UserTableModel userTableModel;
|
private final UserTableModel userTableModel;
|
||||||
private static final int[] DEFAULT_COLUMNS_WIDTH = {20, 100, 100, 80, 80};
|
private static final int[] DEFAULT_COLUMNS_WIDTH = {20, 100, 100, 100, 80, 80};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -118,7 +118,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
class UserTableModel extends AbstractTableModel {
|
class UserTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
private final String[] columnNames = new String[]{"Loc", "Players", "History", "Games", "Connection"};
|
private final String[] columnNames = new String[]{"Loc", "Players", "Matches", "Tourneys", "Games", "Connection"};
|
||||||
private UsersView[] players = new UsersView[0];
|
private UsersView[] players = new UsersView[0];
|
||||||
|
|
||||||
public void loadData(Collection<RoomUsersView> roomUserInfoList) throws MageRemoteException {
|
public void loadData(Collection<RoomUsersView> roomUserInfoList) throws MageRemoteException {
|
||||||
|
@ -128,7 +128,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
||||||
TableColumnModel tcm = th.getColumnModel();
|
TableColumnModel tcm = th.getColumnModel();
|
||||||
|
|
||||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(1)).setHeaderValue("Players (" + this.players.length + ")");
|
tcm.getColumn(jTablePlayers.convertColumnIndexToView(1)).setHeaderValue("Players (" + this.players.length + ")");
|
||||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(3)).setHeaderValue(
|
tcm.getColumn(jTablePlayers.convertColumnIndexToView(4)).setHeaderValue(
|
||||||
"Games " + roomUserInfo.getNumberActiveGames()
|
"Games " + roomUserInfo.getNumberActiveGames()
|
||||||
+ (roomUserInfo.getNumberActiveGames() != roomUserInfo.getNumberGameThreads() ? " (T:" + roomUserInfo.getNumberGameThreads() : " (")
|
+ (roomUserInfo.getNumberActiveGames() != roomUserInfo.getNumberGameThreads() ? " (T:" + roomUserInfo.getNumberGameThreads() : " (")
|
||||||
+ " limit: " + roomUserInfo.getNumberMaxGames() + ")");
|
+ " limit: " + roomUserInfo.getNumberMaxGames() + ")");
|
||||||
|
@ -154,10 +154,12 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
||||||
case 1:
|
case 1:
|
||||||
return players[arg0].getUserName();
|
return players[arg0].getUserName();
|
||||||
case 2:
|
case 2:
|
||||||
return players[arg0].getHistory();
|
return players[arg0].getMatchHistory();
|
||||||
case 3:
|
case 3:
|
||||||
return players[arg0].getInfoGames();
|
return players[arg0].getTourneyHistory();
|
||||||
case 4:
|
case 4:
|
||||||
|
return players[arg0].getInfoGames();
|
||||||
|
case 5:
|
||||||
return players[arg0].getInfoPing();
|
return players[arg0].getInfoPing();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -39,13 +39,15 @@ public class UsersView implements Serializable {
|
||||||
|
|
||||||
private final String flagName;
|
private final String flagName;
|
||||||
private final String userName;
|
private final String userName;
|
||||||
private final String history;
|
private final String matchHistory;
|
||||||
|
private final String tourneyHistory;
|
||||||
private final String infoGames;
|
private final String infoGames;
|
||||||
private final String infoPing;
|
private final String infoPing;
|
||||||
|
|
||||||
public UsersView(String flagName, String userName, String history, String infoGames, String infoPing) {
|
public UsersView(String flagName, String userName, String matchHistory, String tourneyHistory, String infoGames, String infoPing) {
|
||||||
this.flagName = flagName;
|
this.flagName = flagName;
|
||||||
this.history = history;
|
this.matchHistory = matchHistory;
|
||||||
|
this.tourneyHistory = tourneyHistory;
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.infoGames = infoGames;
|
this.infoGames = infoGames;
|
||||||
this.infoPing = infoPing;
|
this.infoPing = infoPing;
|
||||||
|
@ -59,8 +61,12 @@ public class UsersView implements Serializable {
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHistory() {
|
public String getMatchHistory() {
|
||||||
return history;
|
return matchHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTourneyHistory() {
|
||||||
|
return tourneyHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInfoGames() {
|
public String getInfoGames() {
|
||||||
|
|
|
@ -399,12 +399,7 @@ public class User {
|
||||||
this.userData.update(userData);
|
this.userData.update(userData);
|
||||||
} else {
|
} else {
|
||||||
this.userData = userData;
|
this.userData = userData;
|
||||||
this.userStats = UserStatsRepository.instance.getUser(this.userName);
|
resetUserStats();
|
||||||
if (userStats != null) {
|
|
||||||
this.userData.setHistory(userStatsToString(userStats.getProto()));
|
|
||||||
} else {
|
|
||||||
this.userData.setHistory("Matches: 0");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,85 +523,72 @@ public class User {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getUserStats returns the UserStats for this user. This caches the result, so if the stats is
|
|
||||||
// updated call resetUserStats to refresh it.
|
|
||||||
public UserStats getUserStats() {
|
|
||||||
if (this.userStats == null) {
|
|
||||||
resetUserStats();
|
|
||||||
}
|
|
||||||
return this.userStats;
|
|
||||||
}
|
|
||||||
|
|
||||||
// resetUserStats loads UserStats from DB.
|
|
||||||
public void resetUserStats() {
|
public void resetUserStats() {
|
||||||
this.userStats = UserStatsRepository.instance.getUser(this.userName);
|
if (userData == null) {
|
||||||
if (userData != null) {
|
return;
|
||||||
userData.setHistory(userStatsToString(userStats.getProto()));
|
}
|
||||||
|
userStats = UserStatsRepository.instance.getUser(this.userName);
|
||||||
|
if (userStats != null) {
|
||||||
|
userData.setMatchHistory(userStatsToMatchHistory(userStats.getProto()));
|
||||||
|
userData.setTourneyHistory(userStatsToTourneyHistory(userStats.getProto()));
|
||||||
|
} else {
|
||||||
|
userData.setMatchHistory("0");
|
||||||
|
userData.setTourneyHistory("0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHistory() {
|
public String getMatchHistory() {
|
||||||
if (userData != null) {
|
if (userData != null) {
|
||||||
return userData.getHistory();
|
return userData.getMatchHistory();
|
||||||
}
|
}
|
||||||
return "<not available>";
|
return "<not available>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String userStatsToString(ResultProtos.UserStatsProto proto) {
|
public String getTourneyHistory() {
|
||||||
List<StringBuilder> builders = new ArrayList<>();
|
if (userData != null) {
|
||||||
if (proto.getMatches() > 0) {
|
return userData.getTourneyHistory();
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Matches:");
|
|
||||||
builder.append(proto.getMatches());
|
|
||||||
List<String> quit = new ArrayList<>();
|
|
||||||
if (proto.getMatchesIdleTimeout() > 0) {
|
|
||||||
quit.add("I:" + Integer.toString(proto.getMatchesIdleTimeout()));
|
|
||||||
}
|
|
||||||
if (proto.getMatchesTimerTimeout() > 0) {
|
|
||||||
quit.add("T:" + Integer.toString(proto.getMatchesTimerTimeout()));
|
|
||||||
}
|
|
||||||
if (proto.getMatchesQuit() > 0) {
|
|
||||||
quit.add("Q:" + Integer.toString(proto.getMatchesQuit()));
|
|
||||||
}
|
|
||||||
if (quit.size() > 0) {
|
|
||||||
builder.append(" (");
|
|
||||||
joinStrings(builder, quit, " ");
|
|
||||||
builder.append(")");
|
|
||||||
}
|
|
||||||
builders.add(builder);
|
|
||||||
}
|
}
|
||||||
if (proto.getTourneys() > 0) {
|
return "<not available>";
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Tourneys:");
|
|
||||||
builder.append(proto.getTourneys());
|
|
||||||
List<String> quit = new ArrayList<>();
|
|
||||||
if (proto.getTourneysQuitDuringDrafting() > 0) {
|
|
||||||
quit.add("D:" + Integer.toString(proto.getTourneysQuitDuringDrafting()));
|
|
||||||
}
|
|
||||||
if (proto.getTourneysQuitDuringConstruction() > 0) {
|
|
||||||
quit.add("C:" + Integer.toString(proto.getTourneysQuitDuringConstruction()));
|
|
||||||
}
|
|
||||||
if (proto.getTourneysQuitDuringRound() > 0) {
|
|
||||||
quit.add("R:" + Integer.toString(proto.getTourneysQuitDuringRound()));
|
|
||||||
}
|
|
||||||
if (quit.size() > 0) {
|
|
||||||
builder.append(" (");
|
|
||||||
joinStrings(builder, quit, " ");
|
|
||||||
builder.append(")");
|
|
||||||
}
|
|
||||||
builders.add(builder);
|
|
||||||
}
|
|
||||||
return joinBuilders(builders);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String joinBuilders(List<StringBuilder> builders) {
|
public static String userStatsToMatchHistory(ResultProtos.UserStatsProto proto) {
|
||||||
if (builders.isEmpty()) {
|
StringBuilder builder = new StringBuilder();
|
||||||
return null;
|
builder.append(proto.getMatches());
|
||||||
|
List<String> quit = new ArrayList<>();
|
||||||
|
if (proto.getMatchesIdleTimeout() > 0) {
|
||||||
|
quit.add("I:" + Integer.toString(proto.getMatchesIdleTimeout()));
|
||||||
}
|
}
|
||||||
StringBuilder builder = builders.get(0);
|
if (proto.getMatchesTimerTimeout() > 0) {
|
||||||
for (int i = 1; i < builders.size(); ++i) {
|
quit.add("T:" + Integer.toString(proto.getMatchesTimerTimeout()));
|
||||||
builder.append(" ");
|
}
|
||||||
builder.append(builders.get(i));
|
if (proto.getMatchesQuit() > 0) {
|
||||||
|
quit.add("Q:" + Integer.toString(proto.getMatchesQuit()));
|
||||||
|
}
|
||||||
|
if (quit.size() > 0) {
|
||||||
|
builder.append(" (");
|
||||||
|
joinStrings(builder, quit, " ");
|
||||||
|
builder.append(")");
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String userStatsToTourneyHistory(ResultProtos.UserStatsProto proto) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append(proto.getTourneys());
|
||||||
|
List<String> quit = new ArrayList<>();
|
||||||
|
if (proto.getTourneysQuitDuringDrafting() > 0) {
|
||||||
|
quit.add("D:" + Integer.toString(proto.getTourneysQuitDuringDrafting()));
|
||||||
|
}
|
||||||
|
if (proto.getTourneysQuitDuringConstruction() > 0) {
|
||||||
|
quit.add("C:" + Integer.toString(proto.getTourneysQuitDuringConstruction()));
|
||||||
|
}
|
||||||
|
if (proto.getTourneysQuitDuringRound() > 0) {
|
||||||
|
quit.add("R:" + Integer.toString(proto.getTourneysQuitDuringRound()));
|
||||||
|
}
|
||||||
|
if (quit.size() > 0) {
|
||||||
|
builder.append(" (");
|
||||||
|
joinStrings(builder, quit, " ");
|
||||||
|
builder.append(")");
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,13 +114,14 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||||
List<UsersView> users = new ArrayList<>();
|
List<UsersView> users = new ArrayList<>();
|
||||||
for (User user : UserManager.getInstance().getUsers()) {
|
for (User user : UserManager.getInstance().getUsers()) {
|
||||||
try {
|
try {
|
||||||
users.add(new UsersView(user.getUserData().getFlagName(), user.getName(), user.getHistory(), user.getGameInfo(), user.getPingInfo()));
|
users.add(new UsersView(user.getUserData().getFlagName(), user.getName(), user.getMatchHistory(), user.getTourneyHistory(), user.getGameInfo(), user.getPingInfo()));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.fatal("User update exception: " + user.getName() + " - " + ex.toString(), ex);
|
logger.fatal("User update exception: " + user.getName() + " - " + ex.toString(), ex);
|
||||||
users.add(new UsersView(
|
users.add(new UsersView(
|
||||||
(user.getUserData() != null && user.getUserData().getFlagName() != null) ? user.getUserData().getFlagName() : "world",
|
(user.getUserData() != null && user.getUserData().getFlagName() != null) ? user.getUserData().getFlagName() : "world",
|
||||||
user.getName() != null ? user.getName() : "<no name>",
|
user.getName() != null ? user.getName() : "<no name>",
|
||||||
user.getHistory() != null ? user.getHistory() : "<no history>",
|
user.getMatchHistory() != null ? user.getMatchHistory() : "<no match history>",
|
||||||
|
user.getTourneyHistory() != null ? user.getTourneyHistory() : "<no tourney history>",
|
||||||
"[exception]",
|
"[exception]",
|
||||||
user.getPingInfo() != null ? user.getPingInfo() : "<no ping>"));
|
user.getPingInfo() != null ? user.getPingInfo() : "<no ping>"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ public class UserData implements Serializable {
|
||||||
protected boolean passPriorityActivation;
|
protected boolean passPriorityActivation;
|
||||||
protected boolean autoOrderTrigger;
|
protected boolean autoOrderTrigger;
|
||||||
|
|
||||||
protected String history;
|
protected String matchHistory;
|
||||||
|
protected String tourneyHistory;
|
||||||
|
|
||||||
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced,
|
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced,
|
||||||
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps,
|
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps,
|
||||||
|
@ -42,7 +43,8 @@ public class UserData implements Serializable {
|
||||||
this.passPriorityCast = passPriorityCast;
|
this.passPriorityCast = passPriorityCast;
|
||||||
this.passPriorityActivation = passPriorityActivation;
|
this.passPriorityActivation = passPriorityActivation;
|
||||||
this.autoOrderTrigger = autoOrderTrigger;
|
this.autoOrderTrigger = autoOrderTrigger;
|
||||||
this.history = "";
|
this.matchHistory = "";
|
||||||
|
this.tourneyHistory = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(UserData userData) {
|
public void update(UserData userData) {
|
||||||
|
@ -169,12 +171,20 @@ public class UserData implements Serializable {
|
||||||
this.autoOrderTrigger = autoOrderTrigger;
|
this.autoOrderTrigger = autoOrderTrigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHistory(String history) {
|
public void setMatchHistory(String history) {
|
||||||
this.history = history;
|
this.matchHistory = history;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHistory() {
|
public String getMatchHistory() {
|
||||||
return history;
|
return matchHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTourneyHistory(String history) {
|
||||||
|
this.tourneyHistory = history;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTourneyHistory() {
|
||||||
|
return tourneyHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefaultFlagName() {
|
public static String getDefaultFlagName() {
|
||||||
|
|
Loading…
Reference in a new issue