PDA UI refactor and cartridges (#11335)
* Work on cartridges * Work on PDA UI * Work on PDA UIs program list * Work on PDA UI borders * Add DeviceNetworkingComponent to the pda base prototype * Fix submodule version * Fix cartridge loader ui key * Fix pda menu xaml * Implement relaying ui messages * Finish implementing the notekeeper cartridge * Fix submodule version * Fix errors from merging master * Fix test failing * Implement setting preinstalled programs * Add some documentation to CartridgeLoaderSystem * Add more doc comments * Add localization to program names * Implement review suggestions * Fix background programs receiving events twice when active
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
using Content.Client.Message;
|
||||
using Content.Client.CartridgeLoader;
|
||||
using Content.Shared.CartridgeLoader;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.CrewManifest;
|
||||
using Content.Shared.PDA;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Client.PDA
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class PDABoundUserInterface : BoundUserInterface
|
||||
public sealed class PDABoundUserInterface : CartridgeLoaderBoundUserInterface
|
||||
{
|
||||
[Dependency] private readonly IEntityManager? _entityManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
||||
|
||||
private PDAMenu? _menu;
|
||||
@@ -67,54 +70,52 @@ namespace Content.Client.PDA
|
||||
SendMessage(new PDAShowRingtoneMessage());
|
||||
};
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (_menu == null)
|
||||
{
|
||||
if (state is not PDAUpdateState updateState)
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case PDAUpdateState msg:
|
||||
{
|
||||
_menu.FlashLightToggleButton.Pressed = msg.FlashlightEnabled;
|
||||
|
||||
if (msg.PDAOwnerInfo.ActualOwnerName != null)
|
||||
{
|
||||
_menu.PdaOwnerLabel.SetMarkup(Loc.GetString("comp-pda-ui-owner",
|
||||
("ActualOwnerName", msg.PDAOwnerInfo.ActualOwnerName)));
|
||||
}
|
||||
|
||||
|
||||
if (msg.PDAOwnerInfo.IdOwner != null || msg.PDAOwnerInfo.JobTitle != null)
|
||||
{
|
||||
_menu.IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
|
||||
("Owner",msg.PDAOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")),
|
||||
("JobTitle",msg.PDAOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned"))));
|
||||
}
|
||||
else
|
||||
{
|
||||
_menu.IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui-blank"));
|
||||
}
|
||||
|
||||
_menu.StationNameLabel.SetMarkup(Loc.GetString("comp-pda-ui-station", ("Station",msg.StationName ?? Loc.GetString("comp-pda-ui-unknown"))));
|
||||
|
||||
_menu.EjectIdButton.Visible = msg.PDAOwnerInfo.IdOwner != null || msg.PDAOwnerInfo.JobTitle != null;
|
||||
_menu.EjectPenButton.Visible = msg.HasPen;
|
||||
_menu.ActivateUplinkButton.Visible = msg.HasUplink;
|
||||
_menu.ActivateMusicButton.Visible = msg.CanPlayMusic;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
_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"));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
@@ -123,5 +124,10 @@ namespace Content.Client.PDA
|
||||
|
||||
_menu?.Dispose();
|
||||
}
|
||||
|
||||
private PDABorderColorComponent? GetBorderColorComponent()
|
||||
{
|
||||
return _entityManager?.GetComponentOrNull<PDABorderColorComponent>(Owner.Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user