2022-11-08 21:00:20 +01:00
|
|
|
using Content.Client.CartridgeLoader;
|
|
|
|
|
using Content.Shared.CartridgeLoader;
|
2022-08-08 22:10:01 -07:00
|
|
|
using Content.Shared.CCVar;
|
2022-03-28 17:03:03 +13:00
|
|
|
using Content.Shared.Containers.ItemSlots;
|
2022-08-08 22:10:01 -07:00
|
|
|
using Content.Shared.CrewManifest;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.PDA;
|
2020-12-08 11:56:10 +01:00
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Client.GameObjects;
|
2022-11-08 21:00:20 +01:00
|
|
|
using Robust.Client.UserInterface;
|
2022-08-08 22:10:01 -07:00
|
|
|
using Robust.Shared.Configuration;
|
2020-05-28 06:22:47 -05:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.PDA
|
2020-05-28 06:22:47 -05:00
|
|
|
{
|
2020-12-08 11:56:10 +01:00
|
|
|
[UsedImplicitly]
|
2022-11-08 21:00:20 +01:00
|
|
|
public sealed class PDABoundUserInterface : CartridgeLoaderBoundUserInterface
|
2020-05-28 06:22:47 -05:00
|
|
|
{
|
2022-11-08 21:00:20 +01:00
|
|
|
[Dependency] private readonly IEntityManager? _entityManager = default!;
|
2022-08-08 22:10:01 -07:00
|
|
|
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
|
|
|
|
|
2021-03-10 14:48:29 +01:00
|
|
|
private PDAMenu? _menu;
|
2020-05-28 06:22:47 -05:00
|
|
|
|
2022-08-21 05:38:30 +12:00
|
|
|
public PDABoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
2020-05-28 06:22:47 -05:00
|
|
|
{
|
2022-08-08 22:10:01 -07:00
|
|
|
IoCManager.InjectDependencies(this);
|
2020-05-28 06:22:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
{
|
|
|
|
|
base.Open();
|
|
|
|
|
SendMessage(new PDARequestUpdateInterfaceMessage());
|
2021-10-03 07:05:52 +03:00
|
|
|
_menu = new PDAMenu();
|
2022-07-29 14:13:22 +12:00
|
|
|
_menu.OpenCenteredLeft();
|
2020-05-28 06:22:47 -05:00
|
|
|
_menu.OnClose += Close;
|
2021-03-10 14:48:29 +01:00
|
|
|
_menu.FlashLightToggleButton.OnToggled += _ =>
|
2020-05-28 06:22:47 -05:00
|
|
|
{
|
|
|
|
|
SendMessage(new PDAToggleFlashlightMessage());
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-08 22:10:01 -07:00
|
|
|
if (_configManager.GetCVar(CCVars.CrewManifestUnsecure))
|
|
|
|
|
{
|
|
|
|
|
_menu.CrewManifestButton.Visible = true;
|
|
|
|
|
_menu.CrewManifestButton.OnPressed += _ =>
|
|
|
|
|
{
|
|
|
|
|
SendMessage(new CrewManifestOpenUiMessage());
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-03 07:05:52 +03:00
|
|
|
_menu.EjectIdButton.OnPressed += _ =>
|
2020-05-28 06:22:47 -05:00
|
|
|
{
|
2022-03-28 17:03:03 +13:00
|
|
|
SendMessage(new ItemSlotButtonPressedEvent(PDAComponent.PDAIdSlotId));
|
2020-05-28 06:22:47 -05:00
|
|
|
};
|
|
|
|
|
|
2021-03-10 14:48:29 +01:00
|
|
|
_menu.EjectPenButton.OnPressed += _ =>
|
2020-11-08 13:43:13 +01:00
|
|
|
{
|
2022-03-28 17:03:03 +13:00
|
|
|
SendMessage(new ItemSlotButtonPressedEvent(PDAComponent.PDAPenSlotId));
|
2020-11-08 13:43:13 +01:00
|
|
|
};
|
|
|
|
|
|
2021-10-03 07:05:52 +03:00
|
|
|
_menu.ActivateUplinkButton.OnPressed += _ =>
|
2020-05-28 06:22:47 -05:00
|
|
|
{
|
2021-10-03 07:05:52 +03:00
|
|
|
SendMessage(new PDAShowUplinkMessage());
|
2020-05-28 06:22:47 -05:00
|
|
|
};
|
|
|
|
|
|
2022-03-07 14:41:50 +03:00
|
|
|
_menu.ActivateMusicButton.OnPressed += _ =>
|
|
|
|
|
{
|
|
|
|
|
SendMessage(new PDAShowMusicMessage());
|
|
|
|
|
};
|
|
|
|
|
|
2022-02-08 04:39:23 -05:00
|
|
|
_menu.AccessRingtoneButton.OnPressed += _ =>
|
|
|
|
|
{
|
|
|
|
|
SendMessage(new PDAShowRingtoneMessage());
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-08 21:00:20 +01:00
|
|
|
_menu.OnProgramItemPressed += ActivateCartridge;
|
|
|
|
|
_menu.OnInstallButtonPressed += InstallCartridge;
|
|
|
|
|
_menu.OnUninstallButtonPressed += UninstallCartridge;
|
|
|
|
|
_menu.ProgramCloseButton.OnPressed += _ => DeactivateActiveCartridge();
|
|
|
|
|
|
|
|
|
|
var borderColorComponent = GetBorderColorComponent();
|
|
|
|
|
if (borderColorComponent == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_menu.BorderColor = borderColorComponent.BorderColor;
|
|
|
|
|
_menu.AccentHColor = borderColorComponent.AccentHColor;
|
|
|
|
|
_menu.AccentVColor = borderColorComponent.AccentVColor;
|
2020-05-28 06:22:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
|
|
|
{
|
|
|
|
|
base.UpdateState(state);
|
2021-03-10 14:48:29 +01:00
|
|
|
|
2022-11-08 21:00:20 +01:00
|
|
|
if (state is not PDAUpdateState updateState)
|
2021-03-10 14:48:29 +01:00
|
|
|
return;
|
2020-05-28 06:22:47 -05:00
|
|
|
|
2022-11-08 21:00:20 +01:00
|
|
|
_menu?.UpdateState(updateState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void AttachCartridgeUI(Control cartridgeUIFragment, string? title)
|
|
|
|
|
{
|
|
|
|
|
_menu?.ProgramView.AddChild(cartridgeUIFragment);
|
|
|
|
|
_menu?.ToProgramView(title ?? Loc.GetString("comp-pda-io-program-fallback-title"));
|
2020-05-28 06:22:47 -05:00
|
|
|
}
|
|
|
|
|
|
2022-11-08 21:00:20 +01:00
|
|
|
protected override void DetachCartridgeUI(Control cartridgeUIFragment)
|
|
|
|
|
{
|
|
|
|
|
if (_menu is null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_menu.ToHomeScreen();
|
|
|
|
|
_menu.HideProgramHeader();
|
|
|
|
|
_menu.ProgramView.RemoveChild(cartridgeUIFragment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateAvailablePrograms(List<(EntityUid, CartridgeComponent)> programs)
|
|
|
|
|
{
|
|
|
|
|
_menu?.UpdateAvailablePrograms(programs);
|
|
|
|
|
}
|
2020-06-05 11:44:25 -05:00
|
|
|
|
2020-05-28 06:22:47 -05:00
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(disposing);
|
2020-10-06 10:16:42 +02:00
|
|
|
if (!disposing)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-05-28 06:22:47 -05:00
|
|
|
_menu?.Dispose();
|
|
|
|
|
}
|
2022-11-08 21:00:20 +01:00
|
|
|
|
|
|
|
|
private PDABorderColorComponent? GetBorderColorComponent()
|
|
|
|
|
{
|
|
|
|
|
return _entityManager?.GetComponentOrNull<PDABorderColorComponent>(Owner.Owner);
|
|
|
|
|
}
|
2020-05-28 06:22:47 -05:00
|
|
|
}
|
|
|
|
|
}
|