Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make game timer only blink on pause #20116

Merged
merged 1 commit into from Aug 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions OpenRA.Mods.Common/Widgets/Logic/Ingame/GameTimerLogic.cs
Expand Up @@ -29,23 +29,14 @@ public GameTimerLogic(Widget widget, OrderManager orderManager, World world)
Func<bool> shouldShowStatus = () => (world.Paused || world.ReplayTimestep != world.Timestep)
&& (Ui.LastTickTime.Value - startTick) / 1000 % 2 == 0;

Func<string> statusText = () =>
{
if (world.Paused || world.ReplayTimestep == 0)
return "Paused";

if (world.ReplayTimestep == 1)
return "Max Speed";

return $"{world.Timestep * 100 / world.ReplayTimestep}% Speed";
};
Func<bool> paused = () => world.Paused || world.ReplayTimestep == 0;

if (timer != null)
{
timer.GetText = () =>
{
if (status == null && shouldShowStatus())
return statusText();
if (status == null && paused() && shouldShowStatus())
return "Paused";

var timeLimit = tlm?.TimeLimit ?? 0;
var displayTick = timeLimit > 0 ? timeLimit - world.WorldTick : world.WorldTick;
Expand All @@ -57,7 +48,16 @@ public GameTimerLogic(Widget widget, OrderManager orderManager, World world)
{
// Blink the status line
status.IsVisible = shouldShowStatus;
status.GetText = statusText;
status.GetText = () =>
{
if (paused())
return "Paused";

if (world.ReplayTimestep == 1)
return "Max Speed";

return $"{world.Timestep * 100 / world.ReplayTimestep}% Speed";
};
}

if (timer is LabelWithTooltipWidget timerTooltip)
Expand Down