mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
* - add: StyleSheetify * - add: APC style * - tweak: Select only APC now! * - fix: Window positioning * - fix: animations * - add: Fancy chat * - tweak: change some margin think * - fix: add assemblies of stylesheetify for packaging * - tweak: update StyleSheetify * - add: custom LauncherConnection * - tweak: change to paper * - tweak: Update StyleSheetify * - add: fancy lobby screen * - tweak: some beauty think in lobby screen * - add: new icons * - tweak: change icons * - tweak: //WWDP EDIT * - fix: disable style while testing * - fix: Channel Popup button style revert * - fix: test again * - tweak: Update StyleSheetify
90 lines
2.7 KiB
C#
90 lines
2.7 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Numerics;
|
|
using Content.Shared.Chat;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.ResourceManagement;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.Utility;
|
|
|
|
|
|
namespace Content.Client.UserInterface.Systems.Chat.Controls;
|
|
|
|
public sealed class ChannelSelectorButton : ChatPopupButton<ChannelSelectorPopup>
|
|
{
|
|
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
|
public event Action<ChatSelectChannel>? OnChannelSelect;
|
|
|
|
public ChatSelectChannel SelectedChannel { get; private set; }
|
|
|
|
private const int SelectorDropdownOffset = 38;
|
|
|
|
public ChannelSelectorButton()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
Name = "ChannelSelector";
|
|
StyleBoxOverride = new StyleBoxEmpty();
|
|
|
|
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)
|
|
{
|
|
// WWDP EDIT START
|
|
var text = radio != null ? Loc.GetString(radio.Name) : ChannelSelectorName(channel);
|
|
Text = $"[{text}]";
|
|
Modulate = radio?.Color ?? ChannelSelectColor(channel);
|
|
// WWDP EDIT END
|
|
}
|
|
}
|