public void LoadPlayerPalettes(WorldRenderer wr, string playerName, HSLColor color, bool replaceExisting) { var remap = new PlayerColorRemap(info.RemapIndex, color, info.Ramp); var pal = new ImmutablePalette(wr.Palette(info.BasePalette).Palette, remap); wr.AddPalette(info.BaseName + playerName, pal, info.AllowModifiers, replaceExisting); }
public static void RemapShp(string[] args) { var remap = new Dictionary <int, int>(); /* the first 4 entries are fixed */ for (var i = 0; i < 4; i++) { remap[i] = i; } var srcMod = args[1].Split(':')[0]; Game.modData = new ModData(srcMod); FileSystem.LoadFromManifest(Game.modData.Manifest); Rules.LoadRules(Game.modData.Manifest, new Map()); var srcPaletteInfo = Rules.Info["player"].Traits.Get <PlayerColorPaletteInfo>(); int[] srcRemapIndex = srcPaletteInfo.RemapIndex; var destMod = args[2].Split(':')[0]; Game.modData = new ModData(destMod); FileSystem.LoadFromManifest(Game.modData.Manifest); Rules.LoadRules(Game.modData.Manifest, new Map()); 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], ShadowIndex); var destPalette = Palette.Load(args[2].Split(':')[1], ShadowIndex); var fullIndexRange = Exts.MakeArray <int>(256, x => x); for (var i = 0; i < 256; i++) { if (!remap.ContainsKey(i)) { remap[i] = fullIndexRange .Where(a => !remap.ContainsValue(a)) .OrderBy(a => ColorDistance(destPalette.Values[a], srcPalette.Values[i])) .First(); } } var srcImage = ShpReader.Load(args[3]); 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())); }
ColorPalette GetPaletteForPlayerInner(string name) { var pr = Map.Players[name]; var pcpi = Rules.Info["player"].Traits.Get <PlayerColorPaletteInfo>(); var remap = new PlayerColorRemap(pcpi.RemapIndex, pr.ColorRamp); return(new Palette(Palette, remap).AsSystemPalette()); }
ColorPalette GetPaletteForPlayerInner(string name) { var pr = Map.Players[name]; var pcpi = Program.Rules.Actors["player"].Traits.Get <PlayerColorPaletteInfo>(); var remap = new PlayerColorRemap(pcpi.RemapIndex, pr.Color, pcpi.Ramp); return(new ImmutablePalette(PlayerPalette, remap).AsSystemPalette()); }
void ILoadsPalettes.LoadPalettes(WorldRenderer wr) { color = colorManager.Color; var(_, h, s, _) = color.ToAhsv(); var remap = new PlayerColorRemap(info.RemapIndex, h, s); wr.AddPalette(info.Name, new ImmutablePalette(wr.Palette(info.BasePalette).Palette, remap), info.AllowModifiers); }
public void LoadPalettes(WorldRenderer wr) { var(_, h, s, _) = info.Color.ToAhsv(); var remap = new PlayerColorRemap(info.RemapIndex, h, s); wr.AddPalette(info.Name, new ImmutablePalette(wr.Palette(info.Base).Palette, remap), info.AllowModifiers); }
public void Run(ModData modData, string[] args) { var remap = new Dictionary <int, int>(); /* the first 4 entries are fixed */ for (var i = 0; i < 4; i++) { remap[i] = i; } var srcMod = args[1].Split(':')[0]; Game.ModData = new ModData(srcMod); GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest); var srcRules = Game.ModData.RulesetCache.Load(); var srcPaletteInfo = srcRules.Actors["player"].Traits.Get <PlayerColorPaletteInfo>(); var srcRemapIndex = srcPaletteInfo.RemapIndex; var destMod = args[2].Split(':')[0]; Game.ModData = new ModData(destMod); GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest); var destRules = Game.ModData.RulesetCache.Load(); var destPaletteInfo = destRules.Actors["player"].Traits.Get <PlayerColorPaletteInfo>(); var destRemapIndex = destPaletteInfo.RemapIndex; var shadowIndex = new int[] { }; // 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 = new ImmutablePalette(args[1].Split(':')[1], shadowIndex); var destPalette = new ImmutablePalette(args[2].Split(':')[1], shadowIndex); for (var i = 0; i < Palette.Size; i++) { if (!remap.ContainsKey(i)) { remap[i] = Enumerable.Range(0, Palette.Size) .Where(a => !remap.ContainsValue(a)) .MinBy(a => ColorDistance(destPalette[a], srcPalette[i])); } } using (var s = File.OpenRead(args[3])) using (var destStream = File.Create(args[4])) { var srcImage = new ShpTDSprite(s); ShpTDSprite.Write(destStream, srcImage.Size, srcImage.Frames.Select(im => im.Data.Select(px => (byte)remap[px]).ToArray())); } }
public void InitPalette(WorldRenderer wr) { var remap = new PlayerColorRemap(info.RemapIndex, owner.Color, info.Ramp); wr.AddPalette(info.BaseName + owner.InternalName, new Palette(wr.Palette(info.BasePalette).Palette, remap), info.AllowModifiers); var argb = (uint)Color.FromArgb(128, owner.Color.RGB).ToArgb(); wr.AddPalette("highlight" + owner.InternalName, new Palette(Exts.MakeArray(256, i => i == 0 ? 0 : argb)), false); }
void ITickRender.TickRender(WorldRenderer wr, Actor self) { if (color == colorManager.Color) { return; } color = colorManager.Color; var(_, h, s, _) = color.ToAhsv(); var remap = new PlayerColorRemap(info.RemapIndex, h, s); wr.ReplacePalette(info.Name, new ImmutablePalette(wr.Palette(info.BasePalette).Palette, remap)); }
public static void RemapShp(string[] args) { var remap = new Dictionary <int, int>(); /* the first 4 entries are fixed */ 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]); /* 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); } /* 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++) { if (!remap.ContainsKey(i)) { remap[i] = fullIndexRange .Where(a => !remap.ContainsValue(a)) .OrderBy(a => ColorDistance(destPalette.Values[a], srcPalette.Values[i])) .First(); } } var srcImage = ShpReader.Load(args[3]); 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())); }
public void LoadPalettes(WorldRenderer wr) { var remap = new PlayerColorRemap(info.RemapIndex, owner.Color, info.Ramp); wr.AddPalette(info.BaseName + owner.InternalName, new ImmutablePalette(wr.Palette(info.BasePalette).Palette, remap), info.AllowModifiers); }
public static Color ChooseColor(Actor self) { var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0)); return(PlayerColorRemap.ColorLerp(0.5f, ownerColor, Color.White)); }
public void InitPalette(WorldRenderer wr) { var remap = new PlayerColorRemap(info.RemapIndex, info.Color, info.Ramp); wr.AddPalette(info.Name, new Palette(wr.Palette(info.Base).Palette, remap), info.AllowModifiers); }
public void InitPalette(WorldRenderer wr) { var remap = new PlayerColorRemap(info.RemapIndex, info.Color, info.Ramp); wr.AddPalette(info.Name, new Palette(wr.Palette(info.Base).Palette, remap), info.AllowModifiers); }