Instrument band support, submodule update to 138.0.0 (#17995)
This commit is contained in:
committed by
GitHub
parent
69ff0ae2e6
commit
a2893dd6c3
45
Content.Client/Instruments/UI/BandMenu.xaml.cs
Normal file
45
Content.Client/Instruments/UI/BandMenu.xaml.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
|
||||
public BandMenu(InstrumentBoundUserInterface owner) : base()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public void Populate((EntityUid, string)[] nearby)
|
||||
{
|
||||
BandList.Clear();
|
||||
|
||||
foreach (var (uid, name) in nearby)
|
||||
{
|
||||
var item = BandList.AddItem(name, null, true, uid);
|
||||
item.Selected = _owner.Instrument?.Master == uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user