Adding player display for game rooms.

This commit is contained in:
marcins78@gmail.com
2011-12-07 22:10:57 +00:00
parent 0bcb55474a
commit 4694a3b9e9
4 changed files with 48 additions and 8 deletions

View File

@@ -180,7 +180,7 @@ public class LotroGameMediator {
}
if (_lotroGame.getGameState() != null && _lotroGame.getWinnerPlayerId() == null) {
for (Map.Entry<String, Long> playerDecision : _decisionQuerySentTimes.entrySet()) {
for (Map.Entry<String, Long> playerDecision : new HashMap<String, Long>(_decisionQuerySentTimes).entrySet()) {
String playerId = playerDecision.getKey();
long decisionSent = playerDecision.getValue();
if (currentTime > decisionSent + _playerDecisionTimeoutPeriod) {

View File

@@ -243,6 +243,13 @@ body {
font-size: 300%;
}
.ui-tabs .ui-tabs-nav li a.slimTab {
padding-left: 3px;
padding-right: 3px;
padding-top: 2px;
padding-bottom: 2px;
}
#chatBox {
font-size: 90%;
}
@@ -282,6 +289,10 @@ body {
font-size: 70%;
padding: .2em .5em;
}
.ui-tabs .ui-tabs-panel.slimPanel {
padding: 4px;
}
</style>
<link rel="stylesheet" type="text/css" href="css/dark-hive/jquery-ui-1.8.16.custom.css">
<link rel="stylesheet" type="text/css" href="css/jquery.contextMenu.css">

View File

@@ -12,9 +12,11 @@ var ChatBoxUI = Class.extend({
processingMessages: null,
retryCount: null,
maxRetryCount: 5,
playerListener: null,
init: function(name, div, url, showList) {
init: function(name, div, url, showList, playerListener) {
var that = this;
this.playerListener = playerListener;
this.retryCount = 0;
this.name = name;
this.div = div;
@@ -149,12 +151,24 @@ var ChatBoxUI = Class.extend({
}
}
if (this.chatListDiv != null) {
this.chatListDiv.html("");
var users = root.getElementsByTagName("user");
var users = root.getElementsByTagName("user");
if (this.playerListener != null) {
var players = new Array();
for (var i = 0; i < users.length; i++) {
var user = users[i];
var userName = user.childNodes[0].nodeValue;
players.push(userName);
}
this.playerListener(players);
}
if (this.chatListDiv != null) {
this.chatListDiv.html("");
var players = new Array();
for (var i = 0; i < users.length; i++) {
var user = users[i];
var userName = user.childNodes[0].nodeValue;
players.push(userName);
this.chatListDiv.append("<div class='chatUser'>" + userName + "</div>");
}
}

View File

@@ -312,8 +312,15 @@ var GempLotrGameUI = Class.extend({
addBottomLeftTabPane: function() {
var that = this;
this.tabPane = $("<div><ul><li><a href='#chatBox'>Chat</a></li><li><a href='#settingsBox'>Settings</a></li><li><a href='#gameOptionsBox'>Game options</a></li></ul>"
+ "<div id='chatBox'></div><div id='settingsBox'></div><div id='gameOptionsBox'></div></div>").tabs();
var tabsLabels = "<li><a href='#chatBox' class='slimTab'>Chat</a></li>";
var tabsBodies = "<div id='chatBox' class='slimPanel'></div>";
if (!this.replayMode) {
tabsLabels += "<li><a href='#settingsBox' class='slimTab'>Settings</a></li><li><a href='#gameOptionsBox' class='slimTab'>Options</a></li><li><a href='#playersInRoomBox' class='slimTab'>Players</a></li>";
tabsBodies += "<div id='settingsBox' class='slimPanel'></div><div id='gameOptionsBox' class='slimPanel'></div><div id='playersInRoomBox' class='slimPanel'></div>";
}
var tabsStr = "<div id='bottomLeftTabs'><ul>" + tabsLabels + "</ul>" + tabsBodies + "</div>";
this.tabPane = $(tabsStr).tabs();
$("#main").append(this.tabPane);
@@ -345,8 +352,16 @@ var GempLotrGameUI = Class.extend({
$.cookie("autoAccept", "" + selected, { expires: 365 });
});
var playerListener = function(players) {
var val = "";
for (var i = 0; i < players.length; i++)
val += players[i] + "<br/>";
$("a[href='#playersInRoomBox']").html("Players(" + players.length + ")");
$("#playersInRoomBox").html(val);
};
var chatRoomName = (this.replayMode ? null : ("Game" + getUrlParam("gameId")));
this.chatBox = new ChatBoxUI(chatRoomName, $("#chatBox"), this.communication.url);
this.chatBox = new ChatBoxUI(chatRoomName, $("#chatBox"), this.communication.url, false, playerListener);
this.chatBox.chatUpdateInterval = 3000;
if (!this.spectatorMode && !this.replayMode) {