Adds the station name to PDAs (#9987)

Co-authored-by: ike709 <ike709@github.com>
This commit is contained in:
ike709
2022-07-23 18:58:28 -07:00
committed by GitHub
parent e78ede1988
commit c65cf5bb1f
6 changed files with 40 additions and 7 deletions

View File

@@ -79,14 +79,16 @@ namespace Content.Client.PDA
if (msg.PDAOwnerInfo.IdOwner != null || msg.PDAOwnerInfo.JobTitle != null)
{
_menu.IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
("Owner",msg.PDAOwnerInfo.IdOwner ?? "Unknown"),
("JobTitle",msg.PDAOwnerInfo.JobTitle ?? "Unassigned")));
("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;

View File

@@ -8,9 +8,12 @@
HorizontalExpand="True"
MinSize="50 50">
<RichTextLabel Name="PdaOwnerLabel" Access="Public" />
<RichTextLabel Name="IdInfoLabel"
Access="Public"
HorizontalExpand="True" />
<PanelContainer>
<BoxContainer Orientation="Horizontal">
<RichTextLabel Name="IdInfoLabel"
<RichTextLabel Name="StationNameLabel"
Access="Public"
HorizontalExpand="True" />
<Button Name="EjectIdButton"

View File

@@ -6,10 +6,13 @@ using Content.Server.Traitor.Uplink;
using Content.Server.Traitor.Uplink.Account;
using Content.Server.Traitor.Uplink.Components;
using Content.Server.PDA.Ringer;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.UserInterface;
using Content.Shared.PDA;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Map;
namespace Content.Server.PDA
{
@@ -21,6 +24,7 @@ namespace Content.Server.PDA
[Dependency] private readonly RingerSystem _ringerSystem = default!;
[Dependency] private readonly InstrumentSystem _instrumentSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
public override void Initialize()
{
@@ -30,6 +34,7 @@ namespace Content.Server.PDA
SubscribeLocalEvent<PDAComponent, AfterActivatableUIOpenEvent>(AfterUIOpen);
SubscribeLocalEvent<PDAComponent, UplinkInitEvent>(OnUplinkInit);
SubscribeLocalEvent<PDAComponent, UplinkRemovedEvent>(OnUplinkRemoved);
SubscribeLocalEvent<PDAComponent, GridModifiedEvent>(OnGridChanged);
}
protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
@@ -39,6 +44,8 @@ namespace Content.Server.PDA
if (!TryComp(uid, out ServerUserInterfaceComponent? uiComponent))
return;
UpdateStationName(pda);
if (_uiSystem.TryGetUi(uid, PDAUiKey.Key, out var ui, uiComponent))
ui.OnReceiveMessage += (msg) => OnUIMessage(pda, msg);
}
@@ -77,6 +84,12 @@ namespace Content.Server.PDA
UpdatePDAUserInterface(pda);
}
private void OnGridChanged(EntityUid uid, PDAComponent pda, GridModifiedEvent args)
{
UpdateStationName(pda);
UpdatePDAUserInterface(pda);
}
private void UpdatePDAUserInterface(PDAComponent pda)
{
var ownerInfo = new PDAIdInfoText
@@ -90,7 +103,7 @@ namespace Content.Server.PDA
return;
var hasInstrument = HasComp<InstrumentComponent>(pda.Owner);
var state = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, false, hasInstrument);
var state = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, pda.StationName, false, hasInstrument);
ui.SetState(state);
@@ -101,7 +114,7 @@ namespace Content.Server.PDA
if (!HasComp<UplinkComponent>(pda.Owner))
return;
var uplinkState = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, true, hasInstrument);
var uplinkState = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, pda.StationName, true, hasInstrument);
foreach (var session in ui.SubscribedSessions)
{
@@ -149,6 +162,12 @@ namespace Content.Server.PDA
}
}
private void UpdateStationName(PDAComponent pda)
{
var station = _stationSystem.GetOwningStation(pda.Owner);
pda.StationName = station is null ? null : Name(station.Value);
}
private void AfterUIOpen(EntityUid uid, PDAComponent pda, AfterActivatableUIOpenEvent args)
{
// A new user opened the UI --> Check if they are a traitor and should get a user specific UI state override.
@@ -165,7 +184,7 @@ namespace Content.Server.PDA
JobTitle = pda.ContainedID?.JobTitle
};
var state = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, true, HasComp<InstrumentComponent>(pda.Owner));
var state = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, pda.StationName, true, HasComp<InstrumentComponent>(pda.Owner));
ui.SetState(state, args.Session);
}

View File

@@ -27,5 +27,6 @@ namespace Content.Shared.PDA
[ViewVariables] public bool FlashlightOn;
[ViewVariables] public string? OwnerName;
[ViewVariables] public string? StationName;
}
}

View File

@@ -9,16 +9,18 @@ namespace Content.Shared.PDA
public bool FlashlightEnabled;
public bool HasPen;
public PDAIdInfoText PDAOwnerInfo;
public string? StationName;
public bool HasUplink;
public bool CanPlayMusic;
public PDAUpdateState(bool flashlightEnabled, bool hasPen, PDAIdInfoText pDAOwnerInfo, bool hasUplink = false, bool canPlayMusic = false)
public PDAUpdateState(bool flashlightEnabled, bool hasPen, PDAIdInfoText pDAOwnerInfo, string? stationName, bool hasUplink = false, bool canPlayMusic = false)
{
FlashlightEnabled = flashlightEnabled;
HasPen = hasPen;
PDAOwnerInfo = pDAOwnerInfo;
HasUplink = hasUplink;
CanPlayMusic = canPlayMusic;
StationName = stationName;
}
}

View File

@@ -14,6 +14,8 @@ pda-bound-user-interface-uplink-tab-title = Uplink
comp-pda-ui-menu-title = PDA
comp-pda-ui-station = Station: [color=white]{$Station}[/color]
comp-pda-ui-eject-id-button = Eject ID
comp-pda-ui-eject-pen-button = Eject Pen
@@ -23,3 +25,7 @@ comp-pda-ui-ringtone-button = Ringtone
comp-pda-ui-toggle-flashlight-button = Toggle Flashlight
pda-bound-user-interface-music-button = Music Instrument
comp-pda-ui-unknown = Unknown
comp-pda-ui-unassigned = Unassigned