Replace ColorRamp with HSLColor everywhere.
Fixes: * Nuclear-purple color exploit. * #3247. * Removes a bunch of unnecessary color conversions every frame. Caveats: * The ramp range is now defined on the palette, so ramps can no longer be set per-player (may impact maps which define custom colors). * It's no longer possible to perfectly recreate the original WW color ramps (I doubt we care). * The old ColorRamp setting isn't migrated, so players will lose their color settings.
This commit is contained in:
@@ -558,7 +558,7 @@ namespace OpenRA.Editor
|
|||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var color = player.ColorRamp.GetColor(0);
|
var color = player.Color.RGB;
|
||||||
using( var brush = new SolidBrush(color) )
|
using( var brush = new SolidBrush(color) )
|
||||||
e.Graphics.FillRectangle( brush, e.Bounds.Left + 2, e.Bounds.Top + 2, e.Bounds.Height + 6, e.Bounds.Height - 4 );
|
e.Graphics.FillRectangle( brush, e.Bounds.Left + 2, e.Bounds.Top + 2, e.Bounds.Height + 6, e.Bounds.Height - 4 );
|
||||||
using( var foreBrush = new SolidBrush(e.ForeColor) )
|
using( var foreBrush = new SolidBrush(e.ForeColor) )
|
||||||
|
|||||||
@@ -83,18 +83,18 @@ namespace OpenRA.Editor
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: fix this -- will have bitrotted pretty badly.
|
// TODO: fix this -- will have bitrotted pretty badly.
|
||||||
static Dictionary<string,Pair<Color,Color>> namedColorMapping = new Dictionary<string, Pair<Color, Color>>()
|
static Dictionary<string, HSLColor> namedColorMapping = new Dictionary<string, HSLColor>()
|
||||||
{
|
{
|
||||||
{"gold",Pair.New(Color.FromArgb(246,214,121),Color.FromArgb(40,32,8))},
|
{ "gold", HSLColor.FromRGB(246,214,121) },
|
||||||
{"blue",Pair.New(Color.FromArgb(226,230,246),Color.FromArgb(8,20,52))},
|
{ "blue", HSLColor.FromRGB(226,230,246) },
|
||||||
{"red",Pair.New(Color.FromArgb(255,20,0),Color.FromArgb(56,0,0))},
|
{ "red", HSLColor.FromRGB(255,20,0) },
|
||||||
{"neutral",Pair.New(Color.FromArgb(238,238,238),Color.FromArgb(44,28,24))},
|
{ "neutral", HSLColor.FromRGB(238,238,238) },
|
||||||
{"orange",Pair.New(Color.FromArgb(255,230,149),Color.FromArgb(56,0,0))},
|
{ "orange", HSLColor.FromRGB(255,230,149) },
|
||||||
{"teal",Pair.New(Color.FromArgb(93,194,165),Color.FromArgb(0,32,32))},
|
{ "teal", HSLColor.FromRGB(93,194,165) },
|
||||||
{"salmon",Pair.New(Color.FromArgb(210,153,125),Color.FromArgb(56,0,0))},
|
{ "salmon", HSLColor.FromRGB(210,153,125) },
|
||||||
{"green",Pair.New(Color.FromArgb(160,240,140),Color.FromArgb(20,20,20))},
|
{ "green", HSLColor.FromRGB(160,240,140) },
|
||||||
{"white",Pair.New(Color.FromArgb(255,255,255),Color.FromArgb(75,75,75))},
|
{ "white", HSLColor.FromRGB(255,255,255) },
|
||||||
{"black",Pair.New(Color.FromArgb(80,80,80),Color.FromArgb(5,5,5))},
|
{ "black", HSLColor.FromRGB(80,80,80) },
|
||||||
};
|
};
|
||||||
|
|
||||||
int MapSize;
|
int MapSize;
|
||||||
@@ -460,19 +460,13 @@ namespace OpenRA.Editor
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var color = namedColorMapping[c];
|
|
||||||
|
|
||||||
var pr = new PlayerReference
|
var pr = new PlayerReference
|
||||||
{
|
{
|
||||||
Name = section,
|
Name = section,
|
||||||
OwnsWorld = section == "Neutral",
|
OwnsWorld = section == "Neutral",
|
||||||
NonCombatant = section == "Neutral",
|
NonCombatant = section == "Neutral",
|
||||||
Race = race,
|
Race = race,
|
||||||
ColorRamp = new ColorRamp(
|
Color = namedColorMapping[c]
|
||||||
(byte)((color.First.GetHue() / 360.0f) * 255),
|
|
||||||
(byte)(color.First.GetSaturation() * 255),
|
|
||||||
(byte)(color.First.GetBrightness() * 255),
|
|
||||||
(byte)(color.Second.GetBrightness() * 255))
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var neutral = new [] {"Neutral"};
|
var neutral = new [] {"Neutral"};
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
var pr = Map.Players[name];
|
var pr = Map.Players[name];
|
||||||
var pcpi = Rules.Info["player"].Traits.Get<PlayerColorPaletteInfo>();
|
var pcpi = Rules.Info["player"].Traits.Get<PlayerColorPaletteInfo>();
|
||||||
var remap = new PlayerColorRemap(pcpi.RemapIndex, pr.ColorRamp);
|
var remap = new PlayerColorRemap(pcpi.RemapIndex, pr.Color, pcpi.Ramp);
|
||||||
return new Palette(PlayerPalette, remap).AsSystemPalette();
|
return new Palette(PlayerPalette, remap).AsSystemPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 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;
|
|
||||||
|
|
||||||
namespace OpenRA.FileFormats
|
|
||||||
{
|
|
||||||
public struct ColorRamp
|
|
||||||
{
|
|
||||||
public readonly HSLColor Color;
|
|
||||||
public byte Ramp;
|
|
||||||
|
|
||||||
public ColorRamp(HSLColor color, byte ramp)
|
|
||||||
{
|
|
||||||
Color = color;
|
|
||||||
Ramp = ramp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ColorRamp(byte h, byte s, byte l, byte r)
|
|
||||||
{
|
|
||||||
Color = new HSLColor(h, s, l);
|
|
||||||
Ramp = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* returns a color along the Lum ramp */
|
|
||||||
public Color GetColor(float t)
|
|
||||||
{
|
|
||||||
var l = float2.Lerp(Color.L, Color.L*Ramp/255f, t);
|
|
||||||
return HSLColor.RGBFromHSL(Color.H/255f, Color.S/255f, l/255f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return "{0},{1}".F(Color.ToString(), Ramp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(ColorRamp me, ColorRamp other)
|
|
||||||
{
|
|
||||||
return (me.Color == other.Color && me.Ramp == other.Ramp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(ColorRamp me, ColorRamp other) { return !(me == other); }
|
|
||||||
|
|
||||||
public override int GetHashCode() { return Color.GetHashCode() ^ Ramp.GetHashCode(); }
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ColorRamp o = (ColorRamp)obj;
|
|
||||||
return o == this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -148,15 +148,15 @@ namespace OpenRA.FileFormats
|
|||||||
return InvalidValueAction(x,fieldType, field);
|
return InvalidValueAction(x,fieldType, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (fieldType == typeof(ColorRamp))
|
else if (fieldType == typeof(HSLColor))
|
||||||
{
|
{
|
||||||
var parts = x.Split(',');
|
var parts = x.Split(',');
|
||||||
if (parts.Length == 4)
|
// Allow old ColorRamp format to be parsed as HSLColor
|
||||||
return new ColorRamp(
|
if (parts.Length == 3 || parts.Length == 4)
|
||||||
|
return new HSLColor(
|
||||||
(byte)int.Parse(parts[0]).Clamp(0, 255),
|
(byte)int.Parse(parts[0]).Clamp(0, 255),
|
||||||
(byte)int.Parse(parts[1]).Clamp(0, 255),
|
(byte)int.Parse(parts[1]).Clamp(0, 255),
|
||||||
(byte)int.Parse(parts[2]).Clamp(0, 255),
|
(byte)int.Parse(parts[2]).Clamp(0, 255));
|
||||||
(byte)int.Parse(parts[3]).Clamp(0, 255));
|
|
||||||
|
|
||||||
return InvalidValueAction(x, fieldType, field);
|
return InvalidValueAction(x, fieldType, field);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,17 +17,14 @@ namespace OpenRA.FileFormats
|
|||||||
public readonly byte H;
|
public readonly byte H;
|
||||||
public readonly byte S;
|
public readonly byte S;
|
||||||
public readonly byte L;
|
public readonly byte L;
|
||||||
|
public readonly Color RGB;
|
||||||
|
|
||||||
public HSLColor(byte h, byte s, byte l)
|
public HSLColor(byte h, byte s, byte l)
|
||||||
{
|
{
|
||||||
H = h;
|
H = h;
|
||||||
S = s;
|
S = s;
|
||||||
L = l;
|
L = l;
|
||||||
}
|
RGB = RGBFromHSL(H / 255f, S / 255f, L / 255f);
|
||||||
|
|
||||||
public Color ToColor()
|
|
||||||
{
|
|
||||||
return RGBFromHSL(H / 255f, S / 255f, L / 255f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToHSV(out float h, out float s, out float v)
|
public void ToHSV(out float h, out float s, out float v)
|
||||||
@@ -47,6 +44,15 @@ namespace OpenRA.FileFormats
|
|||||||
return new HSLColor((byte)(255*h), (byte)(255*ss), (byte)(255*ll));
|
return new HSLColor((byte)(255*h), (byte)(255*ss), (byte)(255*ll));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HSLColor FromRGB(int r, int g, int b)
|
||||||
|
{
|
||||||
|
var c = Color.FromArgb(r, g, b);
|
||||||
|
var h = (byte)((c.GetHue() / 360.0f) * 255);
|
||||||
|
var s = (byte)(c.GetSaturation() * 255);
|
||||||
|
var l = (byte)(c.GetBrightness() * 255);
|
||||||
|
return new HSLColor(h, s, l);
|
||||||
|
}
|
||||||
|
|
||||||
public static Color RGBFromHSL(float h, float s, float l)
|
public static Color RGBFromHSL(float h, float s, float l)
|
||||||
{
|
{
|
||||||
// Convert from HSL to RGB
|
// Convert from HSL to RGB
|
||||||
|
|||||||
@@ -28,8 +28,10 @@ namespace OpenRA.FileFormats
|
|||||||
public bool LockRace = false;
|
public bool LockRace = false;
|
||||||
public string Race;
|
public string Race;
|
||||||
|
|
||||||
|
// ColorRamp naming retained for backward compatibility
|
||||||
public bool LockColor = false;
|
public bool LockColor = false;
|
||||||
public ColorRamp ColorRamp = new ColorRamp(0,0,238,34);
|
public HSLColor ColorRamp = new HSLColor(0,0,238);
|
||||||
|
public HSLColor Color { get { return ColorRamp; } set { ColorRamp = value; }}
|
||||||
|
|
||||||
public bool LockSpawn = false;
|
public bool LockSpawn = false;
|
||||||
public int Spawn = 0;
|
public int Spawn = 0;
|
||||||
|
|||||||
@@ -77,7 +77,6 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="ColorRamp.cs" />
|
|
||||||
<Compile Include="Evaluator.cs" />
|
<Compile Include="Evaluator.cs" />
|
||||||
<Compile Include="Exts.cs" />
|
<Compile Include="Exts.cs" />
|
||||||
<Compile Include="FieldLoader.cs" />
|
<Compile Include="FieldLoader.cs" />
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -24,18 +25,19 @@ namespace OpenRA.FileFormats
|
|||||||
return Ramp[i];
|
return Ramp[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerColorRemap(int[] Ramp, ColorRamp c)
|
public PlayerColorRemap(int[] Ramp, HSLColor c, float rampFraction)
|
||||||
{
|
{
|
||||||
var c1 = c.GetColor(0);
|
// Increase luminosity if required to represent the full ramp
|
||||||
var c2 = c.GetColor(1); // temptemp: this can be expressed better
|
var rampRange = (byte)((1 - rampFraction)*c.L);
|
||||||
|
var c1 = new HSLColor(c.H, c.S, (byte)Math.Max(rampRange, c.L)).RGB;
|
||||||
|
var c2 = new HSLColor(c.H, c.S, (byte)Math.Max(0, c.L - rampRange)).RGB;
|
||||||
var baseIndex = Ramp[0];
|
var baseIndex = Ramp[0];
|
||||||
var RemapRamp = Ramp.Select(r => r - Ramp[0]).ToArray();
|
var RemapRamp = Ramp.Select(r => r - Ramp[0]).ToArray();
|
||||||
|
|
||||||
if (Ramp[0] > Ramp[15]) // reversed remapping
|
if (Ramp[0] > Ramp[15]) // reversed remapping
|
||||||
{
|
{
|
||||||
baseIndex = Ramp[15];
|
baseIndex = Ramp[15];
|
||||||
for (int i=15; i>0; i--)
|
for (var i = 15; i > 0; i--)
|
||||||
RemapRamp = Ramp.Select(r => r - Ramp[15]).ToArray();
|
RemapRamp = Ramp.Select(r => r - Ramp[15]).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ namespace OpenRA.GameRules
|
|||||||
public class PlayerSettings
|
public class PlayerSettings
|
||||||
{
|
{
|
||||||
public string Name = "Newbie";
|
public string Name = "Newbie";
|
||||||
public ColorRamp ColorRamp = new ColorRamp(75, 255, 180, 25);
|
public HSLColor Color = new HSLColor(75, 255, 180);
|
||||||
public string LastServer = "localhost:1234";
|
public string LastServer = "localhost:1234";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ namespace OpenRA.Network
|
|||||||
public class Client
|
public class Client
|
||||||
{
|
{
|
||||||
public int Index;
|
public int Index;
|
||||||
public ColorRamp PreferredColorRamp; // Color that the client normally uses from settings.yaml.
|
public HSLColor PreferredColor; // Color that the client normally uses from settings.yaml.
|
||||||
public ColorRamp ColorRamp; // Actual color that the client is using.
|
public HSLColor Color; // Actual color that the client is using.
|
||||||
// Usually the same as PreferredColorRamp but can be different on maps with locked colors.
|
// Usually the same as PreferredColor but can be different on maps with locked colors.
|
||||||
public string Country;
|
public string Country;
|
||||||
public int SpawnPoint;
|
public int SpawnPoint;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Network
|
|||||||
var player = world != null ? world.FindPlayerByClient(client) : null;
|
var player = world != null ? world.FindPlayerByClient(client) : null;
|
||||||
var suffix = (player != null && player.WinState == WinState.Lost) ? " (Dead)" : "";
|
var suffix = (player != null && player.WinState == WinState.Lost) ? " (Dead)" : "";
|
||||||
suffix = client.IsObserver ? " (Spectator)" : suffix;
|
suffix = client.IsObserver ? " (Spectator)" : suffix;
|
||||||
Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + suffix, order.TargetString);
|
Game.AddChatLine(client.Color.RGB, client.Name + suffix, order.TargetString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Game.AddChatLine(Color.White, "(player {0})".F(clientId), order.TargetString);
|
Game.AddChatLine(Color.White, "(player {0})".F(clientId), order.TargetString);
|
||||||
@@ -71,7 +71,7 @@ namespace OpenRA.Network
|
|||||||
if (world == null)
|
if (world == null)
|
||||||
{
|
{
|
||||||
if (orderManager.LocalClient != null && client.Team == orderManager.LocalClient.Team)
|
if (orderManager.LocalClient != null && client.Team == orderManager.LocalClient.Team)
|
||||||
Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + " (Team)",
|
Game.AddChatLine(client.Color.RGB, client.Name + " (Team)",
|
||||||
order.TargetString);
|
order.TargetString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -82,7 +82,7 @@ namespace OpenRA.Network
|
|||||||
if (world.LocalPlayer != null && player.Stances[world.LocalPlayer] == Stance.Ally || player.WinState == WinState.Lost)
|
if (world.LocalPlayer != null && player.Stances[world.LocalPlayer] == Stance.Ally || player.WinState == WinState.Lost)
|
||||||
{
|
{
|
||||||
var suffix = player.WinState == WinState.Lost ? " (Dead)" : " (Team)";
|
var suffix = player.WinState == WinState.Lost ? " (Dead)" : " (Team)";
|
||||||
Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + suffix, order.TargetString);
|
Game.AddChatLine(client.Color.RGB, client.Name + suffix, order.TargetString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,8 +133,8 @@ namespace OpenRA.Network
|
|||||||
var info = new Session.Client()
|
var info = new Session.Client()
|
||||||
{
|
{
|
||||||
Name = Game.Settings.Player.Name,
|
Name = Game.Settings.Player.Name,
|
||||||
PreferredColorRamp = Game.Settings.Player.ColorRamp,
|
PreferredColor = Game.Settings.Player.Color,
|
||||||
ColorRamp = Game.Settings.Player.ColorRamp,
|
Color = Game.Settings.Player.Color,
|
||||||
Country = "random",
|
Country = "random",
|
||||||
SpawnPoint = 0,
|
SpawnPoint = 0,
|
||||||
Team = 0,
|
Team = 0,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA
|
|||||||
public int Deaths;
|
public int Deaths;
|
||||||
public WinState WinState = WinState.Undefined;
|
public WinState WinState = WinState.Undefined;
|
||||||
|
|
||||||
public readonly ColorRamp ColorRamp;
|
public readonly HSLColor Color;
|
||||||
|
|
||||||
public readonly string PlayerName;
|
public readonly string PlayerName;
|
||||||
public readonly string InternalName;
|
public readonly string InternalName;
|
||||||
@@ -60,7 +60,7 @@ namespace OpenRA
|
|||||||
if (client != null)
|
if (client != null)
|
||||||
{
|
{
|
||||||
ClientIndex = client.Index;
|
ClientIndex = client.Index;
|
||||||
ColorRamp = client.ColorRamp;
|
Color = client.Color;
|
||||||
PlayerName = client.Name;
|
PlayerName = client.Name;
|
||||||
botType = client.Bot;
|
botType = client.Bot;
|
||||||
Country = ChooseCountry(world, client.Country);
|
Country = ChooseCountry(world, client.Country);
|
||||||
@@ -69,7 +69,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
// Map player
|
// Map player
|
||||||
ClientIndex = 0; // Owned by the host (TODO: fix this)
|
ClientIndex = 0; // Owned by the host (TODO: fix this)
|
||||||
ColorRamp = pr.ColorRamp;
|
Color = pr.Color;
|
||||||
PlayerName = pr.Name;
|
PlayerName = pr.Name;
|
||||||
NonCombatant = pr.NonCombatant;
|
NonCombatant = pr.NonCombatant;
|
||||||
botType = pr.Bot;
|
botType = pr.Bot;
|
||||||
|
|||||||
@@ -337,9 +337,9 @@ namespace OpenRA.Server
|
|||||||
if (pr == null)
|
if (pr == null)
|
||||||
return;
|
return;
|
||||||
if (pr.LockColor)
|
if (pr.LockColor)
|
||||||
c.ColorRamp = pr.ColorRamp;
|
c.Color = pr.Color;
|
||||||
else
|
else
|
||||||
c.ColorRamp = c.PreferredColorRamp;
|
c.Color = c.PreferredColor;
|
||||||
if (pr.LockRace)
|
if (pr.LockRace)
|
||||||
c.Country = pr.Race;
|
c.Country = pr.Race;
|
||||||
if (pr.LockSpawn)
|
if (pr.LockSpawn)
|
||||||
|
|||||||
@@ -16,15 +16,18 @@ namespace OpenRA.Traits
|
|||||||
[Desc("Add this to the Player actor definition.")]
|
[Desc("Add this to the Player actor definition.")]
|
||||||
public class PlayerColorPaletteInfo : ITraitInfo
|
public class PlayerColorPaletteInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
[Desc("The Name of the palette to base off.")]
|
[Desc("The name of the palette to base off.")]
|
||||||
public readonly string BasePalette = null;
|
public readonly string BasePalette = null;
|
||||||
[Desc("The prefix for the resulting player palettes")]
|
[Desc("The prefix for the resulting player palettes")]
|
||||||
public readonly string BaseName = "player";
|
public readonly string BaseName = "player";
|
||||||
[Desc("Remap these indices to player colors.")]
|
[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.")]
|
||||||
public readonly bool AllowModifiers = true;
|
public readonly bool AllowModifiers = true;
|
||||||
|
|
||||||
public object Create( ActorInitializer init ) { return new PlayerColorPalette( init.self.Owner, this ); }
|
public object Create(ActorInitializer init) { return new PlayerColorPalette(init.self.Owner, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerColorPalette : IPalette
|
public class PlayerColorPalette : IPalette
|
||||||
@@ -32,18 +35,16 @@ namespace OpenRA.Traits
|
|||||||
readonly Player owner;
|
readonly Player owner;
|
||||||
readonly PlayerColorPaletteInfo info;
|
readonly PlayerColorPaletteInfo info;
|
||||||
|
|
||||||
public PlayerColorPalette( Player owner, PlayerColorPaletteInfo info )
|
public PlayerColorPalette(Player owner, PlayerColorPaletteInfo info)
|
||||||
{
|
{
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPalette( WorldRenderer wr )
|
public void InitPalette(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var paletteName = "{0}{1}".F( info.BaseName, owner.InternalName );
|
var remap = new PlayerColorRemap(info.RemapIndex, owner.Color, info.Ramp);
|
||||||
var newpal = new Palette(wr.Palette(info.BasePalette).Palette,
|
wr.AddPalette(info.BaseName+owner.InternalName, new Palette(wr.Palette(info.BasePalette).Palette, remap), info.AllowModifiers);
|
||||||
new PlayerColorRemap(info.RemapIndex, owner.ColorRamp));
|
|
||||||
wr.AddPalette(paletteName, newpal, info.AllowModifiers);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace OpenRA.Widgets
|
|||||||
TooltipSpawnIndex = -1;
|
TooltipSpawnIndex = -1;
|
||||||
if (ShowSpawnPoints)
|
if (ShowSpawnPoints)
|
||||||
{
|
{
|
||||||
var colors = SpawnClients().ToDictionary(c => c.Key, c => c.Value.ColorRamp.GetColor(0));
|
var colors = SpawnClients().ToDictionary(c => c.Key, c => c.Value.Color.RGB);
|
||||||
|
|
||||||
var spawnPoints = map.GetSpawnPoints().ToList();
|
var spawnPoints = map.GetSpawnPoints().ToList();
|
||||||
foreach (var p in spawnPoints)
|
foreach (var p in spawnPoints)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
var item = itemTemplate.Clone();
|
var item = itemTemplate.Clone();
|
||||||
var nameLabel = item.Get<LabelWidget>("NAME");
|
var nameLabel = item.Get<LabelWidget>("NAME");
|
||||||
nameLabel.GetText = () => pp.WinState == WinState.Lost ? pp.PlayerName + " (Dead)" : pp.PlayerName;
|
nameLabel.GetText = () => pp.WinState == WinState.Lost ? pp.PlayerName + " (Dead)" : pp.PlayerName;
|
||||||
nameLabel.GetColor = () => pp.ColorRamp.GetColor(0);
|
nameLabel.GetColor = () => pp.Color.RGB;
|
||||||
|
|
||||||
var flag = item.Get<ImageWidget>("FACTIONFLAG");
|
var flag = item.Get<ImageWidget>("FACTIONFLAG");
|
||||||
flag.GetImageName = () => pp.Country.Race;
|
flag.GetImageName = () => pp.Country.Race;
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
nameTextfield.Text = playerSettings.Name;
|
nameTextfield.Text = playerSettings.Name;
|
||||||
|
|
||||||
colorPreview = panel.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
|
colorPreview = panel.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
|
||||||
colorPreview.Ramp = playerSettings.ColorRamp;
|
colorPreview.Color = playerSettings.Color;
|
||||||
|
|
||||||
var colorDropdown = generalPane.Get<DropDownButtonWidget>("COLOR");
|
var colorDropdown = generalPane.Get<DropDownButtonWidget>("COLOR");
|
||||||
colorDropdown.OnMouseDown = _ => ShowColorPicker(colorDropdown, playerSettings);
|
colorDropdown.OnMouseDown = _ => ShowColorPicker(colorDropdown, playerSettings);
|
||||||
colorDropdown.Get<ColorBlockWidget>("COLORBLOCK").GetColor = () => playerSettings.ColorRamp.GetColor(0);
|
colorDropdown.Get<ColorBlockWidget>("COLORBLOCK").GetColor = () => playerSettings.Color.RGB;
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
var perftextCheckbox = generalPane.Get<CheckboxWidget>("PERFTEXT_CHECKBOX");
|
var perftextCheckbox = generalPane.Get<CheckboxWidget>("PERFTEXT_CHECKBOX");
|
||||||
@@ -155,17 +155,21 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
bool ShowColorPicker(DropDownButtonWidget color, PlayerSettings s)
|
bool ShowColorPicker(DropDownButtonWidget color, PlayerSettings s)
|
||||||
{
|
{
|
||||||
Action<ColorRamp> onExit = c => {s.ColorRamp = c; color.RemovePanel();};
|
Action<HSLColor> onChange = c => colorPreview.Color = c;
|
||||||
Action<ColorRamp> onChange = c => {colorPreview.Ramp = c;};
|
Action onExit = () =>
|
||||||
|
{
|
||||||
|
s.Color = colorPreview.Color;
|
||||||
|
color.RemovePanel();
|
||||||
|
};
|
||||||
|
|
||||||
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
|
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onExit", onExit },
|
{ "onExit", onExit },
|
||||||
{ "onChange", onChange },
|
{ "onChange", onChange },
|
||||||
{ "initialRamp", s.ColorRamp }
|
{ "initialColor", s.Color }
|
||||||
});
|
});
|
||||||
|
|
||||||
color.AttachPanel(colorChooser);
|
color.AttachPanel(colorChooser, onExit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
{
|
{
|
||||||
flagRace = o.Country.Race;
|
flagRace = o.Country.Race;
|
||||||
ownerName = o.PlayerName;
|
ownerName = o.PlayerName;
|
||||||
ownerColor = o.ColorRamp.GetColor(0);
|
ownerColor = o.Color.RGB;
|
||||||
widget.Bounds.Height = doubleHeight;
|
widget.Bounds.Height = doubleHeight;
|
||||||
widget.Bounds.Width = Math.Max(widget.Bounds.Width,
|
widget.Bounds.Width = Math.Max(widget.Bounds.Width,
|
||||||
owner.Bounds.X + ownerFont.Measure(ownerName).X + 5);
|
owner.Bounds.X + ownerFont.Measure(ownerName).X + 5);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
self.Destroy();
|
self.Destroy();
|
||||||
|
|
||||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||||
self.World.AddFrameEndTask(w => w.Add(new CashTick(payload, 30, 2, target.CenterLocation, targetPlayer.ColorRamp.GetColor(0))));
|
self.World.AddFrameEndTask(w => w.Add(new CashTick(payload, 30, 2, target.CenterLocation, targetPlayer.Color.RGB)));
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
ns.Sold(self);
|
ns.Sold(self);
|
||||||
|
|
||||||
if (refund > 0 && self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
|
if (refund > 0 && self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
|
||||||
self.World.AddFrameEndTask(
|
self.World.AddFrameEndTask(w => w.Add(new CashTick(refund, 30, 2, self.CenterLocation, self.Owner.Color.RGB)));
|
||||||
w => w.Add(new CashTick(refund, 30, 2,
|
|
||||||
self.CenterLocation,
|
|
||||||
self.Owner.ColorRamp.GetColor(0))));
|
|
||||||
|
|
||||||
self.Destroy();
|
self.Destroy();
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (mod != null)
|
if (mod != null)
|
||||||
return mod.RadarColorOverride(self);
|
return mod.RadarColorOverride(self);
|
||||||
|
|
||||||
return self.Owner.ColorRamp.GetColor(0);
|
return self.Owner.Color.RGB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA
|
|||||||
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(Info.Amount);
|
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(Info.Amount);
|
||||||
ticks = Info.Period;
|
ticks = Info.Period;
|
||||||
if (Info.ShowTicks)
|
if (Info.ShowTicks)
|
||||||
self.World.AddFrameEndTask(w => w.Add(new CashTick(Info.Amount, Info.TickLifetime, Info.TickVelocity, self.CenterLocation, self.Owner.ColorRamp.GetColor(0))));
|
self.World.AddFrameEndTask(w => w.Add(new CashTick(Info.Amount, Info.TickLifetime, Info.TickVelocity, self.CenterLocation, self.Owner.Color.RGB)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public Color RadarColorOverride(Actor self)
|
public Color RadarColorOverride(Actor self)
|
||||||
{
|
{
|
||||||
var c = self.Owner.ColorRamp.GetColor(0);
|
var c = self.Owner.Color.RGB;
|
||||||
if (self.Owner == self.World.LocalPlayer && Cloaked)
|
if (self.Owner == self.World.LocalPlayer && Cloaked)
|
||||||
c = Color.FromArgb(128, c);
|
c = Color.FromArgb(128, c);
|
||||||
return c;
|
return c;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA
|
|||||||
collector.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(amount);
|
collector.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(amount);
|
||||||
|
|
||||||
if ((info as GiveCashCrateActionInfo).UseCashTick)
|
if ((info as GiveCashCrateActionInfo).UseCashTick)
|
||||||
w.Add(new CashTick(amount, 20, 1, collector.CenterLocation, collector.Owner.ColorRamp.GetColor(0)));
|
w.Add(new CashTick(amount, 20, 1, collector.CenterLocation, collector.Owner.Color.RGB));
|
||||||
});
|
});
|
||||||
|
|
||||||
base.Activate(collector);
|
base.Activate(collector);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public static Color ChooseColor(Actor self)
|
public static Color ChooseColor(Actor self)
|
||||||
{
|
{
|
||||||
var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0));
|
var ownerColor = Color.FromArgb(255, self.Owner.Color.RGB);
|
||||||
return Exts.ColorLerp(0.5f, ownerColor, Color.White);
|
return Exts.ColorLerp(0.5f, ownerColor, Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
|
|
||||||
public IEffect Create(ProjectileArgs args)
|
public IEffect Create(ProjectileArgs args)
|
||||||
{
|
{
|
||||||
var c = UsePlayerColor ? args.firedBy.Owner.ColorRamp.GetColor(0) : Color;
|
var c = UsePlayerColor ? args.firedBy.Owner.Color.RGB : Color;
|
||||||
return new LaserZap(args, this, c);
|
return new LaserZap(args, this, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA
|
|||||||
var bounty = cost * GetMultiplier(self) * info.Percentage / 10000;
|
var bounty = cost * GetMultiplier(self) * info.Percentage / 10000;
|
||||||
|
|
||||||
if (bounty > 0 && e.Attacker.World.LocalPlayer != null && e.Attacker.Owner.Stances[e.Attacker.World.LocalPlayer] == Stance.Ally)
|
if (bounty > 0 && e.Attacker.World.LocalPlayer != null && e.Attacker.Owner.Stances[e.Attacker.World.LocalPlayer] == Stance.Ally)
|
||||||
e.Attacker.World.AddFrameEndTask(w => w.Add(new CashTick(bounty, 20, 1, self.CenterLocation, e.Attacker.Owner.ColorRamp.GetColor(0))));
|
e.Attacker.World.AddFrameEndTask(w => w.Add(new CashTick(bounty, 20, 1, self.CenterLocation, e.Attacker.Owner.Color.RGB)));
|
||||||
|
|
||||||
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(bounty);
|
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(bounty);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
|
|||||||
Sound.PlayToPlayer(self.Owner, info.SoundToVictim);
|
Sound.PlayToPlayer(self.Owner, info.SoundToVictim);
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w => w.Add(new CashTick(toGive, 30, 2, self.CenterLocation,
|
self.World.AddFrameEndTask(w => w.Add(new CashTick(toGive, 30, 2, self.CenterLocation,
|
||||||
infiltrator.Owner.ColorRamp.GetColor(0))));
|
infiltrator.Owner.Color.RGB)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var temp = currentDisplayValue;
|
var temp = currentDisplayValue;
|
||||||
if (self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
|
if (self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
|
||||||
self.World.AddFrameEndTask(w => w.Add(new CashTick(temp, Info.TickLifetime, Info.TickVelocity, self.CenterLocation, self.Owner.ColorRamp.GetColor(0))));
|
self.World.AddFrameEndTask(w => w.Add(new CashTick(temp, Info.TickLifetime, Info.TickVelocity, self.CenterLocation, self.Owner.Color.RGB)));
|
||||||
currentDisplayTick = Info.TickRate;
|
currentDisplayTick = Info.TickRate;
|
||||||
currentDisplayValue = 0;
|
currentDisplayValue = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
var hue = (byte)server.Random.Next(255);
|
var hue = (byte)server.Random.Next(255);
|
||||||
var sat = (byte)server.Random.Next(255);
|
var sat = (byte)server.Random.Next(255);
|
||||||
var lum = (byte)server.Random.Next(51,255);
|
var lum = (byte)server.Random.Next(51,255);
|
||||||
bot.ColorRamp = bot.PreferredColorRamp = new ColorRamp(hue, sat, lum, 10);
|
bot.Color = bot.PreferredColor = new HSLColor(hue, sat, lum);
|
||||||
|
|
||||||
server.lobbyInfo.Clients.Add(bot);
|
server.lobbyInfo.Clients.Add(bot);
|
||||||
}
|
}
|
||||||
@@ -520,7 +520,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
var ci = parts[1].Split(',').Select(cc => int.Parse(cc)).ToArray();
|
var ci = parts[1].Split(',').Select(cc => int.Parse(cc)).ToArray();
|
||||||
targetClient.ColorRamp = targetClient.PreferredColorRamp = new ColorRamp((byte)ci[0], (byte)ci[1], (byte)ci[2], (byte)ci[3]);
|
targetClient.Color = targetClient.PreferredColor = new HSLColor((byte)ci[0], (byte)ci[1], (byte)ci[2]);
|
||||||
server.SyncLobbyInfo();
|
server.SyncLobbyInfo();
|
||||||
return true;
|
return true;
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -117,9 +117,9 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (!Disguised || self.World.LocalPlayer == null ||
|
if (!Disguised || self.World.LocalPlayer == null ||
|
||||||
self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
|
self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
|
||||||
return self.Owner.ColorRamp.GetColor(0);
|
return self.Owner.Color.RGB;
|
||||||
|
|
||||||
return disguisedAsPlayer.ColorRamp.GetColor(0);
|
return disguisedAsPlayer.Color.RGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisguiseAs(Actor target)
|
void DisguiseAs(Actor target)
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
// Generate palette in HSV
|
// Generate palette in HSV
|
||||||
for (var v = 0; v < 256; v++)
|
for (var v = 0; v < 256; v++)
|
||||||
for (var s = 0; s < 256; s++)
|
for (var s = 0; s < 256; s++)
|
||||||
*(c + (v * bitmapData.Stride >> 2) + s) = HSLColor.FromHSV(hue, s / 255f, (255 - v) / 255f).ToColor().ToArgb();
|
*(c + (v * bitmapData.Stride >> 2) + s) = HSLColor.FromHSV(hue, s / 255f, (255 - v) / 255f).RGB.ToArgb();
|
||||||
}
|
}
|
||||||
|
|
||||||
backBitmap.UnlockBits(bitmapData);
|
backBitmap.UnlockBits(bitmapData);
|
||||||
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
var sprite = ChromeProvider.GetImage("lobby-bits", "colorpicker");
|
var sprite = ChromeProvider.GetImage("lobby-bits", "colorpicker");
|
||||||
var pos = RenderOrigin + PxFromValue() - new int2(sprite.bounds.Width/2, sprite.bounds.Height/2);
|
var pos = RenderOrigin + PxFromValue() - new int2(sprite.bounds.Width/2, sprite.bounds.Height/2);
|
||||||
WidgetUtils.FillRectWithColor(new Rectangle(pos.X + 3, pos.Y + 3, 10, 10), Color.ToColor());
|
WidgetUtils.FillRectWithColor(new Rectangle(pos.X + 3, pos.Y + 3, 10, 10), Color.RGB);
|
||||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos);
|
Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,10 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
{
|
{
|
||||||
public readonly string Palette = "colorpicker";
|
public readonly string Palette = "colorpicker";
|
||||||
public readonly int[] RemapIndices = {};
|
public readonly int[] RemapIndices = {};
|
||||||
public ColorRamp Ramp;
|
public readonly float Ramp = 0.05f;
|
||||||
|
public HSLColor Color;
|
||||||
|
|
||||||
ColorRamp cachedRamp;
|
HSLColor cachedColor;
|
||||||
WorldRenderer worldRenderer;
|
WorldRenderer worldRenderer;
|
||||||
Palette preview;
|
Palette preview;
|
||||||
|
|
||||||
@@ -43,11 +44,11 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
if (cachedRamp == Ramp)
|
if (cachedColor == Color)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
preview.ApplyRemap(new PlayerColorRemap(RemapIndices, Ramp));
|
preview.ApplyRemap(new PlayerColorRemap(RemapIndices, Color, Ramp));
|
||||||
cachedRamp = Ramp;
|
cachedColor = Color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
{
|
{
|
||||||
int* c = (int*)bitmapData.Scan0;
|
int* c = (int*)bitmapData.Scan0;
|
||||||
for (var h = 0; h < 256; h++)
|
for (var h = 0; h < 256; h++)
|
||||||
*(c + h) = HSLColor.FromHSV(h/255f, 1, 1).ToColor().ToArgb();
|
*(c + h) = HSLColor.FromHSV(h/255f, 1, 1).RGB.ToArgb();
|
||||||
}
|
}
|
||||||
hueBitmap.UnlockBits(bitmapData);
|
hueBitmap.UnlockBits(bitmapData);
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
Text = p.PlayerName,
|
Text = p.PlayerName,
|
||||||
Align = TextAlign.Left,
|
Align = TextAlign.Left,
|
||||||
Font = "Bold",
|
Font = "Bold",
|
||||||
Color = p.ColorRamp.GetColor(0),
|
Color = p.Color.RGB,
|
||||||
};
|
};
|
||||||
|
|
||||||
bg.AddChild(label);
|
bg.AddChild(label);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
NonEditableSpectatorTemplate = Players.Get("TEMPLATE_NONEDITABLE_SPECTATOR");
|
NonEditableSpectatorTemplate = Players.Get("TEMPLATE_NONEDITABLE_SPECTATOR");
|
||||||
NewSpectatorTemplate = Players.Get("TEMPLATE_NEW_SPECTATOR");
|
NewSpectatorTemplate = Players.Get("TEMPLATE_NEW_SPECTATOR");
|
||||||
colorPreview = lobby.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
|
colorPreview = lobby.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
|
||||||
colorPreview.Ramp = Game.Settings.Player.ColorRamp;
|
colorPreview.Color = Game.Settings.Player.Color;
|
||||||
|
|
||||||
var mapPreview = lobby.Get<MapPreviewWidget>("MAP_PREVIEW");
|
var mapPreview = lobby.Get<MapPreviewWidget>("MAP_PREVIEW");
|
||||||
mapPreview.IsVisible = () => Map != null;
|
mapPreview.IsVisible = () => Map != null;
|
||||||
|
|||||||
@@ -107,20 +107,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
if (client.Bot == null)
|
if (client.Bot == null)
|
||||||
{
|
{
|
||||||
Game.Settings.Player.ColorRamp = preview.Ramp;
|
Game.Settings.Player.Color = preview.Color;
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
color.RemovePanel();
|
color.RemovePanel();
|
||||||
orderManager.IssueOrder(Order.Command("color {0} {1}".F(client.Index, preview.Ramp)));
|
orderManager.IssueOrder(Order.Command("color {0} {1}".F(client.Index, preview.Color)));
|
||||||
};
|
};
|
||||||
|
|
||||||
Action<HSLColor> onChange = c => preview.Ramp = new ColorRamp(c, 10);
|
Action<HSLColor> onChange = c => preview.Color = c;
|
||||||
|
|
||||||
var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", null, new WidgetArgs()
|
var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", null, new WidgetArgs()
|
||||||
{
|
{
|
||||||
{ "onChange", onChange },
|
{ "onChange", onChange },
|
||||||
{ "initialColor", client.ColorRamp.Color }
|
{ "initialColor", client.Color }
|
||||||
});
|
});
|
||||||
|
|
||||||
color.AttachPanel(colorChooser, onExit);
|
color.AttachPanel(colorChooser, onExit);
|
||||||
@@ -282,7 +282,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
public static void SetupColorWidget(Widget parent, Session.Slot s, Session.Client c)
|
public static void SetupColorWidget(Widget parent, Session.Slot s, Session.Client c)
|
||||||
{
|
{
|
||||||
var color = parent.Get<ColorBlockWidget>("COLORBLOCK");
|
var color = parent.Get<ColorBlockWidget>("COLORBLOCK");
|
||||||
color.GetColor = () => c.ColorRamp.GetColor(0);
|
color.GetColor = () => c.Color.RGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetupEditableFactionWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, Dictionary<string,string> countryNames)
|
public static void SetupEditableFactionWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, Dictionary<string,string> countryNames)
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
graph.GetSeries = () =>
|
graph.GetSeries = () =>
|
||||||
players.Select(p => new LineGraphSeries(
|
players.Select(p => new LineGraphSeries(
|
||||||
p.PlayerName,
|
p.PlayerName,
|
||||||
p.ColorRamp.GetColor(0),
|
p.Color.RGB,
|
||||||
(p.PlayerActor.TraitOrDefault<PlayerStatistics>() ?? new PlayerStatistics(p.PlayerActor)).EarnedSamples.Select(s => (float)s)
|
(p.PlayerActor.TraitOrDefault<PlayerStatistics>() ?? new PlayerStatistics(p.PlayerActor)).EarnedSamples.Select(s => (float)s)
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
var playerName = template.Get<LabelWidget>("PLAYER");
|
var playerName = template.Get<LabelWidget>("PLAYER");
|
||||||
playerName.GetText = () => player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")");
|
playerName.GetText = () => player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")");
|
||||||
playerName.GetColor = () => player.ColorRamp.GetColor(0);
|
playerName.GetColor = () => player.Color.RGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color GetPowerColor(PowerState state)
|
static Color GetPowerColor(PowerState state)
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
if (ownerText != "")
|
if (ownerText != "")
|
||||||
{
|
{
|
||||||
Game.Renderer.Fonts["Regular"].DrawText(ownerText,
|
Game.Renderer.Fonts["Regular"].DrawText(ownerText,
|
||||||
new float2(Viewport.LastMousePos.X + 65, Viewport.LastMousePos.Y + 50), actor.Owner.ColorRamp.GetColor(0));
|
new float2(Viewport.LastMousePos.X + 65, Viewport.LastMousePos.Y + 50), actor.Owner.Color.RGB);
|
||||||
|
|
||||||
Game.Renderer.Fonts["Regular"].DrawText(stanceText,
|
Game.Renderer.Fonts["Regular"].DrawText(stanceText,
|
||||||
new float2(Viewport.LastMousePos.X + 65 + ownerSize.X, Viewport.LastMousePos.Y + 50), Color.White);
|
new float2(Viewport.LastMousePos.X + 65 + ownerSize.X, Viewport.LastMousePos.Y + 50), Color.White);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
foreach (var pair in layers)
|
foreach (var pair in layers)
|
||||||
{
|
{
|
||||||
Color c = (pair.Key != null) ? pair.Key.ColorRamp.GetColor(0f) : Color.PaleTurquoise;
|
Color c = (pair.Key != null) ? pair.Key.Color.RGB : Color.PaleTurquoise;
|
||||||
var layer = pair.Value;
|
var layer = pair.Value;
|
||||||
|
|
||||||
for (int j = mapBounds.Top; j <= mapBounds.Bottom; ++j)
|
for (int j = mapBounds.Top; j <= mapBounds.Bottom; ++j)
|
||||||
|
|||||||
Reference in New Issue
Block a user