CatStation/Content.Client/BarSign/Ui/BarSignMenu.xaml.cs
Patrik Caes-Sayrs f9f4e09af2
Fixed redundant bar sign windows (#42960)
Fixed redundant bar signs

* Fixes the extra bar sign popups bug introduced in #42364
by making BarSignBUI use CreateWindow

* Fixes bar signs placed from Entity Spawn Window
2026-02-27 15:49:19 +00:00

43 lines
1 KiB
C#

using Content.Client.UserInterface.Controls;
using Content.Shared.BarSign;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.BarSign.Ui;
[GenerateTypedNameReferences]
public sealed partial class BarSignMenu : FancyWindow
{
private List<BarSignPrototype> _cachedPrototypes = new();
public event Action<string>? OnSignSelected;
public BarSignMenu()
{
RobustXamlLoader.Load(this);
SignOptions.OnItemSelected += idx =>
{
OnSignSelected?.Invoke(_cachedPrototypes[idx.Id].ID);
SignOptions.SelectId(idx.Id);
};
}
public void LoadSigns(List<BarSignPrototype> signs)
{
_cachedPrototypes.Clear();
_cachedPrototypes = signs;
foreach (var proto in _cachedPrototypes)
{
SignOptions.AddItem(Loc.GetString(proto.Name));
}
}
public void UpdateState(BarSignPrototype newSign)
{
var idx = _cachedPrototypes.IndexOf(newSign);
SignOptions.TrySelectId(idx);
}
}