Fix spawnpoint rendering
This commit is contained in:
@@ -58,8 +58,9 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
|
|
||||||
bg.GetWidget("SERVER_INFO").IsVisible = () => currentServer != null;
|
bg.GetWidget("SERVER_INFO").IsVisible = () => currentServer != null;
|
||||||
bg.GetWidget<MapPreviewWidget>("MAP_PREVIEW").Map = () => CurrentMap();
|
var preview = bg.GetWidget<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
bg.GetWidget("MAP_CONTAINER").IsVisible = () => CurrentMap() != null;
|
preview.Map = () => CurrentMap();
|
||||||
|
preview.IsVisible = () => CurrentMap() != null;
|
||||||
|
|
||||||
bg.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
|
bg.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
|
||||||
bg.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => string.Join( ",", currentServer.Mods );
|
bg.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => string.Join( ",", currentServer.Mods );
|
||||||
|
|||||||
@@ -25,8 +25,13 @@ namespace OpenRA.Widgets
|
|||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
lastMap = (other as MapPreviewWidget).lastMap;
|
lastMap = (other as MapPreviewWidget).lastMap;
|
||||||
|
Map = (other as MapPreviewWidget).Map;
|
||||||
|
OnSpawnClick = (other as MapPreviewWidget).OnSpawnClick;
|
||||||
|
SpawnColors = (other as MapPreviewWidget).SpawnColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Sprite UnownedSpawn = null;
|
||||||
|
static Sprite OwnedSpawn = null;
|
||||||
const int closeEnough = 50;
|
const int closeEnough = 50;
|
||||||
public override bool HandleInput(MouseInput mi)
|
public override bool HandleInput(MouseInput mi)
|
||||||
{
|
{
|
||||||
@@ -36,10 +41,8 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
if (mi.Event == MouseInputEvent.Down && mi.Button == MouseButton.Left)
|
if (mi.Event == MouseInputEvent.Down && mi.Button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
var container = new Rectangle(RenderOrigin.X, RenderOrigin.Y, Parent.Bounds.Width, Parent.Bounds.Height);
|
|
||||||
|
|
||||||
var p = map.Waypoints
|
var p = map.Waypoints
|
||||||
.Select((sp, i) => Pair.New(map.ConvertToPreview(sp.Value, container), i))
|
.Select((sp, i) => Pair.New(map.ConvertToPreview(sp.Value, RenderBounds), i))
|
||||||
.Where(a => (a.First - mi.Location).LengthSquared < closeEnough)
|
.Where(a => (a.First - mi.Location).LengthSquared < closeEnough)
|
||||||
.Select(a => a.Second + 1)
|
.Select(a => a.Second + 1)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
@@ -54,6 +57,11 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public override void DrawInner( World world )
|
public override void DrawInner( World world )
|
||||||
{
|
{
|
||||||
|
if (UnownedSpawn == null)
|
||||||
|
UnownedSpawn = ChromeProvider.GetImage(Game.chrome.renderer, "spawnpoints", "unowned");
|
||||||
|
if (OwnedSpawn == null)
|
||||||
|
OwnedSpawn = ChromeProvider.GetImage(Game.chrome.renderer, "spawnpoints", "owned");
|
||||||
|
|
||||||
var map = Map();
|
var map = Map();
|
||||||
if( map == null ) return;
|
if( map == null ) return;
|
||||||
if (lastMap != map)
|
if (lastMap != map)
|
||||||
@@ -79,29 +87,30 @@ namespace OpenRA.Widgets
|
|||||||
"chrome",
|
"chrome",
|
||||||
new float2( mapRect.Size ) );
|
new float2( mapRect.Size ) );
|
||||||
|
|
||||||
DrawSpawnPoints( map, new Rectangle(RenderOrigin.X, RenderOrigin.Y, Parent.Bounds.Width, Parent.Bounds.Height ), world );
|
DrawSpawnPoints( map, world );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSpawnPoints(MapStub map, Rectangle container, World world)
|
void DrawSpawnPoints(MapStub map, World world)
|
||||||
{
|
{
|
||||||
var colors = SpawnColors();
|
var colors = SpawnColors();
|
||||||
foreach (var p in map.SpawnPoints)
|
foreach (var p in map.SpawnPoints)
|
||||||
{
|
{
|
||||||
var pos = map.ConvertToPreview(p, container) - new int2(8, 8);
|
var pos = map.ConvertToPreview(p, RenderBounds);
|
||||||
var sprite = "unowned";
|
var sprite = UnownedSpawn;
|
||||||
|
var offset = new int2(-UnownedSpawn.bounds.Width/2, -UnownedSpawn.bounds.Height/2);
|
||||||
|
|
||||||
if (colors.ContainsKey(p))
|
if (colors.ContainsKey(p))
|
||||||
{
|
{
|
||||||
Game.chrome.lineRenderer.FillRect(new RectangleF(
|
sprite = OwnedSpawn;
|
||||||
Game.viewport.Location.X + pos.X + 2,
|
offset = new int2(-OwnedSpawn.bounds.Width/2, -OwnedSpawn.bounds.Height/2);
|
||||||
Game.viewport.Location.Y + pos.Y + 2,
|
|
||||||
12, 12), colors[p]);
|
|
||||||
|
|
||||||
sprite = "owned";
|
Game.chrome.lineRenderer.FillRect(new RectangleF(
|
||||||
|
Game.viewport.Location.X + pos.X + offset.X + 2,
|
||||||
|
Game.viewport.Location.Y + pos.Y + offset.Y + 2,
|
||||||
|
12, 12), colors[p]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.chrome.renderer.RgbaSpriteRenderer.DrawSprite(
|
Game.chrome.renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos + offset, "chrome");
|
||||||
ChromeProvider.GetImage(Game.chrome.renderer, "spawnpoints", sprite), pos, "chrome");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.chrome.lineRenderer.Flush();
|
Game.chrome.lineRenderer.Flush();
|
||||||
|
|||||||
@@ -474,18 +474,10 @@ Container:
|
|||||||
Align:Left
|
Align:Left
|
||||||
Width:70
|
Width:70
|
||||||
Height:20
|
Height:20
|
||||||
Background@MAP_CONTAINER:
|
|
||||||
Id:MAP_CONTAINER
|
|
||||||
X:PARENT_RIGHT-245
|
|
||||||
Y:140
|
|
||||||
Width:200
|
|
||||||
Height:200
|
|
||||||
Background:dialog3
|
|
||||||
Children:
|
|
||||||
MapPreview@MAP_PREVIEW:
|
MapPreview@MAP_PREVIEW:
|
||||||
Id:MAP_PREVIEW
|
Id:MAP_PREVIEW
|
||||||
X:4
|
X:PARENT_RIGHT-241
|
||||||
Y:4
|
Y:140
|
||||||
Width:192
|
Width:192
|
||||||
Height:192
|
Height:192
|
||||||
Button@DIRECTCONNECT_BUTTON:
|
Button@DIRECTCONNECT_BUTTON:
|
||||||
|
|||||||
@@ -474,18 +474,10 @@ Container:
|
|||||||
Align:Left
|
Align:Left
|
||||||
Width:70
|
Width:70
|
||||||
Height:20
|
Height:20
|
||||||
Background@MAP_CONTAINER:
|
|
||||||
Id:MAP_CONTAINER
|
|
||||||
X:PARENT_RIGHT-245
|
|
||||||
Y:140
|
|
||||||
Width:200
|
|
||||||
Height:200
|
|
||||||
Background:dialog3
|
|
||||||
Children:
|
|
||||||
MapPreview@MAP_PREVIEW:
|
MapPreview@MAP_PREVIEW:
|
||||||
Id:MAP_PREVIEW
|
Id:MAP_PREVIEW
|
||||||
X:4
|
X:PARENT_RIGHT-241
|
||||||
Y:4
|
Y:140
|
||||||
Width:192
|
Width:192
|
||||||
Height:192
|
Height:192
|
||||||
Button@DIRECTCONNECT_BUTTON:
|
Button@DIRECTCONNECT_BUTTON:
|
||||||
|
|||||||
Reference in New Issue
Block a user