Show total playtime in player list and AHelp window (#20980)
This commit is contained in:
@@ -19,6 +19,11 @@ namespace Content.Client.Administration.UI.Bwoink
|
||||
if (sel is not null)
|
||||
{
|
||||
Title = $"{sel.CharacterName} / {sel.Username}";
|
||||
|
||||
if (sel.OverallPlaytime != null)
|
||||
{
|
||||
Title += $" | {Loc.GetString("generic-playtime-title")}: {sel.PlaytimeString()}";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -120,9 +120,11 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab
|
||||
player.StartingJob,
|
||||
player.Antag ? "YES" : "NO",
|
||||
new StyleBoxFlat(useAltColor ? _altColor : _defaultColor),
|
||||
player.Connected);
|
||||
player.Connected,
|
||||
player.PlaytimeString());
|
||||
entry.PlayerEntity = player.NetEntity;
|
||||
entry.OnPressed += args => OnEntryPressed?.Invoke(args);
|
||||
entry.ToolTip = Loc.GetString("player-tab-entry-tooltip");
|
||||
PlayerList.AddChild(entry);
|
||||
|
||||
useAltColor ^= true;
|
||||
|
||||
@@ -24,5 +24,9 @@
|
||||
SizeFlagsStretchRatio="2"
|
||||
HorizontalExpand="True"
|
||||
ClipText="True"/>
|
||||
<Label Name="OverallPlaytimeLabel"
|
||||
SizeFlagsStretchRatio="2"
|
||||
HorizontalExpand="True"
|
||||
ClipText="True"/>
|
||||
</BoxContainer>
|
||||
</ContainerButton>
|
||||
|
||||
@@ -10,7 +10,7 @@ public sealed partial class PlayerTabEntry : ContainerButton
|
||||
{
|
||||
public NetEntity? PlayerEntity;
|
||||
|
||||
public PlayerTabEntry(string username, string character, string identity, string job, string antagonist, StyleBox styleBox, bool connected)
|
||||
public PlayerTabEntry(string username, string character, string identity, string job, string antagonist, StyleBox styleBox, bool connected, string overallPlaytime)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
@@ -23,5 +23,6 @@ public sealed partial class PlayerTabEntry : ContainerButton
|
||||
CharacterLabel.Text += $" [{identity}]";
|
||||
AntagonistLabel.Text = antagonist;
|
||||
BackgroundColorPanel.PanelOverride = styleBox;
|
||||
OverallPlaytimeLabel.Text = overallPlaytime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,5 +32,11 @@
|
||||
ClipText="True"
|
||||
Text="{Loc player-tab-antagonist}"
|
||||
MouseFilter="Pass"/>
|
||||
<Label Name="PlaytimeLabel"
|
||||
SizeFlagsStretchRatio="2"
|
||||
HorizontalExpand="True"
|
||||
ClipText="True"
|
||||
Text="{Loc player-tab-playtime}"
|
||||
MouseFilter="Pass"/>
|
||||
</BoxContainer>
|
||||
</ContainerButton>
|
||||
|
||||
@@ -3,11 +3,13 @@ using Content.Server.Administration.Managers;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.IdentityManagement;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Players.PlayTimeTracking;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Events;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Players.PlayTimeTracking;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Roles.Jobs;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -25,6 +27,7 @@ namespace Content.Server.Administration.Systems
|
||||
[Dependency] private readonly IChatManager _chat = default!;
|
||||
[Dependency] private readonly IConfigurationManager _config = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly PlayTimeTrackingManager _playTime = default!;
|
||||
[Dependency] private readonly SharedJobSystem _jobs = default!;
|
||||
[Dependency] private readonly MindSystem _minds = default!;
|
||||
[Dependency] private readonly SharedRoleSystem _role = default!;
|
||||
@@ -210,9 +213,16 @@ namespace Content.Server.Administration.Systems
|
||||
}
|
||||
|
||||
var connected = session != null && session.Status is SessionStatus.Connected or SessionStatus.InGame;
|
||||
TimeSpan? overallPlaytime = null;
|
||||
if (session != null &&
|
||||
_playTime.TryGetTrackerTimes(session, out var playTimes) &&
|
||||
playTimes.TryGetValue(PlayTimeTrackingShared.TrackerOverall, out var playTime))
|
||||
{
|
||||
overallPlaytime = playTime;
|
||||
}
|
||||
|
||||
return new PlayerInfo(name, entityName, identityName, startingRole, antag, GetNetEntity(session?.AttachedEntity), data.UserId,
|
||||
connected, _roundActivePlayers.Contains(data.UserId));
|
||||
connected, _roundActivePlayers.Contains(data.UserId), overallPlaytime);
|
||||
}
|
||||
|
||||
private void OnPanicBunkerChanged(bool enabled)
|
||||
|
||||
@@ -13,5 +13,12 @@ namespace Content.Shared.Administration
|
||||
NetEntity? NetEntity,
|
||||
NetUserId SessionId,
|
||||
bool Connected,
|
||||
bool ActiveThisRound);
|
||||
bool ActiveThisRound,
|
||||
TimeSpan? OverallPlaytime)
|
||||
{
|
||||
public string PlaytimeString()
|
||||
{
|
||||
return OverallPlaytime?.ToString("%d':'hh':'mm") ?? Loc.GetString("generic-unknown-title");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,3 +14,8 @@ Entries:
|
||||
if admins are online or not.', type: Add}
|
||||
id: 2
|
||||
time: '2023-10-12T22:46:00.0000000+00:00'
|
||||
- author: DrSmugleaf
|
||||
changes:
|
||||
- {message: 'Added total playtime to the F7 player list and the AHelp window title.', type: Add}
|
||||
id: 3
|
||||
time: '2023-10-14T08:55:00.0000000+00:00'
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
player-tab-character = Character
|
||||
player-tab-job = Job
|
||||
player-tab-antagonist = Antagonist
|
||||
player-tab-playtime = Playtime
|
||||
player-tab-show-disconnected = Show Disconnected
|
||||
player-tab-overlay = Overlay
|
||||
player-tab-entry-tooltip = Playtime is displayed in days:hours:minutes.
|
||||
|
||||
@@ -10,3 +10,5 @@ generic-error = error
|
||||
generic-invalid = invalid
|
||||
|
||||
generic-hours = hours
|
||||
|
||||
generic-playtime-title = Playtime
|
||||
|
||||
Reference in New Issue
Block a user