made palette shadowindex configurable
This commit is contained in:
committed by
Chris Forbes
parent
007b2c5434
commit
c75c72b525
@@ -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<PlayerColorPaletteInfo>();
|
||||
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<int>(256, x => x);
|
||||
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user