Replace ColorRamp with HSLColor everywhere.

Fixes:
* Nuclear-purple color exploit.
* #3247.
* Removes a bunch of unnecessary color conversions every frame.

Caveats:
* The ramp range is now defined on the palette, so ramps can no longer be set per-player (may impact maps which define custom colors).
* It's no longer possible to perfectly recreate the original WW color ramps (I doubt we care).
* The old ColorRamp setting isn't migrated, so players will lose their color settings.
This commit is contained in:
Paul Chote
2013-05-10 17:14:22 +12:00
parent abcc30f0b7
commit 656476991f
41 changed files with 112 additions and 168 deletions

View File

@@ -55,11 +55,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
nameTextfield.Text = playerSettings.Name;
colorPreview = panel.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
colorPreview.Ramp = playerSettings.ColorRamp;
colorPreview.Color = playerSettings.Color;
var colorDropdown = generalPane.Get<DropDownButtonWidget>("COLOR");
colorDropdown.OnMouseDown = _ => ShowColorPicker(colorDropdown, playerSettings);
colorDropdown.Get<ColorBlockWidget>("COLORBLOCK").GetColor = () => playerSettings.ColorRamp.GetColor(0);
colorDropdown.Get<ColorBlockWidget>("COLORBLOCK").GetColor = () => playerSettings.Color.RGB;
// Debug
var perftextCheckbox = generalPane.Get<CheckboxWidget>("PERFTEXT_CHECKBOX");
@@ -155,17 +155,21 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
bool ShowColorPicker(DropDownButtonWidget color, PlayerSettings s)
{
Action<ColorRamp> onExit = c => {s.ColorRamp = c; color.RemovePanel();};
Action<ColorRamp> onChange = c => {colorPreview.Ramp = c;};
Action<HSLColor> onChange = c => colorPreview.Color = c;
Action onExit = () =>
{
s.Color = colorPreview.Color;
color.RemovePanel();
};
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
{
{ "onExit", onExit },
{ "onChange", onChange },
{ "initialRamp", s.ColorRamp }
{ "initialColor", s.Color }
});
color.AttachPanel(colorChooser);
color.AttachPanel(colorChooser, onExit);
return true;
}