Fix palettes and all palettemods. Remap palettes broken.
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -31,22 +33,27 @@ namespace OpenRA.Mods.RA
|
||||
remainingFrames--;
|
||||
}
|
||||
|
||||
public void AdjustPalette(Bitmap b)
|
||||
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
||||
{
|
||||
if (remainingFrames == 0)
|
||||
return;
|
||||
|
||||
var frac = (float)remainingFrames / chronoEffectLength;
|
||||
|
||||
// TODO: Fix me to only affect "world" palettes
|
||||
for( var y = 0; y < b.Height; y++ )
|
||||
System.Console.WriteLine("{0}",frac);
|
||||
var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker"};
|
||||
foreach (var pal in palettes)
|
||||
{
|
||||
if (excludePalettes.Contains(pal.Key))
|
||||
continue;
|
||||
|
||||
for (var x = 0; x < 256; x++)
|
||||
{
|
||||
var orig = b.GetPixel(x, y);
|
||||
var orig = pal.Value.GetColor(x);
|
||||
var lum = (int)(255 * orig.GetBrightness());
|
||||
var desat = Color.FromArgb(orig.A, lum, lum, lum);
|
||||
b.SetPixel(x, y, OpenRA.Graphics.Util.Lerp(frac, orig, desat));
|
||||
pal.Value.SetColor(x, OpenRA.Graphics.Util.Lerp(frac, orig, desat));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Traits;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -21,16 +23,21 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
t += .5f;
|
||||
}
|
||||
|
||||
public void AdjustPalette(Bitmap b)
|
||||
|
||||
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
||||
{
|
||||
var rotate = (int)t % 18;
|
||||
if (rotate > 9)
|
||||
rotate = 18 - rotate;
|
||||
|
||||
using (var bitmapCopy = new Bitmap(b))
|
||||
for (int j = 0; j < b.Height; j++)
|
||||
b.SetPixel(0x67, j, b.GetPixel(230+rotate, j));
|
||||
var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker"};
|
||||
foreach (var pal in palettes)
|
||||
{
|
||||
if (excludePalettes.Contains(pal.Key))
|
||||
continue;
|
||||
|
||||
var rotate = (int)t % 18;
|
||||
if (rotate > 9)
|
||||
rotate = 18 - rotate;
|
||||
|
||||
pal.Value.SetColor(0x67, pal.Value.GetColor(230+rotate));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Traits;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -31,21 +33,26 @@ namespace OpenRA.Mods.RA
|
||||
remainingFrames--;
|
||||
}
|
||||
|
||||
public void AdjustPalette(Bitmap b)
|
||||
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
||||
{
|
||||
if (remainingFrames == 0)
|
||||
return;
|
||||
|
||||
var frac = (float)remainingFrames / nukeEffectLength;
|
||||
|
||||
// TODO: Fix me to only affect "world" palettes
|
||||
for( var y = 0; y < b.Height; y++ )
|
||||
for (var x = 0; x < 256; x++)
|
||||
{
|
||||
var orig = b.GetPixel(x, y);
|
||||
var white = Color.FromArgb(orig.A, 255, 255, 255);
|
||||
b.SetPixel(x, y, OpenRA.Graphics.Util.Lerp(frac, orig, white));
|
||||
}
|
||||
|
||||
var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker"};
|
||||
foreach (var pal in palettes)
|
||||
{
|
||||
if (excludePalettes.Contains(pal.Key))
|
||||
continue;
|
||||
|
||||
for (var x = 0; x < 256; x++)
|
||||
{
|
||||
var orig = pal.Value.GetColor(x);
|
||||
var white = Color.FromArgb(orig.A, 255, 255, 255);
|
||||
pal.Value.SetColor(x, OpenRA.Graphics.Util.Lerp(frac,orig,white));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Traits;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -33,18 +35,24 @@ namespace OpenRA.Mods.RA
|
||||
t += .25f;
|
||||
}
|
||||
|
||||
public void AdjustPalette(Bitmap b)
|
||||
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
||||
{
|
||||
var rotate = (int)t % 7;
|
||||
using (var bitmapCopy = new Bitmap(b))
|
||||
for (int j = 0; j < b.Height; j++)
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
if (cncmode)
|
||||
b.SetPixel(0x20 + (rotate + i) % 7, j, bitmapCopy.GetPixel(0x20 + i, j));
|
||||
else
|
||||
b.SetPixel(0x60 + (rotate + i) % 7, j, bitmapCopy.GetPixel(0x60 + i, j));
|
||||
}
|
||||
var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker"};
|
||||
foreach (var pal in palettes)
|
||||
{
|
||||
if (excludePalettes.Contains(pal.Key))
|
||||
continue;
|
||||
|
||||
var copy = (uint[])pal.Value.Values.Clone();
|
||||
var rotate = (int)t % 7;
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
if (cncmode)
|
||||
pal.Value.SetColor(0x20 + (rotate + i) % 7, copy[0x20 + i]);
|
||||
else
|
||||
pal.Value.SetColor(0x60 + (rotate + i) % 7, copy[0x60 + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user