Store mapped image coordinates in chrome.xml; port most of specialbin.png to this format
This commit is contained in:
31
OpenRa.Game/Graphics/MappedImage.cs
Normal file
31
OpenRa.Game/Graphics/MappedImage.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user