Beginnings of cursor support.
This commit is contained in:
39
OpenRa.Game/Graphics/CursorSequence.cs
Normal file
39
OpenRa.Game/Graphics/CursorSequence.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace OpenRa.Game.Graphics
|
||||
{
|
||||
class CursorSequence
|
||||
{
|
||||
readonly int start, length;
|
||||
|
||||
public int Start { get { return start; } }
|
||||
public int End { get { return start + length; } }
|
||||
public int Length { get { return length; } }
|
||||
|
||||
Sprite[] sprites;
|
||||
public CursorSequence(string cursorSrc, XmlElement e)
|
||||
{
|
||||
sprites = CursorSheetBuilder.LoadAllSprites(cursorSrc, ".shp");
|
||||
|
||||
start = int.Parse(e.GetAttribute("start"));
|
||||
|
||||
if (e.GetAttribute("length") == "*" || e.GetAttribute("end") == "*")
|
||||
length = sprites.Length - start;
|
||||
else if (e.HasAttribute("length"))
|
||||
length = int.Parse(e.GetAttribute("length"));
|
||||
else if (e.HasAttribute("end"))
|
||||
length = int.Parse(e.GetAttribute("end")) - start;
|
||||
else
|
||||
length = 1;
|
||||
}
|
||||
|
||||
public Sprite GetSprite(int frame)
|
||||
{
|
||||
return sprites[(frame % length) + start];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user