Fix timers in ObserverProductionIconsWidget being calculated wrongly in replays
This commit is contained in:
@@ -25,6 +25,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public Func<Player> GetPlayer;
|
public Func<Player> GetPlayer;
|
||||||
readonly World world;
|
readonly World world;
|
||||||
readonly WorldRenderer worldRenderer;
|
readonly WorldRenderer worldRenderer;
|
||||||
|
readonly int timestep;
|
||||||
Dictionary<ProductionQueue, Animation> clocks;
|
Dictionary<ProductionQueue, Animation> clocks;
|
||||||
|
|
||||||
public int IconWidth = 32;
|
public int IconWidth = 32;
|
||||||
@@ -41,6 +42,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
this.world = world;
|
this.world = world;
|
||||||
this.worldRenderer = worldRenderer;
|
this.worldRenderer = worldRenderer;
|
||||||
clocks = new Dictionary<ProductionQueue, Animation>();
|
clocks = new Dictionary<ProductionQueue, Animation>();
|
||||||
|
timestep = world.IsReplay ? world.WorldActor.Trait<MapOptions>().GameSpeed.Timestep : world.Timestep;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ObserverProductionIconsWidget(ObserverProductionIconsWidget other)
|
protected ObserverProductionIconsWidget(ObserverProductionIconsWidget other)
|
||||||
@@ -49,6 +51,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
GetPlayer = other.GetPlayer;
|
GetPlayer = other.GetPlayer;
|
||||||
world = other.world;
|
world = other.world;
|
||||||
worldRenderer = other.worldRenderer;
|
worldRenderer = other.worldRenderer;
|
||||||
|
timestep = other.timestep;
|
||||||
clocks = other.clocks;
|
clocks = other.clocks;
|
||||||
|
|
||||||
IconWidth = other.IconWidth;
|
IconWidth = other.IconWidth;
|
||||||
@@ -107,7 +110,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer.Palette(ClockPalette), 0.5f);
|
WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer.Palette(ClockPalette), 0.5f);
|
||||||
|
|
||||||
var tiny = Game.Renderer.Fonts["Tiny"];
|
var tiny = Game.Renderer.Fonts["Tiny"];
|
||||||
var text = GetOverlayForItem(current, world.Timestep);
|
var text = GetOverlayForItem(current, timestep);
|
||||||
tiny.DrawTextWithContrast(text,
|
tiny.DrawTextWithContrast(text,
|
||||||
location + new float2(16, 16) - new float2(tiny.Measure(text).X / 2, 0),
|
location + new float2(16, 16) - new float2(tiny.Measure(text).X / 2, 0),
|
||||||
Color.White, Color.Black, 1);
|
Color.White, Color.Black, 1);
|
||||||
@@ -116,8 +119,12 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
static string GetOverlayForItem(ProductionItem item, int timestep)
|
static string GetOverlayForItem(ProductionItem item, int timestep)
|
||||||
{
|
{
|
||||||
if (item.Paused) return "ON HOLD";
|
if (item.Paused)
|
||||||
if (item.Done) return "READY";
|
return "ON HOLD";
|
||||||
|
|
||||||
|
if (item.Done)
|
||||||
|
return "READY";
|
||||||
|
|
||||||
return WidgetUtils.FormatTime(item.RemainingTimeActual, timestep);
|
return WidgetUtils.FormatTime(item.RemainingTimeActual, timestep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user