2023-07-16 21:12:53 +02:00
|
|
|
using Content.Shared.ActionBlocker;
|
|
|
|
|
using Content.Shared.Instruments.UI;
|
|
|
|
|
using Content.Shared.Interaction;
|
|
|
|
|
using Robust.Client.Audio.Midi;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Client.GameObjects;
|
2023-07-16 21:12:53 +02:00
|
|
|
using Robust.Client.Player;
|
|
|
|
|
using Robust.Client.UserInterface;
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Instruments.UI
|
2019-11-25 00:11:47 +01:00
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class InstrumentBoundUserInterface : BoundUserInterface
|
2019-11-25 00:11:47 +01:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public IEntityManager Entities => EntMan;
|
2023-07-16 21:12:53 +02:00
|
|
|
[Dependency] public readonly IMidiManager MidiManager = default!;
|
|
|
|
|
[Dependency] public readonly IFileDialogManager FileDialogManager = default!;
|
|
|
|
|
[Dependency] public readonly IPlayerManager PlayerManager = default!;
|
|
|
|
|
[Dependency] public readonly ILocalizationManager Loc = default!;
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public readonly InstrumentSystem Instruments;
|
|
|
|
|
public readonly ActionBlockerSystem ActionBlocker;
|
|
|
|
|
public readonly SharedInteractionSystem Interactions;
|
2023-07-16 21:12:53 +02:00
|
|
|
|
|
|
|
|
[ViewVariables] private InstrumentMenu? _instrumentMenu;
|
|
|
|
|
[ViewVariables] private BandMenu? _bandMenu;
|
|
|
|
|
[ViewVariables] private ChannelsMenu? _channelsMenu;
|
|
|
|
|
|
|
|
|
|
[ViewVariables] public InstrumentComponent? Instrument { get; private set; }
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2023-07-08 09:02:17 -07:00
|
|
|
public InstrumentBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
2019-11-25 00:11:47 +01:00
|
|
|
{
|
2023-07-16 21:12:53 +02:00
|
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
|
|
|
|
|
|
Instruments = Entities.System<InstrumentSystem>();
|
|
|
|
|
ActionBlocker = Entities.System<ActionBlockerSystem>();
|
|
|
|
|
Interactions = Entities.System<SharedInteractionSystem>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
|
|
|
|
{
|
2024-10-22 22:47:57 +03:00
|
|
|
switch (message)
|
|
|
|
|
{
|
|
|
|
|
case InstrumentBandResponseBuiMessage bandRx:
|
|
|
|
|
_bandMenu?.Populate(bandRx.Nearby, EntMan);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-25 00:11:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
{
|
2023-08-24 03:10:55 -07:00
|
|
|
if (!EntMan.TryGetComponent(Owner, out InstrumentComponent? instrument))
|
2023-07-16 21:12:53 +02:00
|
|
|
return;
|
2019-11-25 00:11:47 +01:00
|
|
|
|
|
|
|
|
Instrument = instrument;
|
|
|
|
|
_instrumentMenu = new InstrumentMenu(this);
|
|
|
|
|
_instrumentMenu.OnClose += Close;
|
|
|
|
|
|
|
|
|
|
_instrumentMenu.OpenCentered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(disposing);
|
2023-07-16 21:12:53 +02:00
|
|
|
if (!disposing)
|
|
|
|
|
return;
|
2019-11-25 00:11:47 +01:00
|
|
|
_instrumentMenu?.Dispose();
|
2023-07-16 21:12:53 +02:00
|
|
|
_bandMenu?.Dispose();
|
|
|
|
|
_channelsMenu?.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RefreshBands()
|
|
|
|
|
{
|
|
|
|
|
SendMessage(new InstrumentBandRequestBuiMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenBandMenu()
|
|
|
|
|
{
|
|
|
|
|
_bandMenu ??= new BandMenu(this);
|
|
|
|
|
|
|
|
|
|
// Refresh cache...
|
|
|
|
|
RefreshBands();
|
|
|
|
|
|
|
|
|
|
_bandMenu.OpenCenteredLeft();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CloseBandMenu()
|
|
|
|
|
{
|
|
|
|
|
if(_bandMenu?.IsOpen ?? false)
|
|
|
|
|
_bandMenu.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OpenChannelsMenu()
|
|
|
|
|
{
|
|
|
|
|
_channelsMenu ??= new ChannelsMenu(this);
|
|
|
|
|
_channelsMenu.Populate();
|
|
|
|
|
_channelsMenu.OpenCenteredRight();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CloseChannelsMenu()
|
|
|
|
|
{
|
|
|
|
|
if(_channelsMenu?.IsOpen ?? false)
|
|
|
|
|
_channelsMenu.Close();
|
2019-11-25 00:11:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|