diff --git a/OpenRA.FileFormats/PlayerColorRemap.cs b/OpenRA.FileFormats/PlayerColorRemap.cs index 0b31def790..2f35f7fa13 100644 --- a/OpenRA.FileFormats/PlayerColorRemap.cs +++ b/OpenRA.FileFormats/PlayerColorRemap.cs @@ -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 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 }; diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index 926a107d52..6205c313bd 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -93,7 +93,7 @@ namespace OpenRA { var info = Rules.Info["world"].Traits.Get(); 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); } diff --git a/OpenRA.Game/Traits/World/PlayerColorPalette.cs b/OpenRA.Game/Traits/World/PlayerColorPalette.cs index 5a2bc53798..d081b12ea2 100644 --- a/OpenRA.Game/Traits/World/PlayerColorPalette.cs +++ b/OpenRA.Game/Traits/World/PlayerColorPalette.cs @@ -8,12 +8,13 @@ */ #endregion +using OpenRA.FileFormats; namespace OpenRA.Traits -{ +{ public class PlayerColorPaletteInfo : TraitInfo { public readonly string BasePalette = null; - public readonly bool SplitRamp = false; + public readonly PaletteFormat PaletteFormat = PaletteFormat.ra; } public class PlayerColorPalette {} diff --git a/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs b/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs index 3cfa544df1..27be188181 100644 --- a/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs +++ b/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs @@ -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(); - 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)); } } } diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 27189a4e9d..1adbf437d1 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -54,7 +54,7 @@ World: Name: terrain PlayerColorPalette: BasePalette: terrain - SplitRamp: yes + PaletteFormat: cnc PaletteFromFile@chrome: Name: chrome Filename: temperat.pal diff --git a/mods/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index 0f7b2e5553..141d8d005a 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -15,6 +15,7 @@ World: Name: terrain PlayerColorPalette: BasePalette: units + PaletteFormat: d2k PaletteFromFile@units: Name: units Filename: units.pal