@@ -14,40 +14,34 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace OpenRA.FileFormats
|
namespace OpenRA.FileFormats
|
||||||
{
|
{
|
||||||
// TODO: ship this out of here.
|
|
||||||
public enum PaletteFormat { ra, cnc, d2k }
|
|
||||||
|
|
||||||
public class PlayerColorRemap : IPaletteRemap
|
public class PlayerColorRemap : IPaletteRemap
|
||||||
{
|
{
|
||||||
Dictionary<int, Color> remapColors;
|
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 int[] GetRemapRamp(int[] Ramp)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
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)
|
public PlayerColorRemap(int[] Ramp, ColorRamp c)
|
||||||
{
|
|
||||||
return GetRemapBase(fmt) + GetRemapRamp(fmt)[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerColorRemap(PaletteFormat fmt, ColorRamp c)
|
|
||||||
{
|
{
|
||||||
var c1 = c.GetColor(0);
|
var c1 = c.GetColor(0);
|
||||||
var c2 = c.GetColor(1); /* temptemp: this can be expressed better */
|
var c2 = c.GetColor(1); /* temptemp: this can be expressed better */
|
||||||
|
|
||||||
var baseIndex = GetRemapBase(fmt);
|
var baseIndex = Ramp[0];
|
||||||
var ramp = GetRemapRamp(fmt);
|
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);
|
.ToDictionary(u => u.First, u => u.Second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public readonly string BasePalette = null;
|
public readonly string BasePalette = null;
|
||||||
public readonly string BaseName = "player";
|
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 ); }
|
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 paletteName = "{0}{1}".F( info.BaseName, owner.InternalName );
|
||||||
var newpal = new Palette(wr.GetPalette(info.BasePalette),
|
var newpal = new Palette(wr.GetPalette(info.BasePalette),
|
||||||
new PlayerColorRemap(info.PaletteFormat, owner.ColorRamp));
|
new PlayerColorRemap(info.RemapIndex, owner.ColorRamp));
|
||||||
wr.AddPalette(paletteName, newpal);
|
wr.AddPalette(paletteName, newpal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public class ColorPickerPaletteModifier : IPalette, IPaletteModifier
|
public class ColorPickerPaletteModifier : IPalette, IPaletteModifier
|
||||||
{
|
{
|
||||||
ColorPickerPaletteModifierInfo Info;
|
ColorPickerPaletteModifierInfo Info;
|
||||||
PaletteFormat format;
|
int[] index;
|
||||||
public ColorRamp Ramp;
|
public ColorRamp Ramp;
|
||||||
|
|
||||||
public ColorPickerPaletteModifier(ColorPickerPaletteModifierInfo info) { Info = info; }
|
public ColorPickerPaletteModifier(ColorPickerPaletteModifierInfo info) { Info = info; }
|
||||||
@@ -34,14 +34,14 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()
|
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()
|
||||||
.First(p => p.BaseName == Info.PlayerPalette);
|
.First(p => p.BaseName == Info.PlayerPalette);
|
||||||
format = info.PaletteFormat;
|
index = info.RemapIndex;
|
||||||
wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette));
|
wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AdjustPalette(Dictionary<string, Palette> palettes)
|
public void AdjustPalette(Dictionary<string, Palette> palettes)
|
||||||
{
|
{
|
||||||
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
||||||
new PlayerColorRemap(format, Ramp));
|
new PlayerColorRemap(index, Ramp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,15 +371,16 @@ namespace OpenRA.Utility
|
|||||||
for (var i = 0; i < 4; i++)
|
for (var i = 0; i < 4; i++)
|
||||||
remap[i] = i;
|
remap[i] = i;
|
||||||
|
|
||||||
var srcPaletteType = Enum<PaletteFormat>.Parse(args[1].Split(':')[0]);
|
// TODO: should read that from mods/*/system.yaml
|
||||||
var destPaletteType = Enum<PaletteFormat>.Parse(args[2].Split(':')[0]);
|
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 */
|
// the remap range is always 16 entries, but their location and order changes
|
||||||
for (var i = 0; i < 16; i++)
|
for (var i = 0; i < 16; i++)
|
||||||
remap[ PlayerColorRemap.GetRemapIndex(srcPaletteType, i) ]
|
remap[PlayerColorRemap.GetRemapIndex(srcRemapIndex, i)]
|
||||||
= PlayerColorRemap.GetRemapIndex(destPaletteType, 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 srcPalette = Palette.Load(args[1].Split(':')[1], false);
|
||||||
var destPalette = Palette.Load(args[2].Split(':')[1], false);
|
var destPalette = Palette.Load(args[2].Split(':')[1], false);
|
||||||
|
|
||||||
|
|||||||
@@ -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(" --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(" --extract MOD[,MOD]* FILES Extract files from mod packages");
|
||||||
Console.WriteLine(" --tmp-png MOD[,MOD]* THEATER FILES Extract terrain tiles to PNG");
|
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(" --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.");
|
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%
|
orca: 5%
|
||||||
PlayerColorPalette:
|
PlayerColorPalette:
|
||||||
BasePalette: terrain
|
BasePalette: terrain
|
||||||
PaletteFormat: cnc
|
RemapIndex: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190
|
||||||
BaseAttackNotifier:
|
BaseAttackNotifier:
|
||||||
|
|
||||||
World:
|
World:
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ Player:
|
|||||||
SquadSize: 10
|
SquadSize: 10
|
||||||
PlayerColorPalette:
|
PlayerColorPalette:
|
||||||
BasePalette: d2k
|
BasePalette: d2k
|
||||||
PaletteFormat: d2k
|
RemapIndex: 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
|
||||||
BaseAttackNotifier:
|
BaseAttackNotifier:
|
||||||
Audio: AI_ATACK.AUD
|
Audio: AI_ATACK.AUD
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ Player:
|
|||||||
SquadSize: 7
|
SquadSize: 7
|
||||||
PlayerColorPalette:
|
PlayerColorPalette:
|
||||||
BasePalette: terrain
|
BasePalette: terrain
|
||||||
|
RemapIndex: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
|
||||||
DebugResourceCash:
|
DebugResourceCash:
|
||||||
DebugResourceOre:
|
DebugResourceOre:
|
||||||
DebugResourceOreCapacity:
|
DebugResourceOreCapacity:
|
||||||
|
|||||||
Reference in New Issue
Block a user