mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-14 19:30:01 +01:00
* refmbcult * fixrule * minich * yeee * linter * somefixes * cultext&gamb * linterfix * fixtarot
93 lines
2.5 KiB
C#
93 lines
2.5 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.Mind => Color.Peru, // Corvax-Wega-MindChat
|
|
ChatSelectChannel.Admin => Color.HotPink,
|
|
_ => Color.DarkGray
|
|
};
|
|
}
|
|
|
|
// Corvax-Wega-MindChat-Edit-start
|
|
public void UpdateChannelSelectButton(ChatSelectChannel channel, Shared.Radio.RadioChannelPrototype? radio, Shared.Mind.MindChannelPrototype? mind)
|
|
{
|
|
if (radio != null)
|
|
{
|
|
Text = Loc.GetString(radio.Name);
|
|
Modulate = radio.Color;
|
|
}
|
|
else if (mind != null)
|
|
{
|
|
Text = Loc.GetString(mind.Name);
|
|
Modulate = mind.Color;
|
|
}
|
|
else
|
|
{
|
|
Text = ChannelSelectorName(channel);
|
|
Modulate = ChannelSelectColor(channel);
|
|
}
|
|
}
|
|
// Corvax-Wega-MindChat-Edit-end
|
|
}
|