Added the spawnpoint map tooltip that displays players name in the lobby (closes #2024)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
mapPreview.IsVisible = () => Map != null;
|
||||
mapPreview.Map = () => Map;
|
||||
mapPreview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint( orderManager, mapPreview, Map, mi );
|
||||
mapPreview.SpawnColors = () => LobbyUtils.GetSpawnColors( orderManager, Map );
|
||||
mapPreview.OnTooltip = (spawnPoint, pos) => LobbyUtils.ShowSpawnPointTooltip(orderManager, spawnPoint, pos);
|
||||
mapPreview.SpawnColors = () => LobbyUtils.GetSpawnColors(orderManager, Map);
|
||||
|
||||
var mapTitle = lobby.GetOrNull<LabelWidget>("MAP_TITLE");
|
||||
if (mapTitle != null)
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
var spawns = map.GetSpawnPoints();
|
||||
return orderManager.LobbyInfo.Clients
|
||||
.Where( c => c.SpawnPoint != 0 )
|
||||
.Where( c => c.SpawnPoint != 0)
|
||||
.ToDictionary(
|
||||
c => spawns[c.SpawnPoint - 1],
|
||||
c => c.ColorRamp.GetColor(0));
|
||||
@@ -173,9 +173,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (selectedSpawn == 0 || !owned)
|
||||
{
|
||||
var locals = orderManager.LobbyInfo.Clients.Where(c => c.Index == orderManager.LocalClient.Index || (Game.IsHost && c.Bot != null));
|
||||
var playerToMove = locals.Where(c => (selectedSpawn == 0) ^ (c.SpawnPoint == 0)).FirstOrDefault();
|
||||
var playerToMove = locals.FirstOrDefault(c => (selectedSpawn == 0) ^ (c.SpawnPoint == 0));
|
||||
orderManager.IssueOrder(Order.Command("spawn {0} {1}".F((playerToMove ?? orderManager.LocalClient).Index, selectedSpawn)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowSpawnPointTooltip(OrderManager orderManager, int spawnPoint, int2 position)
|
||||
{
|
||||
var client = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.SpawnPoint == spawnPoint);
|
||||
if (client != null)
|
||||
{
|
||||
var rect = new Rectangle(position.X, position.Y, Game.Renderer.Fonts["Regular"].Measure(client.Name).X + 15, 25);
|
||||
WidgetUtils.DrawPanel("dialog4", rect);
|
||||
Game.Renderer.Fonts["Regular"].DrawText(client.Name, position + new int2(5, 5), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user