Rename *Time to *Ticks and increase internal resolution.

This commit is contained in:
Paul Chote
2018-10-07 15:03:19 +00:00
committed by reaperrr
parent e03abdc0da
commit 70b020205d
6 changed files with 26 additions and 23 deletions

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// HACK: This abuses knowledge of the internals of WidgetUtils.FormatTime
// to efficiently work when the label is going to change, requiring a panel relayout
var remainingSeconds = (int)Math.Ceiling(sp.RemainingTime * world.Timestep / 1000f);
var remainingSeconds = (int)Math.Ceiling(sp.RemainingTicks * world.Timestep / 1000f);
var hotkey = icon.Hotkey != null ? icon.Hotkey.GetValue() : Hotkey.Invalid;
if (sp == lastPower && hotkey == lastHotkey && lastRemainingSeconds == remainingSeconds)
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
descLabel.Text = sp.Info.LongDesc.Replace("\\n", "\n");
var descSize = descFont.Measure(descLabel.Text);
var remaining = WidgetUtils.FormatTime(sp.RemainingTime, world.Timestep);
var remaining = WidgetUtils.FormatTime(sp.RemainingTicks, world.Timestep);
var total = WidgetUtils.FormatTime(sp.Info.ChargeInterval, world.Timestep);
timeLabel.Text = "{0} / {1}".F(remaining, total);
var timeSize = timeFont.Measure(timeLabel.Text);

View File

@@ -132,8 +132,8 @@ namespace OpenRA.Mods.Common.Widgets
var clock = clocks[power.a.Key];
clock.PlayFetchIndex(ClockSequence,
() => item.TotalTime == 0 ? 0 : ((item.TotalTime - item.RemainingTime)
* (clock.CurrentSequence.Length - 1) / item.TotalTime));
() => item.TotalTicks == 0 ? 0 : ((item.TotalTicks - item.RemainingTicks)
* (clock.CurrentSequence.Length - 1) / item.TotalTicks));
clock.Tick();
WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer.Palette(ClockPalette), 0.5f);
@@ -149,7 +149,7 @@ namespace OpenRA.Mods.Common.Widgets
{
if (item.Disabled) return "ON HOLD";
if (item.Ready) return "READY";
return WidgetUtils.FormatTime(item.RemainingTime, timestep);
return WidgetUtils.FormatTime(item.RemainingTicks, timestep);
}
public override Widget Clone()

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets
texts = displayedPowers.Select(p =>
{
var time = WidgetUtils.FormatTime(p.RemainingTime, false, timestep);
var time = WidgetUtils.FormatTime(p.RemainingTicks, false, timestep);
var text = Format.F(p.Info.Description, time);
var self = p.Instances[0].Self;
var playerColor = self.Owner.Color;

View File

@@ -205,8 +205,8 @@ namespace OpenRA.Mods.Common.Widgets
// Charge progress
var sp = p.Power;
clock.PlayFetchIndex(ClockSequence,
() => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime)
* (clock.CurrentSequence.Length - 1) / sp.TotalTime);
() => sp.TotalTicks == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTicks - sp.RemainingTicks)
* (clock.CurrentSequence.Length - 1) / sp.TotalTicks);
clock.Tick();
WidgetUtils.DrawSHPCentered(clock.Image, p.Pos + iconOffset, p.IconClockPalette);
@@ -224,7 +224,7 @@ namespace OpenRA.Mods.Common.Widgets
p.Pos + holdOffset,
Color.White, Color.Black, 1);
else
overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(p.Power.RemainingTime, worldRenderer.World.Timestep),
overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(p.Power.RemainingTicks, worldRenderer.World.Timestep),
p.Pos + timeOffset,
Color.White, Color.Black, 1);
}