From e275677d11e0ae144f1b81a8870d75c6cdd7e608 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 10 May 2010 18:13:52 +1200 Subject: [PATCH] add removal of mapactors via rmb; add highlight on mouseover --- OpenRA.Editor/Surface.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 6082cdd7ae..fff9dd20ce 100644 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -70,8 +70,7 @@ namespace OpenRA.Editor if (e.Button == MouseButtons.Left && Actor != null) DrawWithActor(); - if (Brush != null || Actor != null) - Invalidate(); + Invalidate(); } } @@ -114,6 +113,9 @@ namespace OpenRA.Editor { Actor = null; Brush = null; + + var key = Map.Actors.FirstOrDefault(a => a.Value.Location == GetBrushLocation()); + if (key.Key != null) Map.Actors.Remove(key.Key); } if (e.Button == MouseButtons.Left && Brush != null) @@ -172,6 +174,17 @@ namespace OpenRA.Editor : int2.Zero)).ToPoint())); } + void DrawActorBorder(System.Drawing.Graphics g, int2 p, ActorTemplate t) + { + var origin = (24 * p + Offset + - (t.Centered + ? new int2(t.Bitmap.Width / 2 - 12, t.Bitmap.Height / 2 - 12) + : int2.Zero)).ToPoint(); + g.DrawRectangle(CordonPen, + origin.X, origin.Y, + t.Bitmap.Width, t.Bitmap.Height ); + } + protected override void OnPaint(PaintEventArgs e) { if (Map == null) return; @@ -197,6 +210,13 @@ namespace OpenRA.Editor if (Actor != null) DrawActor(e.Graphics, GetBrushLocation(), Actor); + + if (Brush == null && Actor == null) + { + var x = Map.Actors.FirstOrDefault(a => a.Value.Location == GetBrushLocation()); + if (x.Key != null) + DrawActorBorder(e.Graphics, x.Value.Location, ActorTemplates[x.Value.Name]); + } } } } \ No newline at end of file