Show the tribute chat notification if a team member sends to another and if teams are locked. Fixes #4308.

Add a new options panel for the chat notifications (attack, barter,
tribute), so that players and observers can disable them if they appear
too noisy.

Patch By: Sandarac
Differential Revision: https://code.wildfiregames.com/D106
This was SVN commit r19237.
This commit is contained in:
elexis 2017-02-23 19:35:55 +00:00
parent 2c86b54838
commit fb6e694fdd
4 changed files with 57 additions and 11 deletions

View File

@ -329,7 +329,6 @@ enabletips = true ; Enable/Disable tips during gamesetup (for ne
limitfps = true ; Limit FPS in the menus and loading screen
[gui.session]
attacknotificationmessage = true ; Show attack notification messages
camerajump.threshold = 40 ; How close do we have to be to the actual location in order to jump back to the previous one?
timeelapsedcounter = false ; Show the game duration in the top right corner
batchtrainingsize = 5 ; Number of units to be trained per batch (when pressing the hotkey)
@ -338,6 +337,11 @@ batchtrainingsize = 5 ; Number of units to be trained per batch (whe
blinkduration = 1.7 ; The blink duration while pinging
pingduration = 50.0 ; The duration for which an entity will be pinged after an attack notification
[gui.session.notifications]
attack = true ; Show a chat notification if you are attacked by another player
tribute = true ; Show a chat notification if an ally tributes resources to another team member if teams are locked, and all tributes in observer mode
barter = true ; Show a chat notification to observers when a player bartered resources
[gui.splashscreen]
enable = true ; Enable/disable the splashscreen
version = 0 ; Splashscreen version (date of last modification). By default, 0 to force splashscreen to appear at first launch

View File

@ -88,7 +88,7 @@
{
"type": "number",
"label": "Observer Limit",
"tooltip": "Prevent further observer from joining if the limit is reached",
"tooltip": "Prevent further observers from joining if the limit is reached",
"parameters": { "config": "network.observerlimit", "min": 0, "max": 32 }
},
{
@ -258,5 +258,26 @@
"tooltip": "Number of backlogged messages to load when joining the lobby",
"parameters": { "config": "lobby.history", "min": "0" }
}
],
"notificationSetting":
[
{
"type": "boolean",
"label": "Attack",
"tooltip": "Show a chat notification if you are attacked by another player",
"parameters": { "config": "gui.session.notifications.attack" }
},
{
"type": "boolean",
"label": "Tribute",
"tooltip": "Show a chat notification if an ally tributes resources to another team member if teams are locked, and all tributes in observer mode",
"parameters": { "config": "gui.session.notifications.tribute" }
},
{
"type": "boolean",
"label": "Barter",
"tooltip": "Show a chat notification to observers when a player bartered resources",
"parameters": { "config": "gui.session.notifications.barter" }
}
]
}

View File

@ -43,7 +43,7 @@
</object>
</repeat>
</object>
<object name="SoundSettings" type="image" sprite="ModernDarkBoxGold" size="620 16 916 50%-4">
<object name="SoundSettings" type="image" sprite="ModernDarkBoxGold" size="620 16 916 40%">
<object style="ModernLabelText" type="text" size="0 5 100% 25">
<translatableAttribute id="caption">Sound Settings</translatableAttribute>
</object>
@ -56,11 +56,11 @@
</object>
</repeat>
</object>
<object name="LobbySettings" type="image" sprite="ModernDarkBoxGold" size="620 50%+4 916 100%-52">
<object name="LobbySettings" type="image" sprite="ModernDarkBoxGold" size="620 40%+8 916 65%">
<object style="ModernLabelText" type="text" size="0 5 100% 25">
<translatableAttribute id="caption">Lobby Settings</translatableAttribute>
</object>
<repeat count="10">
<repeat count="5">
<object name="lobbySetting[n]" size="0 25 100% 50" hidden="true">
<object name="lobbySettingLabel[n]" size="0 0 65% 100%" type="text" style="ModernLabelText" text_align="left"/>
<object name="lobbySettingTickbox[n]" size="90% 5 100% 100%+5" type="checkbox" style="ModernTickBox" hidden="true"/>
@ -69,6 +69,19 @@
</object>
</repeat>
</object>
<object name="NotificationsSettings" type="image" sprite="ModernDarkBoxGold" size="620 65%+8 916 100%-52">
<object style="ModernLabelText" type="text" size="0 5 100% 25">
<translatableAttribute id="caption">Chat Notification Settings</translatableAttribute>
</object>
<repeat count="10">
<object name="notificationSetting[n]" size="0 25 100% 50" hidden="true">
<object name="notificationSettingLabel[n]" size="0 0 65% 100%" type="text" style="ModernLabelText" text_align="left"/>
<object name="notificationSettingTickbox[n]" size="90% 5 100% 100%+5" type="checkbox" style="ModernTickBox" hidden="true"/>
<object name="notificationSettingInput[n]" size="70% 0 100%-8 100%" type="input" style="ModernInput" hidden="true"/>
<object name="notificationSettingDropdown[n]" size="70% 0 100%-8 100%" type="dropdown" style="ModernDropDown" hidden="true"/>
</object>
</repeat>
</object>
<object type="button" style="ModernButtonRed" size="50%-236 100%-44 50%-136 100%-16">
<translatableAttribute id="caption">Reset</translatableAttribute>
<translatableAttribute id="tooltip">Resets user settings to their game default</translatableAttribute>

View File

@ -368,7 +368,7 @@ var g_NotificationsTypes =
g_Selection.addList([notification.target]);
}
if (Engine.ConfigDB_GetValue("user", "gui.session.attacknotificationmessage") !== "true")
if (Engine.ConfigDB_GetValue("user", "gui.session.notifications.attack") !== "true")
return;
addChatMessage({
@ -875,14 +875,22 @@ function formatDiplomacyMessage(msg)
});
}
/**
* Optionally show all tributes sent in observer mode and tributes sent between allied players.
* Otherwise, only show tributes sent directly to us, and tributes that we send.
*/
function formatTributeMessage(msg)
{
// Check observer first, since we also want to see if the selected player in the developer-overlay has sent tributes
let message = "";
if (g_IsObserver)
message = translate("%(player)s has sent %(player2)s %(amounts)s.");
else if (msg.targetPlayer == Engine.GetPlayerID())
if (msg.targetPlayer == Engine.GetPlayerID())
message = translate("%(player)s has sent you %(amounts)s.");
else if (msg.sourcePlayer == Engine.GetPlayerID())
message = translate("You have sent %(player2)s %(amounts)s.")
else if (Engine.ConfigDB_GetValue("user", "gui.session.notifications.tribute") == "true" &&
(g_IsObserver || g_GameAttributes.settings.LockTeams &&
g_Players[msg.sourcePlayer].isMutualAlly[Engine.GetPlayerID()] &&
g_Players[msg.targetPlayer].isMutualAlly[Engine.GetPlayerID()]))
message = translate("%(player)s has sent %(player2)s %(amounts)s.");
return sprintf(message, {
"player": colorizePlayernameByID(msg.sourcePlayer),
@ -893,7 +901,7 @@ function formatTributeMessage(msg)
function formatBarterMessage(msg)
{
if (!g_IsObserver)
if (!g_IsObserver || Engine.ConfigDB_GetValue("user", "gui.session.notifications.barter") != "true")
return "";
let amountsSold = {};