diff --git a/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs index f243ce7cb5..748b1f3105 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs @@ -60,9 +60,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var hue = (byte)Game.CosmeticRandom.Next(255); var sat = (byte)Game.CosmeticRandom.Next(70, 255); var lum = (byte)Game.CosmeticRandom.Next(70, 255); + var color = Color.FromAhsl(hue, sat, lum); - mixer.Set(Color.FromAhsl(hue, sat, lum)); - hueSlider.Value = hue / 255f; + mixer.Set(color); + hueSlider.Value = HueFromColor(color); }; } @@ -70,8 +71,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var validator = modData.Manifest.Get(); mixer.SetPaletteRange(validator.HsvSaturationRange[0], validator.HsvSaturationRange[1], validator.HsvValueRange[0], validator.HsvValueRange[1]); mixer.Set(initialColor); - - hueSlider.Value = initialColor.GetHue() / 360f; + hueSlider.Value = HueFromColor(initialColor); onChange(mixer.Color); // Setup tab controls @@ -126,6 +126,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic newSwatch.OnMouseUp = m => { mixer.Set(color); + hueSlider.Value = HueFromColor(color); onChange(color); }; @@ -148,6 +149,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var color = Game.Settings.Player.CustomColors[colorIndex]; mixer.Set(color); + hueSlider.Value = HueFromColor(color); onChange(color); }; @@ -179,6 +181,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic } } + static float HueFromColor(Color c) + { + float h, s, v; + int a; + c.ToAhsv(out a, out h, out s, out v); + return h; + } + public static void ShowColorDropDown(DropDownButtonWidget color, ColorPreviewManagerWidget preview, World world) { Action onExit = () =>