Abstract ColorBlockWidget away from Player
This commit is contained in:
@@ -25,18 +25,18 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
class ColorBlockWidget : Widget
|
||||
{
|
||||
public Func<int> GetPaletteIndex;
|
||||
public Func<Color> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
color.OnMouseUp = CyclePalette;
|
||||
|
||||
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
|
||||
colorBlock.GetPaletteIndex = () => c.PaletteIndex;
|
||||
colorBlock.GetColor = () => Player.PlayerColors(Game.world)[c.PaletteIndex % Player.PlayerColors(Game.world).Count].c;
|
||||
|
||||
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.GetPaletteIndex = () => c.PaletteIndex;
|
||||
color.GetColor = () => Player.PlayerColors(Game.world)[c.PaletteIndex % Player.PlayerColors(Game.world).Count].c;
|
||||
|
||||
var faction = template.GetWidget<LabelWidget>("FACTION");
|
||||
faction.GetText = () => c.Country;
|
||||
|
||||
Reference in New Issue
Block a user