mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
* Fix chat filter button Oh look, the popup code was copy pasted between chat filter and channel selector. Hilarious. Anyways same stuff as 995f506aafd770dd6572dfc9e7bf9e18186e485a. I pulled it all out into a base class so NO MORE COPY PASTE. Fixes #22360 * Remove all further EnableAllKeybinds buttons. Fixes #22346 Yeah none of these are valid use cases, why is this set...
78 lines
2.2 KiB
C#
78 lines
2.2 KiB
C#
using System.Numerics;
|
|
using Content.Shared.Chat;
|
|
|
|
namespace Content.Client.UserInterface.Systems.Chat.Controls;
|
|
|
|
public sealed class ChannelSelectorButton : ChatPopupButton<ChannelSelectorPopup>
|
|
{
|
|
public event Action<ChatSelectChannel>? OnChannelSelect;
|
|
|
|
public ChatSelectChannel SelectedChannel { get; private set; }
|
|
|
|
private const int SelectorDropdownOffset = 38;
|
|
|
|
public ChannelSelectorButton()
|
|
{
|
|
Name = "ChannelSelector";
|
|
|
|
Popup.Selected += OnChannelSelected;
|
|
|
|
if (Popup.FirstChannel is { } firstSelector)
|
|
{
|
|
Select(firstSelector);
|
|
}
|
|
}
|
|
|
|
protected override UIBox2 GetPopupPosition()
|
|
{
|
|
var globalLeft = GlobalPosition.X;
|
|
var globalBot = GlobalPosition.Y + Height;
|
|
return UIBox2.FromDimensions(
|
|
new Vector2(globalLeft, globalBot),
|
|
new Vector2(SizeBox.Width, SelectorDropdownOffset));
|
|
}
|
|
|
|
private void OnChannelSelected(ChatSelectChannel channel)
|
|
{
|
|
Select(channel);
|
|
}
|
|
|
|
public void Select(ChatSelectChannel channel)
|
|
{
|
|
if (Popup.Visible)
|
|
{
|
|
Popup.Close();
|
|
}
|
|
|
|
if (SelectedChannel == channel)
|
|
return;
|
|
SelectedChannel = channel;
|
|
OnChannelSelect?.Invoke(channel);
|
|
}
|
|
|
|
public static string ChannelSelectorName(ChatSelectChannel channel)
|
|
{
|
|
return Loc.GetString($"hud-chatbox-select-channel-{channel}");
|
|
}
|
|
|
|
public Color ChannelSelectColor(ChatSelectChannel channel)
|
|
{
|
|
return channel switch
|
|
{
|
|
ChatSelectChannel.Radio => Color.LimeGreen,
|
|
ChatSelectChannel.LOOC => Color.MediumTurquoise,
|
|
ChatSelectChannel.OOC => Color.LightSkyBlue,
|
|
ChatSelectChannel.Dead => Color.MediumPurple,
|
|
ChatSelectChannel.Admin => Color.HotPink,
|
|
ChatSelectChannel.Telepathic => Color.PaleVioletRed, //Nyano - Summary: determines the color for the chat.
|
|
_ => Color.DarkGray
|
|
};
|
|
}
|
|
|
|
public void UpdateChannelSelectButton(ChatSelectChannel channel, Shared.Radio.RadioChannelPrototype? radio)
|
|
{
|
|
Text = radio != null ? Loc.GetString(radio.Name) : ChannelSelectorName(channel);
|
|
Modulate = radio?.Color ?? ChannelSelectColor(channel);
|
|
}
|
|
}
|