nice spawnpoint render
This commit is contained in:
@@ -346,10 +346,8 @@ namespace OpenRa
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PaletteAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.PaletteIndex != index); }
|
bool PaletteAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.PaletteIndex != index); }
|
||||||
|
|
||||||
bool SpawnPointAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
|
bool SpawnPointAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
|
||||||
|
|
||||||
|
|
||||||
void CyclePalette(bool left)
|
void CyclePalette(bool left)
|
||||||
{
|
{
|
||||||
var d = left ? +1 : Player.PlayerColors.Count() - 1;
|
var d = left ? +1 : Player.PlayerColors.Count() - 1;
|
||||||
@@ -379,14 +377,13 @@ namespace OpenRa
|
|||||||
|
|
||||||
void CycleSpawnPoint(bool left)
|
void CycleSpawnPoint(bool left)
|
||||||
{
|
{
|
||||||
var d = left ? +1 : Game.world.Map.SpawnPoints.Count() - 1;
|
var d = left ? +1 : Game.world.Map.SpawnPoints.Count();
|
||||||
|
|
||||||
var newIndex = (Game.world.LocalPlayer.SpawnPointIndex + d) % Game.world.Map.SpawnPoints.Count();
|
var newIndex = (Game.world.LocalPlayer.SpawnPointIndex + d) % (Game.world.Map.SpawnPoints.Count()+1);
|
||||||
|
|
||||||
while (!SpawnPointAvailable(newIndex) && newIndex != (int)Game.world.LocalPlayer.SpawnPointIndex)
|
while (!SpawnPointAvailable(newIndex) && newIndex != (int)Game.world.LocalPlayer.SpawnPointIndex)
|
||||||
newIndex = (newIndex + d) % Game.world.Map.SpawnPoints.Count();
|
newIndex = (newIndex + d) % (Game.world.Map.SpawnPoints.Count()+1);
|
||||||
|
|
||||||
Game.world.Minimap.InvalidateSpawnPoints();
|
|
||||||
Game.IssueOrder(
|
Game.IssueOrder(
|
||||||
Order.Chat("/spawn " + newIndex));
|
Order.Chat("/spawn " + newIndex));
|
||||||
|
|
||||||
@@ -413,6 +410,7 @@ namespace OpenRa
|
|||||||
var minimapRect = new Rectangle(r.Right - 322, r.Top + 45, 300, 240);
|
var minimapRect = new Rectangle(r.Right - 322, r.Top + 45, 300, 240);
|
||||||
|
|
||||||
world.Minimap.Update();
|
world.Minimap.Update();
|
||||||
|
world.Minimap.Draw(minimapRect, true);
|
||||||
world.Minimap.DrawSpawnPoints(minimapRect);
|
world.Minimap.DrawSpawnPoints(minimapRect);
|
||||||
|
|
||||||
if (Game.world.LocalPlayer.Index == 0)
|
if (Game.world.LocalPlayer.Index == 0)
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ namespace OpenRa
|
|||||||
Timer.Time( "load rules: {0}" );
|
Timer.Time( "load rules: {0}" );
|
||||||
|
|
||||||
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.
|
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.
|
||||||
|
|
||||||
Player.ResetPlayerColorList();
|
Player.ResetPlayerColorList();
|
||||||
|
ChromeProvider.Initialize(manifest.Chrome);
|
||||||
|
|
||||||
world = new World();
|
world = new World();
|
||||||
|
|
||||||
Game.world.ActorAdded += a =>
|
Game.world.ActorAdded += a =>
|
||||||
@@ -80,7 +83,6 @@ namespace OpenRa
|
|||||||
};
|
};
|
||||||
Timer.Time( "world: {0}" );
|
Timer.Time( "world: {0}" );
|
||||||
|
|
||||||
ChromeProvider.Initialize(manifest.Chrome);
|
|
||||||
SequenceProvider.Initialize(manifest.Sequences);
|
SequenceProvider.Initialize(manifest.Sequences);
|
||||||
viewport = new Viewport(clientSize, Game.world.Map.Offset, Game.world.Map.Offset + Game.world.Map.Size, renderer);
|
viewport = new Viewport(clientSize, Game.world.Map.Offset, Game.world.Map.Offset + Game.world.Map.Size, renderer);
|
||||||
Timer.Time( "ChromeProv, SeqProv, viewport: {0}" );
|
Timer.Time( "ChromeProv, SeqProv, viewport: {0}" );
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using OpenRa.FileFormats;
|
|||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using IjwFramework.Collections;
|
using IjwFramework.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using IjwFramework.Types;
|
||||||
|
|
||||||
namespace OpenRa.Graphics
|
namespace OpenRa.Graphics
|
||||||
{
|
{
|
||||||
@@ -14,8 +15,14 @@ namespace OpenRa.Graphics
|
|||||||
readonly World world;
|
readonly World world;
|
||||||
Sheet sheet, mapOnlySheet, mapSpawnPointSheet;
|
Sheet sheet, mapOnlySheet, mapSpawnPointSheet;
|
||||||
SpriteRenderer rgbaRenderer;
|
SpriteRenderer rgbaRenderer;
|
||||||
|
LineRenderer lineRenderer;
|
||||||
Sprite sprite, mapOnlySprite, mapSpawnPointSprite;
|
Sprite sprite, mapOnlySprite, mapSpawnPointSprite;
|
||||||
Bitmap terrain, oreLayer, spawnPointsLayer;
|
Bitmap terrain, oreLayer, spawnPointsLayer;
|
||||||
|
Rectangle bounds;
|
||||||
|
|
||||||
|
Sprite ownedSpawnPoint;
|
||||||
|
Sprite unownedSpawnPoint;
|
||||||
|
|
||||||
const int alpha = 230;
|
const int alpha = 230;
|
||||||
|
|
||||||
public void Tick() { }
|
public void Tick() { }
|
||||||
@@ -27,18 +34,22 @@ namespace OpenRa.Graphics
|
|||||||
mapOnlySheet = new Sheet(r, new Size(128, 128));
|
mapOnlySheet = new Sheet(r, new Size(128, 128));
|
||||||
mapSpawnPointSheet = new Sheet(r, new Size(128, 128));
|
mapSpawnPointSheet = new Sheet(r, new Size(128, 128));
|
||||||
|
|
||||||
|
lineRenderer = new LineRenderer(r);
|
||||||
rgbaRenderer = new SpriteRenderer(r, true, r.RgbaSpriteShader);
|
rgbaRenderer = new SpriteRenderer(r, true, r.RgbaSpriteShader);
|
||||||
var size = Math.Max(world.Map.Width, world.Map.Height);
|
var size = Math.Max(world.Map.Width, world.Map.Height);
|
||||||
var dw = (size - world.Map.Width) / 2;
|
var dw = (size - world.Map.Width) / 2;
|
||||||
var dh = (size - world.Map.Height) / 2;
|
var dh = (size - world.Map.Height) / 2;
|
||||||
|
|
||||||
var rect = new Rectangle(world.Map.Offset.X - dw, world.Map.Offset.Y - dh, size, size);
|
bounds = new Rectangle(world.Map.Offset.X - dw, world.Map.Offset.Y - dh, size, size);
|
||||||
|
|
||||||
sprite = new Sprite(sheet, rect, TextureChannel.Alpha);
|
sprite = new Sprite(sheet, bounds, TextureChannel.Alpha);
|
||||||
mapOnlySprite = new Sprite(mapOnlySheet, rect, TextureChannel.Alpha);
|
mapOnlySprite = new Sprite(mapOnlySheet, bounds, TextureChannel.Alpha);
|
||||||
mapSpawnPointSprite = new Sprite(mapSpawnPointSheet, rect, TextureChannel.Alpha);
|
mapSpawnPointSprite = new Sprite(mapSpawnPointSheet, bounds, TextureChannel.Alpha);
|
||||||
|
|
||||||
shroudColor = Color.FromArgb(alpha, Color.Black);
|
shroudColor = Color.FromArgb(alpha, Color.Black);
|
||||||
|
|
||||||
|
ownedSpawnPoint = ChromeProvider.GetImage(r, "spawnpoints", "owned");
|
||||||
|
unownedSpawnPoint = ChromeProvider.GetImage(r, "spawnpoints", "unowned");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Rectangle MakeMinimapBounds(Map m)
|
public static Rectangle MakeMinimapBounds(Map m)
|
||||||
@@ -79,6 +90,8 @@ namespace OpenRa.Graphics
|
|||||||
|
|
||||||
public static Bitmap RenderTerrainBitmapWithSpawnPoints(Map map, TileSet tileset)
|
public static Bitmap RenderTerrainBitmapWithSpawnPoints(Map map, TileSet tileset)
|
||||||
{
|
{
|
||||||
|
/* todo: do this a bit nicer */
|
||||||
|
|
||||||
var terrain = RenderTerrainBitmap(map, tileset);
|
var terrain = RenderTerrainBitmap(map, tileset);
|
||||||
foreach (var sp in map.SpawnPoints)
|
foreach (var sp in map.SpawnPoints)
|
||||||
terrain.SetPixel(sp.X, sp.Y, Color.White);
|
terrain.SetPixel(sp.X, sp.Y, Color.White);
|
||||||
@@ -102,27 +115,6 @@ namespace OpenRa.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
mapOnlySheet.Texture.SetData(oreLayer);
|
mapOnlySheet.Texture.SetData(oreLayer);
|
||||||
mapSpawnPointSheet.Texture.SetData(oreLayer);
|
|
||||||
|
|
||||||
if (spawnPointsLayer == null)
|
|
||||||
{
|
|
||||||
spawnPointsLayer = new Bitmap(terrain);
|
|
||||||
var available = Game.world.Map.SpawnPoints.ToList();
|
|
||||||
|
|
||||||
foreach (var player in Game.world.players.Values)
|
|
||||||
{
|
|
||||||
if (player.SpawnPointIndex != 0)
|
|
||||||
{
|
|
||||||
int2 sp = Game.world.Map.SpawnPoints.ElementAt(player.SpawnPointIndex - 1);
|
|
||||||
spawnPointsLayer.SetPixel(sp.X, sp.Y, player.Color);
|
|
||||||
available.Remove(sp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (var sp in available)
|
|
||||||
spawnPointsLayer.SetPixel(sp.X, sp.Y, Color.White);
|
|
||||||
}
|
|
||||||
|
|
||||||
mapSpawnPointSheet.Texture.SetData(spawnPointsLayer);
|
|
||||||
|
|
||||||
if (!world.Queries.OwnedBy[world.LocalPlayer].WithTrait<ProvidesRadar>().Any())
|
if (!world.Queries.OwnedBy[world.LocalPlayer].WithTrait<ProvidesRadar>().Any())
|
||||||
return;
|
return;
|
||||||
@@ -166,10 +158,41 @@ namespace OpenRa.Graphics
|
|||||||
rgbaRenderer.Flush();
|
rgbaRenderer.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int2 TransformCellToMinimapPixel(RectangleF viewRect, int2 p)
|
||||||
|
{
|
||||||
|
var fx = (float)(p.X - bounds.X) / bounds.Width;
|
||||||
|
var fy = (float)(p.Y - bounds.Y) / bounds.Height;
|
||||||
|
|
||||||
|
return new int2(
|
||||||
|
(int)(viewRect.Width * fx + viewRect.Left) - 8,
|
||||||
|
(int)(viewRect.Height * fy + viewRect.Top) - 8);
|
||||||
|
}
|
||||||
|
|
||||||
public void DrawSpawnPoints(RectangleF rect)
|
public void DrawSpawnPoints(RectangleF rect)
|
||||||
{
|
{
|
||||||
rgbaRenderer.DrawSprite( mapSpawnPointSprite,
|
var points = world.Map.SpawnPoints
|
||||||
new float2(rect.X, rect.Y), "chrome", new float2(rect.Width, rect.Height));
|
.Select( (sp,i) => Pair.New(sp,world.players.Values.FirstOrDefault(
|
||||||
|
p => p.SpawnPointIndex == i + 1 ) ))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var p in points)
|
||||||
|
{
|
||||||
|
var pos = TransformCellToMinimapPixel(rect, p.First);
|
||||||
|
|
||||||
|
if (p.Second == null)
|
||||||
|
rgbaRenderer.DrawSprite(unownedSpawnPoint, pos, "chrome");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lineRenderer.FillRect(new RectangleF(
|
||||||
|
Game.viewport.Location.X + pos.X + 2,
|
||||||
|
Game.viewport.Location.Y + pos.Y + 2,
|
||||||
|
12, 12), p.Second.Color);
|
||||||
|
|
||||||
|
rgbaRenderer.DrawSprite(ownedSpawnPoint, pos, "chrome");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lineRenderer.Flush();
|
||||||
rgbaRenderer.Flush();
|
rgbaRenderer.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
artsrc/ra/spawnpoints.psd
Normal file
BIN
artsrc/ra/spawnpoints.psd
Normal file
Binary file not shown.
@@ -143,4 +143,8 @@
|
|||||||
<image name="corner-bl" x="0" y="407" width="23" height="24" />
|
<image name="corner-bl" x="0" y="407" width="23" height="24" />
|
||||||
<image name="corner-br" x="23" y="407" width="23" height="24" />
|
<image name="corner-br" x="23" y="407" width="23" height="24" />
|
||||||
</collection>
|
</collection>
|
||||||
|
<collection name="spawnpoints" src="spawnpoints.png">
|
||||||
|
<image name="unowned" x="16" y="0" width="16" height="16" />
|
||||||
|
<image name="owned" x="0" y="0" width="16" height="16" />
|
||||||
|
</collection>
|
||||||
</chrome>
|
</chrome>
|
||||||
|
|||||||
BIN
mods/cnc/spawnpoints.png
Normal file
BIN
mods/cnc/spawnpoints.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
@@ -143,4 +143,8 @@
|
|||||||
<image name="corner-bl" x="0" y="407" width="23" height="24" />
|
<image name="corner-bl" x="0" y="407" width="23" height="24" />
|
||||||
<image name="corner-br" x="23" y="407" width="23" height="24" />
|
<image name="corner-br" x="23" y="407" width="23" height="24" />
|
||||||
</collection>
|
</collection>
|
||||||
|
<collection name="spawnpoints" src="spawnpoints.png">
|
||||||
|
<image name="unowned" x="16" y="0" width="16" height="16" />
|
||||||
|
<image name="owned" x="0" y="0" width="16" height="16" />
|
||||||
|
</collection>
|
||||||
</chrome>
|
</chrome>
|
||||||
|
|||||||
BIN
mods/ra/spawnpoints.png
Normal file
BIN
mods/ra/spawnpoints.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Reference in New Issue
Block a user