Merge pull request #11647 from abcdefg30/colorBorder
Add a dynamically generated bordercolor for supportpower timers
This commit is contained in:
@@ -9,9 +9,11 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
@@ -26,7 +28,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
readonly int timestep;
|
readonly int timestep;
|
||||||
readonly IEnumerable<SupportPowerInstance> powers;
|
readonly IEnumerable<SupportPowerInstance> powers;
|
||||||
Pair<string, Color>[] texts;
|
Tuple<string, Color, Color>[] texts;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public SupportPowerTimerWidget(World world)
|
public SupportPowerTimerWidget(World world)
|
||||||
@@ -56,7 +58,11 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
var color = !p.Ready || Game.LocalTick % 50 < 25 ? playerColor : Color.White;
|
var color = !p.Ready || Game.LocalTick % 50 < 25 ? playerColor : Color.White;
|
||||||
|
|
||||||
return Pair.New(text, color);
|
var inversedColor = self.Owner.Color;
|
||||||
|
var inversedL = color == Color.White || inversedColor.L > 128 ? (byte)0 : (byte)255;
|
||||||
|
inversedColor = new HSLColor(inversedColor.H, 0, inversedL);
|
||||||
|
|
||||||
|
return Tuple.Create(text, color, inversedColor.RGB);
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,8 +75,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
foreach (var t in texts)
|
foreach (var t in texts)
|
||||||
{
|
{
|
||||||
var font = Game.Renderer.Fonts[Font];
|
var font = Game.Renderer.Fonts[Font];
|
||||||
font.DrawTextWithContrast(t.First, new float2(Bounds.Location) + new float2(0, y), t.Second, Color.Black, 1);
|
font.DrawTextWithContrast(t.Item1, new float2(Bounds.Location) + new float2(0, y), t.Item2, t.Item3, 1);
|
||||||
y += (font.Measure(t.First).Y + 5) * (int)Order;
|
y += (font.Measure(t.Item1).Y + 5) * (int)Order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user