+using Content.Shared.Localizations;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
RoleLabel.Text = role;
Playtime = playtime; // store the TimeSpan value directly
- PlaytimeLabel.Text = playtime.ToString(Loc.GetString("ui-playtime-time-format")); // convert to string for display
+ PlaytimeLabel.Text = ContentLocalizationManager.FormatPlaytime(playtime); // convert to string for display
BackgroundColorPanel.PanelOverride = styleBox;
}
{
var overallPlaytime = _jobRequirementsManager.FetchOverallPlaytime();
- var formattedPlaytime = overallPlaytime.ToString(Loc.GetString("ui-playtime-time-format"));
- OverallPlaytimeLabel.Text = Loc.GetString("ui-playtime-overall", ("time", formattedPlaytime));
+ OverallPlaytimeLabel.Text = Loc.GetString("ui-playtime-overall", ("time", overallPlaytime));
var rolePlaytimes = _jobRequirementsManager.FetchPlaytimeByRoles();
_loc.AddFunction(culture, "LOC", FormatLoc);
_loc.AddFunction(culture, "NATURALFIXED", FormatNaturalFixed);
_loc.AddFunction(culture, "NATURALPERCENT", FormatNaturalPercent);
+ _loc.AddFunction(culture, "PLAYTIME", FormatPlaytime);
/*
return Loc.GetString($"zzzz-fmt-direction-{dir.ToString()}");
}
+ /// <summary>
+ /// Formats playtime as hours and minutes.
+ /// </summary>
+ public static string FormatPlaytime(TimeSpan time)
+ {
+ var hours = (int)time.TotalHours;
+ var minutes = time.Minutes;
+ return Loc.GetString($"zzzz-fmt-playtime", ("hours", hours), ("minutes", minutes));
+ }
+
private static ILocValue FormatLoc(LocArgs args)
{
var id = ((LocValueString) args.Args[0]).Value;
return new LocValueString(res);
}
+
+ private static ILocValue FormatPlaytime(LocArgs args)
+ {
+ var time = TimeSpan.Zero;
+ if (args.Args is { Count: > 0 } && args.Args[0].Value is TimeSpan timeArg)
+ {
+ time = timeArg;
+ }
+ return new LocValueString(FormatPlaytime(time));
+ }
}
}
using System.Diagnostics.CodeAnalysis;
+using Content.Shared.Localizations;
using Content.Shared.Preferences;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
var deptDiffSpan = Time - playtime;
var deptDiff = deptDiffSpan.TotalMinutes;
- var formattedDeptDiff = deptDiffSpan.ToString(Loc.GetString("role-timer-time-format"));
+ var formattedDeptDiff = ContentLocalizationManager.FormatPlaytime(deptDiffSpan);
var nameDepartment = "role-timer-department-unknown";
if (protoManager.TryIndex(Department, out var departmentIndexed))
using System.Diagnostics.CodeAnalysis;
+using Content.Shared.Localizations;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.Preferences;
using JetBrains.Annotations;
var overallTime = playTimes.GetValueOrDefault(PlayTimeTrackingShared.TrackerOverall);
var overallDiffSpan = Time - overallTime;
var overallDiff = overallDiffSpan.TotalMinutes;
- var formattedOverallDiff = overallDiffSpan.ToString(Loc.GetString("role-timer-time-format"));
+ var formattedOverallDiff = ContentLocalizationManager.FormatPlaytime(overallDiffSpan);
if (!Inverted)
{
using System.Diagnostics.CodeAnalysis;
+using Content.Shared.Localizations;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.Preferences;
using Content.Shared.Roles.Jobs;
playTimes.TryGetValue(proto, out var roleTime);
var roleDiffSpan = Time - roleTime;
var roleDiff = roleDiffSpan.TotalMinutes;
- var formattedRoleDiff = roleDiffSpan.ToString(Loc.GetString("role-timer-time-format"));
+ var formattedRoleDiff = ContentLocalizationManager.FormatPlaytime(roleDiffSpan);
var departmentColor = Color.Yellow;
if (entManager.EntitySysManager.TryGetEntitySystem(out SharedJobSystem? jobSystem))
[4] TJ
*[5] ???
}
+
+# Used internally by the PLAYTIME() function.
+zzzz-fmt-playtime = {$hours}H {$minutes}M
\ No newline at end of file
ui-playtime-stats-title = User Playtime Stats
ui-playtime-overall-base = Overall Playtime:
-ui-playtime-overall = Overall Playtime: {$time}
+ui-playtime-overall = Overall Playtime: {PLAYTIME($time)}
ui-playtime-first-time = First Time Playing
ui-playtime-roles = Playtime per Role
-ui-playtime-time-format = %h\H\ %m\M
ui-playtime-header-role-type = Role
ui-playtime-header-role-time = Time
role-timer-overall-too-high = You require [color=yellow]{$time}[/color] less overall playtime to play this role. (Are you trying to play a trainee role?)
role-timer-role-insufficient = You require [color=yellow]{$time}[/color] more playtime with [color={$departmentColor}]{$job}[/color] to play this role.
role-timer-role-too-high = You require[color=yellow] {$time}[/color] less playtime with [color={$departmentColor}]{$job}[/color] to play this role. (Are you trying to play a trainee role?)
-role-timer-time-format = %h\H\ %m\M
role-timer-age-too-old = Your character must be under the age of [color=yellow]{$age}[/color] to play this role.
role-timer-age-too-young = Your character must be over the age of [color=yellow]{$age}[/color] to play this role.
role-timer-whitelisted-species = Your character must be one of the following species to play this role: