Distinguish resign- and defeat-chatmessage. Patch by dpiquet, fixes #3501.
For consistency, also colorize the "You" part in the singleplayer variants. This was SVN commit r18161.
This commit is contained in:
parent
366085e037
commit
7c2ff117f3
@ -53,6 +53,7 @@
|
||||
{"nick": "deebee", "name": "Deepak Anthony"},
|
||||
{"nick": "Deiz"},
|
||||
{"nick": "Dietger", "name": "Dietger van Antwerpen"},
|
||||
{"nick": "dpiquet", "name": "Damien Piquet"},
|
||||
{"nick": "dumbo"},
|
||||
{"nick": "dvangennip", "name": "Doménique"},
|
||||
{"nick": "Echelon9", "name": "Rhys Kidd"},
|
||||
|
@ -188,7 +188,8 @@ var g_NotificationsTypes =
|
||||
addChatMessage({
|
||||
"type": "defeat",
|
||||
"guid": findGuidForPlayerID(player),
|
||||
"player": player
|
||||
"player": player,
|
||||
"resign": !!notification.resign
|
||||
});
|
||||
|
||||
updateDiplomacy();
|
||||
@ -652,12 +653,31 @@ function colorizePlayernameHelper(username, playerID)
|
||||
|
||||
function formatDefeatMessage(msg)
|
||||
{
|
||||
let defeatMsg;
|
||||
let playername;
|
||||
|
||||
// In singleplayer, the local player is "You". "You has" is incorrect.
|
||||
if (!g_IsNetworked && msg.player == Engine.GetPlayerID())
|
||||
return translate("You have been defeated.");
|
||||
{
|
||||
// Translation: String used to colorize the word "You" of that sentence
|
||||
playername = colorizePlayernameHelper(translateWithContext("You have been defeated", "You"), msg.player);
|
||||
if (msg.resign)
|
||||
defeatMsg = translate("%(You)s have resigned.");
|
||||
else
|
||||
defeatMsg = translate("%(You)s have been defeated.");
|
||||
}
|
||||
else
|
||||
{
|
||||
playername = colorizePlayernameByID(msg.player);
|
||||
if (msg.resign)
|
||||
defeatMsg = translate("%(player)s has resigned.");
|
||||
else
|
||||
defeatMsg = translate("%(player)s has been defeated.");
|
||||
}
|
||||
|
||||
return sprintf(translate("%(player)s has been defeated."), {
|
||||
"player": colorizePlayernameByID(msg.player)
|
||||
return sprintf(defeatMsg, {
|
||||
"player": playername,
|
||||
"You": playername
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -426,7 +426,8 @@ function resignGame(leaveGameAfterResign)
|
||||
|
||||
Engine.PostNetworkCommand({
|
||||
"type": "defeat-player",
|
||||
"playerId": Engine.GetPlayerID()
|
||||
"playerId": Engine.GetPlayerID(),
|
||||
"resign": true
|
||||
});
|
||||
|
||||
updateTopPanel();
|
||||
|
@ -671,7 +671,8 @@ Player.prototype.OnPlayerDefeated = function(msg)
|
||||
var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
|
||||
cmpGUIInterface.PushNotification({
|
||||
"type": "defeat",
|
||||
"players": [this.playerID]
|
||||
"players": [this.playerID],
|
||||
"resign": !!msg.resign
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -413,7 +413,7 @@ var g_Commands = {
|
||||
"defeat-player": function(player, cmd, data)
|
||||
{
|
||||
// Send "OnPlayerDefeated" message to player
|
||||
Engine.PostMessage(data.playerEnt, MT_PlayerDefeated, { "playerId": player } );
|
||||
Engine.PostMessage(data.playerEnt, MT_PlayerDefeated, { "playerId": player, "resign": !!cmd.resign });
|
||||
},
|
||||
|
||||
"garrison": function(player, cmd, data)
|
||||
|
Loading…
Reference in New Issue
Block a user