Store mapped image coordinates in chrome.xml; port most of specialbin.png to this format

This commit is contained in:
Paul Chote
2010-01-09 18:00:20 +13:00
parent 2612c273aa
commit f0f499ee8d
4 changed files with 121 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
using System.Xml;
using System.Drawing;
using Ijw.DirectX;
using System.IO;
namespace OpenRa.Game.Graphics
{
class MappedImage
{
readonly Rectangle rect;
public readonly string Src;
public readonly string Name;
public MappedImage(string defaultSrc, XmlElement e)
{
Src = (e.HasAttribute("src")) ? e.GetAttribute("src") : defaultSrc;
Name = e.GetAttribute("name");
if (Src == null)
throw new InvalidDataException("Image src missing");
rect = new Rectangle(int.Parse(e.GetAttribute("x")),
int.Parse(e.GetAttribute("y")),
int.Parse(e.GetAttribute("width")),
int.Parse(e.GetAttribute("height")));
}
public Sprite GetImage(Renderer r, Sheet s)
{
return new Sprite(s, rect, TextureChannel.Alpha);
}
}
}