Implement player stance colors
Adds an option to display actors on radar and support weapon timers in colors denoting the diplomatic stance toward the player.
This commit is contained in:
committed by
Oliver Brakmann
parent
ce8b03a276
commit
eb795909da
@@ -85,29 +85,8 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
Color GetHealthColor(IHealth health)
|
Color GetHealthColor(IHealth health)
|
||||||
{
|
{
|
||||||
var player = actor.World.RenderPlayer ?? actor.World.LocalPlayer;
|
if (Game.Settings.Game.UsePlayerStanceColors)
|
||||||
|
return actor.Owner.PlayerStanceColor(actor);
|
||||||
if (Game.Settings.Game.TeamHealthColors && player != null && !player.Spectating)
|
|
||||||
{
|
|
||||||
var apparentOwner = actor.EffectiveOwner != null && actor.EffectiveOwner.Disguised
|
|
||||||
? actor.EffectiveOwner.Owner
|
|
||||||
: actor.Owner;
|
|
||||||
|
|
||||||
// For friendly spies, treat the unit's owner as the actual owner
|
|
||||||
if (actor.Owner.IsAlliedWith(actor.World.RenderPlayer))
|
|
||||||
apparentOwner = actor.Owner;
|
|
||||||
|
|
||||||
if (apparentOwner == player)
|
|
||||||
return Color.LimeGreen;
|
|
||||||
|
|
||||||
if (apparentOwner.IsAlliedWith(player))
|
|
||||||
return Color.Yellow;
|
|
||||||
|
|
||||||
if (apparentOwner.NonCombatant)
|
|
||||||
return Color.Tan;
|
|
||||||
|
|
||||||
return Color.Red;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return health.DamageState == DamageState.Critical ? Color.Red :
|
return health.DamageState == DamageState.Critical ? Color.Red :
|
||||||
health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen;
|
health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Eluant;
|
using Eluant;
|
||||||
using Eluant.ObjectBinding;
|
using Eluant.ObjectBinding;
|
||||||
@@ -18,6 +19,7 @@ using OpenRA.Network;
|
|||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Scripting;
|
using OpenRA.Scripting;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
@@ -26,6 +28,14 @@ namespace OpenRA
|
|||||||
|
|
||||||
public class Player : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding
|
public class Player : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding
|
||||||
{
|
{
|
||||||
|
struct StanceColors
|
||||||
|
{
|
||||||
|
public Color Self;
|
||||||
|
public Color Allies;
|
||||||
|
public Color Enemies;
|
||||||
|
public Color Neutrals;
|
||||||
|
}
|
||||||
|
|
||||||
public readonly Actor PlayerActor;
|
public readonly Actor PlayerActor;
|
||||||
public readonly HSLColor Color;
|
public readonly HSLColor Color;
|
||||||
|
|
||||||
@@ -50,6 +60,7 @@ namespace OpenRA
|
|||||||
public World World { get; private set; }
|
public World World { get; private set; }
|
||||||
|
|
||||||
readonly IFogVisibilityModifier[] fogVisibilities;
|
readonly IFogVisibilityModifier[] fogVisibilities;
|
||||||
|
readonly StanceColors stanceColors;
|
||||||
|
|
||||||
static FactionInfo ChooseFaction(World world, string name, bool requireSelectable = true)
|
static FactionInfo ChooseFaction(World world, string name, bool requireSelectable = true)
|
||||||
{
|
{
|
||||||
@@ -127,6 +138,11 @@ namespace OpenRA
|
|||||||
else
|
else
|
||||||
logic.Activate(this);
|
logic.Activate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stanceColors.Self = ChromeMetrics.Get<Color>("PlayerStanceColorSelf");
|
||||||
|
stanceColors.Allies = ChromeMetrics.Get<Color>("PlayerStanceColorAllies");
|
||||||
|
stanceColors.Enemies = ChromeMetrics.Get<Color>("PlayerStanceColorEnemies");
|
||||||
|
stanceColors.Neutrals = ChromeMetrics.Get<Color>("PlayerStanceColorNeutrals");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@@ -181,6 +197,31 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color PlayerStanceColor(Actor a)
|
||||||
|
{
|
||||||
|
var player = a.World.RenderPlayer ?? a.World.LocalPlayer;
|
||||||
|
if (player != null && !player.Spectating)
|
||||||
|
{
|
||||||
|
var apparentOwner = a.EffectiveOwner != null && a.EffectiveOwner.Disguised
|
||||||
|
? a.EffectiveOwner.Owner
|
||||||
|
: a.Owner;
|
||||||
|
|
||||||
|
if (a.Owner.IsAlliedWith(a.World.RenderPlayer))
|
||||||
|
apparentOwner = a.Owner;
|
||||||
|
|
||||||
|
if (apparentOwner == player)
|
||||||
|
return stanceColors.Self;
|
||||||
|
|
||||||
|
if (apparentOwner.IsAlliedWith(player))
|
||||||
|
return stanceColors.Allies;
|
||||||
|
|
||||||
|
if (!apparentOwner.NonCombatant)
|
||||||
|
return stanceColors.Enemies;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stanceColors.Neutrals;
|
||||||
|
}
|
||||||
|
|
||||||
#region Scripting interface
|
#region Scripting interface
|
||||||
|
|
||||||
Lazy<ScriptPlayerInterface> luaInterface;
|
Lazy<ScriptPlayerInterface> luaInterface;
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool UseClassicMouseStyle = false;
|
public bool UseClassicMouseStyle = false;
|
||||||
public StatusBarsType StatusBars = StatusBarsType.Standard;
|
public StatusBarsType StatusBars = StatusBarsType.Standard;
|
||||||
public bool TeamHealthColors = false;
|
public bool UsePlayerStanceColors = false;
|
||||||
public bool DrawTargetLine = true;
|
public bool DrawTargetLine = true;
|
||||||
|
|
||||||
public bool AllowDownloading = true;
|
public bool AllowDownloading = true;
|
||||||
@@ -213,6 +213,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public Hotkey CycleStatusBarsKey = new Hotkey(Keycode.COMMA, Modifiers.None);
|
public Hotkey CycleStatusBarsKey = new Hotkey(Keycode.COMMA, Modifiers.None);
|
||||||
public Hotkey TogglePixelDoubleKey = new Hotkey(Keycode.PERIOD, Modifiers.None);
|
public Hotkey TogglePixelDoubleKey = new Hotkey(Keycode.PERIOD, Modifiers.None);
|
||||||
|
public Hotkey TogglePlayerStanceColorsKey = new Hotkey(Keycode.COMMA, Modifiers.Ctrl);
|
||||||
|
|
||||||
public Hotkey DevReloadChromeKey = new Hotkey(Keycode.C, Modifiers.Ctrl | Modifiers.Shift);
|
public Hotkey DevReloadChromeKey = new Hotkey(Keycode.C, Modifiers.Ctrl | Modifiers.Shift);
|
||||||
public Hotkey HideUserInterfaceKey = new Hotkey(Keycode.H, Modifiers.Ctrl | Modifiers.Shift);
|
public Hotkey HideUserInterfaceKey = new Hotkey(Keycode.H, Modifiers.Ctrl | Modifiers.Shift);
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ namespace OpenRA.Traits
|
|||||||
bool HasFogVisibility();
|
bool HasFogVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IRadarColorModifier { Color RadarColorOverride(Actor self); }
|
public interface IRadarColorModifier { Color RadarColorOverride(Actor self, Color color); }
|
||||||
|
|
||||||
public interface IOccupySpaceInfo : ITraitInfoInterface
|
public interface IOccupySpaceInfo : ITraitInfoInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -286,6 +286,8 @@ namespace OpenRA.Widgets
|
|||||||
return TogglePixelDouble();
|
return TogglePixelDouble();
|
||||||
else if (key == Game.Settings.Keys.ToggleMuteKey)
|
else if (key == Game.Settings.Keys.ToggleMuteKey)
|
||||||
return ToggleMute();
|
return ToggleMute();
|
||||||
|
else if (key == Game.Settings.Keys.TogglePlayerStanceColorsKey)
|
||||||
|
return TogglePlayerStanceColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -342,6 +344,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
Game.Settings.Graphics.PixelDouble ^= true;
|
Game.Settings.Graphics.PixelDouble ^= true;
|
||||||
worldRenderer.Viewport.Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
|
worldRenderer.Viewport.Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,5 +365,12 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TogglePlayerStanceColors()
|
||||||
|
{
|
||||||
|
Game.Settings.Game.UsePlayerStanceColors ^= true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public IEnumerable<Pair<CPos, Color>> RadarSignatureCells(Actor self)
|
public IEnumerable<Pair<CPos, Color>> RadarSignatureCells(Actor self)
|
||||||
{
|
{
|
||||||
var color = modifier != null ? modifier.RadarColorOverride(self) : self.Owner.Color.RGB;
|
var color = Game.Settings.Game.UsePlayerStanceColors ? self.Owner.PlayerStanceColor(self) : self.Owner.Color.RGB;
|
||||||
|
if (modifier != null)
|
||||||
|
color = modifier.RadarColorOverride(self, color);
|
||||||
|
|
||||||
if (info.UseLocation)
|
if (info.UseLocation)
|
||||||
return new[] { Pair.New(self.Location, color) };
|
return new[] { Pair.New(self.Location, color) };
|
||||||
|
|||||||
@@ -156,12 +156,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
&& (self.CenterPosition - a.Actor.CenterPosition).LengthSquared <= a.Trait.Info.Range.LengthSquared);
|
&& (self.CenterPosition - a.Actor.CenterPosition).LengthSquared <= a.Trait.Info.Range.LengthSquared);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color IRadarColorModifier.RadarColorOverride(Actor self)
|
Color IRadarColorModifier.RadarColorOverride(Actor self, Color color)
|
||||||
{
|
{
|
||||||
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);
|
color = Color.FromArgb(128, color);
|
||||||
return c;
|
|
||||||
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrantUpgrades(Actor self)
|
void GrantUpgrades(Actor self)
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool VisibleOnRadar(Actor self) { return true; }
|
public bool VisibleOnRadar(Actor self) { return true; }
|
||||||
public Color RadarColorOverride(Actor self) { return c; }
|
public Color RadarColorOverride(Actor self, Color color) { return c; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate");
|
BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate");
|
||||||
BindCheckboxPref(panel, "SHOW_SHELLMAP", gs, "ShowShellmap");
|
BindCheckboxPref(panel, "SHOW_SHELLMAP", gs, "ShowShellmap");
|
||||||
BindCheckboxPref(panel, "DISPLAY_TARGET_LINES_CHECKBOX", gs, "DrawTargetLine");
|
BindCheckboxPref(panel, "DISPLAY_TARGET_LINES_CHECKBOX", gs, "DrawTargetLine");
|
||||||
BindCheckboxPref(panel, "TEAM_HEALTH_COLORS_CHECKBOX", gs, "TeamHealthColors");
|
BindCheckboxPref(panel, "PLAYER_STANCE_COLORS_CHECKBOX", gs, "UsePlayerStanceColors");
|
||||||
|
|
||||||
var languageDropDownButton = panel.Get<DropDownButtonWidget>("LANGUAGE_DROPDOWNBUTTON");
|
var languageDropDownButton = panel.Get<DropDownButtonWidget>("LANGUAGE_DROPDOWNBUTTON");
|
||||||
languageDropDownButton.OnMouseDown = _ => ShowLanguageDropdown(languageDropDownButton);
|
languageDropDownButton.OnMouseDown = _ => ShowLanguageDropdown(languageDropDownButton);
|
||||||
@@ -436,6 +436,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "CycleStatusBarsKey", "Cycle status bars display" },
|
{ "CycleStatusBarsKey", "Cycle status bars display" },
|
||||||
{ "TogglePixelDoubleKey", "Toggle pixel doubling" },
|
{ "TogglePixelDoubleKey", "Toggle pixel doubling" },
|
||||||
{ "ToggleMuteKey", "Toggle audio mute" },
|
{ "ToggleMuteKey", "Toggle audio mute" },
|
||||||
|
{ "TogglePlayerStanceColorsKey", "Toggle player stance colors" },
|
||||||
|
|
||||||
{ "MapScrollUp", "Map scroll up" },
|
{ "MapScrollUp", "Map scroll up" },
|
||||||
{ "MapScrollDown", "Map scroll down" },
|
{ "MapScrollDown", "Map scroll down" },
|
||||||
|
|||||||
@@ -52,7 +52,14 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
var time = WidgetUtils.FormatTime(p.RemainingTime, false, timestep);
|
var time = WidgetUtils.FormatTime(p.RemainingTime, false, timestep);
|
||||||
var text = Format.F(p.Info.Description, time);
|
var text = Format.F(p.Info.Description, time);
|
||||||
var color = !p.Ready || Game.LocalTick % 50 < 25 ? p.Instances[0].Self.Owner.Color.RGB : Color.White;
|
var self = p.Instances[0].Self;
|
||||||
|
var playerColor = self.Owner.Color.RGB;
|
||||||
|
|
||||||
|
if (Game.Settings.Game.UsePlayerStanceColors)
|
||||||
|
playerColor = self.Owner.PlayerStanceColor(self);
|
||||||
|
|
||||||
|
var color = !p.Ready || Game.LocalTick % 50 < 25 ? playerColor : Color.White;
|
||||||
|
|
||||||
return Pair.New(text, color);
|
return Pair.New(text, color);
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,12 +120,12 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
return order.OrderString == "Disguise" ? info.Voice : null;
|
return order.OrderString == "Disguise" ? info.Voice : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color RadarColorOverride(Actor self)
|
public Color RadarColorOverride(Actor self, Color color)
|
||||||
{
|
{
|
||||||
if (!Disguised || self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
if (!Disguised || self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||||
return self.Owner.Color.RGB;
|
return color;
|
||||||
|
|
||||||
return AsPlayer.Color.RGB;
|
return color = Game.Settings.Game.UsePlayerStanceColors ? AsPlayer.PlayerStanceColor(self) : AsPlayer.Color.RGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisguiseAs(Actor target)
|
public void DisguiseAs(Actor target)
|
||||||
|
|||||||
@@ -145,13 +145,13 @@ Container@SETTINGS_PANEL:
|
|||||||
Y: 152
|
Y: 152
|
||||||
Height: 25
|
Height: 25
|
||||||
Text: FPS
|
Text: FPS
|
||||||
Checkbox@TEAM_HEALTH_COLORS_CHECKBOX:
|
Checkbox@PLAYER_STANCE_COLORS_CHECKBOX:
|
||||||
X: 310
|
X: 310
|
||||||
Y: 185
|
Y: 185
|
||||||
Width: 200
|
Width: 200
|
||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Team Health Colors
|
Text: Player Stance Colors
|
||||||
Checkbox@SHOW_SHELLMAP:
|
Checkbox@SHOW_SHELLMAP:
|
||||||
X: 15
|
X: 15
|
||||||
Y: 185
|
Y: 185
|
||||||
|
|||||||
@@ -36,3 +36,7 @@ Metrics:
|
|||||||
IncompatibleGameStartedColor: D2691E
|
IncompatibleGameStartedColor: D2691E
|
||||||
GlobalChatTextColor: FFFFFF
|
GlobalChatTextColor: FFFFFF
|
||||||
GlobalChatNotificationColor: D3D3D3
|
GlobalChatNotificationColor: D3D3D3
|
||||||
|
PlayerStanceColorSelf: 32CD32
|
||||||
|
PlayerStanceColorAllies: FFFF00
|
||||||
|
PlayerStanceColorEnemies: FF0000
|
||||||
|
PlayerStanceColorNeutrals: D2B48C
|
||||||
|
|||||||
@@ -35,3 +35,7 @@ Metrics:
|
|||||||
IncompatibleGameStartedColor: D2691E
|
IncompatibleGameStartedColor: D2691E
|
||||||
GlobalChatTextColor: FFFFFF
|
GlobalChatTextColor: FFFFFF
|
||||||
GlobalChatNotificationColor: D3D3D3
|
GlobalChatNotificationColor: D3D3D3
|
||||||
|
PlayerStanceColorSelf: 32CD32
|
||||||
|
PlayerStanceColorAllies: FFFF00
|
||||||
|
PlayerStanceColorEnemies: FF0000
|
||||||
|
PlayerStanceColorNeutrals: D2B48C
|
||||||
|
|||||||
@@ -158,13 +158,13 @@ Background@SETTINGS_PANEL:
|
|||||||
Y: 157
|
Y: 157
|
||||||
Height: 25
|
Height: 25
|
||||||
Text: FPS
|
Text: FPS
|
||||||
Checkbox@TEAM_HEALTH_COLORS_CHECKBOX:
|
Checkbox@PLAYER_STANCE_COLORS_CHECKBOX:
|
||||||
X: 310
|
X: 310
|
||||||
Y: 195
|
Y: 195
|
||||||
Width: 200
|
Width: 200
|
||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Team Health Colors
|
Text: Player Stance Colors
|
||||||
Checkbox@SHOW_SHELLMAP:
|
Checkbox@SHOW_SHELLMAP:
|
||||||
X: 15
|
X: 15
|
||||||
Y: 195
|
Y: 195
|
||||||
|
|||||||
@@ -43,3 +43,7 @@ Metrics:
|
|||||||
IncompatibleGameStartedColor: D2691E
|
IncompatibleGameStartedColor: D2691E
|
||||||
GlobalChatTextColor: FFFFFF
|
GlobalChatTextColor: FFFFFF
|
||||||
GlobalChatNotificationColor: D3D3D3
|
GlobalChatNotificationColor: D3D3D3
|
||||||
|
PlayerStanceColorSelf: 32CD32
|
||||||
|
PlayerStanceColorAllies: FFFF00
|
||||||
|
PlayerStanceColorEnemies: FF0000
|
||||||
|
PlayerStanceColorNeutrals: D2B48C
|
||||||
|
|||||||
@@ -35,3 +35,7 @@ Metrics:
|
|||||||
IncompatibleGameStartedColor: D2691E
|
IncompatibleGameStartedColor: D2691E
|
||||||
GlobalChatTextColor: FFFFFF
|
GlobalChatTextColor: FFFFFF
|
||||||
GlobalChatNotificationColor: D3D3D3
|
GlobalChatNotificationColor: D3D3D3
|
||||||
|
PlayerStanceColorSelf: 32CD32
|
||||||
|
PlayerStanceColorAllies: FFFF00
|
||||||
|
PlayerStanceColorEnemies: FF0000
|
||||||
|
PlayerStanceColorNeutrals: D2B48C
|
||||||
|
|||||||
Reference in New Issue
Block a user