mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
43 lines
1 KiB
C#
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);
|
|
}
|
|
}
|