Rework color picker palette modification.

The old method had the lobby code dig around inside
the palette modification machinery, which was a giant
hack preventing necessary streamlining.
This commit is contained in:
Paul Chote
2013-02-21 18:48:31 +13:00
parent 750bdb7bba
commit f593807617
16 changed files with 100 additions and 68 deletions

View File

@@ -0,0 +1,54 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets
{
public class ColorPreviewManagerWidget : Widget
{
public readonly string Palette = "colorpicker";
public readonly int[] RemapIndices = {};
public ColorRamp Ramp;
ColorRamp cachedRamp;
WorldRenderer worldRenderer;
Palette preview;
[ObjectCreator.UseCtor]
public ColorPreviewManagerWidget(WorldRenderer worldRenderer)
: base()
{
this.worldRenderer = worldRenderer;
}
public override void Initialize(WidgetArgs args)
{
base.Initialize(args);
preview = worldRenderer.GetPalette(Palette);
}
public override void Tick()
{
if (cachedRamp == Ramp)
return;
preview.ApplyRemap(new PlayerColorRemap(RemapIndices, Ramp));
cachedRamp = Ramp;
}
}
}