Change color of selection box based on selection mode.

This commit is contained in:
tovl
2019-11-21 00:34:05 +01:00
committed by reaperrr
parent efc06a020b
commit 088919fecc
5 changed files with 32 additions and 1 deletions

View File

@@ -27,6 +27,10 @@ namespace OpenRA.Mods.Common.Widgets
protected readonly World World;
readonly WorldRenderer worldRenderer;
readonly Color normalSelectionColor;
readonly Color altSelectionColor;
readonly Color ctrlSelectionColor;
int2 dragStart, mousePos;
bool isDragging = false;
@@ -43,6 +47,14 @@ namespace OpenRA.Mods.Common.Widgets
{
World = world;
this.worldRenderer = worldRenderer;
if (!ChromeMetrics.TryGet("AltSelectionColor", out altSelectionColor))
altSelectionColor = Color.White;
if (!ChromeMetrics.TryGet("CtrlSelectionColor", out ctrlSelectionColor))
ctrlSelectionColor = Color.White;
if (!ChromeMetrics.TryGet("NormalSelectionColor", out normalSelectionColor))
normalSelectionColor = Color.White;
}
void DrawRollover(Actor unit)
@@ -61,7 +73,14 @@ namespace OpenRA.Mods.Common.Widgets
{
var a = worldRenderer.Viewport.WorldToViewPx(dragStart);
var b = worldRenderer.Viewport.WorldToViewPx(mousePos);
Game.Renderer.RgbaColorRenderer.DrawRect(a, b, 1, Color.White);
var color = normalSelectionColor;
if (modifiers.HasFlag(Modifiers.Alt) && !modifiers.HasFlag(Modifiers.Ctrl))
color = altSelectionColor;
else if (modifiers.HasFlag(Modifiers.Ctrl) && !modifiers.HasFlag(Modifiers.Alt))
color = ctrlSelectionColor;
Game.Renderer.RgbaColorRenderer.DrawRect(a, b, 1, color);
// Render actors in the dragbox
foreach (var u in SelectActorsInBoxWithDeadzone(World, dragStart, mousePos, modifiers))

View File

@@ -12,3 +12,6 @@ Metrics:
ClickSound: ClickSound
ChatMessageColor: FFFFFF
SystemMessageColor: FFFF00
NormalSelectionColor: FFFFFF
AltSelectionColor: 00FFFF
CtrlSelectionColor: FFFF00

View File

@@ -12,3 +12,6 @@ Metrics:
ClickSound: ClickSound
ChatMessageColor: FFFFFF
SystemMessageColor: FFFF00
NormalSelectionColor: FFFFFF
AltSelectionColor: 00FFFF
CtrlSelectionColor: FFFF00

View File

@@ -21,3 +21,6 @@ Metrics:
ClickSound: ClickSound
ChatMessageColor: FFFFFF
SystemMessageColor: FFFF00
NormalSelectionColor: FFFFFF
AltSelectionColor: 00FFFF
CtrlSelectionColor: FFFF00

View File

@@ -8,3 +8,6 @@ Metrics:
ClickSound: ClickSound
ChatMessageColor: FFFFFF
SystemMessageColor: FFFF00
NormalSelectionColor: FFFFFF
AltSelectionColor: 00FFFF
CtrlSelectionColor: FFFF00