forked from mirrors/0ad
Colorize playernames in the wonder victory time notification.
Differential Revision: https://code.wildfiregames.com Reviewed By: Imarok This was SVN commit r19181.
This commit is contained in:
@@ -296,14 +296,7 @@ var g_NotificationsTypes =
|
||||
{
|
||||
message.translateParameters = notification.translateParameters;
|
||||
message.parameters = notification.parameters;
|
||||
// special case for formatting of player names which are transmitted as _player_num
|
||||
for (let param in message.parameters)
|
||||
{
|
||||
if (!param.startsWith("_player_"))
|
||||
continue;
|
||||
|
||||
message.parameters[param] = colorizePlayernameByID(message.parameters[param]);
|
||||
}
|
||||
colorizePlayernameParameters(notification.parameters);
|
||||
}
|
||||
|
||||
addChatMessage(message);
|
||||
@@ -546,6 +539,8 @@ function updateTimeNotifications()
|
||||
|
||||
parameters.time = timeToString(n.endTime - g_SimState.timeElapsed);
|
||||
|
||||
colorizePlayernameParameters(parameters);
|
||||
|
||||
notificationText += sprintf(message, parameters) + "\n";
|
||||
}
|
||||
Engine.GetGUIObjectByName("notificationText").caption = notificationText;
|
||||
@@ -834,6 +829,16 @@ function colorizePlayernameHelper(username, playerID)
|
||||
return '[color="' + playerColor + '"]' + (username || translate("Unknown Player")) + "[/color]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the colorized playername to chat messages sent by the AI and time notifications.
|
||||
*/
|
||||
function colorizePlayernameParameters(parameters)
|
||||
{
|
||||
for (let param in parameters)
|
||||
if (param.startsWith("_player_"))
|
||||
parameters[param] = colorizePlayernameByID(parameters[param]);
|
||||
}
|
||||
|
||||
function formatDefeatMessage(msg)
|
||||
{
|
||||
return sprintf(
|
||||
|
||||
@@ -41,10 +41,10 @@ Trigger.prototype.CheckWonderVictory = function(data)
|
||||
let wonderDuration = cmpEndGameManager.GetGameTypeSettings().wonderDuration || 0;
|
||||
|
||||
messages.otherMessage = cmpGuiInterface.AddTimeNotification({
|
||||
"message": markForTranslation("%(player)s will have won in %(time)s"),
|
||||
"message": markForTranslation("%(_player_)s will have won in %(time)s"),
|
||||
"players": players,
|
||||
"parameters": {
|
||||
"player": cmpPlayer.GetName()
|
||||
"_player_": cmpPlayer.GetPlayerID()
|
||||
},
|
||||
"translateMessage": true,
|
||||
"translateParameters": [],
|
||||
|
||||
Reference in New Issue
Block a user