Added the spawnpoint map tooltip that displays players name in the lobby (closes #2024)

This commit is contained in:
Carko
2013-01-05 00:05:45 +01:00
committed by Chris Forbes
parent 914afa2dee
commit e10920d4ea
3 changed files with 24 additions and 4 deletions

View File

@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
@@ -21,6 +22,7 @@ namespace OpenRA.Widgets
public Func<Map> Map = () => null;
public Func<Dictionary<int2, Color>> SpawnColors = () => new Dictionary<int2, Color>();
public Action<MouseInput> OnMouseDown = _ => {};
public Action<int, int2> OnTooltip = (_, __) => { };
public bool IgnoreMouseInput = false;
public bool ShowSpawnPoints = true;
@@ -96,7 +98,8 @@ namespace OpenRA.Widgets
{
var colors = SpawnColors();
foreach (var p in map.GetSpawnPoints())
var spawnPoints = map.GetSpawnPoints().ToList();
foreach (var p in spawnPoints)
{
var owned = colors.ContainsKey(p);
var pos = ConvertToPreview(p);
@@ -107,6 +110,11 @@ namespace OpenRA.Widgets
WidgetUtils.FillRectWithColor(new Rectangle(pos.X + offset.X + 2, pos.Y + offset.Y + 2, 12, 12), colors[p]);
Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos + offset);
if ((pos - Viewport.LastMousePos).LengthSquared < 64)
{
OnTooltip(spawnPoints.IndexOf(p) + 1, pos);
}
}
}
}