Jobreq format (#32806)
* Format job requirements as hours and minutes * Use TimeSpan.ToString for playtime instead of custom method * wehflicts --------- Co-authored-by: jmcb <joelsgp@protonmail.com>
This commit is contained in:
@@ -104,7 +104,7 @@ public sealed partial class PlaytimeStatsWindow : FancyWindow
|
||||
{
|
||||
var overallPlaytime = _jobRequirementsManager.FetchOverallPlaytime();
|
||||
|
||||
var formattedPlaytime = ConvertTimeSpanToHoursMinutes(overallPlaytime);
|
||||
var formattedPlaytime = overallPlaytime.ToString(Loc.GetString("ui-playtime-time-format"));
|
||||
OverallPlaytimeLabel.Text = Loc.GetString("ui-playtime-overall", ("time", formattedPlaytime));
|
||||
|
||||
var rolePlaytimes = _jobRequirementsManager.FetchPlaytimeByRoles();
|
||||
@@ -134,13 +134,4 @@ public sealed partial class PlaytimeStatsWindow : FancyWindow
|
||||
_sawmill.Error($"The provided playtime string '{playtimeString}' is not in the correct format.");
|
||||
}
|
||||
}
|
||||
|
||||
private static string ConvertTimeSpanToHoursMinutes(TimeSpan timeSpan)
|
||||
{
|
||||
var hours = (int) timeSpan.TotalHours;
|
||||
var minutes = timeSpan.Minutes;
|
||||
|
||||
var formattedTimeLoc = Loc.GetString("ui-playtime-time-format", ("hours", hours), ("minutes", minutes));
|
||||
return formattedTimeLoc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public sealed partial class AgeRequirement : JobRequirement
|
||||
|
||||
if (!Inverted)
|
||||
{
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString("role-timer-age-to-young",
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString("role-timer-age-too-young",
|
||||
("age", RequiredAge)));
|
||||
|
||||
if (profile.Age < RequiredAge)
|
||||
@@ -38,7 +38,7 @@ public sealed partial class AgeRequirement : JobRequirement
|
||||
}
|
||||
else
|
||||
{
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString("role-timer-age-to-old",
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString("role-timer-age-too-old",
|
||||
("age", RequiredAge)));
|
||||
|
||||
if (profile.Age > RequiredAge)
|
||||
|
||||
@@ -15,7 +15,7 @@ public sealed partial class DepartmentTimeRequirement : JobRequirement
|
||||
/// Which department needs the required amount of time.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public ProtoId<DepartmentPrototype> Department = default!;
|
||||
public ProtoId<DepartmentPrototype> Department;
|
||||
|
||||
/// <summary>
|
||||
/// How long (in seconds) this requirement is.
|
||||
@@ -47,7 +47,9 @@ public sealed partial class DepartmentTimeRequirement : JobRequirement
|
||||
playtime += otherTime;
|
||||
}
|
||||
|
||||
var deptDiff = Time.TotalMinutes - playtime.TotalMinutes;
|
||||
var deptDiffSpan = Time - playtime;
|
||||
var deptDiff = deptDiffSpan.TotalMinutes;
|
||||
var formattedDeptDiff = deptDiffSpan.ToString(Loc.GetString("role-timer-time-format"));
|
||||
var nameDepartment = "role-timer-department-unknown";
|
||||
|
||||
if (protoManager.TryIndex(Department, out var departmentIndexed))
|
||||
@@ -62,7 +64,7 @@ public sealed partial class DepartmentTimeRequirement : JobRequirement
|
||||
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString(
|
||||
"role-timer-department-insufficient",
|
||||
("time", Math.Ceiling(deptDiff)),
|
||||
("time", formattedDeptDiff),
|
||||
("department", Loc.GetString(nameDepartment)),
|
||||
("departmentColor", department.Color.ToHex())));
|
||||
return false;
|
||||
@@ -72,7 +74,7 @@ public sealed partial class DepartmentTimeRequirement : JobRequirement
|
||||
{
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString(
|
||||
"role-timer-department-too-high",
|
||||
("time", -deptDiff),
|
||||
("time", formattedDeptDiff),
|
||||
("department", Loc.GetString(nameDepartment)),
|
||||
("departmentColor", department.Color.ToHex())));
|
||||
return false;
|
||||
|
||||
@@ -25,7 +25,9 @@ public sealed partial class OverallPlaytimeRequirement : JobRequirement
|
||||
reason = new FormattedMessage();
|
||||
|
||||
var overallTime = playTimes.GetValueOrDefault(PlayTimeTrackingShared.TrackerOverall);
|
||||
var overallDiff = Time.TotalMinutes - overallTime.TotalMinutes;
|
||||
var overallDiffSpan = Time - overallTime;
|
||||
var overallDiff = overallDiffSpan.TotalMinutes;
|
||||
var formattedOverallDiff = overallDiffSpan.ToString(Loc.GetString("role-timer-time-format"));
|
||||
|
||||
if (!Inverted)
|
||||
{
|
||||
@@ -34,14 +36,14 @@ public sealed partial class OverallPlaytimeRequirement : JobRequirement
|
||||
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString(
|
||||
"role-timer-overall-insufficient",
|
||||
("time", Math.Ceiling(overallDiff))));
|
||||
("time", formattedOverallDiff)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (overallDiff <= 0 || overallTime >= Time)
|
||||
{
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString("role-timer-overall-too-high",
|
||||
("time", -overallDiff)));
|
||||
("time", formattedOverallDiff)));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public sealed partial class RoleTimeRequirement : JobRequirement
|
||||
/// What particular role they need the time requirement with.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public ProtoId<PlayTimeTrackerPrototype> Role = default!;
|
||||
public ProtoId<PlayTimeTrackerPrototype> Role;
|
||||
|
||||
/// <inheritdoc cref="DepartmentTimeRequirement.Time"/>
|
||||
[DataField(required: true)]
|
||||
@@ -34,7 +34,9 @@ public sealed partial class RoleTimeRequirement : JobRequirement
|
||||
string proto = Role;
|
||||
|
||||
playTimes.TryGetValue(proto, out var roleTime);
|
||||
var roleDiff = Time.TotalMinutes - roleTime.TotalMinutes;
|
||||
var roleDiffSpan = Time - roleTime;
|
||||
var roleDiff = roleDiffSpan.TotalMinutes;
|
||||
var formattedRoleDiff = roleDiffSpan.ToString(Loc.GetString("role-timer-time-format"));
|
||||
var departmentColor = Color.Yellow;
|
||||
|
||||
if (entManager.EntitySysManager.TryGetEntitySystem(out SharedJobSystem? jobSystem))
|
||||
@@ -52,7 +54,7 @@ public sealed partial class RoleTimeRequirement : JobRequirement
|
||||
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString(
|
||||
"role-timer-role-insufficient",
|
||||
("time", Math.Ceiling(roleDiff)),
|
||||
("time", formattedRoleDiff),
|
||||
("job", Loc.GetString(proto)),
|
||||
("departmentColor", departmentColor.ToHex())));
|
||||
return false;
|
||||
@@ -62,7 +64,7 @@ public sealed partial class RoleTimeRequirement : JobRequirement
|
||||
{
|
||||
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString(
|
||||
"role-timer-role-too-high",
|
||||
("time", -roleDiff),
|
||||
("time", formattedRoleDiff),
|
||||
("job", Loc.GetString(proto)),
|
||||
("departmentColor", departmentColor.ToHex())));
|
||||
return false;
|
||||
|
||||
@@ -5,6 +5,6 @@ ui-playtime-overall-base = Overall Playtime:
|
||||
ui-playtime-overall = Overall Playtime: {$time}
|
||||
ui-playtime-first-time = First Time Playing
|
||||
ui-playtime-roles = Playtime per Role
|
||||
ui-playtime-time-format = {$hours}H {$minutes}M
|
||||
ui-playtime-time-format = %h\H\ %m\M
|
||||
ui-playtime-header-role-type = Role
|
||||
ui-playtime-header-role-time = Time
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
role-timer-department-insufficient = You require [color=yellow]{TOSTRING($time, "0")}[/color] more minutes of [color={$departmentColor}]{$department}[/color] department playtime to play this role.
|
||||
role-timer-department-too-high = You require [color=yellow]{TOSTRING($time, "0")}[/color] fewer minutes in [color={$departmentColor}]{$department}[/color] department to play this role. (Are you trying to play a trainee role?)
|
||||
role-timer-overall-insufficient = You require [color=yellow]{TOSTRING($time, "0")}[/color] more minutes of playtime to play this role.
|
||||
role-timer-overall-too-high = You require [color=yellow]{TOSTRING($time, "0")}[/color] fewer minutes of playtime to play this role. (Are you trying to play a trainee role?)
|
||||
role-timer-role-insufficient = You require [color=yellow]{TOSTRING($time, "0")}[/color] more minutes with [color={$departmentColor}]{$job}[/color] to play this role.
|
||||
role-timer-role-too-high = You require[color=yellow] {TOSTRING($time, "0")}[/color] fewer minutes with [color={$departmentColor}]{$job}[/color] to play this role. (Are you trying to play a trainee role?)
|
||||
role-timer-age-to-old = Your character's age must be at most [color=yellow]{$age}[/color] to play this role.
|
||||
role-timer-age-to-young = Your character's age must be at least [color=yellow]{$age}[/color] to play this role.
|
||||
role-timer-department-insufficient = You require [color=yellow]{$time}[/color] more playtime in the [color={$departmentColor}]{$department}[/color] department to play this role.
|
||||
role-timer-department-too-high = You require [color=yellow]{$time}[/color] less playtime in the [color={$departmentColor}]{$department}[/color] department to play this role. (Are you trying to play a trainee role?)
|
||||
role-timer-overall-insufficient = You require [color=yellow]{$time}[/color] more overall playtime to play this role.
|
||||
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:
|
||||
role-timer-blacklisted-species = Your character must not be one of the following species to play this role:
|
||||
role-timer-whitelisted-traits = Your character must have one of the following traits:
|
||||
|
||||
Reference in New Issue
Block a user