Adds the station name to PDAs (#9987)
Co-authored-by: ike709 <ike709@github.com>
This commit is contained in:
@@ -79,14 +79,16 @@ namespace Content.Client.PDA
|
|||||||
if (msg.PDAOwnerInfo.IdOwner != null || msg.PDAOwnerInfo.JobTitle != null)
|
if (msg.PDAOwnerInfo.IdOwner != null || msg.PDAOwnerInfo.JobTitle != null)
|
||||||
{
|
{
|
||||||
_menu.IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
|
_menu.IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
|
||||||
("Owner",msg.PDAOwnerInfo.IdOwner ?? "Unknown"),
|
("Owner",msg.PDAOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")),
|
||||||
("JobTitle",msg.PDAOwnerInfo.JobTitle ?? "Unassigned")));
|
("JobTitle",msg.PDAOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned"))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_menu.IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui-blank"));
|
_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.EjectIdButton.Visible = msg.PDAOwnerInfo.IdOwner != null || msg.PDAOwnerInfo.JobTitle != null;
|
||||||
_menu.EjectPenButton.Visible = msg.HasPen;
|
_menu.EjectPenButton.Visible = msg.HasPen;
|
||||||
_menu.ActivateUplinkButton.Visible = msg.HasUplink;
|
_menu.ActivateUplinkButton.Visible = msg.HasUplink;
|
||||||
|
|||||||
@@ -8,9 +8,12 @@
|
|||||||
HorizontalExpand="True"
|
HorizontalExpand="True"
|
||||||
MinSize="50 50">
|
MinSize="50 50">
|
||||||
<RichTextLabel Name="PdaOwnerLabel" Access="Public" />
|
<RichTextLabel Name="PdaOwnerLabel" Access="Public" />
|
||||||
|
<RichTextLabel Name="IdInfoLabel"
|
||||||
|
Access="Public"
|
||||||
|
HorizontalExpand="True" />
|
||||||
<PanelContainer>
|
<PanelContainer>
|
||||||
<BoxContainer Orientation="Horizontal">
|
<BoxContainer Orientation="Horizontal">
|
||||||
<RichTextLabel Name="IdInfoLabel"
|
<RichTextLabel Name="StationNameLabel"
|
||||||
Access="Public"
|
Access="Public"
|
||||||
HorizontalExpand="True" />
|
HorizontalExpand="True" />
|
||||||
<Button Name="EjectIdButton"
|
<Button Name="EjectIdButton"
|
||||||
|
|||||||
@@ -6,10 +6,13 @@ using Content.Server.Traitor.Uplink;
|
|||||||
using Content.Server.Traitor.Uplink.Account;
|
using Content.Server.Traitor.Uplink.Account;
|
||||||
using Content.Server.Traitor.Uplink.Components;
|
using Content.Server.Traitor.Uplink.Components;
|
||||||
using Content.Server.PDA.Ringer;
|
using Content.Server.PDA.Ringer;
|
||||||
|
using Content.Server.Station.Components;
|
||||||
|
using Content.Server.Station.Systems;
|
||||||
using Content.Server.UserInterface;
|
using Content.Server.UserInterface;
|
||||||
using Content.Shared.PDA;
|
using Content.Shared.PDA;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
namespace Content.Server.PDA
|
namespace Content.Server.PDA
|
||||||
{
|
{
|
||||||
@@ -21,6 +24,7 @@ namespace Content.Server.PDA
|
|||||||
[Dependency] private readonly RingerSystem _ringerSystem = default!;
|
[Dependency] private readonly RingerSystem _ringerSystem = default!;
|
||||||
[Dependency] private readonly InstrumentSystem _instrumentSystem = default!;
|
[Dependency] private readonly InstrumentSystem _instrumentSystem = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||||
|
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -30,6 +34,7 @@ namespace Content.Server.PDA
|
|||||||
SubscribeLocalEvent<PDAComponent, AfterActivatableUIOpenEvent>(AfterUIOpen);
|
SubscribeLocalEvent<PDAComponent, AfterActivatableUIOpenEvent>(AfterUIOpen);
|
||||||
SubscribeLocalEvent<PDAComponent, UplinkInitEvent>(OnUplinkInit);
|
SubscribeLocalEvent<PDAComponent, UplinkInitEvent>(OnUplinkInit);
|
||||||
SubscribeLocalEvent<PDAComponent, UplinkRemovedEvent>(OnUplinkRemoved);
|
SubscribeLocalEvent<PDAComponent, UplinkRemovedEvent>(OnUplinkRemoved);
|
||||||
|
SubscribeLocalEvent<PDAComponent, GridModifiedEvent>(OnGridChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
|
protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
|
||||||
@@ -39,6 +44,8 @@ namespace Content.Server.PDA
|
|||||||
if (!TryComp(uid, out ServerUserInterfaceComponent? uiComponent))
|
if (!TryComp(uid, out ServerUserInterfaceComponent? uiComponent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
UpdateStationName(pda);
|
||||||
|
|
||||||
if (_uiSystem.TryGetUi(uid, PDAUiKey.Key, out var ui, uiComponent))
|
if (_uiSystem.TryGetUi(uid, PDAUiKey.Key, out var ui, uiComponent))
|
||||||
ui.OnReceiveMessage += (msg) => OnUIMessage(pda, msg);
|
ui.OnReceiveMessage += (msg) => OnUIMessage(pda, msg);
|
||||||
}
|
}
|
||||||
@@ -77,6 +84,12 @@ namespace Content.Server.PDA
|
|||||||
UpdatePDAUserInterface(pda);
|
UpdatePDAUserInterface(pda);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGridChanged(EntityUid uid, PDAComponent pda, GridModifiedEvent args)
|
||||||
|
{
|
||||||
|
UpdateStationName(pda);
|
||||||
|
UpdatePDAUserInterface(pda);
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdatePDAUserInterface(PDAComponent pda)
|
private void UpdatePDAUserInterface(PDAComponent pda)
|
||||||
{
|
{
|
||||||
var ownerInfo = new PDAIdInfoText
|
var ownerInfo = new PDAIdInfoText
|
||||||
@@ -90,7 +103,7 @@ namespace Content.Server.PDA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var hasInstrument = HasComp<InstrumentComponent>(pda.Owner);
|
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);
|
ui.SetState(state);
|
||||||
|
|
||||||
@@ -101,7 +114,7 @@ namespace Content.Server.PDA
|
|||||||
if (!HasComp<UplinkComponent>(pda.Owner))
|
if (!HasComp<UplinkComponent>(pda.Owner))
|
||||||
return;
|
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)
|
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)
|
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.
|
// 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
|
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);
|
ui.SetState(state, args.Session);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,5 +27,6 @@ namespace Content.Shared.PDA
|
|||||||
[ViewVariables] public bool FlashlightOn;
|
[ViewVariables] public bool FlashlightOn;
|
||||||
|
|
||||||
[ViewVariables] public string? OwnerName;
|
[ViewVariables] public string? OwnerName;
|
||||||
|
[ViewVariables] public string? StationName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,18 @@ namespace Content.Shared.PDA
|
|||||||
public bool FlashlightEnabled;
|
public bool FlashlightEnabled;
|
||||||
public bool HasPen;
|
public bool HasPen;
|
||||||
public PDAIdInfoText PDAOwnerInfo;
|
public PDAIdInfoText PDAOwnerInfo;
|
||||||
|
public string? StationName;
|
||||||
public bool HasUplink;
|
public bool HasUplink;
|
||||||
public bool CanPlayMusic;
|
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;
|
FlashlightEnabled = flashlightEnabled;
|
||||||
HasPen = hasPen;
|
HasPen = hasPen;
|
||||||
PDAOwnerInfo = pDAOwnerInfo;
|
PDAOwnerInfo = pDAOwnerInfo;
|
||||||
HasUplink = hasUplink;
|
HasUplink = hasUplink;
|
||||||
CanPlayMusic = canPlayMusic;
|
CanPlayMusic = canPlayMusic;
|
||||||
|
StationName = stationName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ pda-bound-user-interface-uplink-tab-title = Uplink
|
|||||||
|
|
||||||
comp-pda-ui-menu-title = PDA
|
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-id-button = Eject ID
|
||||||
|
|
||||||
comp-pda-ui-eject-pen-button = Eject Pen
|
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
|
comp-pda-ui-toggle-flashlight-button = Toggle Flashlight
|
||||||
|
|
||||||
pda-bound-user-interface-music-button = Music Instrument
|
pda-bound-user-interface-music-button = Music Instrument
|
||||||
|
|
||||||
|
comp-pda-ui-unknown = Unknown
|
||||||
|
|
||||||
|
comp-pda-ui-unassigned = Unassigned
|
||||||
|
|||||||
Reference in New Issue
Block a user