diff --git a/OpenRA.Game/Graphics/CursorProvider.cs b/OpenRA.Game/Graphics/CursorProvider.cs index a0dc94b86d..4184facd60 100644 --- a/OpenRA.Game/Graphics/CursorProvider.cs +++ b/OpenRA.Game/Graphics/CursorProvider.cs @@ -34,7 +34,7 @@ namespace OpenRA.Graphics } foreach (var s in sequences.NodesDict["Palettes"].Nodes) - Game.modData.Palette.AddPalette(s.Key, new Palette(FileSystem.Open(s.Value.Value), ShadowIndex)); + Game.modData.Palette.AddPalette(s.Key, new Palette(FileSystem.Open(s.Value.Value), ShadowIndex), false); foreach (var s in sequences.NodesDict["Cursors"].Nodes) LoadSequencesForCursor(s.Key, s.Value); diff --git a/OpenRA.Game/Graphics/HardwarePalette.cs b/OpenRA.Game/Graphics/HardwarePalette.cs index fcda7438e3..98f486e2cf 100644 --- a/OpenRA.Game/Graphics/HardwarePalette.cs +++ b/OpenRA.Game/Graphics/HardwarePalette.cs @@ -25,11 +25,13 @@ namespace OpenRA.Graphics ITexture texture; Dictionary palettes; Dictionary indices; + Dictionary allowsMods; public HardwarePalette() { palettes = new Dictionary(); indices = new Dictionary(); + allowsMods = new Dictionary(); texture = Game.Renderer.Device.CreateTexture(); } @@ -49,22 +51,24 @@ namespace OpenRA.Graphics return ret; } - public void AddPalette(string name, Palette p) + public void AddPalette(string name, Palette p, bool allowModifiers) { if (palettes.ContainsKey(name)) throw new InvalidOperationException("Palette {0} has already been defined".F(name)); palettes.Add(name, p); indices.Add(name, allocated++); + allowsMods.Add(name, allowModifiers); } uint[,] data = new uint[MaxPalettes, 256]; public void Update(IEnumerable paletteMods) { var copy = palettes.ToDictionary(p => p.Key, p => new Palette(p.Value)); + var modifiable = copy.Where(p => allowsMods[p.Key]).ToDictionary(p => p.Key, p => p.Value); foreach (var mod in paletteMods) - mod.AdjustPalette(copy); + mod.AdjustPalette(modifiable); foreach (var pal in copy) { diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index ba662975a2..8aaed1c3f2 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -37,7 +37,7 @@ namespace OpenRA.Graphics public int GetPaletteIndex(string name) { return palette.GetPaletteIndex(name); } public Palette GetPalette(string name) { return palette.GetPalette(name); } - public void AddPalette(string name, Palette pal) { palette.AddPalette(name, pal); } + public void AddPalette(string name, Palette pal, bool allowModifiers) { palette.AddPalette(name, pal, allowModifiers); } class SpriteComparer : IComparer { diff --git a/OpenRA.Game/Traits/World/PlayerColorPalette.cs b/OpenRA.Game/Traits/World/PlayerColorPalette.cs index bb3547aaea..1e50140945 100644 --- a/OpenRA.Game/Traits/World/PlayerColorPalette.cs +++ b/OpenRA.Game/Traits/World/PlayerColorPalette.cs @@ -18,6 +18,7 @@ namespace OpenRA.Traits public readonly string BasePalette = null; public readonly string BaseName = "player"; public readonly int[] RemapIndex = {}; + public readonly bool AllowModifiers = true; public object Create( ActorInitializer init ) { return new PlayerColorPalette( init.self.Owner, this ); } } @@ -38,7 +39,7 @@ namespace OpenRA.Traits var paletteName = "{0}{1}".F( info.BaseName, owner.InternalName ); var newpal = new Palette(wr.GetPalette(info.BasePalette), new PlayerColorRemap(info.RemapIndex, owner.ColorRamp)); - wr.AddPalette(paletteName, newpal); + wr.AddPalette(paletteName, newpal, info.AllowModifiers); } } } diff --git a/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs b/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs index df198b1430..a351b80128 100644 --- a/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs +++ b/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs @@ -61,8 +61,6 @@ namespace OpenRA.Mods.Cnc } } - static Set excludePalettes = new Set("cursor", "chrome", "colorpicker", "shroud", "fog"); - public void AdjustPalette(Dictionary palettes) { if (to == EffectType.None && remainingFrames == 0) @@ -70,9 +68,6 @@ namespace OpenRA.Mods.Cnc foreach (var pal in palettes) { - if (excludePalettes.Contains(pal.Key)) - continue; - for (var x = 0; x < 256; x++) { var orig = pal.Value.GetColor(x); diff --git a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs index 242f112c8e..419875c151 100644 --- a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs +++ b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs @@ -32,8 +32,6 @@ namespace OpenRA.Mods.RA if (remainingFrames > 0) remainingFrames--; } - - static List excludePalettes = new List{"cursor", "chrome", "colorpicker", "shroud", "fog"}; public void AdjustPalette(Dictionary palettes) { @@ -44,9 +42,6 @@ namespace OpenRA.Mods.RA foreach (var pal in palettes) { - if (excludePalettes.Contains(pal.Key)) - continue; - for (var x = 0; x < 256; x++) { var orig = pal.Value.GetColor(x); diff --git a/OpenRA.Mods.RA/LightPaletteRotator.cs b/OpenRA.Mods.RA/LightPaletteRotator.cs index d3e827b540..ec2e166a3f 100644 --- a/OpenRA.Mods.RA/LightPaletteRotator.cs +++ b/OpenRA.Mods.RA/LightPaletteRotator.cs @@ -24,15 +24,10 @@ namespace OpenRA.Mods.RA t += .5f; } - static readonly string[] ExcludePalettes = { "cursor", "chrome", "colorpicker", "terrain" }; - public void AdjustPalette(Dictionary palettes) { foreach (var pal in palettes) { - if (ExcludePalettes.Contains(pal.Key)) - continue; - var rotate = (int)t % 18; if (rotate > 9) rotate = 18 - rotate; diff --git a/OpenRA.Mods.RA/NukePaletteEffect.cs b/OpenRA.Mods.RA/NukePaletteEffect.cs index 3e463fdd11..21215ee546 100644 --- a/OpenRA.Mods.RA/NukePaletteEffect.cs +++ b/OpenRA.Mods.RA/NukePaletteEffect.cs @@ -32,8 +32,6 @@ namespace OpenRA.Mods.RA if (remainingFrames > 0) remainingFrames--; } - - static List excludePalettes = new List{ "cursor", "chrome", "colorpicker", "shroud", "fog" }; public void AdjustPalette(Dictionary palettes) { @@ -44,9 +42,6 @@ namespace OpenRA.Mods.RA foreach (var pal in palettes) { - if (excludePalettes.Contains(pal.Key)) - continue; - for (var x = 0; x < 256; x++) { var orig = pal.Value.GetColor(x); diff --git a/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs b/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs index f98af6175c..8c045aef07 100644 --- a/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs +++ b/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs @@ -17,6 +17,7 @@ namespace OpenRA.Mods.RA { public readonly string Name = null; public readonly int[] ShadowIndex = { }; + public readonly bool AllowModifiers = true; public object Create(ActorInitializer init) { return new PaletteFromCurrentTileset(init.world, this); } } @@ -32,9 +33,9 @@ namespace OpenRA.Mods.RA this.info = info; } - public void InitPalette( OpenRA.Graphics.WorldRenderer wr ) + public void InitPalette(OpenRA.Graphics.WorldRenderer wr) { - wr.AddPalette( info.Name, new Palette( FileSystem.Open( world.TileSet.Palette ), info.ShadowIndex ) ); + wr.AddPalette(info.Name, new Palette(FileSystem.Open(world.TileSet.Palette), info.ShadowIndex), info.AllowModifiers); } } } diff --git a/OpenRA.Mods.RA/PaletteFromFile.cs b/OpenRA.Mods.RA/PaletteFromFile.cs index 94706ea61e..6a60aa8d67 100644 --- a/OpenRA.Mods.RA/PaletteFromFile.cs +++ b/OpenRA.Mods.RA/PaletteFromFile.cs @@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA public readonly string Tileset = null; public readonly string Filename = null; public readonly int[] ShadowIndex = { }; + public readonly bool AllowModifiers = true; public object Create(ActorInitializer init) { return new PaletteFromFile(init.world, this); } } @@ -34,10 +35,10 @@ namespace OpenRA.Mods.RA this.info = info; } - public void InitPalette( WorldRenderer wr ) + public void InitPalette(WorldRenderer wr) { - if( info.Tileset == null || info.Tileset.ToLowerInvariant() == world.Map.Tileset.ToLowerInvariant() ) - wr.AddPalette( info.Name, new Palette( FileSystem.Open( info.Filename ), info.ShadowIndex ) ); + if (info.Tileset == null || info.Tileset.ToLowerInvariant() == world.Map.Tileset.ToLowerInvariant()) + wr.AddPalette(info.Name, new Palette(FileSystem.Open(info.Filename), info.ShadowIndex), info.AllowModifiers); } } } diff --git a/OpenRA.Mods.RA/PaletteFromRGBA.cs b/OpenRA.Mods.RA/PaletteFromRGBA.cs index 95ebef6905..9fd84ba698 100644 --- a/OpenRA.Mods.RA/PaletteFromRGBA.cs +++ b/OpenRA.Mods.RA/PaletteFromRGBA.cs @@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA public readonly int G = 0; public readonly int B = 0; public readonly int A = 255; + public readonly bool AllowModifiers = true; public object Create(ActorInitializer init) { return new PaletteFromRGBA(init.world, this); } } @@ -43,7 +44,7 @@ namespace OpenRA.Mods.RA { // TODO: This shouldn't rely on a base palette var pal = wr.GetPalette("terrain"); - wr.AddPalette(info.Name, new Palette(pal, new SingleColorRemap(Color.FromArgb(info.A, info.R, info.G, info.B)))); + wr.AddPalette(info.Name, new Palette(pal, new SingleColorRemap(Color.FromArgb(info.A, info.R, info.G, info.B))), info.AllowModifiers); } } } diff --git a/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs b/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs index 2315236f30..a28fac7522 100644 --- a/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs +++ b/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs @@ -17,6 +17,7 @@ namespace OpenRA.Mods.RA { public readonly string Name = null; public readonly int[] ShadowIndex = { }; + public readonly bool AllowModifiers = true; public object Create(ActorInitializer init) { return new PlayerPaletteFromCurrentTileset(init.world, this); } } @@ -35,7 +36,7 @@ namespace OpenRA.Mods.RA public void InitPalette (OpenRA.Graphics.WorldRenderer wr) { string Filename = world.TileSet.PlayerPalette == null ? world.TileSet.Palette : world.TileSet.PlayerPalette; - wr.AddPalette(info.Name, new Palette(FileSystem.Open(Filename), info.ShadowIndex)); + wr.AddPalette(info.Name, new Palette(FileSystem.Open(Filename), info.ShadowIndex), info.AllowModifiers); } } } diff --git a/OpenRA.Mods.RA/ShroudPalette.cs b/OpenRA.Mods.RA/ShroudPalette.cs index f8015a979a..a8858b12d6 100644 --- a/OpenRA.Mods.RA/ShroudPalette.cs +++ b/OpenRA.Mods.RA/ShroudPalette.cs @@ -27,12 +27,12 @@ namespace OpenRA.Mods.RA { readonly ShroudPaletteInfo info; - public ShroudPalette( ShroudPaletteInfo info ) { this.info = info; } + public ShroudPalette(ShroudPaletteInfo info) { this.info = info; } - public void InitPalette( WorldRenderer wr ) + public void InitPalette(WorldRenderer wr) { - var pal = wr.GetPalette( "terrain" ); - wr.AddPalette( info.Name, new Palette( pal, new ShroudPaletteRemap( info.IsFog ) ) ); + var pal = wr.GetPalette("terrain"); + wr.AddPalette(info.Name, new Palette(pal, new ShroudPaletteRemap(info.IsFog)), false); } } diff --git a/OpenRA.Mods.RA/WaterPaletteRotation.cs b/OpenRA.Mods.RA/WaterPaletteRotation.cs index 9a3aedf454..a8a24127c1 100644 --- a/OpenRA.Mods.RA/WaterPaletteRotation.cs +++ b/OpenRA.Mods.RA/WaterPaletteRotation.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA { class WaterPaletteRotationInfo : ITraitInfo { - public readonly string[] ExcludePalettes = { "cursor", "chrome", "colorpicker", "player" }; + public readonly string[] ExcludePalettes = {}; public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.world, this); } } diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index f968a228b6..b03db10d59 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -84,6 +84,7 @@ World: Name: colorpicker Filename: temperat.pal ShadowIndex: 4 + AllowModifiers: false PaletteFromRGBA@shadow: Name: shadow R: 0 diff --git a/mods/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index 31c6ffc05e..f00901c7f9 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -273,6 +273,7 @@ World: Name: colorpicker Filename: d2k.pal ShadowIndex: 4 + AllowModifiers: false PaletteFromRGBA@shadow: Name: shadow R: 0 diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index eb0fd1a1ea..729edaf08f 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -228,6 +228,7 @@ World: Name: colorpicker Filename: temperat.pal ShadowIndex: 4 + AllowModifiers: false PaletteFromRGBA@shadow: Name: shadow R: 0