Instrument band support, submodule update to 138.0.0 (#17995)
This commit is contained in:
committed by
GitHub
parent
69ff0ae2e6
commit
a2893dd6c3
@@ -1,22 +1,56 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Instruments.UI;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Client.Audio.Midi;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
namespace Content.Client.Instruments.UI
|
||||
{
|
||||
public sealed class InstrumentBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[ViewVariables]
|
||||
private InstrumentMenu? _instrumentMenu;
|
||||
[Dependency] public readonly IEntityManager Entities = default!;
|
||||
[Dependency] public readonly IMidiManager MidiManager = default!;
|
||||
[Dependency] public readonly IFileDialogManager FileDialogManager = default!;
|
||||
[Dependency] public readonly IPlayerManager PlayerManager = default!;
|
||||
[Dependency] public readonly ILocalizationManager Loc = default!;
|
||||
|
||||
[ViewVariables]
|
||||
public InstrumentComponent? Instrument { get; set; }
|
||||
public readonly InstrumentSystem Instruments = default!;
|
||||
public readonly ActionBlockerSystem ActionBlocker = default!;
|
||||
public readonly SharedInteractionSystem Interactions = default!;
|
||||
|
||||
[ViewVariables] private InstrumentMenu? _instrumentMenu;
|
||||
[ViewVariables] private BandMenu? _bandMenu;
|
||||
[ViewVariables] private ChannelsMenu? _channelsMenu;
|
||||
|
||||
[ViewVariables] public InstrumentComponent? Instrument { get; private set; }
|
||||
|
||||
public InstrumentBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
Instruments = Entities.System<InstrumentSystem>();
|
||||
ActionBlocker = Entities.System<ActionBlockerSystem>();
|
||||
Interactions = Entities.System<SharedInteractionSystem>();
|
||||
}
|
||||
|
||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case InstrumentBandResponseBuiMessage bandRx:
|
||||
_bandMenu?.Populate(bandRx.Nearby);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
if (!EntMan.TryGetComponent<InstrumentComponent?>(Owner, out var instrument)) return;
|
||||
if (!EntMan.TryGetComponent<InstrumentComponent?>(Owner, out var instrument))
|
||||
return;
|
||||
|
||||
Instrument = instrument;
|
||||
_instrumentMenu = new InstrumentMenu(this);
|
||||
@@ -28,8 +62,45 @@ namespace Content.Client.Instruments.UI
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing) return;
|
||||
if (!disposing)
|
||||
return;
|
||||
_instrumentMenu?.Dispose();
|
||||
_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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user