Remove HSLColor.
This commit is contained in:
@@ -134,7 +134,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var c = (int*)cc;
|
||||
for (var v = 0; v < 256; v++)
|
||||
for (var s = 0; s < 256; s++)
|
||||
*(c + (v * 256) + s) = HSLColor.FromHSV(hue, s / 255f, (255 - v) / 255f).RGB.ToArgb();
|
||||
*(c + (v * 256) + s) = Color.FromAhsv(hue, s / 255f, (255 - v) / 255f).ToArgb();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
var sprite = ChromeProvider.GetImage("lobby-bits", "colorpicker");
|
||||
var pos = RenderOrigin + PxFromValue() - new int2(sprite.Bounds.Width, sprite.Bounds.Height) / 2;
|
||||
WidgetUtils.FillEllipseWithColor(new Rectangle(pos.X + 1, pos.Y + 1, sprite.Bounds.Width - 2, sprite.Bounds.Height - 2), Color.RGB);
|
||||
WidgetUtils.FillEllipseWithColor(new Rectangle(pos.X + 1, pos.Y + 1, sprite.Bounds.Width - 2, sprite.Bounds.Height - 2), Color);
|
||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
public HSLColor Color { get { return HSLColor.FromHSV(H, S, V); } }
|
||||
public Color Color { get { return Color.FromAhsv(H, S, V); } }
|
||||
|
||||
public void Set(float hue)
|
||||
{
|
||||
@@ -233,10 +233,11 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
}
|
||||
}
|
||||
|
||||
public void Set(HSLColor color)
|
||||
public void Set(Color color)
|
||||
{
|
||||
float h, s, v;
|
||||
color.ToHSV(out h, out s, out v);
|
||||
int a;
|
||||
color.ToAhsv(out a, out h, out s, out v);
|
||||
|
||||
if (H != h || S != s || V != v)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets
|
||||
@@ -19,9 +20,9 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public readonly string PaletteName = "colorpicker";
|
||||
public readonly int[] RemapIndices = ChromeMetrics.Get<int[]>("ColorPickerRemapIndices");
|
||||
public readonly float Ramp = 0.05f;
|
||||
public HSLColor Color;
|
||||
public Color Color;
|
||||
|
||||
HSLColor cachedColor;
|
||||
Color cachedColor;
|
||||
WorldRenderer worldRenderer;
|
||||
IPalette preview;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
var hueData = new uint[1, 256];
|
||||
for (var x = 0; x < 256; x++)
|
||||
hueData[0, x] = (uint)HSLColor.FromHSV(x / 255f, 1, 1).RGB.ToArgb();
|
||||
hueData[0, x] = (uint)Color.FromAhsv(x / 255f, 1, 1).ToArgb();
|
||||
|
||||
hueSheet.GetTexture().SetData(hueData);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
colorDropdown.IsDisabled = () => currentPalette != colorPreview.PaletteName;
|
||||
colorDropdown.OnMouseDown = _ => ColorPickerLogic.ShowColorDropDown(colorDropdown, colorPreview, world);
|
||||
panel.Get<ColorBlockWidget>("COLORBLOCK").GetColor = () => Game.Settings.Player.Color.RGB;
|
||||
panel.Get<ColorBlockWidget>("COLORBLOCK").GetColor = () => Game.Settings.Player.Color;
|
||||
}
|
||||
|
||||
filenameInput = panel.Get<TextFieldWidget>("FILENAME_INPUT");
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
int paletteTabHighlighted = 0;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ColorPickerLogic(Widget widget, ModData modData, World world, HSLColor initialColor, string initialFaction, Action<HSLColor> onChange,
|
||||
public ColorPickerLogic(Widget widget, ModData modData, World world, Color initialColor, string initialFaction, Action<Color> onChange,
|
||||
Dictionary<string, MiniYaml> logicArgs)
|
||||
{
|
||||
string actorType;
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var sat = (byte)Game.CosmeticRandom.Next(70, 255);
|
||||
var lum = (byte)Game.CosmeticRandom.Next(70, 255);
|
||||
|
||||
mixer.Set(new HSLColor(hue, sat, lum));
|
||||
mixer.Set(Color.FromAhsl(hue, sat, lum));
|
||||
hueSlider.Value = hue / 255f;
|
||||
};
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
mixer.SetPaletteRange(validator.HsvSaturationRange[0], validator.HsvSaturationRange[1], validator.HsvValueRange[0], validator.HsvValueRange[1]);
|
||||
mixer.Set(initialColor);
|
||||
|
||||
hueSlider.Value = initialColor.H / 255f;
|
||||
hueSlider.Value = initialColor.GetHue() / 360f;
|
||||
onChange(mixer.Color);
|
||||
|
||||
// Setup tab controls
|
||||
@@ -117,10 +117,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
break;
|
||||
|
||||
var color = validator.TeamColorPresets[colorIndex];
|
||||
var rgbColor = color.RGB;
|
||||
|
||||
var newSwatch = (ColorBlockWidget)presetColorTemplate.Clone();
|
||||
newSwatch.GetColor = () => rgbColor;
|
||||
newSwatch.GetColor = () => color;
|
||||
newSwatch.IsVisible = () => true;
|
||||
newSwatch.Bounds.X = i * newSwatch.Bounds.Width;
|
||||
newSwatch.Bounds.Y = j * newSwatch.Bounds.Height;
|
||||
@@ -141,7 +140,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var colorIndex = j * paletteCols + i;
|
||||
|
||||
var newSwatch = (ColorBlockWidget)customColorTemplate.Clone();
|
||||
newSwatch.GetColor = () => Game.Settings.Player.CustomColors[colorIndex].RGB;
|
||||
newSwatch.GetColor = () => Game.Settings.Player.CustomColors[colorIndex];
|
||||
newSwatch.IsVisible = () => Game.Settings.Player.CustomColors.Length > colorIndex;
|
||||
newSwatch.Bounds.X = i * newSwatch.Bounds.Width;
|
||||
newSwatch.Bounds.Y = j * newSwatch.Bounds.Height;
|
||||
@@ -190,7 +189,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
color.RemovePanel();
|
||||
|
||||
Action<HSLColor> onChange = c => preview.Color = c;
|
||||
Action<Color> onChange = c => preview.Color = c;
|
||||
|
||||
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
|
||||
{
|
||||
|
||||
@@ -212,12 +212,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
});
|
||||
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Name;
|
||||
item.GetColor = () => option.Color.RGB;
|
||||
item.GetColor = () => option.Color;
|
||||
return item;
|
||||
};
|
||||
|
||||
ownerDropdown.GetText = () => selectedOwner.Name;
|
||||
ownerDropdown.GetColor = () => selectedOwner.Color.RGB;
|
||||
ownerDropdown.GetColor = () => selectedOwner.Color;
|
||||
ownerDropdown.OnClick = () =>
|
||||
{
|
||||
var owners = editorActorLayer.Players.Players.Values.OrderBy(p => p.Name);
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var item = ScrollItemWidget.Setup(template, () => selectedOwner == option, () => SelectOwner(option));
|
||||
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Name;
|
||||
item.GetColor = () => option.Color.RGB;
|
||||
item.GetColor = () => option.Color;
|
||||
|
||||
return item;
|
||||
};
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
};
|
||||
|
||||
ownersDropDown.Text = selectedOwner.Name;
|
||||
ownersDropDown.TextColor = selectedOwner.Color.RGB;
|
||||
ownersDropDown.TextColor = selectedOwner.Color;
|
||||
|
||||
var tileSetId = world.Map.Rules.TileSet.Id;
|
||||
var allActorsTemp = new List<ActorSelectorActor>();
|
||||
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
selectedOwner = option;
|
||||
ownersDropDown.Text = option.Name;
|
||||
ownersDropDown.TextColor = option.Color.RGB;
|
||||
ownersDropDown.TextColor = option.Color;
|
||||
InitializePreviews();
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
return name.Update(Pair.New(pp.PlayerName, suffix));
|
||||
};
|
||||
nameLabel.GetColor = () => pp.Color.RGB;
|
||||
nameLabel.GetColor = () => pp.Color;
|
||||
|
||||
var flag = item.Get<ImageWidget>("FACTIONFLAG");
|
||||
flag.GetImageCollection = () => "flags";
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
Player = p;
|
||||
Label = p.PlayerName;
|
||||
Color = p.Color.RGB;
|
||||
Color = p.Color;
|
||||
Faction = p.Faction.InternalName;
|
||||
IsSelected = () => p.World.RenderPlayer == p;
|
||||
OnClick = () => { p.World.RenderPlayer = p; logic.selected = this; p.World.Selection.Clear(); };
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
graph.GetSeries = () =>
|
||||
players.Select(p => new LineGraphSeries(
|
||||
p.PlayerName,
|
||||
p.Color.RGB,
|
||||
p.Color,
|
||||
(p.PlayerActor.TraitOrDefault<PlayerStatistics>() ?? new PlayerStatistics(p.PlayerActor)).EarnedSamples.Select(s => (float)s)));
|
||||
|
||||
playerStatsPanel.AddChild(template);
|
||||
@@ -184,7 +184,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
graph.GetSeries = () =>
|
||||
players.Select(p => new LineGraphSeries(
|
||||
p.PlayerName,
|
||||
p.Color.RGB,
|
||||
p.Color,
|
||||
(p.PlayerActor.TraitOrDefault<PlayerStatistics>() ?? new PlayerStatistics(p.PlayerActor)).ArmySamples.Select(s => (float)s)));
|
||||
|
||||
playerStatsPanel.AddChild(template);
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
flagFaction = o.Faction.InternalName;
|
||||
ownerName = o.PlayerName;
|
||||
ownerColor = o.Color.RGB;
|
||||
ownerColor = o.Color;
|
||||
widget.Bounds.Height = doubleHeight;
|
||||
widget.Bounds.Width = Math.Max(widget.Bounds.Width,
|
||||
owner.Bounds.X + ownerFont.Measure(ownerName).X + label.Bounds.X);
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
orderManager.IssueOrder(Order.Command("color {0} {1}".F(client.Index, preview.Color)));
|
||||
};
|
||||
|
||||
Action<HSLColor> onChange = c => preview.Color = c;
|
||||
Action<Color> onChange = c => preview.Color = c;
|
||||
|
||||
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
|
||||
{
|
||||
@@ -484,7 +484,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public static void SetupColorWidget(Widget parent, Session.Slot s, Session.Client c)
|
||||
{
|
||||
var color = parent.Get<ColorBlockWidget>("COLORBLOCK");
|
||||
color.GetColor = () => c.Color.RGB;
|
||||
color.GetColor = () => c.Color;
|
||||
}
|
||||
|
||||
public static void SetupEditableFactionWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager,
|
||||
@@ -604,7 +604,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return name.Update(Pair.New(player.PlayerName, sl)) + suffix;
|
||||
};
|
||||
|
||||
playerName.GetColor = () => player.Color.RGB;
|
||||
playerName.GetColor = () => player.Color;
|
||||
}
|
||||
|
||||
public static string GetExternalIP(Session.Client client, OrderManager orderManager)
|
||||
|
||||
@@ -648,7 +648,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var o = option;
|
||||
|
||||
var color = o.Color.RGB;
|
||||
var color = o.Color;
|
||||
|
||||
var item = ScrollItemWidget.Setup(playerTemplate, () => false, () => { });
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var font = Game.Renderer.Fonts[label.Font];
|
||||
var name = WidgetUtils.TruncateText(o.Name, label.Bounds.Width, font);
|
||||
label.GetText = () => name;
|
||||
label.GetColor = () => o.Color.RGB;
|
||||
label.GetColor = () => o.Color;
|
||||
|
||||
var flag = item.Get<ImageWidget>("FLAG");
|
||||
flag.IsVisible = () => true;
|
||||
@@ -484,7 +484,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var name = WidgetUtils.TruncateText(o.Name, label.Bounds.Width, font);
|
||||
|
||||
// Force spectator color to prevent spoofing by the server
|
||||
var color = o.IsSpectator ? Color.White : o.Color.RGB;
|
||||
var color = o.IsSpectator ? Color.White : o.Color;
|
||||
label.GetText = () => name;
|
||||
label.GetColor = () => color;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var colorDropdown = panel.Get<DropDownButtonWidget>("PLAYERCOLOR");
|
||||
colorDropdown.IsDisabled = () => worldRenderer.World.Type != WorldType.Shellmap;
|
||||
colorDropdown.OnMouseDown = _ => ColorPickerLogic.ShowColorDropDown(colorDropdown, colorPreview, worldRenderer.World);
|
||||
colorDropdown.Get<ColorBlockWidget>("COLORBLOCK").GetColor = () => ps.Color.RGB;
|
||||
colorDropdown.Get<ColorBlockWidget>("COLORBLOCK").GetColor = () => ps.Color;
|
||||
|
||||
return () =>
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class SpawnOccupant
|
||||
{
|
||||
public readonly HSLColor Color;
|
||||
public readonly Color Color;
|
||||
public readonly string PlayerName;
|
||||
public readonly int Team;
|
||||
public readonly string Faction;
|
||||
@@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
TooltipSpawnIndex = -1;
|
||||
if (ShowSpawnPoints)
|
||||
{
|
||||
var colors = SpawnOccupants().ToDictionary(c => c.Key, c => c.Value.Color.RGB);
|
||||
var colors = SpawnOccupants().ToDictionary(c => c.Key, c => c.Value.Color);
|
||||
|
||||
var spawnPoints = preview.SpawnPoints;
|
||||
var gridType = preview.GridType;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var time = WidgetUtils.FormatTime(p.RemainingTime, false, timestep);
|
||||
var text = Format.F(p.Info.Description, time);
|
||||
var self = p.Instances[0].Self;
|
||||
var playerColor = self.Owner.Color.RGB;
|
||||
var playerColor = self.Owner.Color;
|
||||
|
||||
if (Game.Settings.Game.UsePlayerStanceColors)
|
||||
playerColor = self.Owner.PlayerStanceColor(self);
|
||||
|
||||
Reference in New Issue
Block a user