diff --git a/OpenRA.Game/Graphics/SelectionBarsRenderable.cs b/OpenRA.Game/Graphics/SelectionBarsRenderable.cs index 0443c3ad62..68a5c179a4 100644 --- a/OpenRA.Game/Graphics/SelectionBarsRenderable.cs +++ b/OpenRA.Game/Graphics/SelectionBarsRenderable.cs @@ -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) { } diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index df7c68abc8..312e53021f 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -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().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()) - new SelectionBarsRenderable(unit).Render(this); + new SelectionBarsRenderable(unit, true, true).Render(this); } public void DrawRangeCircle(WPos pos, WDist range, Color c) diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 879d34bd84..d8efb14788 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -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); diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index 363aaa393d..c581301a32 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -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; } diff --git a/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs b/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs index 331b4e729e..609967c33e 100644 --- a/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs +++ b/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs @@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits yield return new SelectionBoxRenderable(self, Info.SelectionBoxColor); if (Info.RenderSelectionBars) - yield return new SelectionBarsRenderable(self); + yield return new SelectionBarsRenderable(self, true, true); if (!self.Owner.IsAlliedWith(wr.World.RenderPlayer)) yield break; diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 9127f910a8..25cbde9528 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -153,7 +153,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic BindCheckboxPref(panel, "CURSORDOUBLE_CHECKBOX", ds, "CursorDouble"); BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate"); BindCheckboxPref(panel, "SHOW_SHELLMAP", gs, "ShowShellmap"); - BindCheckboxPref(panel, "ALWAYS_SHOW_STATUS_BARS_CHECKBOX", gs, "AlwaysShowStatusBars"); BindCheckboxPref(panel, "DISPLAY_TARGET_LINES_CHECKBOX", gs, "DrawTargetLine"); BindCheckboxPref(panel, "TEAM_HEALTH_COLORS_CHECKBOX", gs, "TeamHealthColors"); @@ -166,6 +165,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic windowModeDropdown.GetText = () => ds.Mode == WindowMode.Windowed ? "Windowed" : ds.Mode == WindowMode.Fullscreen ? "Fullscreen" : "Pseudo-Fullscreen"; + var statusBarsDropDown = panel.Get("STATUS_BAR_DROPDOWN"); + statusBarsDropDown.OnMouseDown = _ => ShowStatusBarsDropdown(statusBarsDropDown, gs); + statusBarsDropDown.GetText = () => gs.StatusBars.ToString() == "Standard" ? + "Standard" : gs.StatusBars.ToString() == "DamageShow" ? "Show On Damage" : "Always Show"; + // Update zoom immediately var pixelDoubleCheckbox = panel.Get("PIXELDOUBLE_CHECKBOX"); var pixelDoubleOnClick = pixelDoubleCheckbox.OnClick; @@ -408,7 +412,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { "PreviousProductionTabKey", "Previous production tab" }, { "CycleProductionBuildingsKey", "Cycle production facilities" }, - { "ToggleStatusBarsKey", "Toggle status bars" }, + { "CycleStatusBarsKey", "Cycle status bars display" }, { "TogglePixelDoubleKey", "Toggle pixel doubling" }, { "MapScrollUp", "Map scroll up" }, @@ -669,6 +673,29 @@ namespace OpenRA.Mods.Common.Widgets.Logic return true; } + static bool ShowStatusBarsDropdown(DropDownButtonWidget dropdown, GameSettings s) + { + var options = new Dictionary() + { + { "Standard", StatusBarsType.Standard }, + { "Show On Damage", StatusBarsType.DamageShow }, + { "Always Show", StatusBarsType.AlwaysShow }, + }; + + Func setupItem = (o, itemTemplate) => + { + var item = ScrollItemWidget.Setup(itemTemplate, + () => s.StatusBars == options[o], + () => s.StatusBars = options[o]); + + item.Get("LABEL").GetText = () => o; + return item; + }; + + dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem); + return true; + } + void MakeMouseFocusSettingsLive() { var gameSettings = Game.Settings.Game; diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 3a36d3140f..c1f867fdf0 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -183,16 +183,20 @@ Container@SETTINGS_PANEL: Y: 6 Width: PARENT_RIGHT-35 Height: PARENT_BOTTOM-12 - Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX: + Label@STATUS_BARS: X: 310 - Y: 215 - Width: 200 - Height: 20 + Y: 255 + Text: Status Bars: + DropDownButton@STATUS_BAR_DROPDOWN: + X: 400 + Y: 245 + Width: 170 + Height: 25 Font: Regular - Text: Always Show Status Bars + Text: Standard Checkbox@DISPLAY_TARGET_LINES_CHECKBOX: X: 310 - Y: 245 + Y: 215 Width: 200 Height: 20 Font: Regular diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index 032bb99c7e..91a804e930 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -196,16 +196,20 @@ Background@SETTINGS_PANEL: Y: 6 Width: PARENT_RIGHT-35 Height: PARENT_BOTTOM-12 - Checkbox@ALWAYS_SHOW_STATUS_BARS_CHECKBOX: + Label@STATUS_BARS: X: 310 - Y: 230 - Width: 200 - Height: 20 + Y: 275 + Text: Status Bars: + DropDownButton@STATUS_BAR_DROPDOWN: + X: 400 + Y: 265 + Width: 170 + Height: 25 Font: Regular - Text: Always Show Status Bars + Text: Standard Checkbox@DISPLAY_TARGET_LINES_CHECKBOX: X: 310 - Y: 265 + Y: 230 Width: 200 Height: 20 Font: Regular