forked from 0ad/0ad
Moved the translation of AI messages to a later point
This avoids attempts to translate messages prefixed with keywords, such as “/team Message prefixed with a keyword”, and translates them only after the keyword has been removed. Some keywords may hide the message, removing the need for a translation altogether. This was SVN commit r15027.
This commit is contained in:
parent
d91756b251
commit
d4109916a3
@ -41,24 +41,21 @@ function handleNotifications()
|
||||
if (notification.type == "chat" ||
|
||||
notification.type == "aichat")
|
||||
{
|
||||
var message = {
|
||||
"type": "message",
|
||||
"text": notification.message
|
||||
}
|
||||
if (notification.type == "aichat")
|
||||
notification.message = translate(notification.message);
|
||||
message["translate"] = true;
|
||||
var guid = findGuidForPlayerID(g_PlayerAssignments, notification.player);
|
||||
if (guid == undefined)
|
||||
{
|
||||
addChatMessage({
|
||||
"type": "message",
|
||||
"guid": -1,
|
||||
"player": notification.player,
|
||||
"text": notification.message
|
||||
});
|
||||
message["guid"] = -1;
|
||||
message["player"] = notification.player;
|
||||
} else {
|
||||
addChatMessage({
|
||||
"type": "message",
|
||||
"guid": findGuidForPlayerID(g_PlayerAssignments, notification.player),
|
||||
"text": notification.message
|
||||
});
|
||||
message["guid"] = findGuidForPlayerID(g_PlayerAssignments, notification.player);
|
||||
}
|
||||
addChatMessage(message);
|
||||
}
|
||||
else if (notification.type == "defeat")
|
||||
{
|
||||
@ -274,7 +271,7 @@ function handleNetMessage(message)
|
||||
break;
|
||||
|
||||
case "aichat":
|
||||
addChatMessage({ "type": "message", "guid": message.guid, "text": translate(message.text) });
|
||||
addChatMessage({ "type": "message", "guid": message.guid, "text": message.text, "translate": true });
|
||||
break;
|
||||
|
||||
// To prevent errors, ignore these message types that occur during autostart
|
||||
@ -489,7 +486,11 @@ function addChatMessage(msg, playerAssignments)
|
||||
if (msg.hide)
|
||||
return;
|
||||
|
||||
var message = escapeText(msg.text);
|
||||
var message;
|
||||
if ("translate" in msg && msg.translate)
|
||||
message = translate(msg.text); // No need to escape, not a use message.
|
||||
else
|
||||
message = escapeText(msg.text)
|
||||
|
||||
if (msg.action)
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ function displaySingle(entState, template)
|
||||
var armorString = sprintf(translate("%(label)s %(details)s"), { label: armorLabel, details: armorTypeDetails(entState.armour) });
|
||||
|
||||
// Attack and Armor
|
||||
if (entState.attack)
|
||||
if ("attack" in entState && entState.attack)
|
||||
{
|
||||
// Rate
|
||||
if (entState.buildingAI)
|
||||
|
@ -990,10 +990,10 @@ GuiInterface.prototype.DisplayRallyPoint = function(player, cmd)
|
||||
if (pos)
|
||||
{
|
||||
// Only update the position if we changed it (cmd.queued is set)
|
||||
if (cmd.queued == true)
|
||||
cmpRallyPointRenderer.AddPosition({'x': pos.x, 'y': pos.z}); // AddPosition takes a CFixedVector2D which has X/Y components, not X/Z
|
||||
else if (cmd.queued == false)
|
||||
if (!("queued" in cmd) || cmd.queued == false)
|
||||
cmpRallyPointRenderer.SetPosition({'x': pos.x, 'y': pos.z}); // SetPosition takes a CFixedVector2D which has X/Y components, not X/Z
|
||||
else if (cmd.queued == true)
|
||||
cmpRallyPointRenderer.AddPosition({'x': pos.x, 'y': pos.z}); // AddPosition takes a CFixedVector2D which has X/Y components, not X/Z
|
||||
// rebuild the renderer when not set (when reading saved game or in case of building update)
|
||||
else if (!cmpRallyPointRenderer.IsSet())
|
||||
for each (var posi in cmpRallyPoint.GetPositions())
|
||||
|
@ -220,7 +220,10 @@ function ProcessCommand(player, cmd)
|
||||
var queue = Engine.QueryInterface(ent, IID_ProductionQueue);
|
||||
// Check if the building can train the unit
|
||||
if (queue && queue.GetEntitiesList().indexOf(cmd.template) != -1)
|
||||
queue.AddBatch(cmd.template, "unit", +cmd.count, cmd.metadata);
|
||||
if ("metadata" in cmd)
|
||||
queue.AddBatch(cmd.template, "unit", +cmd.count, cmd.metadata);
|
||||
else
|
||||
queue.AddBatch(cmd.template, "unit", +cmd.count);
|
||||
}
|
||||
else if (g_DebugCommands)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user