Files
OldThink/Content.Client/PDA/PdaBoundUserInterface.cs

129 lines
3.9 KiB
C#
Raw Normal View History

using Content.Client.CartridgeLoader;
using Content.Shared.CartridgeLoader;
using Content.Shared.Containers.ItemSlots;
2021-06-09 22:19:39 +02:00
using Content.Shared.PDA;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Shared.Configuration;
2021-06-09 22:19:39 +02:00
namespace Content.Client.PDA
{
[UsedImplicitly]
public sealed class PdaBoundUserInterface : CartridgeLoaderBoundUserInterface
{
2023-07-08 09:02:17 -07:00
[ViewVariables]
private PdaMenu? _menu;
2023-07-08 09:02:17 -07:00
public PdaBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
SendMessage(new PdaRequestUpdateInterfaceMessage());
_menu = new PdaMenu();
_menu.OpenCenteredLeft();
_menu.OnClose += Close;
_menu.FlashLightToggleButton.OnToggled += _ =>
{
SendMessage(new PdaToggleFlashlightMessage());
};
Moving PDA to ECS (#4538) * Moved pen slot to separate component * Moved it all to more generic item slot class * Add sounds * Item slots now supports many slots * Some clean-up * Refactored slots a bit * Moving ID card out * Moving pda to system * Moving PDA owner to ECS * Moved PDA flashlight to separate component * Toggle lights work through events * Fixing UI * Moving uplink to separate component * Continue moving uplink to separate component * More cleaning * Removing pda shared * Nuked shared pda component * Fixed flashlight * Pen slot now showed in UI * Light toggle now shows correctly in UI * Small refactoring of item slots * Added contained entity * Fixed tests * Finished with PDA * Moving PDA uplink to separate window * Adding-removing uplink should show new button * Working on a better debug * Debug command to add uplink * Uplink send state to UI * Almost working UI * Uplink correcty updates when you buy-sell items * Ups * Moved localization to separate file * Minor fixes * Removed item slots methods events * Removed PDA owner name * Removed one uplink event * Deleted all uplink events * Removed flashlight events * Update Content.Shared/Traitor/Uplink/UplinkVisuals.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Containers/ItemSlot/ItemSlotsSystem.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Containers/ItemSlot/ItemSlotsSystem.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameTicking/Presets/PresetTraitorDeathMatch.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Item slots system review * Flashlight review * PDA to XAML * Move UplinkMenu to seperate class, fix WeightedColors methods * Move UI to XAML * Moved events to entity id * Address review * Removed uplink extensions * Minor fix * Moved item slots to shared * My bad Robust... * Fixed pda sound * Fixed pda tests * Fixed pda test again Co-authored-by: Alexander Evgrashin <evgrashin.adl@gmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Visne <vincefvanwijk@gmail.com>
2021-10-03 07:05:52 +03:00
_menu.EjectIdButton.OnPressed += _ =>
{
SendMessage(new ItemSlotButtonPressedEvent(PdaComponent.PdaIdSlotId));
};
_menu.EjectPenButton.OnPressed += _ =>
{
SendMessage(new ItemSlotButtonPressedEvent(PdaComponent.PdaPenSlotId));
};
_menu.EjectPaiButton.OnPressed += _ =>
{
SendMessage(new ItemSlotButtonPressedEvent(PdaComponent.PdaPaiSlotId));
};
2022-03-07 14:41:50 +03:00
_menu.ActivateMusicButton.OnPressed += _ =>
{
SendMessage(new PdaShowMusicMessage());
2022-03-07 14:41:50 +03:00
};
_menu.AccessRingtoneButton.OnPressed += _ =>
{
SendMessage(new PdaShowRingtoneMessage());
};
_menu.ShowUplinkButton.OnPressed += _ =>
{
SendMessage(new PdaShowUplinkMessage());
};
_menu.LockUplinkButton.OnPressed += _ =>
{
SendMessage(new PdaLockUplinkMessage());
};
_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 (state is not PdaUpdateState updateState)
return;
_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);
if (!disposing)
return;
_menu?.Dispose();
}
private PdaBorderColorComponent? GetBorderColorComponent()
{
2023-07-08 09:02:17 -07:00
return EntMan.GetComponentOrNull<PdaBorderColorComponent>(Owner);
}
}
}