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
56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using System.Linq;
|
|
using Content.Client.Audio.Midi;
|
|
using Content.Client.Stylesheets;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.ContentPack;
|
|
|
|
namespace Content.Client.Instruments.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class MidiCollectionUtilsControl : BoxContainer
|
|
{
|
|
[Dependency] private MidiFileCollectionManager _midiCollection = default!;
|
|
[Dependency] private IResourceManager _resourceManager = default!;
|
|
|
|
public MidiCollectionUtilsControl()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
_midiCollection.MidiFileAdded += _ => UpdateCount();
|
|
_midiCollection.MidiFileRemoved += _ => UpdateCount();
|
|
_midiCollection.MidiFilesReset += UpdateCount;
|
|
|
|
DeleteAllButton.StyleClasses.Add(StyleClass.Negative);
|
|
|
|
OpenDirectoryButton.OnPressed += OnOpenDirectoryButtonPressed;
|
|
ReloadCollectionButton.OnPressed += OnReloadCollectionButtonPressed;
|
|
DeleteAllButton.OnPressed += OnDeleteAllButtonPressed;
|
|
|
|
UpdateCount();
|
|
}
|
|
|
|
private void OnOpenDirectoryButtonPressed(BaseButton.ButtonEventArgs obj)
|
|
{
|
|
_resourceManager.UserData.OpenOsWindow(MidiFileCollectionManager.UserMidiDirectory);
|
|
}
|
|
|
|
private void OnReloadCollectionButtonPressed(BaseButton.ButtonEventArgs obj)
|
|
{
|
|
_midiCollection.ReloadLibrary();
|
|
}
|
|
|
|
private void OnDeleteAllButtonPressed(BaseButton.ButtonEventArgs obj)
|
|
{
|
|
_midiCollection.RemoveAllMidiFiles();
|
|
}
|
|
|
|
private void UpdateCount()
|
|
{
|
|
MidiCountLabel.Text = Loc.GetString(
|
|
"instruments-component-midi-file-collection-size-label",
|
|
("count", _midiCollection.GetMidiFiles().Count()));
|
|
}
|
|
}
|