2023-07-16 21:12:53 +02:00
|
|
|
using Robust.Client.AutoGenerated;
|
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
|
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
|
using Robust.Shared.Timing;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Instruments.UI;
|
|
|
|
|
|
|
|
|
|
[GenerateTypedNameReferences]
|
|
|
|
|
public sealed partial class BandMenu : DefaultWindow
|
|
|
|
|
{
|
|
|
|
|
private readonly InstrumentBoundUserInterface _owner;
|
|
|
|
|
|
2024-07-21 14:48:13 +10:00
|
|
|
public EntityUid? Master;
|
|
|
|
|
|
|
|
|
|
public BandMenu(InstrumentBoundUserInterface owner)
|
2023-07-16 21:12:53 +02:00
|
|
|
{
|
|
|
|
|
RobustXamlLoader.Load(this);
|
|
|
|
|
|
|
|
|
|
_owner = owner;
|
|
|
|
|
BandList.OnItemSelected += OnItemSelected;
|
|
|
|
|
RefreshButton.OnPressed += OnRefreshPressed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnRefreshPressed(BaseButton.ButtonEventArgs obj)
|
|
|
|
|
{
|
|
|
|
|
_owner.RefreshBands();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnItemSelected(ItemList.ItemListSelectedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
_owner.Instruments.SetMaster(_owner.Owner, (EntityUid)args.ItemList[args.ItemIndex].Metadata!);
|
|
|
|
|
BandList.Clear();
|
|
|
|
|
Timer.Spawn(0, Close);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public void Populate((NetEntity, string)[] nearby, IEntityManager entManager)
|
2023-07-16 21:12:53 +02:00
|
|
|
{
|
|
|
|
|
BandList.Clear();
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
foreach (var (nent, name) in nearby)
|
2023-07-16 21:12:53 +02:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
var uid = entManager.GetEntity(nent);
|
2023-07-16 21:12:53 +02:00
|
|
|
var item = BandList.AddItem(name, null, true, uid);
|
2024-07-21 14:48:13 +10:00
|
|
|
item.Selected = Master == uid;
|
2023-07-16 21:12:53 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|