Instrument band support, submodule update to 138.0.0 (#17995)
This commit is contained in:
committed by
GitHub
parent
69ff0ae2e6
commit
a2893dd6c3
66
Content.Client/Instruments/UI/ChannelsMenu.xaml.cs
Normal file
66
Content.Client/Instruments/UI/ChannelsMenu.xaml.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Audio.Midi;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Instruments.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class ChannelsMenu : DefaultWindow
|
||||
{
|
||||
private readonly InstrumentBoundUserInterface _owner;
|
||||
|
||||
public ChannelsMenu(InstrumentBoundUserInterface owner) : base()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_owner = owner;
|
||||
|
||||
ChannelList.OnItemSelected += OnItemSelected;
|
||||
ChannelList.OnItemDeselected += OnItemDeselected;
|
||||
AllButton.OnPressed += OnAllPressed;
|
||||
ClearButton.OnPressed += OnClearPressed;
|
||||
}
|
||||
|
||||
private void OnItemSelected(ItemList.ItemListSelectedEventArgs args)
|
||||
{
|
||||
_owner.Instruments.SetFilteredChannel(_owner.Owner, (int)ChannelList[args.ItemIndex].Metadata!, false);
|
||||
}
|
||||
|
||||
private void OnItemDeselected(ItemList.ItemListDeselectedEventArgs args)
|
||||
{
|
||||
_owner.Instruments.SetFilteredChannel(_owner.Owner, (int)ChannelList[args.ItemIndex].Metadata!, true);
|
||||
}
|
||||
|
||||
private void OnAllPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
foreach (var item in ChannelList)
|
||||
{
|
||||
// TODO: Make this efficient jfc
|
||||
item.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClearPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
foreach (var item in ChannelList)
|
||||
{
|
||||
// TODO: Make this efficient jfc
|
||||
item.Selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Populate()
|
||||
{
|
||||
ChannelList.Clear();
|
||||
|
||||
for (int i = 0; i < RobustMidiEvent.MaxChannels; i++)
|
||||
{
|
||||
var item = ChannelList.AddItem(_owner.Loc.GetString("instrument-component-channel-name",
|
||||
("number", i)), null, true, i);
|
||||
|
||||
item.Selected = !_owner.Instrument?.FilteredChannels[i] ?? false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user