support d2k remap range
This commit is contained in:
@@ -15,15 +15,16 @@ using System.Linq;
|
||||
namespace OpenRA.FileFormats
|
||||
{
|
||||
// TODO: ship this out of here.
|
||||
public enum PaletteFormat { ra, cnc, d2k }
|
||||
|
||||
public class PlayerColorRemap : IPaletteRemap
|
||||
{
|
||||
Dictionary<int, Color> remapColors;
|
||||
|
||||
public PlayerColorRemap(Color c1, Color c2, bool useSplitRamp)
|
||||
public PlayerColorRemap(Color c1, Color c2, PaletteFormat fmt)
|
||||
{
|
||||
var baseIndex = useSplitRamp ? 0xb0 : 80;
|
||||
var ramp = useSplitRamp
|
||||
var baseIndex = (fmt == PaletteFormat.cnc) ? 0xb0 : (fmt == PaletteFormat.d2k) ? 240 : 80;
|
||||
var ramp = (fmt == PaletteFormat.cnc)
|
||||
? new[] { 0, 2, 4, 6, 8, 10, 13, 15, 1, 3, 5, 7, 9, 11, 12, 14 }
|
||||
: new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA
|
||||
{
|
||||
var info = Rules.Info["world"].Traits.Get<PlayerColorPaletteInfo>();
|
||||
var newpal = new Palette(world.WorldRenderer.GetPalette(info.BasePalette),
|
||||
new PlayerColorRemap(Color, Color2, info.SplitRamp));
|
||||
new PlayerColorRemap(Color, Color2, info.PaletteFormat));
|
||||
world.WorldRenderer.AddPalette(palette, newpal);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.FileFormats;
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
{
|
||||
public class PlayerColorPaletteInfo : TraitInfo<PlayerColorPalette>
|
||||
{
|
||||
public readonly string BasePalette = null;
|
||||
public readonly bool SplitRamp = false;
|
||||
public readonly PaletteFormat PaletteFormat = PaletteFormat.ra;
|
||||
}
|
||||
|
||||
public class PlayerColorPalette {}
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
class ColorPickerPaletteModifier : IPaletteModifier, IWorldLoaded
|
||||
{
|
||||
bool SplitPlayerPalette;
|
||||
PaletteFormat format;
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
// Copy the base palette for the colorpicker
|
||||
var info = Rules.Info["world"].Traits.Get<PlayerColorPaletteInfo>();
|
||||
SplitPlayerPalette = info.SplitRamp;
|
||||
format = info.PaletteFormat;
|
||||
w.WorldRenderer.AddPalette("colorpicker", w.WorldRenderer.GetPalette(info.BasePalette));
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
||||
new PlayerColorRemap(LobbyDelegate.CurrentColorPreview1,
|
||||
LobbyDelegate.CurrentColorPreview2, SplitPlayerPalette));
|
||||
LobbyDelegate.CurrentColorPreview2, format));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ World:
|
||||
Name: terrain
|
||||
PlayerColorPalette:
|
||||
BasePalette: terrain
|
||||
SplitRamp: yes
|
||||
PaletteFormat: cnc
|
||||
PaletteFromFile@chrome:
|
||||
Name: chrome
|
||||
Filename: temperat.pal
|
||||
|
||||
@@ -15,6 +15,7 @@ World:
|
||||
Name: terrain
|
||||
PlayerColorPalette:
|
||||
BasePalette: units
|
||||
PaletteFormat: d2k
|
||||
PaletteFromFile@units:
|
||||
Name: units
|
||||
Filename: units.pal
|
||||
|
||||
Reference in New Issue
Block a user