Merge pull request #9650 from r34ch/health-bars-on-damage
Display status bars dropdown
This commit is contained in:
@@ -18,17 +18,26 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
readonly WPos pos;
|
||||
readonly Actor actor;
|
||||
readonly bool displayHealth;
|
||||
readonly bool displayExtra;
|
||||
|
||||
public SelectionBarsRenderable(Actor actor)
|
||||
: this(actor.CenterPosition, actor) { }
|
||||
public SelectionBarsRenderable(Actor actor, bool displayHealth, bool displayExtra)
|
||||
: this(actor.CenterPosition, actor)
|
||||
{
|
||||
this.displayHealth = displayHealth;
|
||||
this.displayExtra = displayExtra;
|
||||
}
|
||||
|
||||
public SelectionBarsRenderable(WPos pos, Actor actor)
|
||||
: this()
|
||||
{
|
||||
this.pos = pos;
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
public WPos Pos { get { return pos; } }
|
||||
public bool DisplayHealth { get { return displayHealth; } }
|
||||
public bool DisplayExtra { get { return displayExtra; } }
|
||||
|
||||
public PaletteReference Palette { get { return null; } }
|
||||
public int ZOffset { get { return 0; } }
|
||||
@@ -164,8 +173,11 @@ namespace OpenRA.Graphics
|
||||
var start = new float2(bounds.Left + 1, bounds.Top);
|
||||
var end = new float2(bounds.Right - 1, bounds.Top);
|
||||
|
||||
DrawHealthBar(wr, health, start, end);
|
||||
DrawExtraBars(wr, start, end);
|
||||
if (DisplayHealth)
|
||||
DrawHealthBar(wr, health, start, end);
|
||||
|
||||
if (DisplayExtra)
|
||||
DrawExtraBars(wr, start, end);
|
||||
}
|
||||
|
||||
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||
|
||||
@@ -183,13 +183,26 @@ namespace OpenRA.Graphics
|
||||
foreach (var r in g)
|
||||
r.RenderDebugGeometry(this);
|
||||
|
||||
if (World.Type == WorldType.Regular && Game.Settings.Game.AlwaysShowStatusBars)
|
||||
if (World.Type == WorldType.Regular)
|
||||
{
|
||||
foreach (var g in World.ActorsHavingTrait<Selectable>().Where(a => !a.Disposed
|
||||
&& !World.FogObscures(a)
|
||||
&& !World.Selection.Actors.Contains(a)))
|
||||
{
|
||||
if (Game.Settings.Game.StatusBars == StatusBarsType.Standard)
|
||||
new SelectionBarsRenderable(g, false, false).Render(this);
|
||||
|
||||
DrawRollover(g);
|
||||
if (Game.Settings.Game.StatusBars == StatusBarsType.AlwaysShow)
|
||||
new SelectionBarsRenderable(g, true, true).Render(this);
|
||||
|
||||
if (Game.Settings.Game.StatusBars == StatusBarsType.DamageShow)
|
||||
{
|
||||
if (g.GetDamageState() != DamageState.Undamaged)
|
||||
new SelectionBarsRenderable(g, true, true).Render(this);
|
||||
else
|
||||
new SelectionBarsRenderable(g, false, true).Render(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Game.Renderer.Flush();
|
||||
@@ -198,7 +211,7 @@ namespace OpenRA.Graphics
|
||||
public void DrawRollover(Actor unit)
|
||||
{
|
||||
if (unit.Info.HasTraitInfo<SelectableInfo>())
|
||||
new SelectionBarsRenderable(unit).Render(this);
|
||||
new SelectionBarsRenderable(unit, true, true).Render(this);
|
||||
}
|
||||
|
||||
public void DrawRangeCircle(WPos pos, WDist range, Color c)
|
||||
|
||||
@@ -20,6 +20,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA
|
||||
{
|
||||
public enum MouseScrollType { Disabled, Standard, Inverted, Joystick }
|
||||
public enum StatusBarsType { Standard, DamageShow, AlwaysShow }
|
||||
|
||||
public class ServerSettings
|
||||
{
|
||||
@@ -153,7 +154,7 @@ namespace OpenRA
|
||||
public int JoystickScrollDeadzone = 8;
|
||||
|
||||
public bool UseClassicMouseStyle = false;
|
||||
public bool AlwaysShowStatusBars = false;
|
||||
public StatusBarsType StatusBars = StatusBarsType.Standard;
|
||||
public bool TeamHealthColors = false;
|
||||
public bool DrawTargetLine = true;
|
||||
|
||||
@@ -197,7 +198,7 @@ namespace OpenRA
|
||||
public Hotkey ObserverCombinedView = new Hotkey(Keycode.MINUS, Modifiers.None);
|
||||
public Hotkey ObserverWorldView = new Hotkey(Keycode.EQUALS, Modifiers.None);
|
||||
|
||||
public Hotkey ToggleStatusBarsKey = 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 DevReloadChromeKey = new Hotkey(Keycode.C, Modifiers.Ctrl | Modifiers.Shift);
|
||||
|
||||
@@ -275,8 +275,8 @@ namespace OpenRA.Widgets
|
||||
|
||||
World.Selection.Combine(World, newSelection, true, false);
|
||||
}
|
||||
else if (key == Game.Settings.Keys.ToggleStatusBarsKey)
|
||||
return ToggleStatusBars();
|
||||
else if (key == Game.Settings.Keys.CycleStatusBarsKey)
|
||||
return CycleStatusBars();
|
||||
else if (key == Game.Settings.Keys.TogglePixelDoubleKey)
|
||||
return TogglePixelDouble();
|
||||
}
|
||||
@@ -319,9 +319,15 @@ namespace OpenRA.Widgets
|
||||
.SubsetWithHighestSelectionPriority();
|
||||
}
|
||||
|
||||
bool ToggleStatusBars()
|
||||
bool CycleStatusBars()
|
||||
{
|
||||
Game.Settings.Game.AlwaysShowStatusBars ^= true;
|
||||
if (Game.Settings.Game.StatusBars == StatusBarsType.Standard)
|
||||
Game.Settings.Game.StatusBars = StatusBarsType.DamageShow;
|
||||
else if (Game.Settings.Game.StatusBars == StatusBarsType.DamageShow)
|
||||
Game.Settings.Game.StatusBars = StatusBarsType.AlwaysShow;
|
||||
else if (Game.Settings.Game.StatusBars == StatusBarsType.AlwaysShow)
|
||||
Game.Settings.Game.StatusBars = StatusBarsType.Standard;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user