From d2da37f0260608a9452361c0fd101ba417bf2de5 Mon Sep 17 00:00:00 2001 From: alzeih Date: Sun, 13 Jun 2010 15:46:09 +1200 Subject: [PATCH] start of clicking on spawn points, compile fail still --- OpenRA.Game/Widgets/MapPreviewWidget.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/OpenRA.Game/Widgets/MapPreviewWidget.cs b/OpenRA.Game/Widgets/MapPreviewWidget.cs index ad4a84b7c3..8b9846a5b4 100755 --- a/OpenRA.Game/Widgets/MapPreviewWidget.cs +++ b/OpenRA.Game/Widgets/MapPreviewWidget.cs @@ -22,6 +22,30 @@ namespace OpenRA.Widgets { lastMap = (other as MapPreviewWidget).lastMap; } + + public override bool HandleInput(MouseInput mi) + { + var points = Game.chrome.currentMap.Waypoints + .Select((sp, i) => Pair.New(sp, Game.LobbyInfo.Clients.FirstOrDefault( + c => c.SpawnPoint == i + 1))) + .ToList(); + + var container = new Rectangle(DrawPosition().X, DrawPosition().Y, Parent.Bounds.Width, Parent.Bounds.Height ); + + foreach(var p in points) + { + var pos = Game.chrome.currentMap.ConvertToPreview(p.First.Value, container); + + //todo: check within bounds + if (mi.Location.Equals(pos) && p.Second == null) + { + Game.LobbyInfo.Clients[Game.LocalClient.Index].SpawnPoint = + Game.chrome.currentMap.Waypoints.Keys.ToList().IndexOf(p.First.Value) + 1; + return true; + } + } + return false; + } public override Widget Clone() { return new MapPreviewWidget(this); }