read the production icons from sequences
this allows d2k to read them from DATA.R8 without trouble
This commit is contained in:
@@ -18,8 +18,9 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
public readonly string Description = "";
|
||||
public readonly string Name = "";
|
||||
[Desc("Defaults to actor name + icon suffix.")]
|
||||
public readonly string Icon = null;
|
||||
|
||||
[Desc("Sequence of the actor that contains the cameo.")]
|
||||
public readonly string Icon = "icon";
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new Tooltip(init.self, this); }
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
List<ProductionQueue> VisibleQueues;
|
||||
|
||||
bool paletteOpen = false;
|
||||
Dictionary<string, Sprite> iconSprites;
|
||||
|
||||
float2 paletteOpenOrigin = new float2(Game.viewport.Width - 215, 280);
|
||||
float2 paletteClosedOrigin = new float2(Game.viewport.Width - 16, 280);
|
||||
@@ -67,13 +66,6 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
paletteOrigin = paletteClosedOrigin;
|
||||
VisibleQueues = new List<ProductionQueue>();
|
||||
CurrentQueue = null;
|
||||
|
||||
iconSprites = Rules.Info.Values
|
||||
.Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
|
||||
.ToDictionary(
|
||||
u => u.Name,
|
||||
u => Game.modData.SpriteLoader.LoadAllSprites(
|
||||
u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);
|
||||
}
|
||||
|
||||
public override Rectangle EventBounds
|
||||
@@ -230,7 +222,9 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
{
|
||||
var rect = new RectangleF(origin.X + x * IconWidth, origin.Y + IconHeight * y, IconWidth, IconHeight);
|
||||
var drawPos = new float2(rect.Location);
|
||||
WidgetUtils.DrawSHP(iconSprites[item.Name], drawPos, worldRenderer);
|
||||
var icon = new Animation(RenderSimple.GetImage(item));
|
||||
icon.Play(item.Traits.Get<TooltipInfo>().Icon);
|
||||
WidgetUtils.DrawSHP(icon.Image, drawPos, worldRenderer);
|
||||
|
||||
var firstOfThis = queue.AllQueued().FirstOrDefault(a => a.Item == item.Name);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.RA.Widgets
|
||||
@@ -20,7 +21,6 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
public class ObserverProductionIconsWidget : Widget
|
||||
{
|
||||
public Func<Player> GetPlayer;
|
||||
Dictionary<string, Sprite> iconSprites;
|
||||
World world;
|
||||
WorldRenderer worldRenderer;
|
||||
Dictionary<ProductionQueue, Animation> clocks;
|
||||
@@ -29,10 +29,6 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
public ObserverProductionIconsWidget(World world, WorldRenderer worldRenderer)
|
||||
: base()
|
||||
{
|
||||
iconSprites = Rules.Info.Values.Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
|
||||
.ToDictionary(
|
||||
u => u.Name,
|
||||
u => Game.modData.SpriteLoader.LoadAllSprites(u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);
|
||||
this.world = world;
|
||||
this.worldRenderer = worldRenderer;
|
||||
clocks = new Dictionary<ProductionQueue, Animation>();
|
||||
@@ -42,7 +38,6 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
: base(other)
|
||||
{
|
||||
GetPlayer = other.GetPlayer;
|
||||
iconSprites = other.iconSprites;
|
||||
world = other.world;
|
||||
worldRenderer = other.worldRenderer;
|
||||
clocks = other.clocks;
|
||||
@@ -67,25 +62,27 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
}
|
||||
foreach (var queue in queues)
|
||||
{
|
||||
var item = queue.Trait.CurrentItem();
|
||||
var item = queue.Trait.AllItems().FirstOrDefault();
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var sprite = iconSprites[item.Item];
|
||||
var size = sprite.size / new float2(2, 2);
|
||||
var icon = new Animation(RenderSimple.GetImage(item));
|
||||
icon.Play(item.Traits.Get<TooltipInfo>().Icon);
|
||||
var size = icon.Image.size / new float2(2, 2);
|
||||
var location = new float2(RenderBounds.Location) + new float2(queue.i * (int)size.Length, 0);
|
||||
WidgetUtils.DrawSHP(sprite, location, worldRenderer, size);
|
||||
WidgetUtils.DrawSHP(icon.Image, location, worldRenderer, size);
|
||||
|
||||
var current = queue.Trait.CurrentItem();
|
||||
if (current == null)
|
||||
continue;
|
||||
var clock = clocks[queue.Trait];
|
||||
clock.PlayFetchIndex("idle",
|
||||
() => item.TotalTime == 0 ? 0 : ((item.TotalTime - item.RemainingTime)
|
||||
* (clock.CurrentSequence.Length - 1) / item.TotalTime));
|
||||
() => current.TotalTime == 0 ? 0 : ((current.TotalTime - current.RemainingTime)
|
||||
* (clock.CurrentSequence.Length - 1) / current.TotalTime));
|
||||
clock.Tick();
|
||||
WidgetUtils.DrawSHP(clock.Image, location, worldRenderer, size);
|
||||
|
||||
var tiny = Game.Renderer.Fonts["Tiny"];
|
||||
var text = GetOverlayForItem(item);
|
||||
var text = GetOverlayForItem(current);
|
||||
tiny.DrawTextWithContrast(text,
|
||||
location + new float2(16, 16) - new float2(tiny.Measure(text).X / 2, 0),
|
||||
Color.White, Color.Black, 1);
|
||||
|
||||
Reference in New Issue
Block a user