Replace DrawTargetLine checkbox with an Automatic/Manual/Disabled dropdown.

This commit is contained in:
Paul Chote
2019-08-07 10:32:55 +00:00
committed by teinarss
parent 2909445452
commit 95ca14d4a3
6 changed files with 63 additions and 22 deletions

View File

@@ -21,6 +21,7 @@ namespace OpenRA
{ {
public enum MouseScrollType { Disabled, Standard, Inverted, Joystick } public enum MouseScrollType { Disabled, Standard, Inverted, Joystick }
public enum StatusBarsType { Standard, DamageShow, AlwaysShow } public enum StatusBarsType { Standard, DamageShow, AlwaysShow }
public enum TargetLinesType { Disabled, Manual, Automatic }
[Flags] [Flags]
public enum MPGameFilters public enum MPGameFilters
@@ -208,8 +209,8 @@ namespace OpenRA
public bool UseClassicMouseStyle = false; public bool UseClassicMouseStyle = false;
public StatusBarsType StatusBars = StatusBarsType.Standard; public StatusBarsType StatusBars = StatusBarsType.Standard;
public TargetLinesType TargetLines = TargetLinesType.Automatic;
public bool UsePlayerStanceColors = false; public bool UsePlayerStanceColors = false;
public bool DrawTargetLine = true;
public bool AllowDownloading = true; public bool AllowDownloading = true;

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Effects
IEnumerable<IRenderable> RenderInner(WorldRenderer wr) IEnumerable<IRenderable> 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); yield return new TargetLineRenderable(targetLine, building.Owner.Color, rp.Info.LineWidth);
if (circles != null || flag != null) if (circles != null || flag != null)

View File

@@ -45,6 +45,9 @@ namespace OpenRA.Mods.Common.Traits
public void ShowTargetLines(Actor self) public void ShowTargetLines(Actor self)
{ {
if (Game.Settings.Game.TargetLines < TargetLinesType.Automatic)
return;
// Target lines are only automatically shown for the owning player // Target lines are only automatically shown for the owning player
// Spectators and allies must use the force-display modifier // Spectators and allies must use the force-display modifier
if (self.IsIdle || self.Owner != self.World.LocalPlayer) if (self.IsIdle || self.Owner != self.World.LocalPlayer)
@@ -61,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<IRenderable> IRenderAboveShroudWhenSelected.RenderAboveShroud(Actor self, WorldRenderer wr) IEnumerable<IRenderable> 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<IRenderable>(); return Enumerable.Empty<IRenderable>();
// Players want to see the lines when in waypoint mode. // Players want to see the lines when in waypoint mode.
@@ -70,9 +73,6 @@ namespace OpenRA.Mods.Common.Traits
if (--lifetime <= 0 && !force) if (--lifetime <= 0 && !force)
return Enumerable.Empty<IRenderable>(); return Enumerable.Empty<IRenderable>();
if (!(force || Game.Settings.Game.DrawTargetLine))
return Enumerable.Empty<IRenderable>();
renderableCache.Clear(); renderableCache.Clear();
var prev = self.CenterPosition; var prev = self.CenterPosition;
var a = self.CurrentActivity; var a = self.CurrentActivity;

View File

@@ -205,7 +205,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
BindCheckboxPref(panel, "PIXELDOUBLE_CHECKBOX", ds, "PixelDouble"); BindCheckboxPref(panel, "PIXELDOUBLE_CHECKBOX", ds, "PixelDouble");
BindCheckboxPref(panel, "CURSORDOUBLE_CHECKBOX", ds, "CursorDouble"); BindCheckboxPref(panel, "CURSORDOUBLE_CHECKBOX", ds, "CursorDouble");
BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate"); BindCheckboxPref(panel, "FRAME_LIMIT_CHECKBOX", ds, "CapFramerate");
BindCheckboxPref(panel, "DISPLAY_TARGET_LINES_CHECKBOX", gs, "DrawTargetLine");
BindCheckboxPref(panel, "PLAYER_STANCE_COLORS_CHECKBOX", gs, "UsePlayerStanceColors"); BindCheckboxPref(panel, "PLAYER_STANCE_COLORS_CHECKBOX", gs, "UsePlayerStanceColors");
var languageDropDownButton = panel.Get<DropDownButtonWidget>("LANGUAGE_DROPDOWNBUTTON"); var languageDropDownButton = panel.Get<DropDownButtonWidget>("LANGUAGE_DROPDOWNBUTTON");
@@ -219,8 +218,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var statusBarsDropDown = panel.Get<DropDownButtonWidget>("STATUS_BAR_DROPDOWN"); var statusBarsDropDown = panel.Get<DropDownButtonWidget>("STATUS_BAR_DROPDOWN");
statusBarsDropDown.OnMouseDown = _ => ShowStatusBarsDropdown(statusBarsDropDown, gs); statusBarsDropDown.OnMouseDown = _ => ShowStatusBarsDropdown(statusBarsDropDown, gs);
statusBarsDropDown.GetText = () => gs.StatusBars.ToString() == "Standard" ? statusBarsDropDown.GetText = () => gs.StatusBars == StatusBarsType.Standard ?
"Standard" : gs.StatusBars.ToString() == "DamageShow" ? "Show On Damage" : "Always Show"; "Standard" : gs.StatusBars == StatusBarsType.DamageShow ? "Show On Damage" : "Always Show";
var targetLinesDropDown = panel.Get<DropDownButtonWidget>("TARGET_LINES_DROPDOWN");
targetLinesDropDown.OnMouseDown = _ => ShowTargetLinesDropdown(targetLinesDropDown, gs);
targetLinesDropDown.GetText = () => gs.TargetLines == TargetLinesType.Automatic ?
"Automatic" : gs.TargetLines == TargetLinesType.Manual ? "Manual" : "Disabled";
// Update zoom immediately // Update zoom immediately
var pixelDoubleCheckbox = panel.Get<CheckboxWidget>("PIXELDOUBLE_CHECKBOX"); var pixelDoubleCheckbox = panel.Get<CheckboxWidget>("PIXELDOUBLE_CHECKBOX");
@@ -716,6 +720,29 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return true; return true;
} }
static bool ShowTargetLinesDropdown(DropDownButtonWidget dropdown, GameSettings s)
{
var options = new Dictionary<string, TargetLinesType>()
{
{ "Automatic", TargetLinesType.Automatic },
{ "Manual", TargetLinesType.Manual },
{ "Disabled", TargetLinesType.Disabled },
};
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
{
var item = ScrollItemWidget.Setup(itemTemplate,
() => s.TargetLines == options[o],
() => s.TargetLines = options[o]);
item.Get<LabelWidget>("LABEL").GetText = () => o;
return item;
};
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
return true;
}
void MakeMouseFocusSettingsLive() void MakeMouseFocusSettingsLive()
{ {
var gameSettings = Game.Settings.Game; var gameSettings = Game.Settings.Game;

View File

@@ -210,23 +210,29 @@ Container@SETTINGS_PANEL:
Width: PARENT_RIGHT - 35 Width: PARENT_RIGHT - 35
Height: PARENT_BOTTOM - 12 Height: PARENT_BOTTOM - 12
Label@STATUS_BARS: Label@STATUS_BARS:
X: 310 X: 250
Y: 257 Y: 257
Width: 145
Text: Status Bars: Text: Status Bars:
Align: Right
DropDownButton@STATUS_BAR_DROPDOWN: DropDownButton@STATUS_BAR_DROPDOWN:
X: 400 X: 400
Y: 245 Y: 245
Width: 170 Width: 170
Height: 25 Height: 25
Font: Regular Font: Regular
Text: Standard Label@TARGET_LINES:
Checkbox@DISPLAY_TARGET_LINES_CHECKBOX: X: 250
X: 310 Y: 228
Width: 145
Text: Target Lines:
Align: Right
DropDownButton@TARGET_LINES_DROPDOWN:
X: 400
Y: 215 Y: 215
Width: 200 Width: 170
Height: 20 Height: 25
Font: Regular Font: Regular
Text: Display Target Lines
Label@LOCALIZATION_TITLE: Label@LOCALIZATION_TITLE:
Y: 265 Y: 265
Width: PARENT_RIGHT Width: PARENT_RIGHT

View File

@@ -224,9 +224,11 @@ Background@SETTINGS_PANEL:
Width: PARENT_RIGHT - 35 Width: PARENT_RIGHT - 35
Height: PARENT_BOTTOM - 12 Height: PARENT_BOTTOM - 12
Label@STATUS_BARS: Label@STATUS_BARS:
X: 310 X: 250
Y: 278 Y: 278
Width: 145
Text: Status Bars: Text: Status Bars:
Align: Right
DropDownButton@STATUS_BAR_DROPDOWN: DropDownButton@STATUS_BAR_DROPDOWN:
X: 400 X: 400
Y: 265 Y: 265
@@ -234,13 +236,18 @@ Background@SETTINGS_PANEL:
Height: 25 Height: 25
Font: Regular Font: Regular
Text: Standard Text: Standard
Checkbox@DISPLAY_TARGET_LINES_CHECKBOX: Label@TARGET_LINES:
X: 310 X: 250
Y: 243
Width: 145
Text: Target Lines:
Align: Right
DropDownButton@TARGET_LINES_DROPDOWN:
X: 400
Y: 230 Y: 230
Width: 200 Width: 170
Height: 20 Height: 25
Font: Regular Font: Regular
Text: Display Target Lines
Label@LOCALIZATION_TITLE: Label@LOCALIZATION_TITLE:
Y: 270 Y: 270
Width: PARENT_RIGHT Width: PARENT_RIGHT