mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-19 06:28:40 +03:00
* Revert "remove: отключим наше меню эмоций в пользу колеса эмоций" This reverts commit526211be* Revert "fix: linter" This reverts commit8bf2cbfb* feature: emotes menu type * fix: linter * fix: linter * fixs * fix * Update speech_emote_sounds.yml * Update speech_emote_sounds.yml * Update dogs.yml * Update animals.yml * Update disease_emotes.yml * Update WhiteEmotesMenu.xaml.cs * Update WhiteEmotesMenu.xaml.cs * Update tags.yml
69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using System.Linq;
|
|
using Content.Shared.Chat.Prototypes;
|
|
using Content.Shared.Speech;
|
|
using Content.Shared.Whitelist;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client._White.UI.Emotes;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class WhiteEmotesMenu : DefaultWindow, IBaseEmoteMenu
|
|
{
|
|
[Dependency] private readonly EntityManager _entManager = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
|
|
|
|
public event Action<ProtoId<EmotePrototype>>? OnPlayEmote;
|
|
|
|
public WhiteEmotesMenu()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
RobustXamlLoader.Load(this);
|
|
|
|
var whitelistSystem = _entManager.System<EntityWhitelistSystem>();
|
|
|
|
var emotes = _prototypeManager.EnumeratePrototypes<EmotePrototype>().ToList();
|
|
emotes.Sort((a,b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal));
|
|
foreach (var emote in emotes)
|
|
{
|
|
var player = _playerManager.LocalEntity;
|
|
if (emote.Category == EmoteCategory.Invalid ||
|
|
emote.ChatTriggers.Count == 0 ||
|
|
!(player.HasValue && whitelistSystem.IsWhitelistPassOrNull(emote.Whitelist, player.Value)) ||
|
|
whitelistSystem.IsBlacklistPass(emote.Blacklist, player.Value))
|
|
continue;
|
|
|
|
if (!emote.Available &&
|
|
_entManager.TryGetComponent<SpeechComponent>(player.Value, out var speech) &&
|
|
!speech.AllowedEmotes.Contains(emote.ID))
|
|
continue;
|
|
|
|
var button = new EmoteMenuButton
|
|
{
|
|
ClipText = true,
|
|
HorizontalExpand = true,
|
|
VerticalExpand = true,
|
|
MinWidth = 120,
|
|
MaxWidth = 250,
|
|
MaxHeight = 35,
|
|
TextAlign = Label.AlignMode.Left,
|
|
Text = Loc.GetString(emote.Name),
|
|
ProtoId = emote,
|
|
};
|
|
|
|
button.OnPressed += _ => OnPlayEmote?.Invoke(emote);
|
|
EmotionsContainer.AddChild(button);
|
|
}
|
|
}
|
|
}
|
|
|
|
public sealed class EmoteMenuButton : Button
|
|
{
|
|
public ProtoId<EmotePrototype> ProtoId { get; set; }
|
|
}
|