1
0
forked from 0ad/0ad

This should finish up multiplayer chat (#216)

Made chat window look a little better
Fixed issue with autostart

This was SVN commit r7914.
This commit is contained in:
WhiteTreePaladin 2010-08-12 03:01:33 +00:00
parent 053bc539fc
commit d5bd374586
4 changed files with 17 additions and 15 deletions

View File

@ -15,8 +15,10 @@ function layoutSelectionSingle(entState)
getGUIObjectByName("sdIcon").hidden = false;
getGUIObjectByName("sdStatsArea").hidden = false;
if (entState.maxHitpoints != undefined)
if (entState.hitpoints != undefined)
getGUIObjectByName("sdHealth").hidden = false;
else
getGUIObjectByName("sdHealth").hidden = true;
var player = Engine.GetPlayerID();
if (entState.player == player || g_DevSettings.controlAll)

View File

@ -19,7 +19,7 @@ const PERSIANS = "Persians";
const IBERIANS = "Iberians";
// Chat data
const maxNumChatLines = 30;
const maxNumChatLines = 20;
var g_ChatMessages = [];
var g_ChatTimers = [];
@ -51,6 +51,10 @@ function init(initData, hotloadData)
g_IsNetworked = initData.isNetworked; // Set network mode
g_Players = getPlayerData(initData.playerAssignments); // Cache the player data
}
else // Needed for autostart loading option
{
g_Players = getPlayerData(null);
}
onSimulationUpdate();
}
@ -156,7 +160,7 @@ function submitChatInput()
if (g_IsNetworked)
Engine.SendNetworkChat(text);
else
getGUIObjectByName("chatText").caption = "Chat is not currently supported in single player mode.";
addChatMessage({ "type": "message", "username": g_Players[1].name, "text": text });
input.caption = "";
}
@ -183,15 +187,15 @@ function addChatMessage(msg)
switch (msg.type)
{
case "connect":
formatted = '<[color="' + playerColor + '"]' + msg.username + '[/color]> [color="64 64 64"]has joined[/color]';
formatted = '<[font=\"serif-stroke-14\"][color="' + playerColor + '"]' + msg.username + '[/color][/font]> [color="64 64 64"]has joined[/color]';
break;
case "disconnect":
formatted = '<[color="' + playerColor + '"]' + msg.username + '[/color]> [color="64 64 64"]has left[/color]';
formatted = '<[font=\"serif-stroke-14\"][color="' + playerColor + '"]' + msg.username + '[/color][/font]> [color="64 64 64"]has left[/color]';
break;
case "message":
formatted = '<[color="' + playerColor + '"]' + msg.username + '[/color]> ' + msg.text;
formatted = '<[font=\"serif-stroke-14\"][color="' + playerColor + '"]' + msg.username + '[/color][/font]> ' + msg.text;
break;
default:
@ -263,10 +267,6 @@ function onSimulationUpdate()
updateDebug(simState);
updatePlayerDisplay(simState);
updateSelectionDetails();
if (g_ChatTimers.length)
console.write(g_ChatTimers[0]);
}
function updateDebug(simState)

View File

@ -129,13 +129,13 @@
<!-- ================================ ================================ -->
<!-- Chat panel -->
<object name="chatPanel" size="0 50 512 100%-200" type="image" ghost="true">
<object name="chatText" size="3 1 100%-1 100%-25" type="text" style="chatPanel" ghost="true"/>
<object name="chatPanel" size="0 100 512 100%-240" type="image" ghost="true">
<object name="chatText" size="3 1 100%-1 100%-1" type="text" style="chatPanel" ghost="true"/>
</object>
<!-- Chat window -->
<object name="chatWindow" size="50%-200 50%-13 50%+200 50%+13" type="image" sprite="wheatIndentFillLight" hidden="true" z="10">
<object name="chatInput" size="2 100%-23 100%-66 100%-3" type="input" style="wheatInput" max_length="40">
<object name="chatWindow" size="50%-200 50%-13 50%+200 50%+13" type="image" hidden="true" z="10" style="sessionPanelStyle">
<object name="chatInput" size="2 2 100%-66 100%-2" type="input" style="wheatInput" max_length="40">
<action on="Press">submitChatInput();</action>
</object>

View File

@ -148,7 +148,7 @@
<style name="chatPanel"
buffer_zone="5"
font="serif-bold-13"
font="serif-bold-14"
textcolor="white"
textcolor_selected="white"
text_align="left"