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" ||
|
if (notification.type == "chat" ||
|
||||||
notification.type == "aichat")
|
notification.type == "aichat")
|
||||||
{
|
{
|
||||||
|
var message = {
|
||||||
|
"type": "message",
|
||||||
|
"text": notification.message
|
||||||
|
}
|
||||||
if (notification.type == "aichat")
|
if (notification.type == "aichat")
|
||||||
notification.message = translate(notification.message);
|
message["translate"] = true;
|
||||||
var guid = findGuidForPlayerID(g_PlayerAssignments, notification.player);
|
var guid = findGuidForPlayerID(g_PlayerAssignments, notification.player);
|
||||||
if (guid == undefined)
|
if (guid == undefined)
|
||||||
{
|
{
|
||||||
addChatMessage({
|
message["guid"] = -1;
|
||||||
"type": "message",
|
message["player"] = notification.player;
|
||||||
"guid": -1,
|
|
||||||
"player": notification.player,
|
|
||||||
"text": notification.message
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
addChatMessage({
|
message["guid"] = findGuidForPlayerID(g_PlayerAssignments, notification.player);
|
||||||
"type": "message",
|
|
||||||
"guid": findGuidForPlayerID(g_PlayerAssignments, notification.player),
|
|
||||||
"text": notification.message
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
addChatMessage(message);
|
||||||
}
|
}
|
||||||
else if (notification.type == "defeat")
|
else if (notification.type == "defeat")
|
||||||
{
|
{
|
||||||
@ -274,7 +271,7 @@ function handleNetMessage(message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "aichat":
|
case "aichat":
|
||||||
addChatMessage({ "type": "message", "guid": message.guid, "text": translate(message.text) });
|
addChatMessage({ "type": "message", "guid": message.guid, "text": message.text, "translate": true });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// To prevent errors, ignore these message types that occur during autostart
|
// To prevent errors, ignore these message types that occur during autostart
|
||||||
@ -489,7 +486,11 @@ function addChatMessage(msg, playerAssignments)
|
|||||||
if (msg.hide)
|
if (msg.hide)
|
||||||
return;
|
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)
|
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) });
|
var armorString = sprintf(translate("%(label)s %(details)s"), { label: armorLabel, details: armorTypeDetails(entState.armour) });
|
||||||
|
|
||||||
// Attack and Armor
|
// Attack and Armor
|
||||||
if (entState.attack)
|
if ("attack" in entState && entState.attack)
|
||||||
{
|
{
|
||||||
// Rate
|
// Rate
|
||||||
if (entState.buildingAI)
|
if (entState.buildingAI)
|
||||||
|
@ -990,10 +990,10 @@ GuiInterface.prototype.DisplayRallyPoint = function(player, cmd)
|
|||||||
if (pos)
|
if (pos)
|
||||||
{
|
{
|
||||||
// Only update the position if we changed it (cmd.queued is set)
|
// Only update the position if we changed it (cmd.queued is set)
|
||||||
if (cmd.queued == true)
|
if (!("queued" in cmd) || cmd.queued == false)
|
||||||
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)
|
|
||||||
cmpRallyPointRenderer.SetPosition({'x': pos.x, 'y': pos.z}); // SetPosition takes a CFixedVector2D which has X/Y components, not X/Z
|
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)
|
// rebuild the renderer when not set (when reading saved game or in case of building update)
|
||||||
else if (!cmpRallyPointRenderer.IsSet())
|
else if (!cmpRallyPointRenderer.IsSet())
|
||||||
for each (var posi in cmpRallyPoint.GetPositions())
|
for each (var posi in cmpRallyPoint.GetPositions())
|
||||||
|
@ -220,7 +220,10 @@ function ProcessCommand(player, cmd)
|
|||||||
var queue = Engine.QueryInterface(ent, IID_ProductionQueue);
|
var queue = Engine.QueryInterface(ent, IID_ProductionQueue);
|
||||||
// Check if the building can train the unit
|
// Check if the building can train the unit
|
||||||
if (queue && queue.GetEntitiesList().indexOf(cmd.template) != -1)
|
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)
|
else if (g_DebugCommands)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user