mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
71 lines
1.8 KiB
C#
71 lines
1.8 KiB
C#
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Input;
|
|
|
|
namespace Content.Client.Instruments.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class ChannelItem : Control
|
|
{
|
|
/// <summary>
|
|
/// Raised when a channel is toggled by the user.
|
|
/// </summary>
|
|
public event Action<int, bool>? SwitchFilteredChannel;
|
|
|
|
/// <summary>
|
|
/// MIDI channel ID this item is assigned to.
|
|
/// </summary>
|
|
public int ChannelId
|
|
{
|
|
get;
|
|
set
|
|
{
|
|
field = value;
|
|
ChannelNumberLabel.Text = (value + 1).ToString();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// UI state (on/off) of this channel item.
|
|
/// </summary>
|
|
public bool ChannelState
|
|
{
|
|
get => ChannelEnableSwitchButton.Pressed;
|
|
set => ChannelEnableSwitchButton.Pressed = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Name of this channel item in the UI.
|
|
/// </summary>
|
|
public string? ChannelName
|
|
{
|
|
get => ChannelNameLabel.Text;
|
|
set => ChannelNameLabel.Text = value;
|
|
}
|
|
|
|
public ChannelItem()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
ChannelEnableSwitchButton.OnPressed += OnChannelEnableSwitchButtonPressed;
|
|
MouseFilter = MouseFilterMode.Stop;
|
|
}
|
|
|
|
protected override void KeyBindUp(GUIBoundKeyEventArgs args)
|
|
{
|
|
base.KeyBindUp(args);
|
|
if (args.Function != EngineKeyFunctions.UIClick)
|
|
return;
|
|
|
|
ChannelState = !ChannelState;
|
|
SwitchFilteredChannel?.Invoke(ChannelId, ChannelState);
|
|
}
|
|
|
|
private void OnChannelEnableSwitchButtonPressed(BaseButton.ButtonEventArgs obj)
|
|
{
|
|
SwitchFilteredChannel?.Invoke(ChannelId, ChannelState);
|
|
}
|
|
}
|