Update color picker hue slider when the color changes.
This commit is contained in:
committed by
Matthias Mailänder
parent
9d68b815a1
commit
3f601e1ec1
@@ -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<ColorValidator>();
|
||||
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 = () =>
|
||||
|
||||
Reference in New Issue
Block a user