forked from mirrors/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:
@@ -15,8 +15,10 @@ function layoutSelectionSingle(entState)
|
|||||||
getGUIObjectByName("sdIcon").hidden = false;
|
getGUIObjectByName("sdIcon").hidden = false;
|
||||||
getGUIObjectByName("sdStatsArea").hidden = false;
|
getGUIObjectByName("sdStatsArea").hidden = false;
|
||||||
|
|
||||||
if (entState.maxHitpoints != undefined)
|
if (entState.hitpoints != undefined)
|
||||||
getGUIObjectByName("sdHealth").hidden = false;
|
getGUIObjectByName("sdHealth").hidden = false;
|
||||||
|
else
|
||||||
|
getGUIObjectByName("sdHealth").hidden = true;
|
||||||
|
|
||||||
var player = Engine.GetPlayerID();
|
var player = Engine.GetPlayerID();
|
||||||
if (entState.player == player || g_DevSettings.controlAll)
|
if (entState.player == player || g_DevSettings.controlAll)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const PERSIANS = "Persians";
|
|||||||
const IBERIANS = "Iberians";
|
const IBERIANS = "Iberians";
|
||||||
|
|
||||||
// Chat data
|
// Chat data
|
||||||
const maxNumChatLines = 30;
|
const maxNumChatLines = 20;
|
||||||
var g_ChatMessages = [];
|
var g_ChatMessages = [];
|
||||||
var g_ChatTimers = [];
|
var g_ChatTimers = [];
|
||||||
|
|
||||||
@@ -51,6 +51,10 @@ function init(initData, hotloadData)
|
|||||||
g_IsNetworked = initData.isNetworked; // Set network mode
|
g_IsNetworked = initData.isNetworked; // Set network mode
|
||||||
g_Players = getPlayerData(initData.playerAssignments); // Cache the player data
|
g_Players = getPlayerData(initData.playerAssignments); // Cache the player data
|
||||||
}
|
}
|
||||||
|
else // Needed for autostart loading option
|
||||||
|
{
|
||||||
|
g_Players = getPlayerData(null);
|
||||||
|
}
|
||||||
|
|
||||||
onSimulationUpdate();
|
onSimulationUpdate();
|
||||||
}
|
}
|
||||||
@@ -156,7 +160,7 @@ function submitChatInput()
|
|||||||
if (g_IsNetworked)
|
if (g_IsNetworked)
|
||||||
Engine.SendNetworkChat(text);
|
Engine.SendNetworkChat(text);
|
||||||
else
|
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 = "";
|
input.caption = "";
|
||||||
}
|
}
|
||||||
@@ -183,15 +187,15 @@ function addChatMessage(msg)
|
|||||||
switch (msg.type)
|
switch (msg.type)
|
||||||
{
|
{
|
||||||
case "connect":
|
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;
|
break;
|
||||||
|
|
||||||
case "disconnect":
|
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;
|
break;
|
||||||
|
|
||||||
case "message":
|
case "message":
|
||||||
formatted = '<[color="' + playerColor + '"]' + msg.username + '[/color]> ' + msg.text;
|
formatted = '<[font=\"serif-stroke-14\"][color="' + playerColor + '"]' + msg.username + '[/color][/font]> ' + msg.text;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -263,10 +267,6 @@ function onSimulationUpdate()
|
|||||||
updateDebug(simState);
|
updateDebug(simState);
|
||||||
updatePlayerDisplay(simState);
|
updatePlayerDisplay(simState);
|
||||||
updateSelectionDetails();
|
updateSelectionDetails();
|
||||||
|
|
||||||
if (g_ChatTimers.length)
|
|
||||||
console.write(g_ChatTimers[0]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDebug(simState)
|
function updateDebug(simState)
|
||||||
|
|||||||
@@ -129,13 +129,13 @@
|
|||||||
<!-- ================================ ================================ -->
|
<!-- ================================ ================================ -->
|
||||||
|
|
||||||
<!-- Chat panel -->
|
<!-- Chat panel -->
|
||||||
<object name="chatPanel" size="0 50 512 100%-200" type="image" ghost="true">
|
<object name="chatPanel" size="0 100 512 100%-240" type="image" ghost="true">
|
||||||
<object name="chatText" size="3 1 100%-1 100%-25" type="text" style="chatPanel" ghost="true"/>
|
<object name="chatText" size="3 1 100%-1 100%-1" type="text" style="chatPanel" ghost="true"/>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
<!-- Chat window -->
|
<!-- Chat window -->
|
||||||
<object name="chatWindow" size="50%-200 50%-13 50%+200 50%+13" type="image" sprite="wheatIndentFillLight" hidden="true" z="10">
|
<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 100%-23 100%-66 100%-3" type="input" style="wheatInput" max_length="40">
|
<object name="chatInput" size="2 2 100%-66 100%-2" type="input" style="wheatInput" max_length="40">
|
||||||
<action on="Press">submitChatInput();</action>
|
<action on="Press">submitChatInput();</action>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@
|
|||||||
|
|
||||||
<style name="chatPanel"
|
<style name="chatPanel"
|
||||||
buffer_zone="5"
|
buffer_zone="5"
|
||||||
font="serif-bold-13"
|
font="serif-bold-14"
|
||||||
textcolor="white"
|
textcolor="white"
|
||||||
textcolor_selected="white"
|
textcolor_selected="white"
|
||||||
text_align="left"
|
text_align="left"
|
||||||
|
|||||||
Reference in New Issue
Block a user