PlayerListGui troubles...
by WestWood_Online (#0004) · in Torque Game Engine · 07/14/2009 (10:31 am) · 0 replies
ok, i have a kinda unusual bug... i have searched and searched but cannot find the root of it.
The problem is in my PlayerListGui, which i have modified to support 2 different teams and team scores
it works perfectly for the server, but the client side has a bug that they can only see their score and the scores of people that joined teh game after them.
i.e. all players can only see their score and the scores of the people that joined the game after they joined...
This creates a problem as the endGame scores just take the text from the PlayerListGui and puts it on the new canvas for all players to see. if they are missing some player scores in game then they can't see the scores endGame.
any insight in this... i have put up the PlayerList.gui file so you can review it, and in the function GameConnection::onClientEnterGame i added in PlayerListGui.update to try and get them to see the other players too... but even just reviewing the standard starter.fps functions, they don't come across this problem and the functions already look extremely similar.
The problem is in my PlayerListGui, which i have modified to support 2 different teams and team scores
it works perfectly for the server, but the client side has a bug that they can only see their score and the scores of people that joined teh game after them.
i.e. all players can only see their score and the scores of the people that joined the game after they joined...
This creates a problem as the endGame scores just take the text from the PlayerListGui and puts it on the new canvas for all players to see. if they are missing some player scores in game then they can't see the scores endGame.
any insight in this... i have put up the PlayerList.gui file so you can review it, and in the function GameConnection::onClientEnterGame i added in PlayerListGui.update to try and get them to see the other players too... but even just reviewing the standard starter.fps functions, they don't come across this problem and the functions already look extremely similar.
//-----------------------------------------------------------------------------
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
//-----------------------------------------------------------------------------
//--- OBJECT WRITE BEGIN ---
new GuiControl(PlayerListGui) {
Profile = "GuiModelessDialogProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "0 0";
Extent = "640 480";
MinExtent = "8 8";
Visible = "1";
helpTag = "0";
noCursor = "1";
new GuiBitmapBorderCtrl() {
Profile = "ChatHudBorderProfile";
HorizSizing = "center";
VertSizing = "center";
position = "150 118";
Extent = "333 238";
MinExtent = "8 8";
Visible = "1";
helpTag = "0";
new GuiBitmapCtrl() {
Profile = "GuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "5 5";
Extent = "325 231";
MinExtent = "8 8";
Visible = "1";
bitmap = "./hudfill.png";
wrap = "0";
helpTag = "0";
new GuiTextCtrl() {
Profile = "HudTextProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "132 7";
Extent = "76 20";
MinExtent = "8 8";
Visible = "1";
text = "Score Board";
maxLength = "255";
helpTag = "0";
};
new GuiScrollCtrl() {
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
position = "0 27";
Extent = "161 184";
MinExtent = "8 8";
Visible = "1";
willFirstRespond = "1";
hScrollBar = "alwaysOff";
vScrollBar = "dynamic";
constantThumbHeight = "0";
childMargin = "0 0";
helpTag = "0";
defaultLineHeight = "15";
new GuiTextListCtrl(PlayerListTeam1GuiList) {
Profile = "HudTextProfileRed";
HorizSizing = "width";
VertSizing = "height";
position = "1 1";
Extent = "159 8";
MinExtent = "8 8";
Visible = "1";
enumerate = "0";
resizeCell = "1";
columns = "0 120";
fitParentWidth = "1";
clipColumnText = "0";
helpTag = "0";
};
};
new GuiScrollCtrl() {
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
position = "160 27";
Extent = "161 184";
MinExtent = "8 8";
Visible = "1";
willFirstRespond = "1";
hScrollBar = "alwaysOff";
vScrollBar = "dynamic";
constantThumbHeight = "0";
childMargin = "0 0";
helpTag = "0";
defaultLineHeight = "15";
new GuiTextListCtrl(PlayerListTeam2GuiList) {
Profile = "HudTextProfileBlue";
HorizSizing = "width";
VertSizing = "height";
position = "1 1";
Extent = "159 8";
MinExtent = "8 8";
Visible = "1";
enumerate = "0";
resizeCell = "1";
columns = "0 120";
fitParentWidth = "1";
clipColumnText = "0";
helpTag = "0";
};
};
new GuiScrollCtrl() {
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
position = "0 43";
Extent = "161 184";
MinExtent = "8 8";
Visible = "1";
willFirstRespond = "1";
hScrollBar = "alwaysOff";
vScrollBar = "dynamic";
constantThumbHeight = "0";
childMargin = "0 0";
helpTag = "0";
defaultLineHeight = "15";
new GuiTextListCtrl(PlayerListGuiList) {
Profile = "HudTextProfileRed";
HorizSizing = "width";
VertSizing = "height";
position = "1 1";
Extent = "159 8";
MinExtent = "8 8";
Visible = "1";
enumerate = "0";
resizeCell = "1";
columns = "0 120";
fitParentWidth = "1";
clipColumnText = "0";
helpTag = "0";
};
};
new GuiScrollCtrl() {
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
position = "160 43";
Extent = "161 184";
MinExtent = "8 8";
Visible = "1";
willFirstRespond = "1";
hScrollBar = "alwaysOff";
vScrollBar = "dynamic";
constantThumbHeight = "0";
childMargin = "0 0";
helpTag = "0";
defaultLineHeight = "15";
new GuiTextListCtrl(PlayerList2GuiList) {
Profile = "HudTextProfileBlue";
HorizSizing = "width";
VertSizing = "height";
position = "1 1";
Extent = "159 8";
MinExtent = "8 8";
Visible = "1";
enumerate = "0";
resizeCell = "1";
columns = "0 120";
fitParentWidth = "1";
clipColumnText = "0";
helpTag = "0";
};
};
};
};
};
//--- OBJECT WRITE END ---
function PlayerListGui::update(%this,%clientId,%name,%isSuperAdmin,%isAdmin,%isAI,%score)
{
// Build the row to display. The name can have ML control tags,
// including color and font. Since we're not using and
// ML control here, we need to strip them off.
%tag = %isSuperAdmin? "[Super]":
(%isAdmin? "[Admin]":
(%isAI? "[Bot]":
""));
%text = "Red: " @ $Team1.score;
if (PlayerListTeam1GuiList.getRowNumById(111) == -1)
PlayerListTeam1GuiList.addRow(111, %text);
else
PlayerListTeam1GuiList.setRowById(111, %text);
%text = "Blue: " @ $Team2.score;
if (PlayerListTeam2GuiList.getRowNumById(222) == -1)
PlayerListTeam2GuiList.addRow(222, %text);
else
PlayerListTeam2GuiList.setRowById(222, %text);
%text = StripMLControlChars(%name) SPC %tag TAB %score;
if (%team == 1)
{
if (PlayerListGuiList.getRowNumById(%clientId) == -1)
PlayerListGuiList.addRow(%clientId, %text);
else
PlayerListGuiList.setRowById(%clientId, %text);
PlayerListGuiList.sortNumerical(1,false);
PlayerListGuiList.clearSelection();
}
else if (%team == 2)
{
if (PlayerList2GuiList.getRowNumById(%clientId) == -1)
PlayerList2GuiList.addRow(%clientId, %text);
else
PlayerList2GuiList.setRowById(%clientId, %text);
PlayerList2GuiList.sortNumerical(1,false);
PlayerList2GuiList.clearSelection();
}
}
function PlayerListGui::updateTeam(%this,%clientname,%clientId,%teamid,%score)
{
error ("Update Team: PlayerName = " @%clientname @ " ClientID = " @ %clientId @ " TeamId = " @ %teamid);
%text = "Red: " @ $Team1.score;
if (PlayerListTeam1GuiList.getRowNumById(111) == -1)
PlayerListTeam1GuiList.addRow(111, %text);
else
PlayerListTeam1GuiList.setRowById(111, %text);
%text = "Blue: " @ $Team2.score;
if (PlayerListTeam2GuiList.getRowNumById(222) == -1)
PlayerListTeam2GuiList.addRow(222, %text);
else
PlayerListTeam2GuiList.setRowById(222, %text);
if (%teamid ==1)
{
%text = StripMLControlChars(%clientname) TAB %score;
if (PlayerListGuiList.getRowNumById(%clientId) == -1)
PlayerListGuiList.addRow(%clientId, %text);
%textid = PlayerListGuiList.getRowTextById(%clientId);
PlayerListGuiList.setRowById(%clientId, %textid);
PlayerListGuiList.sortNumerical(1,false);
PlayerListGuiList.clearSelection();
PlayerList2GuiList.removeRowById(%clientId); // Remove from other side
PlayerList2GuiList.clearSelection();
}
else if (%teamid ==2)
{
%text = StripMLControlChars(%clientname) TAB %score;
if (PlayerList2GuiList.getRowNumById(%clientId) == -1)
PlayerList2GuiList.addRow(%clientId, %text);
%textid = PlayerList2GuiList.getRowTextById(%clientId);
PlayerList2GuiList.setRowById(%clientId, %textid);
PlayerList2GuiList.sortNumerical(1,false);
PlayerList2GuiList.clearSelection();
PlayerListGuiList.removeRowById(%clientId); // Remove from other side
PlayerListGuiList.clearSelection();
}
}
function PlayerListGui::updateScore(%this,%clientId,%score)
{
%text = "Red: " @ $Team1.score;
if (PlayerListTeam1GuiList.getRowNumById(111) == -1)
PlayerListTeam1GuiList.addRow(111, %text);
else
PlayerListTeam1GuiList.setRowById(111, %text);
%text = "Blue: " @ $Team2.score;
if (PlayerListTeam2GuiList.getRowNumById(222) == -1)
PlayerListTeam2GuiList.addRow(222, %text);
else
PlayerListTeam2GuiList.setRowById(222, %text);
if (PlayerListGuiList.getRowNumById(%clientId) != -1)
{
error ("Updated Score Team1: ClientID = "@%clientID@" Score = "@%score);
%text = PlayerListGuiList.getRowTextById(%clientId);
%text = setField(%text,1,%score);
PlayerListGuiList.setRowById(%clientId, %text);
PlayerListGuiList.sortNumerical(1,false);
PlayerListGuiList.clearSelection();
}
else if (PlayerList2GuiList.getRowNumById(%clientId) != -1)
{
error ("Updated Score Team2: ClientID = "@%clientID@" Score = "@%score);
%text = PlayerList2GuiList.getRowTextById(%clientId);
%text = setField(%text,1,%score);
PlayerList2GuiList.setRowById(%clientId, %text);
PlayerList2GuiList.sortNumerical(1,false);
PlayerList2GuiList.clearSelection();
}
}
function PlayerListGui::remove(%this,%clientId)
{
PlayerListGuiList.removeRowById(%clientId);
PlayerList2GuiList.removeRowById(%clientId);
}
function PlayerListGui::toggle(%this)
{
if (%this.isAwake())
Canvas.popDialog(%this);
else
Canvas.pushDialog(%this);
}
function PlayerListGui::clear(%this)
{
// Override to clear the list.
PlayerListTeam1GuiList.clear();
PlayerListTeam2GuiList.clear();
PlayerListGuiList.clear();
PlayerList2GuiList.clear();
}
function PlayerListGui::zeroScores(%this)
{
for (%i = 0; %i < PlayerListGuiList.rowCount(); %i++) {
%text = PlayerListGuiList.getRowText(%i);
%text = setField(%text,1,"0");
PlayerListGuiList.setRowById(PlayerListGuiList.getRowId(%i), %text);
}
PlayerListGuiList.clearSelection();
}