mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Vertically expanding channels, -pointless Controls * scamboni * XAML control for the base midi CFG item
61 lines
1.6 KiB
C#
61 lines
1.6 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 MinVolumeControl : BoxContainer
|
|
{
|
|
/// <summary>
|
|
/// Raised when the user changes the min volume for MIDI input.
|
|
/// </summary>
|
|
public event Action<int>? MinVolumeChanged;
|
|
|
|
public int MinVolume
|
|
{
|
|
get => (int)Math.Ceiling(MidiMinVolumeSlider.Value);
|
|
set
|
|
{
|
|
MidiMinVolumeSlider.Value = value;
|
|
UpdateLabel();
|
|
}
|
|
}
|
|
|
|
public MinVolumeControl()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
MidiMinVolumeSlider.OnValueChanged += OnMidiMinVolumeSliderValueChanged;
|
|
MidiMinVolumeSlider.OnKeyBindUp += OnMidiMinVolumeSliderKeyUp;
|
|
MidiMinVolumeSlider.Value = 0;
|
|
}
|
|
|
|
private void OnMidiMinVolumeSliderValueChanged(Robust.Client.UserInterface.Controls.Range _)
|
|
{
|
|
UpdateLabel();
|
|
|
|
// Do not update while still grabbed.
|
|
if (MidiMinVolumeSlider.Grabbed)
|
|
return;
|
|
|
|
MinVolumeChanged?.Invoke(MinVolume);
|
|
}
|
|
|
|
private void OnMidiMinVolumeSliderKeyUp(GUIBoundKeyEventArgs args)
|
|
{
|
|
if (args.Function != EngineKeyFunctions.UIClick)
|
|
return;
|
|
|
|
UpdateLabel();
|
|
MinVolumeChanged?.Invoke(MinVolume);
|
|
}
|
|
|
|
private void UpdateLabel()
|
|
{
|
|
MidiMinVolumeValueLabel.Text = ((int)Math.Ceiling(MidiMinVolumeSlider.Value)).ToString();
|
|
}
|
|
}
|