Remove OnMouseDown from Widget. Define it on just the widgets that want it.

This commit is contained in:
Paul Chote
2011-07-04 02:09:31 +12:00
parent 7a69daa99c
commit bbeaf2047b
6 changed files with 46 additions and 18 deletions

View File

@@ -20,6 +20,8 @@ namespace OpenRA.Widgets
{
public Func<Map> Map = () => null;
public Func<Dictionary<int2, Color>> SpawnColors = () => new Dictionary<int2, Color>();
public Action<MouseInput> OnMouseDown = _ => {};
Cache<Map,Bitmap> PreviewCache = new Cache<Map, Bitmap>(stub => Minimap.RenderMapPreview( new Map( stub.Path )));
public MapPreviewWidget() : base() { }
@@ -32,6 +34,15 @@ namespace OpenRA.Widgets
}
public override Widget Clone() { return new MapPreviewWidget(this); }
public override bool HandleMouseInput(MouseInput mi)
{
if (mi.Event != MouseInputEvent.Down)
return false;
OnMouseDown(mi);
return true;
}
public int2 ConvertToPreview(Map map, int2 point)
{
return new int2(MapRect.X + (int)(PreviewScale*(point.X - map.Bounds.Left)) , MapRect.Y + (int)(PreviewScale*(point.Y - map.Bounds.Top)));