diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 6fe2f3ec10..a84eb221de 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -231,6 +231,7 @@ + diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index efc15efdbe..61476ed80d 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -123,8 +123,14 @@ namespace OpenRA.Widgets.Delegates teamChat ^= true; chatLabel.Text = (teamChat) ? "Team:" : "Chat:"; return true; + }; + + var colorChooser = lobby.GetWidget("COLOR_CHOOSER"); + colorChooser.GetWidget("BUTTON_OK").OnMouseUp = mi => + { + colorChooser.IsVisible = () => false; + return true; }; - } void UpdateCurrentMap() @@ -169,7 +175,11 @@ namespace OpenRA.Widgets.Delegates name.OnLoseFocus = () => name.OnEnterKey(); var color = template.GetWidget("COLOR"); - //color.OnMouseUp = CyclePalette; + color.OnMouseUp = mi => + { + Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget("COLOR_CHOOSER").IsVisible = () => true; + return true; + }; var colorBlock = color.GetWidget("COLORBLOCK"); colorBlock.GetColor = () => c.Color; diff --git a/OpenRA.Game/Widgets/ImageWidget.cs b/OpenRA.Game/Widgets/ImageWidget.cs index 3778ba9524..dc300b964b 100644 --- a/OpenRA.Game/Widgets/ImageWidget.cs +++ b/OpenRA.Game/Widgets/ImageWidget.cs @@ -1,3 +1,22 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion using System; using OpenRA.Graphics; diff --git a/OpenRA.Game/Widgets/ShpImageWidget.cs b/OpenRA.Game/Widgets/ShpImageWidget.cs new file mode 100644 index 0000000000..35df1d3789 --- /dev/null +++ b/OpenRA.Game/Widgets/ShpImageWidget.cs @@ -0,0 +1,77 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using System; +using OpenRA.Graphics; + +namespace OpenRA.Widgets +{ + public class ShpImageWidget : Widget + { + public string Image = ""; + public int Frame = 0; + public string Palette = "chrome"; + + public Func GetImage; + public Func GetFrame; + public Func GetPalette; + + public ShpImageWidget() + : base() + { + GetImage = () => { return Image; }; + GetFrame = () => { return Frame; }; + GetPalette = () => { return Palette; }; + } + + protected ShpImageWidget(ShpImageWidget other) + : base(other) + { + Image = other.Image; + Frame = other.Frame; + Palette = other.Palette; + GetImage = other.GetImage; + GetFrame = other.GetFrame; + GetPalette = other.GetPalette; + } + + public override Widget Clone() { return new ShpImageWidget(this); } + + + Sprite sprite = null; + string cachedImage = null; + int cachedFrame= -1; + public override void DrawInner(World world) + { + var image = GetImage(); + var frame = GetFrame(); + var palette = GetPalette(); + + if (image != cachedImage || frame != cachedFrame) + { + sprite = SpriteSheetBuilder.LoadAllSprites(image)[frame]; + cachedImage = image; + cachedFrame = frame; + } + + Game.chrome.renderer.WorldSpriteRenderer.DrawSprite(sprite,RenderOrigin, palette); + } + } +} diff --git a/mods/ra/chrome/gamelobby.yaml b/mods/ra/chrome/gamelobby.yaml index 541f628cbe..b24a3f2ec6 100644 --- a/mods/ra/chrome/gamelobby.yaml +++ b/mods/ra/chrome/gamelobby.yaml @@ -251,6 +251,89 @@ Container@ROOT: Width: 80 Height: 20 Text: Lock Teams + Background@COLOR_CHOOSER: + Id:COLOR_CHOOSER + Width:500 + Height:195 + X:(WINDOW_RIGHT - WIDTH)/2 - PARENT_LEFT + Y:100 + Visible:false + Children: + Button@BUTTON_OK: + Id:BUTTON_OK + X:PARENT_RIGHT - 180 + Y:PARENT_BOTTOM - 45 + Width:160 + Height:25 + Text:Ok + Bold:True + ShpImage@MCV: + Id:MCV + X:PARENT_RIGHT - 90 + Y:20 + Image:mcv + Frame:8 + ShpImage@FACT: + Id:FACT + X:PARENT_RIGHT - 100 + Y:70 + Image:fact + Label@HUE_LABEL: + X:0 + Y:30 + Width:110 + Height:20 + Align: Right + Text: Hue: + Slider@HUE: + Id:HUE_SLIDER + X:120 + Y:30 + Width:260 + Height:20 + Ticks:5 + Label@SAT_LABEL: + X:0 + Y:60 + Width:110 + Height:20 + Align: Right + Text: Saturation: + Slider@SAT: + Id:SAT_SLIDER + X:120 + Y:60 + Width:260 + Height:20 + Ticks:5 + Label@LUM_LABEL: + X:0 + Y:90 + Width:110 + Height:20 + Align: Right + Text: Brightness: + Slider@LUM: + Id:LUM_SLIDER + X:120 + Y:90 + Width:260 + Height:20 + Ticks:5 + Label@RANGE_LABEL: + X:0 + Y:120 + Width:110 + Height:20 + Align: Right + Text: Range: + Slider@RANGE: + Id:RANGE_SLIDER + X:120 + Y:120 + Width:260 + Height:20 + Ticks:5 Background@MAP_CHOOSER: Id:MAP_CHOOSER X:(WINDOW_RIGHT - WIDTH)/2