Merge ColorPreviewManagerWidget into ColorPickerManager.

This commit is contained in:
Paul Chote
2021-04-11 21:55:23 +01:00
committed by teinarss
parent 7b58f03f1c
commit f65de2dd43
25 changed files with 59 additions and 103 deletions

View File

@@ -12,6 +12,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Primitives;
using OpenRA.Support;
using OpenRA.Traits;
@@ -27,6 +28,22 @@ namespace OpenRA.Mods.Common.Traits
public readonly float[] HsvValueRange = new[] { 0.2f, 1.0f };
public readonly Color[] TeamColorPresets = { };
[PaletteReference]
public readonly string PaletteName = "colorpicker";
public readonly int[] RemapIndices = { };
public readonly float Ramp = 0.05f;
public Color Color { get; private set; }
public void Update(WorldRenderer worldRenderer, Color color)
{
Color = color;
var newPalette = new MutablePalette(worldRenderer.Palette(PaletteName).Palette);
newPalette.ApplyRemap(new PlayerColorRemap(RemapIndices, Color, Ramp));
worldRenderer.ReplacePalette(PaletteName, newPalette);
}
double GetColorDelta(Color colorA, Color colorB)
{
var rmean = (colorA.R + colorB.R) / 2.0;