Refactored ProductionQueue to support different production styles.
This commit is contained in:
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var chromeName = button.ProductionGroup.ToLowerInvariant();
|
||||
var icon = button.Get<ImageWidget>("ICON");
|
||||
icon.GetImageName = () => button.IsDisabled() ? chromeName + "-disabled" :
|
||||
queues.Any(q => q.CurrentDone) ? chromeName + "-alert" : chromeName;
|
||||
queues.Any(q => q.AllQueued().Any(i => i.Done)) ? chromeName + "-alert" : chromeName;
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (!clocks.ContainsKey(queue.Trait))
|
||||
clocks.Add(queue.Trait, new Animation(world, ClockAnimation));
|
||||
|
||||
var current = queue.Trait.CurrentItem();
|
||||
var current = queue.Trait.AllQueued().FirstOrDefault();
|
||||
if (current == null || queue.i >= icons.Length)
|
||||
continue;
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (item.Done)
|
||||
return "READY";
|
||||
|
||||
return WidgetUtils.FormatTime(item.RemainingTimeActual, timestep);
|
||||
return WidgetUtils.FormatTime(item.Queue.RemainingTimeActual(item), timestep);
|
||||
}
|
||||
|
||||
public override Widget Clone()
|
||||
|
||||
@@ -334,7 +334,9 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
bool HandleEvent(ProductionIcon icon, MouseButton btn, Modifiers modifiers)
|
||||
{
|
||||
var startCount = modifiers.HasModifier(Modifiers.Shift) ? 5 : 1;
|
||||
var cancelCount = modifiers.HasModifier(Modifiers.Ctrl) ? CurrentQueue.QueueLength : startCount;
|
||||
|
||||
// PERF: avoid an unnecessary enumeration by casting back to its known type
|
||||
var cancelCount = modifiers.HasModifier(Modifiers.Ctrl) ? ((List<ProductionItem>)CurrentQueue.AllQueued()).Count : startCount;
|
||||
var item = icon.Queued.FirstOrDefault();
|
||||
var handled = btn == MouseButton.Left ? HandleLeftClick(item, icon, startCount)
|
||||
: btn == MouseButton.Right ? HandleRightClick(item, icon, cancelCount)
|
||||
@@ -465,7 +467,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (total > 0)
|
||||
{
|
||||
var first = icon.Queued[0];
|
||||
var waiting = first != CurrentQueue.CurrentItem() && !first.Done;
|
||||
var waiting = !CurrentQueue.IsProducing(first) && !first.Done;
|
||||
if (first.Done)
|
||||
{
|
||||
if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber * worldRenderer.World.Timestep / 360 % 2 == 0)
|
||||
@@ -478,7 +480,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
icon.Pos + holdOffset,
|
||||
Color.White, Color.Black, 1);
|
||||
else if (!waiting && DrawTime)
|
||||
overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual, World.Timestep),
|
||||
overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.Queue.RemainingTimeActual(first), World.Timestep),
|
||||
icon.Pos + timeOffset,
|
||||
Color.White, Color.Black, 1);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public List<ProductionTab> Tabs = new List<ProductionTab>();
|
||||
public string Group;
|
||||
public int NextQueueName = 1;
|
||||
public bool Alert { get { return Tabs.Any(t => t.Queue.CurrentDone); } }
|
||||
public bool Alert { get { return Tabs.Any(t => t.Queue.AllQueued().Any(i => i.Done)); } }
|
||||
|
||||
public void Update(IEnumerable<ProductionQueue> allQueues)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
// Prioritize alerted queues
|
||||
var queues = Groups[queueGroup].Tabs.Select(t => t.Queue)
|
||||
.OrderByDescending(q => q.CurrentDone ? 1 : 0)
|
||||
.OrderByDescending(q => q.AllQueued().Any(i => i.Done) ? 1 : 0)
|
||||
.ToList();
|
||||
|
||||
if (reverse) queues.Reverse();
|
||||
@@ -195,7 +195,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
var textSize = font.Measure(tab.Name);
|
||||
var position = new int2(rect.X + (rect.Width - textSize.X) / 2, rect.Y + (rect.Height - textSize.Y) / 2);
|
||||
font.DrawTextWithContrast(tab.Name, position, tab.Queue.CurrentDone ? Color.Gold : Color.White, Color.Black, 1);
|
||||
font.DrawTextWithContrast(tab.Name, position, tab.Queue.AllQueued().Any(i => i.Done) ? Color.Gold : Color.White, Color.Black, 1);
|
||||
}
|
||||
|
||||
Game.Renderer.DisableScissor();
|
||||
|
||||
Reference in New Issue
Block a user