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)
{
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)

View File

@@ -188,7 +188,7 @@ namespace OpenRA.Graphics
lineRenderer.FillRect(new RectangleF(
Game.viewport.Location.X + pos.X + 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");
}

View File

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

View File

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

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Widgets.Delegates
color.OnMouseUp = CyclePalette;
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");
faction.OnMouseUp = CycleRace;
@@ -91,7 +91,7 @@ namespace OpenRA.Widgets.Delegates
else
{
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");
faction.GetText = () => c.Country;

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Widgets
Game.chrome.lineRenderer.FillRect(new RectangleF(
Game.viewport.Location.X + pos.X + 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(
ChromeProvider.GetImage(Game.chrome.renderer, "spawnpoints", "owned"), pos, "chrome");