# Conflicts: # Content.Client/UserInterface/Controls/RadialContainer.cs # Content.Server/Lathe/LatheSystem.cs # Content.Server/Silicons/Laws/SiliconLawSystem.cs # Content.Shared/Inventory/InventorySystem.Relay.cs # Content.Shared/Materials/SharedMaterialReclaimerSystem.cs # Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs # Content.Shared/VendingMachines/SharedVendingMachineSystem.cs # Content.Shared/Wieldable/SharedWieldableSystem.cs # Resources/Locale/en-US/_strings/station-events/events/radiation-storm.ftl # Resources/Locale/en-US/_strings/store/uplink-catalog.ftl # Resources/Prototypes/Atmospherics/gases.yml # Resources/Prototypes/Catalog/Fills/Lockers/heads.yml # Resources/Prototypes/Datasets/Names/borg.yml # Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml # Resources/Prototypes/Entities/Mobs/Player/silicon.yml # Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml # Resources/Prototypes/Entities/Structures/Specific/Atmospherics/sensor.yml # Resources/ServerInfo/Guidebook/Engineering/AME.xml # Resources/ServerInfo/Guidebook/Engineering/AirlockSecurity.xml # Resources/ServerInfo/Guidebook/Engineering/Atmospherics.xml # Resources/ServerInfo/Guidebook/Engineering/Construction.xml # Resources/ServerInfo/Guidebook/Engineering/Engineering.xml # Resources/ServerInfo/Guidebook/Engineering/Fires.xml # Resources/ServerInfo/Guidebook/Engineering/NetworkConfigurator.xml # Resources/ServerInfo/Guidebook/Engineering/Networking.xml # Resources/ServerInfo/Guidebook/Engineering/Power.xml # Resources/ServerInfo/Guidebook/Engineering/RTG.xml # Resources/ServerInfo/Guidebook/Engineering/Shuttlecraft.xml # Resources/ServerInfo/Guidebook/Engineering/Singularity.xml # Resources/ServerInfo/Guidebook/Engineering/TEG.xml # Resources/ServerInfo/Guidebook/Security/CriminalRecords.xml # Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/equipped-OUTERCLOTHING.png # Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/icon.png # Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/meta.json # Resources/Textures/Objects/Weapons/Guns/Rifles/lecter.rsi/equipped-BACKPACK.png # Resources/migration.yml
111 lines
3.6 KiB
C#
111 lines
3.6 KiB
C#
using System.Numerics;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Chat.Prototypes;
|
|
using Content.Shared.Speech;
|
|
using Content.Shared.Whitelist;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Chat.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class EmotesMenu : RadialMenu
|
|
{
|
|
[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 EmotesMenu()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
RobustXamlLoader.Load(this);
|
|
|
|
var spriteSystem = _entManager.System<SpriteSystem>();
|
|
var whitelistSystem = _entManager.System<EntityWhitelistSystem>();
|
|
|
|
var main = FindControl<RadialContainer>("Main");
|
|
|
|
var emotes = _prototypeManager.EnumeratePrototypes<EmotePrototype>();
|
|
foreach (var emote in emotes)
|
|
{
|
|
var player = _playerManager.LocalSession?.AttachedEntity;
|
|
if (emote.Category == EmoteCategory.Invalid || emote.Category == EmoteCategory.Verb ||
|
|
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 parent = FindControl<RadialContainer>(emote.Category.ToString());
|
|
|
|
var button = new EmoteMenuButton
|
|
{
|
|
SetSize = new Vector2(64f, 64f),
|
|
ToolTip = Loc.GetString(emote.Name),
|
|
ProtoId = emote.ID,
|
|
};
|
|
|
|
var tex = new TextureRect
|
|
{
|
|
VerticalAlignment = VAlignment.Center,
|
|
HorizontalAlignment = HAlignment.Center,
|
|
Texture = spriteSystem.Frame0(emote.Icon),
|
|
TextureScale = new Vector2(2f, 2f),
|
|
};
|
|
|
|
button.AddChild(tex);
|
|
parent.AddChild(button);
|
|
foreach (var child in main.Children)
|
|
{
|
|
if (child is not RadialMenuTextureButton castChild)
|
|
continue;
|
|
|
|
if (castChild.TargetLayer == emote.Category.ToString())
|
|
{
|
|
castChild.Visible = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Set up menu actions
|
|
foreach (var child in Children)
|
|
{
|
|
if (child is not RadialContainer container)
|
|
continue;
|
|
AddEmoteClickAction(container);
|
|
}
|
|
}
|
|
|
|
private void AddEmoteClickAction(RadialContainer container)
|
|
{
|
|
foreach (var child in container.Children)
|
|
{
|
|
if (child is not EmoteMenuButton castChild)
|
|
continue;
|
|
|
|
castChild.OnButtonUp += _ =>
|
|
{
|
|
OnPlayEmote?.Invoke(castChild.ProtoId);
|
|
Close();
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public sealed class EmoteMenuButton : RadialMenuTextureButtonWithSector
|
|
{
|
|
public ProtoId<EmotePrototype> ProtoId { get; set; }
|
|
}
|