@@ -14,40 +14,34 @@ 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;
|
||||
|
||||
static readonly int[] CncRemapRamp = new[] { 0, 2, 4, 6, 8, 10, 13, 15, 1, 3, 5, 7, 9, 11, 12, 14 };
|
||||
static readonly int[] NormalRemapRamp = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
|
||||
static int GetRemapBase(PaletteFormat fmt)
|
||||
static int[] GetRemapRamp(int[] Ramp)
|
||||
{
|
||||
return (fmt == PaletteFormat.cnc) ? 0xb0 : (fmt == PaletteFormat.d2k) ? 240 : 80;
|
||||
int[] RemapRamp = new int[Ramp.Length];
|
||||
for (var i=0; i < Ramp.Length; i++)
|
||||
RemapRamp[i] = Ramp[i] - Ramp[0];
|
||||
|
||||
return RemapRamp;
|
||||
}
|
||||
|
||||
static int[] GetRemapRamp(PaletteFormat fmt)
|
||||
public static int GetRemapIndex(int[] Ramp, int i)
|
||||
{
|
||||
return (fmt == PaletteFormat.cnc) ? CncRemapRamp : NormalRemapRamp;
|
||||
return Ramp[i];
|
||||
}
|
||||
|
||||
public static int GetRemapIndex(PaletteFormat fmt, int i)
|
||||
{
|
||||
return GetRemapBase(fmt) + GetRemapRamp(fmt)[i];
|
||||
}
|
||||
|
||||
public PlayerColorRemap(PaletteFormat fmt, ColorRamp c)
|
||||
public PlayerColorRemap(int[] Ramp, ColorRamp c)
|
||||
{
|
||||
var c1 = c.GetColor(0);
|
||||
var c2 = c.GetColor(1); /* temptemp: this can be expressed better */
|
||||
|
||||
var baseIndex = GetRemapBase(fmt);
|
||||
var ramp = GetRemapRamp(fmt);
|
||||
var baseIndex = Ramp[0];
|
||||
var RemapRamp = GetRemapRamp(Ramp);
|
||||
|
||||
remapColors = ramp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / 16f, c1, c2)))
|
||||
remapColors = RemapRamp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / 16f, c1, c2)))
|
||||
.ToDictionary(u => u.First, u => u.Second);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public readonly string BasePalette = null;
|
||||
public readonly string BaseName = "player";
|
||||
public readonly PaletteFormat PaletteFormat = PaletteFormat.ra;
|
||||
public readonly int[] RemapIndex = new[] {};
|
||||
|
||||
public object Create( ActorInitializer init ) { return new PlayerColorPalette( init.self.Owner, this ); }
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
var paletteName = "{0}{1}".F( info.BaseName, owner.InternalName );
|
||||
var newpal = new Palette(wr.GetPalette(info.BasePalette),
|
||||
new PlayerColorRemap(info.PaletteFormat, owner.ColorRamp));
|
||||
new PlayerColorRemap(info.RemapIndex, owner.ColorRamp));
|
||||
wr.AddPalette(paletteName, newpal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
|
||||
public class ColorPickerPaletteModifier : IPalette, IPaletteModifier
|
||||
{
|
||||
ColorPickerPaletteModifierInfo Info;
|
||||
PaletteFormat format;
|
||||
int[] index;
|
||||
public ColorRamp Ramp;
|
||||
|
||||
public ColorPickerPaletteModifier(ColorPickerPaletteModifierInfo info) { Info = info; }
|
||||
@@ -34,14 +34,14 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()
|
||||
.First(p => p.BaseName == Info.PlayerPalette);
|
||||
format = info.PaletteFormat;
|
||||
index = info.RemapIndex;
|
||||
wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette));
|
||||
}
|
||||
|
||||
public void AdjustPalette(Dictionary<string, Palette> palettes)
|
||||
{
|
||||
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
||||
new PlayerColorRemap(format, Ramp));
|
||||
new PlayerColorRemap(index, Ramp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,24 +368,25 @@ namespace OpenRA.Utility
|
||||
var remap = new Dictionary<int,int>();
|
||||
|
||||
/* the first 4 entries are fixed */
|
||||
for( var i = 0; i < 4; i++ )
|
||||
for (var i = 0; i < 4; i++)
|
||||
remap[i] = i;
|
||||
|
||||
var srcPaletteType = Enum<PaletteFormat>.Parse(args[1].Split(':')[0]);
|
||||
var destPaletteType = Enum<PaletteFormat>.Parse(args[2].Split(':')[0]);
|
||||
// TODO: should read that from mods/*/system.yaml
|
||||
var srcRemapIndex = Enum<int[]>.Parse(args[1].Split(':')[0]);
|
||||
var destRemapIndex = Enum<int[]>.Parse(args[2].Split(':')[0]);
|
||||
|
||||
/* the remap range is always 16 entries, but their location and order changes */
|
||||
for( var i = 0; i < 16; i++ )
|
||||
remap[ PlayerColorRemap.GetRemapIndex(srcPaletteType, i) ]
|
||||
= PlayerColorRemap.GetRemapIndex(destPaletteType, i);
|
||||
// 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 */
|
||||
// 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 fullIndexRange = Exts.MakeArray<int>(256, x => x);
|
||||
|
||||
for( var i = 0; i < 256; i++ )
|
||||
for (var i = 0; i < 256; i++)
|
||||
if (!remap.ContainsKey(i))
|
||||
remap[i] = fullIndexRange
|
||||
.Where(a => !remap.ContainsValue(a))
|
||||
@@ -394,7 +395,7 @@ namespace OpenRA.Utility
|
||||
|
||||
var srcImage = ShpReader.Load(args[3]);
|
||||
|
||||
using( var destStream = File.Create(args[4]) )
|
||||
using (var destStream = File.Create(args[4]))
|
||||
ShpWriter.Write(destStream, srcImage.Width, srcImage.Height,
|
||||
srcImage.Frames.Select( im => im.Image.Select(px => (byte)remap[px]).ToArray() ));
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Utility
|
||||
Console.WriteLine(" --png SHPFILE PALETTE [--transparent] Convert a SHP to a PNG containing all of its frames, optionally setting up transparency");
|
||||
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(" --remap SRCREMAPINDEX:PAL DESTREMAPINDEX: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(" --transpose SRCSHP DESTSHP START N M [START N M ...] Transpose the N*M block of frames starting at START.");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ Player:
|
||||
orca: 5%
|
||||
PlayerColorPalette:
|
||||
BasePalette: terrain
|
||||
PaletteFormat: cnc
|
||||
RemapIndex: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190
|
||||
BaseAttackNotifier:
|
||||
|
||||
World:
|
||||
|
||||
@@ -101,7 +101,7 @@ Player:
|
||||
SquadSize: 10
|
||||
PlayerColorPalette:
|
||||
BasePalette: d2k
|
||||
PaletteFormat: d2k
|
||||
RemapIndex: 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
|
||||
BaseAttackNotifier:
|
||||
Audio: AI_ATACK.AUD
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ Player:
|
||||
SquadSize: 7
|
||||
PlayerColorPalette:
|
||||
BasePalette: terrain
|
||||
RemapIndex: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
|
||||
DebugResourceCash:
|
||||
DebugResourceOre:
|
||||
DebugResourceOreCapacity:
|
||||
|
||||
Reference in New Issue
Block a user