what a hack, but the cursors work and the terrain doesnt break anymore
This commit is contained in:
@@ -14,7 +14,10 @@ namespace OpenRa.Game.Graphics
|
||||
public int End { get { return start + length; } }
|
||||
public int Length { get { return length; } }
|
||||
|
||||
public readonly int2 Hotspot;
|
||||
|
||||
Sprite[] sprites;
|
||||
|
||||
public CursorSequence(string cursorSrc, XmlElement e)
|
||||
{
|
||||
sprites = CursorSheetBuilder.LoadAllSprites(cursorSrc, ".shp");
|
||||
@@ -29,6 +32,9 @@ namespace OpenRa.Game.Graphics
|
||||
length = int.Parse(e.GetAttribute("end")) - start;
|
||||
else
|
||||
length = 1;
|
||||
|
||||
int.TryParse( e.GetAttribute("x"), out Hotspot.X );
|
||||
int.TryParse( e.GetAttribute("y"), out Hotspot.Y );
|
||||
}
|
||||
|
||||
public Sprite GetSprite(int frame)
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace OpenRa.Game.Graphics
|
||||
|
||||
foreach (XmlElement eSequence in eCursor.SelectNodes("./sequence"))
|
||||
cursors.Add(eSequence.GetAttribute("name"), new CursorSequence(cursorSrc, eSequence));
|
||||
|
||||
Log.Write("* LoadSequencesForCursor() done");
|
||||
}
|
||||
|
||||
public static void ForcePrecache() { } // force static ctor to run
|
||||
|
||||
@@ -25,6 +25,12 @@ namespace OpenRa.Game.Graphics
|
||||
return Add(data, size);
|
||||
}
|
||||
|
||||
public static void ForceNewSheet()
|
||||
{
|
||||
current = NewSheet();
|
||||
channel = NextChannel(null);
|
||||
}
|
||||
|
||||
static Sheet NewSheet() { return new Sheet(renderer, new Size(512, 512)); }
|
||||
|
||||
static Renderer renderer;
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace OpenRa.Game.Graphics
|
||||
|
||||
Size tileSize = new Size( Game.CellSize, Game.CellSize );
|
||||
|
||||
SheetBuilder.ForceNewSheet();
|
||||
|
||||
var tileMapping = new Cache<TileReference, Sprite>(
|
||||
x => SheetBuilder.Add(tileSet.GetBytes(x), tileSize));
|
||||
|
||||
|
||||
@@ -17,6 +17,11 @@ namespace OpenRa.Game.Graphics
|
||||
public int Width { get { return (int)size.X; } }
|
||||
public int Height { get { return (int)size.Y; } }
|
||||
|
||||
public Cursor cursor = Cursor.Move;
|
||||
SpriteRenderer cursorRenderer;
|
||||
int2 mousePos;
|
||||
float cursorFrame = 0f;
|
||||
|
||||
public void Scroll(float2 delta)
|
||||
{
|
||||
scrollPosition = (scrollPosition + delta).Constrain(float2.Zero, mapSize);
|
||||
@@ -27,6 +32,7 @@ namespace OpenRa.Game.Graphics
|
||||
this.size = size;
|
||||
this.mapSize = Game.CellSize * mapSize - size + new float2(128, 0);
|
||||
this.renderer = renderer;
|
||||
cursorRenderer = new SpriteRenderer(renderer, true);
|
||||
}
|
||||
|
||||
List<Region> regions = new List<Region>();
|
||||
@@ -42,6 +48,9 @@ namespace OpenRa.Game.Graphics
|
||||
|
||||
foreach (Region region in regions)
|
||||
region.Draw(renderer);
|
||||
cursorFrame += 0.01f;
|
||||
cursorRenderer.DrawSprite(cursor.GetSprite((int)cursorFrame), mousePos + Location - cursor.GetHotspot(), 0);
|
||||
cursorRenderer.Flush();
|
||||
|
||||
renderer.EndFrame();
|
||||
}
|
||||
@@ -49,6 +58,9 @@ namespace OpenRa.Game.Graphics
|
||||
Region dragRegion = null;
|
||||
public void DispatchMouseInput(MouseInput mi)
|
||||
{
|
||||
if (mi.Event == MouseInputEvent.Move)
|
||||
mousePos = mi.Location;
|
||||
|
||||
if (dragRegion != null) {
|
||||
dragRegion.HandleMouseInput( mi );
|
||||
if (mi.Event == MouseInputEvent.Up) dragRegion = null;
|
||||
|
||||
Reference in New Issue
Block a user