Make the ready overlay blink. Fixes #3032.

This commit is contained in:
Paul Chote
2014-04-22 23:49:24 +12:00
parent bef3439055
commit 1a69118f02
2 changed files with 21 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Mods.RA; using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders; using OpenRA.Mods.RA.Orders;
@@ -43,6 +44,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public string TooltipActor { get; private set; } public string TooltipActor { get; private set; }
public readonly World World; public readonly World World;
readonly OrderManager orderManager;
Lazy<TooltipContainerWidget> tooltipContainer; Lazy<TooltipContainerWidget> tooltipContainer;
ProductionQueue currentQueue; ProductionQueue currentQueue;
@@ -62,8 +64,9 @@ namespace OpenRA.Mods.Cnc.Widgets
float2 holdOffset, readyOffset, timeOffset, queuedOffset; float2 holdOffset, readyOffset, timeOffset, queuedOffset;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ProductionPaletteWidget(World world, WorldRenderer worldRenderer) public ProductionPaletteWidget(OrderManager orderManager, World world, WorldRenderer worldRenderer)
{ {
this.orderManager = orderManager;
this.World = world; this.World = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;
tooltipContainer = Exts.Lazy(() => tooltipContainer = Exts.Lazy(() =>
@@ -244,9 +247,13 @@ namespace OpenRA.Mods.Cnc.Widgets
var first = icon.Queued[0]; var first = icon.Queued[0];
var waiting = first != CurrentQueue.CurrentItem() && !first.Done; var waiting = first != CurrentQueue.CurrentItem() && !first.Done;
if (first.Done) if (first.Done)
{
// Blink the ready text
if (orderManager.LocalFrameNumber / 25 % 2 == 0)
overlayFont.DrawTextWithContrast(ReadyText, overlayFont.DrawTextWithContrast(ReadyText,
icon.Pos + readyOffset, icon.Pos + readyOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
}
else if (first.Paused) else if (first.Paused)
overlayFont.DrawTextWithContrast(HoldText, overlayFont.DrawTextWithContrast(HoldText,
icon.Pos + holdOffset, icon.Pos + holdOffset,

View File

@@ -15,6 +15,7 @@ using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders; using OpenRA.Mods.RA.Orders;
using OpenRA.Network;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -53,10 +54,12 @@ namespace OpenRA.Mods.RA.Widgets
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
readonly World world; readonly World world;
readonly OrderManager orderManager;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public BuildPaletteWidget(World world, WorldRenderer worldRenderer) public BuildPaletteWidget(OrderManager orderManager, World world, WorldRenderer worldRenderer)
{ {
this.orderManager = orderManager;
this.world = world; this.world = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;
@@ -299,8 +302,12 @@ namespace OpenRA.Mods.RA.Widgets
string GetOverlayForItem(ProductionItem item) string GetOverlayForItem(ProductionItem item)
{ {
if (item.Paused) return HoldText; if (item.Paused)
if (item.Done) return ReadyText; return HoldText;
if (item.Done)
return orderManager.LocalFrameNumber / 25 % 2 == 0 ? ReadyText : "";
return WidgetUtils.FormatTime(item.RemainingTimeActual); return WidgetUtils.FormatTime(item.RemainingTimeActual);
} }