Merge pull request #3818 from pchote/palette-fix

Player color / highlight palette fix
This commit is contained in:
Matthias Mailänder
2013-09-07 04:09:44 -07:00
7 changed files with 52 additions and 7 deletions

View File

@@ -181,7 +181,6 @@
<Compile Include="Traits\ValidateOrder.cs" />
<Compile Include="Traits\Waypoint.cs" />
<Compile Include="Traits\World\Country.cs" />
<Compile Include="Traits\World\PlayerColorPalette.cs" />
<Compile Include="Traits\World\ResourceLayer.cs" />
<Compile Include="Traits\World\ResourceType.cs" />
<Compile Include="Traits\World\ScreenShaker.cs" />
@@ -237,6 +236,8 @@
<Compile Include="Widgets\ViewportControllerWidget.cs" />
<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

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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,
@@ -22,7 +22,7 @@ namespace OpenRA.Traits
[Desc("The prefix for the resulting player palettes")]
public readonly string BaseName = "player";
[Desc("Remap these indices to player colors.")]
public readonly int[] RemapIndex = {};
public readonly int[] RemapIndex = { };
[Desc("Luminosity range to span.")]
public readonly float Ramp = 0.05f;
[Desc("Allow palette modifiers to change the palette.")]
@@ -45,10 +45,7 @@ namespace OpenRA.Traits
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);
wr.AddPalette(info.BaseName + owner.InternalName, new Palette(wr.Palette(info.BasePalette).Palette, remap), info.AllowModifiers);
}
}
}

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: