mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 14:53:56 -07:00
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:
parent
a74fcdcb35
commit
9a6c5eac60
2 changed files with 15 additions and 10 deletions
|
|
@ -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": [],
|
||||
|
|
|
|||
Loading…
Reference in a new issue