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 hue = (byte)Game.CosmeticRandom.Next(255);
|
||||||
var sat = (byte)Game.CosmeticRandom.Next(70, 255);
|
var sat = (byte)Game.CosmeticRandom.Next(70, 255);
|
||||||
var lum = (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));
|
mixer.Set(color);
|
||||||
hueSlider.Value = hue / 255f;
|
hueSlider.Value = HueFromColor(color);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,8 +71,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var validator = modData.Manifest.Get<ColorValidator>();
|
var validator = modData.Manifest.Get<ColorValidator>();
|
||||||
mixer.SetPaletteRange(validator.HsvSaturationRange[0], validator.HsvSaturationRange[1], validator.HsvValueRange[0], validator.HsvValueRange[1]);
|
mixer.SetPaletteRange(validator.HsvSaturationRange[0], validator.HsvSaturationRange[1], validator.HsvValueRange[0], validator.HsvValueRange[1]);
|
||||||
mixer.Set(initialColor);
|
mixer.Set(initialColor);
|
||||||
|
hueSlider.Value = HueFromColor(initialColor);
|
||||||
hueSlider.Value = initialColor.GetHue() / 360f;
|
|
||||||
onChange(mixer.Color);
|
onChange(mixer.Color);
|
||||||
|
|
||||||
// Setup tab controls
|
// Setup tab controls
|
||||||
@@ -126,6 +126,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
newSwatch.OnMouseUp = m =>
|
newSwatch.OnMouseUp = m =>
|
||||||
{
|
{
|
||||||
mixer.Set(color);
|
mixer.Set(color);
|
||||||
|
hueSlider.Value = HueFromColor(color);
|
||||||
onChange(color);
|
onChange(color);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -148,6 +149,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var color = Game.Settings.Player.CustomColors[colorIndex];
|
var color = Game.Settings.Player.CustomColors[colorIndex];
|
||||||
mixer.Set(color);
|
mixer.Set(color);
|
||||||
|
hueSlider.Value = HueFromColor(color);
|
||||||
onChange(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)
|
public static void ShowColorDropDown(DropDownButtonWidget color, ColorPreviewManagerWidget preview, World world)
|
||||||
{
|
{
|
||||||
Action onExit = () =>
|
Action onExit = () =>
|
||||||
|
|||||||
Reference in New Issue
Block a user