diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 7e3b9c9e66..5463bcdaf5 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -309,6 +309,7 @@ + diff --git a/OpenRA.Game/Widgets/ColorButtonWidget.cs b/OpenRA.Game/Widgets/ColorButtonWidget.cs new file mode 100644 index 0000000000..bf22279aba --- /dev/null +++ b/OpenRA.Game/Widgets/ColorButtonWidget.cs @@ -0,0 +1,54 @@ + +using System; +using System.Drawing; + +namespace OpenRA.Widgets +{ + class ColorButtonWidget : ButtonWidget + { + public int PaletteIndex = 0; + public Func GetPaletteIndex; + + public ColorButtonWidget() + : base() + { + GetPaletteIndex = () => { return PaletteIndex; }; + } + + public ColorButtonWidget(Widget widget) + :base(widget) + { + PaletteIndex = (widget as ColorButtonWidget).PaletteIndex; + GetPaletteIndex = (widget as ColorButtonWidget).GetPaletteIndex; + } + + public override Widget Clone() + { + return new ColorButtonWidget(this); + } + + public override void Draw(World world) + { + if (!IsVisible()) + { + base.Draw(world); + return; + } + + DrawColorBlock(); + + base.Draw(world); + } + + void DrawColorBlock() + { + var pos = DrawPosition(); + var paletteRect = new Rectangle(pos.X ,pos.Y + 2 , 65, 22); + Game.chrome.lineRenderer.FillRect(RectangleF.FromLTRB(paletteRect.Left + Game.viewport.Location.X + 5, + paletteRect.Top + Game.viewport.Location.Y + 5, + paletteRect.Right + Game.viewport.Location.X - 5, + paletteRect.Bottom+Game.viewport.Location.Y - 5), + Player.PlayerColors(Game.world)[GetPaletteIndex() % Player.PlayerColors(Game.world).Count].c); + } + } +} diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index e12d3f227f..81d319b2e1 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -48,9 +48,9 @@ namespace OpenRA.Widgets.Delegates if(client.Index == Game.LocalClient.Index) { //TODO: Real Color Button - var color = template.GetWidget("COLOR"); + var color = template.GetWidget("COLOR"); color.OnMouseUp = CyclePalette; - color.GetText = () => c.PaletteIndex.ToString(); + color.GetPaletteIndex = () => c.PaletteIndex; var faction = template.GetWidget("FACTION"); faction.OnMouseUp = CycleRace; diff --git a/mods/ra/menus.yaml b/mods/ra/menus.yaml index 7024e7f6fa..601bb34913 100644 --- a/mods/ra/menus.yaml +++ b/mods/ra/menus.yaml @@ -310,13 +310,13 @@ Container: Height:25 X:0 Y:5 - Button@COLOR: + ColorButton@COLOR: Id:COLOR - Text:Color Width:65 Height:25 X:100 Y:0 + PaletteIndex:0 Button@FACTION: Id:FACTION Text:Faction