unfail slightly player color handling

This commit is contained in:
Chris Forbes
2010-05-12 14:21:25 +12:00
parent b3fbe96627
commit f0e5b9728f
6 changed files with 13 additions and 14 deletions

View File

@@ -63,7 +63,7 @@ namespace OpenRA
public void AddLine(Session.Client p, string text) public void AddLine(Session.Client p, string text)
{ {
AddLine(Player.PlayerColors( Game.world )[p.PaletteIndex].c, p.Name, text); AddLine(Player.PlayerColors( Game.world )[p.PaletteIndex].Color, p.Name, text);
} }
public void AddLine(Color c, string from, string text) public void AddLine(Color c, string from, string text)

View File

@@ -188,7 +188,7 @@ namespace OpenRA.Graphics
lineRenderer.FillRect(new RectangleF( lineRenderer.FillRect(new RectangleF(
Game.viewport.Location.X + pos.X + 2, Game.viewport.Location.X + pos.X + 2,
Game.viewport.Location.Y + pos.Y + 2, Game.viewport.Location.Y + pos.Y + 2,
12, 12), Player.PlayerColors(world)[ p.Second.PaletteIndex % Player.PlayerColors(world).Count() ].c); 12, 12), Player.PlayerColors(world)[ p.Second.PaletteIndex % Player.PlayerColors(world).Count() ].Color);
rgbaRenderer.DrawSprite(ownedSpawnPoint, pos, "chrome"); rgbaRenderer.DrawSprite(ownedSpawnPoint, pos, "chrome");
} }

View File

@@ -53,11 +53,10 @@ namespace OpenRA
public ShroudRenderer Shroud; public ShroudRenderer Shroud;
public World World { get; private set; } public World World { get; private set; }
public static List<OpenRA.FileFormats.Tuple<string, string, Color>> PlayerColors(World world) public static List<PlayerColorPaletteInfo> PlayerColors(World world)
{ {
return world.WorldActor.Info.Traits.WithInterface<PlayerColorPaletteInfo>() return world.WorldActor.Info.Traits.WithInterface<PlayerColorPaletteInfo>()
.Where(p => p.Playable) .Where(p => p.Playable)
.Select(p => OpenRA.FileFormats.Tuple.New(p.Name, p.DisplayName, p.Color))
.ToList(); .ToList();
} }
@@ -71,8 +70,8 @@ namespace OpenRA
if (client != null) if (client != null)
{ {
Index = client.Index; Index = client.Index;
Palette = PlayerColors(world)[client.PaletteIndex % PlayerColors(world).Count()].a; Palette = PlayerColors(world)[client.PaletteIndex % PlayerColors(world).Count()].Name;
Color = PlayerColors(world)[client.PaletteIndex % PlayerColors(world).Count()].c; Color = PlayerColors(world)[client.PaletteIndex % PlayerColors(world).Count()].Color;
PlayerName = client.Name; PlayerName = client.Name;
InternalName = "Multi{0}".F(client.Index); InternalName = "Multi{0}".F(client.Index);
} }

View File

@@ -23,7 +23,7 @@ using OpenRA.FileFormats;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
class PlayerColorPaletteInfo : ITraitInfo public class PlayerColorPaletteInfo : ITraitInfo
{ {
public readonly string Name = null; public readonly string Name = null;
public readonly string DisplayName = null; public readonly string DisplayName = null;
@@ -41,7 +41,7 @@ namespace OpenRA.Traits
public Color Color { get { return Util.ArrayToColor(DisplayColor); } } public Color Color { get { return Util.ArrayToColor(DisplayColor); } }
} }
class PlayerColorPalette public class PlayerColorPalette
{ {
public PlayerColorPalette(Actor self, PlayerColorPaletteInfo info) public PlayerColorPalette(Actor self, PlayerColorPaletteInfo info)
{ {

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Widgets.Delegates
color.OnMouseUp = CyclePalette; color.OnMouseUp = CyclePalette;
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK"); var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
colorBlock.GetColor = () => Player.PlayerColors(Game.world)[c.PaletteIndex % Player.PlayerColors(Game.world).Count].c; colorBlock.GetColor = () => Player.PlayerColors(Game.world)[c.PaletteIndex % Player.PlayerColors(Game.world).Count].Color;
var faction = template.GetWidget<ButtonWidget>("FACTION"); var faction = template.GetWidget<ButtonWidget>("FACTION");
faction.OnMouseUp = CycleRace; faction.OnMouseUp = CycleRace;
@@ -91,7 +91,7 @@ namespace OpenRA.Widgets.Delegates
else else
{ {
var color = template.GetWidget<ColorBlockWidget>("COLOR"); var color = template.GetWidget<ColorBlockWidget>("COLOR");
color.GetColor = () => Player.PlayerColors(Game.world)[c.PaletteIndex % Player.PlayerColors(Game.world).Count].c; color.GetColor = () => Player.PlayerColors(Game.world)[c.PaletteIndex % Player.PlayerColors(Game.world).Count].Color;
var faction = template.GetWidget<LabelWidget>("FACTION"); var faction = template.GetWidget<LabelWidget>("FACTION");
faction.GetText = () => c.Country; faction.GetText = () => c.Country;

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Widgets
Game.chrome.lineRenderer.FillRect(new RectangleF( Game.chrome.lineRenderer.FillRect(new RectangleF(
Game.viewport.Location.X + pos.X + 2, Game.viewport.Location.X + pos.X + 2,
Game.viewport.Location.Y + pos.Y + 2, Game.viewport.Location.Y + pos.Y + 2,
12, 12), playerColors[p.Second.PaletteIndex % playerColors.Count()].c); 12, 12), playerColors[p.Second.PaletteIndex % playerColors.Count()].Color);
Game.chrome.renderer.RgbaSpriteRenderer.DrawSprite( Game.chrome.renderer.RgbaSpriteRenderer.DrawSprite(
ChromeProvider.GetImage(Game.chrome.renderer, "spawnpoints", "owned"), pos, "chrome"); ChromeProvider.GetImage(Game.chrome.renderer, "spawnpoints", "owned"), pos, "chrome");