Merge branch 'master' of git://github.com/chrisforbes/OpenRA

This commit is contained in:
Paul Chote
2010-01-07 23:23:23 +13:00
7 changed files with 68 additions and 20 deletions

View File

@@ -60,10 +60,11 @@
<Compile Include="PackageEntry.cs" /> <Compile Include="PackageEntry.cs" />
<Compile Include="Package.cs" /> <Compile Include="Package.cs" />
<Compile Include="Palette.cs" /> <Compile Include="Palette.cs" />
<Compile Include="PaletteRemap.cs" /> <Compile Include="PlayerColorRemap.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShpReader.cs" /> <Compile Include="ShpReader.cs" />
<Compile Include="ShroudPaletteRemap.cs" /> <Compile Include="ShroudPaletteRemap.cs" />
<Compile Include="SingleColorRemap.cs" />
<Compile Include="Terrain.cs" /> <Compile Include="Terrain.cs" />
<Compile Include="TileReference.cs" /> <Compile Include="TileReference.cs" />
<Compile Include="TileSet.cs" /> <Compile Include="TileSet.cs" />

View File

@@ -4,13 +4,12 @@ using System.IO;
namespace OpenRa.FileFormats namespace OpenRa.FileFormats
{ {
public class PaletteRemap : IPaletteRemap public class PlayerColorRemap : IPaletteRemap
{ {
int offset; int offset;
List<Color> remapColors = new List<Color>(); List<Color> remapColors = new List<Color>();
Color shadowColor;
public PaletteRemap(Stream s) public PlayerColorRemap(Stream s)
{ {
using (BinaryReader reader = new BinaryReader(s)) using (BinaryReader reader = new BinaryReader(s))
{ {
@@ -27,22 +26,12 @@ namespace OpenRa.FileFormats
offset = 80; offset = 80;
} }
public PaletteRemap( Color shadowColor )
{
this.shadowColor = shadowColor;
}
public Color GetRemappedColor(Color original, int index) public Color GetRemappedColor(Color original, int index)
{ {
if (remapColors.Count > 0) if (index < offset || index >= offset + remapColors.Count)
{ return original;
if (index < offset || index >= offset + remapColors.Count)
return original;
return remapColors[index - offset]; return remapColors[index - offset];
}
return original.A > 0 ? shadowColor : original;
} }
} }
} }

View File

@@ -0,0 +1,18 @@
using System.Drawing;
namespace OpenRa.FileFormats
{
public class SingleColorRemap : IPaletteRemap
{
Color c;
public SingleColorRemap(Color c)
{
this.c = c;
}
public Color GetRemappedColor(Color original, int index)
{
return original.A > 0 ? c : original;
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.Traits;
using OpenRa.Game.Graphics;
namespace OpenRa.Game.Effects
{
class FlashTarget : IEffect
{
Actor target;
int remainingTicks = 4;
public FlashTarget(Actor target)
{
this.target = target;
foreach (var e in Game.world.Effects.OfType<FlashTarget>().Where(a => a.target == target).ToArray())
Game.world.Remove(e);
}
public void Tick()
{
if (--remainingTicks == 0)
Game.world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()
{
if (remainingTicks % 2 == 0)
foreach (var r in target.Render())
yield return r.WithPalette(PaletteType.Highlight);
}
}
}

View File

@@ -6,7 +6,7 @@ namespace OpenRa.Game.Graphics
public enum PaletteType public enum PaletteType
{ {
Gold, Blue, Red, Orange, Teal, Salmon, Green, Gray, Gold, Blue, Red, Orange, Teal, Salmon, Green, Gray,
Shadow, Invuln, Chrome, Shroud, Shadow, Invuln, Chrome, Shroud, Highlight,
}; };
class HardwarePalette : Sheet class HardwarePalette : Sheet
@@ -21,12 +21,13 @@ namespace OpenRa.Game.Graphics
AddPalette(pal); AddPalette(pal);
foreach (string remap in new string[] { "blue", "red", "orange", "teal", "salmon", "green", "gray" }) foreach (string remap in new string[] { "blue", "red", "orange", "teal", "salmon", "green", "gray" })
AddPalette(new Palette(pal, new PaletteRemap(FileSystem.Open(remap + ".rem")))); AddPalette(new Palette(pal, new PlayerColorRemap(FileSystem.Open(remap + ".rem"))));
AddPalette(new Palette(pal, new PaletteRemap(Color.FromArgb(140, 0, 0, 0)))); AddPalette(new Palette(pal, new SingleColorRemap(Color.FromArgb(140, 0, 0, 0))));
AddPalette(pal); // iron curtain. todo: remap! AddPalette(pal); // iron curtain. todo: remap!
AddPalette(pal); // chrome (it's like gold, but we're not going to hax it in palettemods) AddPalette(pal); // chrome (it's like gold, but we're not going to hax it in palettemods)
AddPalette(new Palette(pal, new ShroudPaletteRemap())); AddPalette(new Palette(pal, new ShroudPaletteRemap()));
AddPalette(new Palette(pal, new SingleColorRemap(Color.FromArgb(128, 255, 255, 255))));
} }
int AddPalette(Palette p) int AddPalette(Palette p)

View File

@@ -82,6 +82,7 @@
<Compile Include="Combat.cs" /> <Compile Include="Combat.cs" />
<Compile Include="Effects\Corpse.cs" /> <Compile Include="Effects\Corpse.cs" />
<Compile Include="Effects\DelayedAction.cs" /> <Compile Include="Effects\DelayedAction.cs" />
<Compile Include="Effects\FlashTarget.cs" />
<Compile Include="Effects\MoveFlash.cs" /> <Compile Include="Effects\MoveFlash.cs" />
<Compile Include="Effects\RepairIndicator.cs" /> <Compile Include="Effects\RepairIndicator.cs" />
<Compile Include="Effects\Smoke.cs" /> <Compile Include="Effects\Smoke.cs" />

View File

@@ -155,6 +155,9 @@ namespace OpenRa.Game.Traits
{ {
self.CancelActivity(); self.CancelActivity();
QueueAttack(self, order); QueueAttack(self, order);
if (self.Owner == Game.LocalPlayer)
Game.world.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
} }
else else
target = null; target = null;