diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs index 8b7f853796..b107275097 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs @@ -308,6 +308,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic slider.OnChange += value => so.OnChange(actor, value); slider.OnChange += value => editorActionHandle.OnChange(value); + var valueField = sliderContainer.GetOrNull("VALUE"); + if (valueField != null) + { + Action updateValueField = f => valueField.Text = ((int)f).ToString(); + updateValueField(so.GetValue(actor)); + slider.OnChange += updateValueField; + + valueField.OnTextEdited = () => + { + if (float.TryParse(valueField.Text, out var result)) + slider.UpdateValue(result); + }; + } + initContainer.AddChild(sliderContainer); } else if (o is EditorActorDropdown) diff --git a/OpenRA.Mods.Common/Widgets/SliderWidget.cs b/OpenRA.Mods.Common/Widgets/SliderWidget.cs index d3413ee57c..0044896547 100644 --- a/OpenRA.Mods.Common/Widgets/SliderWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SliderWidget.cs @@ -48,10 +48,12 @@ namespace OpenRA.Mods.Common.Widgets GetValue = other.GetValue; } - void UpdateValue(float newValue) + public void UpdateValue(float newValue) { + var oldValue = Value; Value = newValue.Clamp(MinimumValue, MaximumValue); - OnChange(Value); + if (oldValue != Value) + OnChange(Value); } public override bool HandleMouseInput(MouseInput mi) @@ -114,7 +116,7 @@ namespace OpenRA.Mods.Common.Widgets if (!IsVisible()) return; - Value = GetValue(); + UpdateValue(GetValue()); var tr = ThumbRect; var rb = RenderBounds; diff --git a/mods/cnc/chrome/editor.yaml b/mods/cnc/chrome/editor.yaml index 6e2799b194..63afc0b75c 100644 --- a/mods/cnc/chrome/editor.yaml +++ b/mods/cnc/chrome/editor.yaml @@ -277,8 +277,14 @@ Container@EDITOR_WORLD_ROOT: Slider@OPTION: X: 58 Y: 1 - Width: 207 + Width: 146 Height: 20 + TextField@VALUE: + X: 206 + Y: 1 + Width: 50 + Height: 20 + Type: Integer Container@DROPDOWN_OPTION_TEMPLATE: Width: PARENT_RIGHT Height: 27 diff --git a/mods/common/chrome/editor.yaml b/mods/common/chrome/editor.yaml index d10198d6ba..fbfc994d07 100644 --- a/mods/common/chrome/editor.yaml +++ b/mods/common/chrome/editor.yaml @@ -271,8 +271,14 @@ Container@EDITOR_WORLD_ROOT: Slider@OPTION: X: 75 Y: 1 - Width: 210 + Width: 149 Height: 20 + TextField@VALUE: + X: 226 + Y: 1 + Width: 50 + Height: 20 + Type: Integer Container@DROPDOWN_OPTION_TEMPLATE: Width: PARENT_RIGHT Height: 27