From e11b2a18017453c1ebc3815b12724f207ba6e50a Mon Sep 17 00:00:00 2001 From: alzeih Date: Sun, 25 Apr 2010 14:03:31 +1200 Subject: [PATCH] Abstract ColorBlockWidget away from Player --- OpenRA.Game/Widgets/ColorBlockWidget.cs | 9 ++++----- OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/Widgets/ColorBlockWidget.cs b/OpenRA.Game/Widgets/ColorBlockWidget.cs index 8f2a63d85e..300ba78545 100644 --- a/OpenRA.Game/Widgets/ColorBlockWidget.cs +++ b/OpenRA.Game/Widgets/ColorBlockWidget.cs @@ -25,18 +25,18 @@ namespace OpenRA.Widgets { class ColorBlockWidget : Widget { - public Func GetPaletteIndex; + public Func GetColor; public ColorBlockWidget() : base() { - GetPaletteIndex = () => 0; + GetColor = () => Color.White; } public ColorBlockWidget(Widget widget) :base(widget) { - GetPaletteIndex = (widget as ColorBlockWidget).GetPaletteIndex; + GetColor = (widget as ColorBlockWidget).GetColor; } public override Widget Clone() @@ -54,8 +54,7 @@ namespace OpenRA.Widgets var pos = DrawPosition(); var paletteRect = new RectangleF(pos.X + Game.viewport.Location.X, pos.Y + Game.viewport.Location.Y, Bounds.Width, Bounds.Height); - Game.chrome.lineRenderer.FillRect(paletteRect, Player.PlayerColors(Game.world)[GetPaletteIndex() % Player.PlayerColors(Game.world).Count].c); - + Game.chrome.lineRenderer.FillRect(paletteRect, GetColor()); base.Draw(world); } } diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index d37660c7f1..2800facc3a 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -70,7 +70,7 @@ namespace OpenRA.Widgets.Delegates color.OnMouseUp = CyclePalette; var colorBlock = color.GetWidget("COLORBLOCK"); - colorBlock.GetPaletteIndex = () => c.PaletteIndex; + colorBlock.GetColor = () => Player.PlayerColors(Game.world)[c.PaletteIndex % Player.PlayerColors(Game.world).Count].c; var faction = template.GetWidget("FACTION"); faction.OnMouseUp = CycleRace; @@ -91,7 +91,7 @@ namespace OpenRA.Widgets.Delegates else { var color = template.GetWidget("COLOR"); - color.GetPaletteIndex = () => c.PaletteIndex; + color.GetColor = () => Player.PlayerColors(Game.world)[c.PaletteIndex % Player.PlayerColors(Game.world).Count].c; var faction = template.GetWidget("FACTION"); faction.GetText = () => c.Country;