diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 4eda4f950e..d3353199df 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -138,7 +138,8 @@ namespace OpenRA.Editor Rules.LoadRules(manifest, map); tileset = Rules.TileSets[map.Tileset]; tileset.LoadTiles(); - var palette = new Palette(FileSystem.Open(tileset.Palette), true); + int[] ShadowIndex = { 3, 4 }; + var palette = new Palette(FileSystem.Open(tileset.Palette), ShadowIndex); surface1.Bind(map, tileset, palette); // construct the palette of tiles diff --git a/OpenRA.FileFormats/Palette.cs b/OpenRA.FileFormats/Palette.cs index bf3bd46cd1..9b96021f6f 100644 --- a/OpenRA.FileFormats/Palette.cs +++ b/OpenRA.FileFormats/Palette.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2012 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, @@ -39,7 +39,7 @@ namespace OpenRA.FileFormats get { return colors; } } - public Palette(Stream s, bool remapTransparent) + public Palette(Stream s, int[] remapShadow) { colors = new uint[256]; @@ -54,13 +54,9 @@ namespace OpenRA.FileFormats } } - colors[0] = 0; - if (remapTransparent) - { - colors[1] = 178u << 24; // Hack for d2k; may have side effects - colors[3] = 178u << 24; - colors[4] = 140u << 24; - } + colors[0] = 0; //convert black background to transparency + foreach (int i in remapShadow) + colors[i] = 140u << 24; } public Palette(Palette p, IPaletteRemap r) @@ -92,12 +88,12 @@ namespace OpenRA.FileFormats return pal; } - public static Palette Load( string filename, bool remap ) + public static Palette Load(string filename, int[] remap) { using(var s = File.OpenRead(filename)) return new Palette(s, remap); } } - public interface IPaletteRemap { Color GetRemappedColor(Color original, int index); } + public interface IPaletteRemap { Color GetRemappedColor(Color original, int index); } } diff --git a/OpenRA.Game/Graphics/CursorProvider.cs b/OpenRA.Game/Graphics/CursorProvider.cs index 032ae22447..a0dc94b86d 100644 --- a/OpenRA.Game/Graphics/CursorProvider.cs +++ b/OpenRA.Game/Graphics/CursorProvider.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2012 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, @@ -25,13 +25,16 @@ namespace OpenRA.Graphics { cursors = new Dictionary(); var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal)); - var transparent = false; + int[] ShadowIndex = { }; - if (sequences.NodesDict.ContainsKey("Transparent")) - transparent = true; + if (sequences.NodesDict.ContainsKey("ShadowIndex")) + { + Array.Resize(ref ShadowIndex, ShadowIndex.Length + 1); + ShadowIndex[ShadowIndex.Length - 1] = Convert.ToInt32(sequences.NodesDict["ShadowIndex"].Value); + } foreach (var s in sequences.NodesDict["Palettes"].Nodes) - Game.modData.Palette.AddPalette(s.Key, new Palette(FileSystem.Open(s.Value.Value), transparent)); + Game.modData.Palette.AddPalette(s.Key, new Palette(FileSystem.Open(s.Value.Value), ShadowIndex)); foreach (var s in sequences.NodesDict["Cursors"].Nodes) LoadSequencesForCursor(s.Key, s.Value); diff --git a/OpenRA.Mods.D2k/Widgets/Logic/D2kExtractGameFilesLogic.cs b/OpenRA.Mods.D2k/Widgets/Logic/D2kExtractGameFilesLogic.cs index 6b2a4edab5..f2a0609b47 100644 --- a/OpenRA.Mods.D2k/Widgets/Logic/D2kExtractGameFilesLogic.cs +++ b/OpenRA.Mods.D2k/Widgets/Logic/D2kExtractGameFilesLogic.cs @@ -267,7 +267,7 @@ namespace OpenRA.Mods.D2k.Widgets.Logic new string[] {"--r8", PathToDataR8, PathToPalette, "4463", "4477", Path.Combine(PathToSHPs, "craneo"), "--building"}, new string[] {"--r8", PathToDataR8, PathToPalette, "4760", "4819", Path.Combine(PathToSHPs, "windtrap_anim"), "--building"}, //? new string[] {"--r8", PathToDataR8, PathToPalette, "4820", "4840", Path.Combine(PathToSHPs, "missile_launch"), "--building"}, - new string[] {"--r8", Path.Combine(Platform.SupportDir, "Content/d2k/MOUSE.R8"), PathToPalette, "0", "264", Path.Combine(PathToSHPs, "mouse"), "--transparent"}, + new string[] {"--r8", Path.Combine(Platform.SupportDir, "Content/d2k/MOUSE.R8"), PathToPalette, "0", "264", Path.Combine(PathToSHPs, "mouse")}, new string[] {"--r8", Path.Combine(Platform.SupportDir, "Content/d2k/BLOXBASE.R8"), PathToPalette, "0", "799", Path.Combine(PathToTilesets, "BASE"), "--tileset"}, new string[] {"--r8", Path.Combine(Platform.SupportDir, "Content/d2k/BLOXBASE.R8"), PathToPalette, "748", "749", Path.Combine(PathToSHPs, "spice0")}, new string[] {"--r8", Path.Combine(Platform.SupportDir, "Content/d2k/BLOXBAT.R8"), PathToPalette, "0", "799", Path.Combine(PathToTilesets, "BAT"), "--tileset"}, diff --git a/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs b/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs index ab6db57594..f98af6175c 100644 --- a/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs +++ b/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2012 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, @@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA class PaletteFromCurrentTilesetInfo : ITraitInfo { public readonly string Name = null; - public readonly bool Transparent = true; + public readonly int[] ShadowIndex = { }; public object Create(ActorInitializer init) { return new PaletteFromCurrentTileset(init.world, this); } } @@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA public void InitPalette( OpenRA.Graphics.WorldRenderer wr ) { - wr.AddPalette( info.Name, new Palette( FileSystem.Open( world.TileSet.Palette ), info.Transparent ) ); + wr.AddPalette( info.Name, new Palette( FileSystem.Open( world.TileSet.Palette ), info.ShadowIndex ) ); } } } diff --git a/OpenRA.Mods.RA/PaletteFromFile.cs b/OpenRA.Mods.RA/PaletteFromFile.cs index 8ea64870b9..94706ea61e 100644 --- a/OpenRA.Mods.RA/PaletteFromFile.cs +++ b/OpenRA.Mods.RA/PaletteFromFile.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2012 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, @@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA public readonly string Name = null; public readonly string Tileset = null; public readonly string Filename = null; - public readonly bool Transparent = true; + public readonly int[] ShadowIndex = { }; public object Create(ActorInitializer init) { return new PaletteFromFile(init.world, this); } } @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA 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.Transparent ) ); + wr.AddPalette( info.Name, new Palette( FileSystem.Open( info.Filename ), info.ShadowIndex ) ); } } } diff --git a/OpenRA.TilesetBuilder/frmBuilder.cs b/OpenRA.TilesetBuilder/frmBuilder.cs index b9d6c5eabe..bf85e2825d 100644 --- a/OpenRA.TilesetBuilder/frmBuilder.cs +++ b/OpenRA.TilesetBuilder/frmBuilder.cs @@ -56,9 +56,11 @@ namespace OpenRA.TilesetBuilder Bitmap rbitmap = fbitmap.Clone(new Rectangle(0, 0, fbitmap.Width, fbitmap.Height), fbitmap.PixelFormat); + int[] ShadowIndex = { }; + if (!PaletteFromImage) { - tpal = Palette.Load(PaletteFile, false); + tpal = Palette.Load(PaletteFile, ShadowIndex); rbitmap.Palette = tpal.AsSystemPalette(); } diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index 6857e757e6..725976ce01 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -81,8 +81,15 @@ namespace OpenRA.Utility var dest = Path.ChangeExtension(src, ".png"); var srcImage = ShpReader.Load(src); - var shouldRemap = args.Contains( "--transparent" ); - var palette = Palette.Load(args[2], shouldRemap); + int[] ShadowIndex = { }; + if (args.Contains("--noshadow")) + { + Array.Resize(ref ShadowIndex, ShadowIndex.Length + 3); + ShadowIndex[ShadowIndex.Length - 1] = 1; + ShadowIndex[ShadowIndex.Length - 2] = 3; + ShadowIndex[ShadowIndex.Length - 1] = 4; + } + var palette = Palette.Load(args[2], ShadowIndex); using (var bitmap = new Bitmap(srcImage.ImageCount * srcImage.Width, srcImage.Height, PixelFormat.Format8bppIndexed)) { @@ -110,8 +117,13 @@ namespace OpenRA.Utility public static void ConvertR8ToPng(string[] args) { var srcImage = new R8Reader(File.OpenRead(args[1])); - var shouldRemap = args.Contains("--transparent"); - var palette = Palette.Load(args[2], shouldRemap); + int[] ShadowIndex = { }; + if (args.Contains("--noshadow")) + { + Array.Resize(ref ShadowIndex, ShadowIndex.Length + 1); + ShadowIndex[ShadowIndex.Length - 1] = 3; + } + var palette = Palette.Load(args[2], ShadowIndex); var startFrame = int.Parse(args[3]); var endFrame = int.Parse(args[4]) + 1; var filename = args[5]; @@ -319,6 +331,7 @@ namespace OpenRA.Utility var mods = args[1].Split(','); var theater = args[2]; var templateNames = args.Skip(3); + int[] ShadowIndex = { 3, 4 }; var manifest = new Manifest(mods); FileSystem.LoadFromManifest(manifest); @@ -330,7 +343,7 @@ namespace OpenRA.Utility throw new InvalidOperationException("No theater named '{0}'".F(theater)); tileset.LoadTiles(); - var palette = new Palette(FileSystem.Open(tileset.Palette), true); + var palette = new Palette(FileSystem.Open(tileset.Palette), ShadowIndex); foreach( var templateName in templateNames ) { @@ -413,14 +426,15 @@ namespace OpenRA.Utility var destPaletteInfo = Rules.Info["player"].Traits.Get(); int[] destRemapIndex = destPaletteInfo.RemapIndex; + int[] ShadowIndex = { }; // the remap range is always 16 entries, but their location and order changes for (var i = 0; i < 16; i++) remap[PlayerColorRemap.GetRemapIndex(srcRemapIndex, i)] = PlayerColorRemap.GetRemapIndex(destRemapIndex, i); // map everything else to the best match based on channel-wise distance - var srcPalette = Palette.Load(args[1].Split(':')[1], false); - var destPalette = Palette.Load(args[2].Split(':')[1], false); + var srcPalette = Palette.Load(args[1].Split(':')[1], ShadowIndex); + var destPalette = Palette.Load(args[2].Split(':')[1], ShadowIndex); var fullIndexRange = Exts.MakeArray(256, x => x); diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index d46783c004..b6cc18f8c0 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -57,11 +57,11 @@ namespace OpenRA.Utility Console.WriteLine(); Console.WriteLine(" --settings-value KEY Get value of KEY from settings.yaml"); Console.WriteLine(" --shp PNGFILE FRAMEWIDTH Convert a single PNG with multiple frames appended after another to a SHP"); - Console.WriteLine(" --png SHPFILE PALETTE [--transparent] Convert a SHP to a PNG containing all of its frames, optionally setting up transparency"); + Console.WriteLine(" --png SHPFILE PALETTE [--noshadow] Convert a SHP to a PNG containing all of its frames, optionally removing the shadow"); Console.WriteLine(" --extract MOD[,MOD]* FILES Extract files from mod packages"); Console.WriteLine(" --tmp-png MOD[,MOD]* THEATER FILES Extract terrain tiles to PNG"); Console.WriteLine(" --remap SRCMOD:PAL DESTMOD:PAL SRCSHP DESTSHP Remap SHPs to another palette"); - Console.WriteLine(" --r8 R8FILE PALETTE START END FILENAME [--transparent] [--infrantry] [--vehicle] [--projectile] [--building] [--wall] [--tileset] Convert Dune 2000 DATA.R8 to PNGs choosing start- and endframe as well as type for correct offset to append multiple frames to one PNG named by filename optionally setting up transparency."); + Console.WriteLine(" --r8 R8FILE PALETTE START END FILENAME [--noshadow] [--infrantry] [--vehicle] [--projectile] [--building] [--wall] [--tileset] Convert Dune 2000 DATA.R8 to PNGs choosing start- and endframe as well as type for correct offset to append multiple frames to one PNG named by filename optionally removing the shadow."); Console.WriteLine(" --transpose SRCSHP DESTSHP START N M [START N M ...] Transpose the N*M block of frames starting at START."); } diff --git a/doc/cnc extracted inirules link.txt b/doc/cnc extracted inirules link.txt deleted file mode 100644 index 84788a199d..0000000000 --- a/doc/cnc extracted inirules link.txt +++ /dev/null @@ -1 +0,0 @@ -http://nyerguds.arsaneus-design.com/cnc95upd/inirules/ diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 99a95d595c..1b5424fe86 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -68,14 +68,18 @@ World: Bridges: bridge1, bridge2, bridge3, bridge4 PaletteFromCurrentTileset@terrain: Name: terrain + ShadowIndex: 4 PaletteFromCurrentTileset@static: Name: staticterrain + ShadowIndex: 4 PaletteFromFile@chrome: Name: chrome Filename: temperat.pal + ShadowIndex: 3 PaletteFromFile@effect: Name: effect Filename: temperat.pal + ShadowIndex: 4 PaletteFromRGBA@shadow: Name: shadow R: 0 diff --git a/mods/d2k/cursors.yaml b/mods/d2k/cursors.yaml index eda2e1e1dc..51cc2e42ab 100644 --- a/mods/d2k/cursors.yaml +++ b/mods/d2k/cursors.yaml @@ -1,4 +1,4 @@ -Transparent: +ShadowIndex: 1 Palettes: cursor: cursor.pal diff --git a/mods/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index 0a190450dd..15eb594d82 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -73,15 +73,19 @@ World: ValidGround: Sand, Dune, Rock PaletteFromCurrentTileset: Name: terrain + ShadowIndex: 1 PaletteFromFile@d2k: Name: d2k Filename: d2k.pal + ShadowIndex: 1 PaletteFromFile@chrome: Name: chrome Filename: d2k.pal + ShadowIndex: 3 PaletteFromFile@effect: Name: effect Filename: temperat.pal + ShadowIndex: 4 PaletteFromRGBA@shadow: Name: shadow R: 0 diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index acc46c8213..349a0a6653 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -210,12 +210,15 @@ World: WaterChance: .2 PaletteFromCurrentTileset: Name: terrain + ShadowIndex: 4 PaletteFromFile@chrome: Name: chrome Filename: temperat.pal + ShadowIndex: 3 PaletteFromFile@effect: Name: effect Filename: temperat.pal + ShadowIndex: 4 PaletteFromRGBA@shadow: Name: shadow R: 0