Add per player mutes
This commit is contained in:
@@ -27,6 +27,8 @@ namespace OpenRA.Network
|
||||
readonly Dictionary<int, (int SyncHash, ulong DefeatState)> syncForFrame = new Dictionary<int, (int, ulong)>();
|
||||
|
||||
public Session LobbyInfo = new Session();
|
||||
|
||||
/// <summary> Null when watching a replay </summary>
|
||||
public Session.Client LocalClient => LobbyInfo.ClientWithIndex(Connection.LocalClientId);
|
||||
public World World;
|
||||
public int OrderQueueLength => pendingOrders.Count > 0 ? pendingOrders.Min(q => q.Value.Count) : 0;
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace OpenRA
|
||||
static readonly string SystemMessageLabel;
|
||||
|
||||
public static long ChatDisabledUntil { get; internal set; }
|
||||
public static readonly Dictionary<int, bool> MutedPlayers = new Dictionary<int, bool>();
|
||||
|
||||
static readonly List<TextNotification> NotificationsCache = new List<TextNotification>();
|
||||
public static IReadOnlyList<TextNotification> Notifications => NotificationsCache;
|
||||
|
||||
@@ -94,6 +96,7 @@ namespace OpenRA
|
||||
public static void Clear()
|
||||
{
|
||||
NotificationsCache.Clear();
|
||||
MutedPlayers.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
class GameInfoStatsLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference]
|
||||
static readonly string Unmute = "unmute";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string Mute = "mute";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public GameInfoStatsLogic(Widget widget, World world, OrderManager orderManager, WorldRenderer worldRenderer, Action<bool> hideMenu)
|
||||
public GameInfoStatsLogic(Widget widget, ModData modData, World world, OrderManager orderManager, WorldRenderer worldRenderer, Action<bool> hideMenu)
|
||||
{
|
||||
var player = world.LocalPlayer;
|
||||
var playerPanel = widget.Get<ScrollPanelWidget>("PLAYER_LIST");
|
||||
var statsHeader = widget.Get("STATS_HEADERS");
|
||||
|
||||
if (player != null && !player.NonCombatant)
|
||||
{
|
||||
@@ -51,7 +58,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
// Expand the stats window to cover the hidden objectives
|
||||
var objectiveGroup = widget.Get("OBJECTIVE");
|
||||
var statsHeader = widget.Get("STATS_HEADERS");
|
||||
|
||||
objectiveGroup.Visible = false;
|
||||
statsHeader.Bounds.Y -= objectiveGroup.Bounds.Height;
|
||||
@@ -59,9 +65,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
playerPanel.Bounds.Height += objectiveGroup.Bounds.Height;
|
||||
}
|
||||
|
||||
if (!orderManager.LobbyInfo.Clients.Any(c => !c.IsBot && c.Index != orderManager.LocalClient?.Index && c.State != Session.ClientState.Disconnected))
|
||||
statsHeader.Get<LabelWidget>("ACTIONS").Visible = false;
|
||||
|
||||
var teamTemplate = playerPanel.Get<ScrollItemWidget>("TEAM_TEMPLATE");
|
||||
var playerTemplate = playerPanel.Get("PLAYER_TEMPLATE");
|
||||
var spectatorTemplate = playerPanel.Get("SPECTATOR_TEMPLATE");
|
||||
var unmuteTooltip = modData.Translation.GetString(Unmute);
|
||||
var muteTooltip = modData.Translation.GetString(Mute);
|
||||
playerPanel.RemoveChildren();
|
||||
|
||||
var teams = world.Players.Where(p => !p.NonCombatant && p.Playable)
|
||||
@@ -112,6 +123,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var scoreCache = new CachedTransform<int, string>(s => s.ToString());
|
||||
item.Get<LabelWidget>("SCORE").GetText = () => scoreCache.Update(p.PlayerStatistics?.Experience ?? 0);
|
||||
|
||||
var muteCheckbox = item.Get<CheckboxWidget>("MUTE");
|
||||
muteCheckbox.IsChecked = () => TextNotificationsManager.MutedPlayers[pp.ClientIndex];
|
||||
muteCheckbox.OnClick = () => TextNotificationsManager.MutedPlayers[pp.ClientIndex] ^= true;
|
||||
muteCheckbox.IsVisible = () => !pp.IsBot && client.State != Session.ClientState.Disconnected && pp.ClientIndex != orderManager.LocalClient?.Index;
|
||||
muteCheckbox.GetTooltipText = () => muteCheckbox.IsChecked() ? unmuteTooltip : muteTooltip;
|
||||
|
||||
playerPanel.AddChild(item);
|
||||
}
|
||||
}
|
||||
@@ -143,7 +160,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
};
|
||||
|
||||
var kickButton = item.Get<ButtonWidget>("KICK");
|
||||
kickButton.IsVisible = () => Game.IsHost && client.Index != orderManager.LocalClient.Index && client.State != Session.ClientState.Disconnected;
|
||||
kickButton.IsVisible = () => Game.IsHost && client.Index != orderManager.LocalClient?.Index && client.State != Session.ClientState.Disconnected;
|
||||
kickButton.OnClick = () =>
|
||||
{
|
||||
hideMenu(true);
|
||||
@@ -159,6 +176,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
confirmText: "Kick");
|
||||
};
|
||||
|
||||
var muteCheckbox = item.Get<CheckboxWidget>("MUTE");
|
||||
muteCheckbox.IsChecked = () => TextNotificationsManager.MutedPlayers[client.Index];
|
||||
muteCheckbox.OnClick = () => TextNotificationsManager.MutedPlayers[client.Index] ^= true;
|
||||
muteCheckbox.IsVisible = () => !client.IsBot && client.State != Session.ClientState.Disconnected && client.Index != orderManager.LocalClient?.Index;
|
||||
muteCheckbox.GetTooltipText = () => muteCheckbox.IsChecked() ? unmuteTooltip : muteTooltip;
|
||||
|
||||
playerPanel.AddChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var teamMessage = modData.Translation.GetString(Team);
|
||||
var allMessage = modData.Translation.GetString(All);
|
||||
|
||||
// Only execute this once, the first time this widget is loaded
|
||||
if (TextNotificationsManager.MutedPlayers.Count == 0)
|
||||
foreach (var c in orderManager.LobbyInfo.Clients)
|
||||
TextNotificationsManager.MutedPlayers.Add(c.Index, false);
|
||||
|
||||
tabCompletion.Commands = chatTraits.OfType<ChatCommands>().ToArray().SelectMany(x => x.Commands.Keys);
|
||||
tabCompletion.Names = orderManager.LobbyInfo.Clients.Select(c => c.Name).Distinct().ToList();
|
||||
|
||||
@@ -273,6 +278,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (!IsNotificationEligible(notification))
|
||||
return;
|
||||
|
||||
if (notification.ClientId != TextNotificationsManager.SystemClientId && TextNotificationsManager.MutedPlayers[notification.ClientId])
|
||||
return;
|
||||
|
||||
if (!IsNotificationMuted(notification))
|
||||
chatOverlayDisplay?.AddNotification(notification);
|
||||
|
||||
|
||||
@@ -265,6 +265,22 @@ checkbox-highlighted-disabled:
|
||||
checkbox-highlighted-pressed:
|
||||
Inherits: button-highlighted-pressed
|
||||
|
||||
checkbox-toggle:
|
||||
|
||||
checkbox-toggle-hover:
|
||||
Inherits: checkbox
|
||||
|
||||
checkbox-toggle-pressed:
|
||||
Inherits: checkbox-pressed
|
||||
|
||||
checkbox-toggle-highlighted:
|
||||
|
||||
checkbox-toggle-highlighted-hover:
|
||||
Inherits: checkbox-highlighted
|
||||
|
||||
checkbox-toggle-highlighted-pressed:
|
||||
Inherits: checkbox-highlighted-pressed
|
||||
|
||||
#
|
||||
# Panels
|
||||
# ===
|
||||
@@ -418,6 +434,17 @@ checkmark-cross:
|
||||
checkmark-highlighted-cross:
|
||||
Inherits: checkmark-cross
|
||||
|
||||
checkmark-mute:
|
||||
Inherits: ^Chrome
|
||||
Regions:
|
||||
unchecked: 989, 34, 16, 16
|
||||
unchecked-pressed: 1006, 34, 16, 16
|
||||
checked: 1006, 34, 16, 16
|
||||
checked-pressed: 989, 34, 16, 16
|
||||
|
||||
checkmark-highlighted-mute:
|
||||
Inherits: checkmark-mute
|
||||
|
||||
flags:
|
||||
Inherits: ^Chrome
|
||||
Regions:
|
||||
|
||||
@@ -125,6 +125,13 @@ Container@SKIRMISH_STATS:
|
||||
Width: 60
|
||||
Height: 25
|
||||
Shadow: True
|
||||
Checkbox@MUTE:
|
||||
X: 457
|
||||
Width: 25
|
||||
Height: 25
|
||||
Checkmark: mute
|
||||
Background: checkbox-toggle
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
Container@SPECTATOR_TEMPLATE:
|
||||
Width: PARENT_RIGHT - 27
|
||||
Height: 25
|
||||
@@ -148,6 +155,13 @@ Container@SKIRMISH_STATS:
|
||||
Width: 191
|
||||
Height: 25
|
||||
Shadow: True
|
||||
Checkbox@MUTE:
|
||||
X: 457
|
||||
Width: 25
|
||||
Height: 25
|
||||
Checkmark: mute
|
||||
Background: checkbox-toggle
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
Button@KICK:
|
||||
X: 485
|
||||
Width: 25
|
||||
|
||||
@@ -123,6 +123,13 @@ Container@SKIRMISH_STATS:
|
||||
Width: 60
|
||||
Height: 25
|
||||
Shadow: True
|
||||
Checkbox@MUTE:
|
||||
X: 457
|
||||
Width: 25
|
||||
Height: 25
|
||||
Checkmark: mute
|
||||
Background: checkbox-toggle
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
Container@SPECTATOR_TEMPLATE:
|
||||
Width: PARENT_RIGHT - 26
|
||||
Height: 25
|
||||
@@ -146,6 +153,13 @@ Container@SKIRMISH_STATS:
|
||||
Width: 191
|
||||
Height: 25
|
||||
Shadow: True
|
||||
Checkbox@MUTE:
|
||||
X: 457
|
||||
Width: 25
|
||||
Height: 25
|
||||
Checkmark: mute
|
||||
Background: checkbox-toggle
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
Button@KICK:
|
||||
X: 485
|
||||
Width: 25
|
||||
|
||||
@@ -117,6 +117,10 @@ in-progress = In progress
|
||||
accomplished = Accomplished
|
||||
failed = Failed
|
||||
|
||||
## GameInfoStatsLogic
|
||||
mute = Mute this player
|
||||
unmute = Unmute this player
|
||||
|
||||
## GameTimerLogic
|
||||
paused = Paused
|
||||
max-speed = Max Speed
|
||||
|
||||
@@ -395,6 +395,17 @@ checkmark-cross:
|
||||
checkmark-highlighted-cross:
|
||||
Inherits: checkmark-cross
|
||||
|
||||
checkmark-mute:
|
||||
Inherits: ^Glyphs
|
||||
Regions:
|
||||
unchecked: 221, 34, 16, 16
|
||||
unchecked-pressed: 238, 34, 16, 16
|
||||
checked: 238, 34, 16, 16
|
||||
checked-pressed: 221, 34, 16, 16
|
||||
|
||||
checkmark-highlighted-mute:
|
||||
Inherits: checkmark-mute
|
||||
|
||||
checkbox-hover:
|
||||
Inherits: ^Dialog
|
||||
PanelRegion: 641, 129, 2, 2, 122, 122, 2, 2
|
||||
@@ -419,6 +430,22 @@ checkbox-highlighted-pressed:
|
||||
checkbox-highlighted-disabled:
|
||||
Inherits: checkbox-disabled
|
||||
|
||||
checkbox-toggle:
|
||||
|
||||
checkbox-toggle-hover:
|
||||
Inherits: button
|
||||
|
||||
checkbox-toggle-pressed:
|
||||
Inherits: checkbox-pressed
|
||||
|
||||
checkbox-toggle-highlighted:
|
||||
|
||||
checkbox-toggle-highlighted-hover:
|
||||
Inherits: button-highlighted
|
||||
|
||||
checkbox-toggle-highlighted-pressed:
|
||||
Inherits: checkbox-highlighted-pressed
|
||||
|
||||
scrollitem-selected:
|
||||
Inherits: button-pressed
|
||||
|
||||
|
||||
@@ -125,6 +125,13 @@ Container@SKIRMISH_STATS:
|
||||
Width: 60
|
||||
Height: 25
|
||||
Shadow: True
|
||||
Checkbox@MUTE:
|
||||
X: 457
|
||||
Width: 25
|
||||
Height: 25
|
||||
Checkmark: mute
|
||||
Background: checkbox-toggle
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
Container@SPECTATOR_TEMPLATE:
|
||||
Width: PARENT_RIGHT - 27
|
||||
Height: 25
|
||||
@@ -148,6 +155,13 @@ Container@SKIRMISH_STATS:
|
||||
Width: 191
|
||||
Height: 25
|
||||
Shadow: True
|
||||
Checkbox@MUTE:
|
||||
X: 457
|
||||
Width: 25
|
||||
Height: 25
|
||||
Checkmark: mute
|
||||
Background: checkbox-toggle
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
Button@KICK:
|
||||
X: 485
|
||||
Width: 25
|
||||
|
||||
@@ -524,6 +524,17 @@ checkmark-cross:
|
||||
checkmark-highlighted-cross:
|
||||
Inherits: checkmark-cross
|
||||
|
||||
checkmark-mute:
|
||||
Inherits: ^Glyphs
|
||||
Regions:
|
||||
unchecked: 0, 170, 16, 16
|
||||
unchecked-pressed: 17, 170, 16, 16
|
||||
checked: 17, 170, 16, 16
|
||||
checked-pressed: 0, 170, 16, 16
|
||||
|
||||
checkmark-highlighted-mute:
|
||||
Inherits: checkmark-mute
|
||||
|
||||
checkbox-hover:
|
||||
Inherits: ^Dialog
|
||||
PanelRegion: 641, 129, 2, 2, 122, 122, 2, 2
|
||||
@@ -548,6 +559,22 @@ checkbox-highlighted-pressed:
|
||||
checkbox-highlighted-disabled:
|
||||
Inherits: checkbox-disabled
|
||||
|
||||
checkbox-toggle:
|
||||
|
||||
checkbox-toggle-hover:
|
||||
Inherits: button
|
||||
|
||||
checkbox-toggle-pressed:
|
||||
Inherits: checkbox-pressed
|
||||
|
||||
checkbox-toggle-highlighted:
|
||||
|
||||
checkbox-toggle-highlighted-hover:
|
||||
Inherits: button-highlighted
|
||||
|
||||
checkbox-toggle-highlighted-pressed:
|
||||
Inherits: checkbox-highlighted-pressed
|
||||
|
||||
scrollitem-selected:
|
||||
Inherits: button-pressed
|
||||
|
||||
|
||||
@@ -657,6 +657,17 @@ checkmark-cross:
|
||||
checkmark-highlighted-cross:
|
||||
Inherits: checkmark-cross
|
||||
|
||||
checkmark-mute:
|
||||
Inherits: ^Glyphs
|
||||
Regions:
|
||||
unchecked: 221, 34, 16, 16
|
||||
unchecked-pressed: 238, 34, 16, 16
|
||||
checked: 238, 34, 16, 16
|
||||
checked-pressed: 221, 34, 16, 16
|
||||
|
||||
checkmark-highlighted-mute:
|
||||
Inherits: checkmark-mute
|
||||
|
||||
checkbox-hover:
|
||||
Inherits: ^Dialog
|
||||
PanelRegion: 641, 129, 2, 2, 122, 122, 2, 2
|
||||
@@ -681,6 +692,22 @@ checkbox-highlighted-pressed:
|
||||
checkbox-highlighted-disabled:
|
||||
Inherits: checkbox-disabled
|
||||
|
||||
checkbox-toggle:
|
||||
|
||||
checkbox-toggle-hover:
|
||||
Inherits: button
|
||||
|
||||
checkbox-toggle-pressed:
|
||||
Inherits: checkbox-pressed
|
||||
|
||||
checkbox-toggle-highlighted:
|
||||
|
||||
checkbox-toggle-highlighted-hover:
|
||||
Inherits: button-highlighted
|
||||
|
||||
checkbox-toggle-highlighted-pressed:
|
||||
Inherits: checkbox-highlighted-pressed
|
||||
|
||||
scrollitem-selected:
|
||||
Inherits: button-pressed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user