Split highlight and player palettes. Fixes #3799.

This commit is contained in:
Paul Chote
2013-09-07 20:58:17 +12:00
parent 75ae34b9fe
commit dca59f12f7
7 changed files with 48 additions and 3 deletions

View File

@@ -237,6 +237,7 @@
<Compile Include="Traits\Player\FrozenActorLayer.cs" />
<Compile Include="Graphics\Theater.cs" />
<Compile Include="Traits\Player\PlayerColorPalette.cs" />
<Compile Include="Traits\Player\PlayerHighlightPalette.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -46,9 +46,6 @@ namespace OpenRA.Traits
{
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);
}
}
}

View File

@@ -0,0 +1,43 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.Graphics;
namespace OpenRA.Traits
{
[Desc("Add this to the Player actor definition.")]
public class PlayerHighlightPaletteInfo : ITraitInfo
{
[Desc("The prefix for the resulting player palettes")]
public readonly string BaseName = "highlight";
public object Create(ActorInitializer init) { return new PlayerHighlightPalette(init.self.Owner, this); }
}
public class PlayerHighlightPalette : IPalette
{
readonly Player owner;
readonly PlayerHighlightPaletteInfo info;
public PlayerHighlightPalette(Player owner, PlayerHighlightPaletteInfo info)
{
this.owner = owner;
this.info = info;
}
public void InitPalette(WorldRenderer wr)
{
var argb = (uint)Color.FromArgb(128, owner.Color.RGB).ToArgb();
wr.AddPalette(info.BaseName + owner.InternalName, new Palette(Exts.MakeArray(256, i => i == 0 ? 0 : argb)), false);
}
}
}

View File

@@ -199,6 +199,7 @@ Player:
PlayerColorPalette:
BasePalette: terrain
RemapIndex: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190
PlayerHighlightPalette:
BaseAttackNotifier:
Shroud:
PlayerStatistics:

View File

@@ -349,6 +349,7 @@ Player:
PlayerColorPalette:
BasePalette: d2k
RemapIndex: 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240
PlayerHighlightPalette:
BaseAttackNotifier:
Shroud:
FrozenActorLayer:

View File

@@ -521,6 +521,7 @@ Player:
PlayerColorPalette:
BasePalette: player
RemapIndex: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
PlayerHighlightPalette:
GpsWatcher:
Shroud:
FrozenActorLayer:

View File

@@ -35,6 +35,7 @@ Player:
PlayerColorPalette:
BasePalette: player
RemapIndex: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
PlayerHighlightPalette:
GpsWatcher:
Shroud:
BaseAttackNotifier: