Add lobby sounds for leave, join and option change
This commit is contained in:
committed by
Gustas
parent
d217ab39c2
commit
a1efb28f0b
@@ -20,6 +20,12 @@ namespace OpenRA.Network
|
|||||||
{
|
{
|
||||||
public const int ChatMessageMaxLength = 2500;
|
public const int ChatMessageMaxLength = 2500;
|
||||||
|
|
||||||
|
[TranslationReference("player")]
|
||||||
|
const string Joined = "notification-joined";
|
||||||
|
|
||||||
|
[TranslationReference("player")]
|
||||||
|
const string Left = "notification-lobby-disconnected";
|
||||||
|
|
||||||
static Player FindPlayerByClient(this World world, Session.Client c)
|
static Player FindPlayerByClient(this World world, Session.Client c)
|
||||||
{
|
{
|
||||||
return world.Players.FirstOrDefault(p => p.ClientIndex == c.Index && p.PlayerReference.Playable);
|
return world.Players.FirstOrDefault(p => p.ClientIndex == c.Index && p.PlayerReference.Playable);
|
||||||
@@ -44,7 +50,12 @@ namespace OpenRA.Network
|
|||||||
foreach (var node in yaml)
|
foreach (var node in yaml)
|
||||||
{
|
{
|
||||||
var localizedMessage = new LocalizedMessage(node.Value);
|
var localizedMessage = new LocalizedMessage(node.Value);
|
||||||
TextNotificationsManager.AddSystemLine(localizedMessage.TranslatedText);
|
if (localizedMessage.Key == Joined)
|
||||||
|
TextNotificationsManager.AddPlayerJoinedLine(localizedMessage.TranslatedText);
|
||||||
|
else if (localizedMessage.Key == Left)
|
||||||
|
TextNotificationsManager.AddPlayerLeftLine(localizedMessage.TranslatedText);
|
||||||
|
else
|
||||||
|
TextNotificationsManager.AddSystemLine(localizedMessage.TranslatedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using OpenRA.Primitives;
|
|||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
public enum TextNotificationPool { System, Chat, Mission, Feedback, Transients }
|
public enum TextNotificationPool { System, Join, Leave, Chat, Mission, Feedback, Transients }
|
||||||
|
|
||||||
public class TextNotification : IEquatable<TextNotification>
|
public class TextNotification : IEquatable<TextNotification>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,6 +51,16 @@ namespace OpenRA
|
|||||||
AddTextNotification(TextNotificationPool.Mission, SystemClientId, prefix, text, prefixColor);
|
AddTextNotification(TextNotificationPool.Mission, SystemClientId, prefix, text, prefixColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddPlayerJoinedLine(string text)
|
||||||
|
{
|
||||||
|
AddTextNotification(TextNotificationPool.Join, SystemClientId, SystemMessageLabel, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddPlayerLeftLine(string text)
|
||||||
|
{
|
||||||
|
AddTextNotification(TextNotificationPool.Leave, SystemClientId, SystemMessageLabel, text);
|
||||||
|
}
|
||||||
|
|
||||||
public static void AddSystemLine(string text)
|
public static void AddSystemLine(string text)
|
||||||
{
|
{
|
||||||
AddSystemLine(SystemMessageLabel, text);
|
AddSystemLine(SystemMessageLabel, text);
|
||||||
@@ -86,11 +96,15 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var filters = Game.Settings.Game.TextNotificationPoolFilters;
|
var filters = Game.Settings.Game.TextNotificationPoolFilters;
|
||||||
|
|
||||||
return pool == TextNotificationPool.Chat ||
|
switch (pool)
|
||||||
pool == TextNotificationPool.System ||
|
{
|
||||||
pool == TextNotificationPool.Mission ||
|
case TextNotificationPool.Transients:
|
||||||
(pool == TextNotificationPool.Transients && filters.HasFlag(TextNotificationPoolFilters.Transients)) ||
|
return filters.HasFlag(TextNotificationPoolFilters.Transients);
|
||||||
(pool == TextNotificationPool.Feedback && filters.HasFlag(TextNotificationPoolFilters.Feedback));
|
case TextNotificationPool.Feedback:
|
||||||
|
return filters.HasFlag(TextNotificationPoolFilters.Feedback);
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Clear()
|
public static void Clear()
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
Dictionary<int, SpawnOccupant> spawnOccupants = new();
|
Dictionary<int, SpawnOccupant> spawnOccupants = new();
|
||||||
|
|
||||||
readonly string chatLineSound = ChromeMetrics.Get<string>("ChatLineSound");
|
readonly string chatLineSound = ChromeMetrics.Get<string>("ChatLineSound");
|
||||||
|
readonly string playerJoinedSound = ChromeMetrics.Get<string>("PlayerJoinedSound");
|
||||||
|
readonly string playerLeftSound = ChromeMetrics.Get<string>("PlayerLeftSound");
|
||||||
|
readonly string lobbyOptionChangedSound = ChromeMetrics.Get<string>("LobbyOptionChangedSound");
|
||||||
|
|
||||||
bool MapIsPlayable => (mapStatus & Session.MapStatus.Playable) == Session.MapStatus.Playable;
|
bool MapIsPlayable => (mapStatus & Session.MapStatus.Playable) == Session.MapStatus.Playable;
|
||||||
|
|
||||||
@@ -440,7 +443,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
forceStartBin.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => panel = PanelType.Players;
|
forceStartBin.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => panel = PanelType.Players;
|
||||||
|
|
||||||
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
||||||
disconnectButton.OnClick = () => { Ui.CloseWindow(); onExit(); };
|
disconnectButton.OnClick = () =>
|
||||||
|
{
|
||||||
|
Ui.CloseWindow();
|
||||||
|
onExit();
|
||||||
|
Game.Sound.PlayNotification(modRules, null, "Sounds", playerLeftSound, null);
|
||||||
|
};
|
||||||
|
|
||||||
if (skirmishMode)
|
if (skirmishMode)
|
||||||
disconnectButton.Text = TranslationProvider.GetString(Back);
|
disconnectButton.Text = TranslationProvider.GetString(Back);
|
||||||
@@ -519,6 +527,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
if (logicArgs.TryGetValue("ChatLineSound", out var yaml))
|
if (logicArgs.TryGetValue("ChatLineSound", out var yaml))
|
||||||
chatLineSound = yaml.Value;
|
chatLineSound = yaml.Value;
|
||||||
|
if (logicArgs.TryGetValue("PlayerJoinedSound", out yaml))
|
||||||
|
playerJoinedSound = yaml.Value;
|
||||||
|
if (logicArgs.TryGetValue("PlayerLeftSound", out yaml))
|
||||||
|
playerLeftSound = yaml.Value;
|
||||||
|
if (logicArgs.TryGetValue("LobbyOptionChangedSound", out yaml))
|
||||||
|
lobbyOptionChangedSound = yaml.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool disposed;
|
bool disposed;
|
||||||
@@ -577,7 +591,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (scrolledToBottom)
|
if (scrolledToBottom)
|
||||||
lobbyChatPanel.ScrollToBottom(smooth: true);
|
lobbyChatPanel.ScrollToBottom(smooth: true);
|
||||||
|
|
||||||
Game.Sound.PlayNotification(modRules, null, "Sounds", chatLineSound, null);
|
switch (notification.Pool)
|
||||||
|
{
|
||||||
|
case TextNotificationPool.Chat:
|
||||||
|
Game.Sound.PlayNotification(modRules, null, "Sounds", chatLineSound, null);
|
||||||
|
break;
|
||||||
|
case TextNotificationPool.System:
|
||||||
|
Game.Sound.PlayNotification(modRules, null, "Sounds", lobbyOptionChangedSound, null);
|
||||||
|
break;
|
||||||
|
case TextNotificationPool.Join:
|
||||||
|
Game.Sound.PlayNotification(modRules, null, "Sounds", playerJoinedSound, null);
|
||||||
|
break;
|
||||||
|
case TextNotificationPool.Leave:
|
||||||
|
Game.Sound.PlayNotification(modRules, null, "Sounds", playerLeftSound, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateCurrentMap()
|
void UpdateCurrentMap()
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ Container@SERVER_LOBBY:
|
|||||||
Logic: LobbyLogic
|
Logic: LobbyLogic
|
||||||
ChatTemplates:
|
ChatTemplates:
|
||||||
Chat: CHAT_LINE_TEMPLATE
|
Chat: CHAT_LINE_TEMPLATE
|
||||||
|
Join: SYSTEM_LINE_TEMPLATE
|
||||||
|
Leave: SYSTEM_LINE_TEMPLATE
|
||||||
System: SYSTEM_LINE_TEMPLATE
|
System: SYSTEM_LINE_TEMPLATE
|
||||||
Mission: CHAT_LINE_TEMPLATE
|
Mission: CHAT_LINE_TEMPLATE
|
||||||
Feedback: TRANSIENT_LINE_TEMPLATE
|
Feedback: TRANSIENT_LINE_TEMPLATE
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ Background@SERVER_LOBBY:
|
|||||||
Logic: LobbyLogic
|
Logic: LobbyLogic
|
||||||
ChatTemplates:
|
ChatTemplates:
|
||||||
Chat: CHAT_LINE_TEMPLATE
|
Chat: CHAT_LINE_TEMPLATE
|
||||||
|
Join: SYSTEM_LINE_TEMPLATE
|
||||||
|
Leave: SYSTEM_LINE_TEMPLATE
|
||||||
System: SYSTEM_LINE_TEMPLATE
|
System: SYSTEM_LINE_TEMPLATE
|
||||||
Mission: CHAT_LINE_TEMPLATE
|
Mission: CHAT_LINE_TEMPLATE
|
||||||
Feedback: TRANSIENT_LINE_TEMPLATE
|
Feedback: TRANSIENT_LINE_TEMPLATE
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ notification-requires-host = Only the host can do that.
|
|||||||
notification-invalid-bot-slot = Can't add bots to a slot with another client.
|
notification-invalid-bot-slot = Can't add bots to a slot with another client.
|
||||||
notification-invalid-bot-type = Invalid bot type.
|
notification-invalid-bot-type = Invalid bot type.
|
||||||
notification-admin-change-map = Only the host can change the map.
|
notification-admin-change-map = Only the host can change the map.
|
||||||
notification-lobby-disconnected = { $player } has left.
|
|
||||||
notification-player-disconnected = { $player } has disconnected.
|
notification-player-disconnected = { $player } has disconnected.
|
||||||
notification-team-player-disconnected = { $player } (Team { $team }) has disconnected.
|
notification-team-player-disconnected = { $player } (Team { $team }) has disconnected.
|
||||||
notification-observer-disconnected = { $player } (Spectator) has disconnected.
|
notification-observer-disconnected = { $player } (Spectator) has disconnected.
|
||||||
@@ -57,7 +56,6 @@ notification-incompatible-protocol = Server is running an incompatible protocol.
|
|||||||
notification-you-were-banned = You have been banned from the server.
|
notification-you-were-banned = You have been banned from the server.
|
||||||
notification-you-were-temp-banned = You have been temporarily banned from the server.
|
notification-you-were-temp-banned = You have been temporarily banned from the server.
|
||||||
notification-game-full = The game is full.
|
notification-game-full = The game is full.
|
||||||
notification-joined = { $player } has joined the game.
|
|
||||||
notification-new-admin = { $player } is now the admin.
|
notification-new-admin = { $player } is now the admin.
|
||||||
notification-option-locked = { $option } cannot be changed.
|
notification-option-locked = { $option } cannot be changed.
|
||||||
notification-invalid-configuration-command = Invalid configuration command.
|
notification-invalid-configuration-command = Invalid configuration command.
|
||||||
@@ -85,6 +83,10 @@ notification-requires-authentication = Server requires players to have an OpenRA
|
|||||||
notification-no-permission-to-join = You do not have permission to join this server.
|
notification-no-permission-to-join = You do not have permission to join this server.
|
||||||
notification-slot-closed = Your slot was closed by the host.
|
notification-slot-closed = Your slot was closed by the host.
|
||||||
|
|
||||||
|
## ServerOrders, UnitOrders
|
||||||
|
notification-joined = { $player } has joined the game.
|
||||||
|
notification-lobby-disconnected = { $player } has left.
|
||||||
|
|
||||||
## Server
|
## Server
|
||||||
notification-game-started = Game started
|
notification-game-started = Game started
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ Metrics:
|
|||||||
NoticeSuccessColor: 00FF00
|
NoticeSuccessColor: 00FF00
|
||||||
NoticeErrorColor: FF0000
|
NoticeErrorColor: FF0000
|
||||||
ChatLineSound: ChatLine
|
ChatLineSound: ChatLine
|
||||||
|
PlayerJoinedSound: ChatLine
|
||||||
|
LobbyOptionChangedSound: ChatLine
|
||||||
|
PlayerLeftSound: ChatLine
|
||||||
ClickDisabledSound: ClickDisabledSound
|
ClickDisabledSound: ClickDisabledSound
|
||||||
ClickSound: ClickSound
|
ClickSound: ClickSound
|
||||||
NormalSelectionColor: FFFFFF
|
NormalSelectionColor: FFFFFF
|
||||||
|
|||||||
Reference in New Issue
Block a user