diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 5063ab2da8..835d6dcdb2 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -21,6 +21,7 @@ namespace OpenRA { public enum MouseScrollType { Disabled, Standard, Inverted, Joystick } public enum StatusBarsType { Standard, DamageShow, AlwaysShow } + public enum TargetLinesType { Disabled, Manual, Automatic } [Flags] public enum MPGameFilters @@ -208,8 +209,8 @@ namespace OpenRA public bool UseClassicMouseStyle = false; public StatusBarsType StatusBars = StatusBarsType.Standard; + public TargetLinesType TargetLines = TargetLinesType.Automatic; public bool UsePlayerStanceColors = false; - public bool DrawTargetLine = true; public bool AllowDownloading = true; diff --git a/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs b/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs index 9556f92419..61b644772e 100644 --- a/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs +++ b/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs @@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Effects IEnumerable RenderInner(WorldRenderer wr) { - if (Game.Settings.Game.DrawTargetLine) + if (Game.Settings.Game.TargetLines != TargetLinesType.Disabled) yield return new TargetLineRenderable(targetLine, building.Owner.Color, rp.Info.LineWidth); if (circles != null || flag != null) diff --git a/OpenRA.Mods.Common/Traits/Render/DrawLineToTarget.cs b/OpenRA.Mods.Common/Traits/Render/DrawLineToTarget.cs index cdd3194a26..aa2de7394e 100644 --- a/OpenRA.Mods.Common/Traits/Render/DrawLineToTarget.cs +++ b/OpenRA.Mods.Common/Traits/Render/DrawLineToTarget.cs @@ -45,6 +45,9 @@ namespace OpenRA.Mods.Common.Traits public void ShowTargetLines(Actor self) { + if (Game.Settings.Game.TargetLines < TargetLinesType.Automatic) + return; + // Target lines are only automatically shown for the owning player // Spectators and allies must use the force-display modifier if (self.IsIdle || self.Owner != self.World.LocalPlayer) @@ -61,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits IEnumerable IRenderAboveShroudWhenSelected.RenderAboveShroud(Actor self, WorldRenderer wr) { - if (!self.Owner.IsAlliedWith(self.World.LocalPlayer)) + if (!self.Owner.IsAlliedWith(self.World.LocalPlayer) || Game.Settings.Game.TargetLines == TargetLinesType.Disabled) return Enumerable.Empty(); // Players want to see the lines when in waypoint mode. @@ -70,9 +73,6 @@ namespace OpenRA.Mods.Common.Traits if (--lifetime <= 0 && !force) return Enumerable.Empty(); - if (!(force || Game.Settings.Game.DrawTargetLine)) - return Enumerable.Empty(); - renderableCache.Clear(); var prev = self.CenterPosition; var a = self.CurrentActivity; diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 905b06a9cb..13f495242c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -205,7 +205,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic BindCheckboxPref(panel, "PIXELDOUBLE_CHECKBOX", ds, "PixelDouble"); BindCheckboxPref(panel, "CURSORDOUBLE_CHECKBOX", ds, "CursorDouble"); BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate"); - BindCheckboxPref(panel, "DISPLAY_TARGET_LINES_CHECKBOX", gs, "DrawTargetLine"); BindCheckboxPref(panel, "PLAYER_STANCE_COLORS_CHECKBOX", gs, "UsePlayerStanceColors"); var languageDropDownButton = panel.Get("LANGUAGE_DROPDOWNBUTTON"); @@ -219,8 +218,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic 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"; + statusBarsDropDown.GetText = () => gs.StatusBars == StatusBarsType.Standard ? + "Standard" : gs.StatusBars == StatusBarsType.DamageShow ? "Show On Damage" : "Always Show"; + + var targetLinesDropDown = panel.Get("TARGET_LINES_DROPDOWN"); + targetLinesDropDown.OnMouseDown = _ => ShowTargetLinesDropdown(targetLinesDropDown, gs); + targetLinesDropDown.GetText = () => gs.TargetLines == TargetLinesType.Automatic ? + "Automatic" : gs.TargetLines == TargetLinesType.Manual ? "Manual" : "Disabled"; // Update zoom immediately var pixelDoubleCheckbox = panel.Get("PIXELDOUBLE_CHECKBOX"); @@ -716,6 +720,29 @@ namespace OpenRA.Mods.Common.Widgets.Logic return true; } + static bool ShowTargetLinesDropdown(DropDownButtonWidget dropdown, GameSettings s) + { + var options = new Dictionary() + { + { "Automatic", TargetLinesType.Automatic }, + { "Manual", TargetLinesType.Manual }, + { "Disabled", TargetLinesType.Disabled }, + }; + + Func setupItem = (o, itemTemplate) => + { + var item = ScrollItemWidget.Setup(itemTemplate, + () => s.TargetLines == options[o], + () => s.TargetLines = 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 c8c55b9229..c17d16f818 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -210,23 +210,29 @@ Container@SETTINGS_PANEL: Width: PARENT_RIGHT - 35 Height: PARENT_BOTTOM - 12 Label@STATUS_BARS: - X: 310 + X: 250 Y: 257 + Width: 145 Text: Status Bars: + Align: Right DropDownButton@STATUS_BAR_DROPDOWN: X: 400 Y: 245 Width: 170 Height: 25 Font: Regular - Text: Standard - Checkbox@DISPLAY_TARGET_LINES_CHECKBOX: - X: 310 + Label@TARGET_LINES: + X: 250 + Y: 228 + Width: 145 + Text: Target Lines: + Align: Right + DropDownButton@TARGET_LINES_DROPDOWN: + X: 400 Y: 215 - Width: 200 - Height: 20 + Width: 170 + Height: 25 Font: Regular - Text: Display Target Lines Label@LOCALIZATION_TITLE: Y: 265 Width: PARENT_RIGHT diff --git a/mods/common/chrome/settings.yaml b/mods/common/chrome/settings.yaml index 8434a61e2b..a3df32821d 100644 --- a/mods/common/chrome/settings.yaml +++ b/mods/common/chrome/settings.yaml @@ -224,9 +224,11 @@ Background@SETTINGS_PANEL: Width: PARENT_RIGHT - 35 Height: PARENT_BOTTOM - 12 Label@STATUS_BARS: - X: 310 + X: 250 Y: 278 + Width: 145 Text: Status Bars: + Align: Right DropDownButton@STATUS_BAR_DROPDOWN: X: 400 Y: 265 @@ -234,13 +236,18 @@ Background@SETTINGS_PANEL: Height: 25 Font: Regular Text: Standard - Checkbox@DISPLAY_TARGET_LINES_CHECKBOX: - X: 310 + Label@TARGET_LINES: + X: 250 + Y: 243 + Width: 145 + Text: Target Lines: + Align: Right + DropDownButton@TARGET_LINES_DROPDOWN: + X: 400 Y: 230 - Width: 200 - Height: 20 + Width: 170 + Height: 25 Font: Regular - Text: Display Target Lines Label@LOCALIZATION_TITLE: Y: 270 Width: PARENT_RIGHT