diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-15 15:24:35 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-15 15:26:46 +0100 |
commit | 840675ee0704368f13ef79467b4ff7b4461065b6 (patch) | |
tree | 49902b9ded853e4c559d502cfffdfda08b04dfcc | |
parent | d2b1474da79a4dce5c2031b3a3fafe8aaa2a161f (diff) |
EditorProperty: Fix missing increment buttons for integers
Fixes #73192.
-rw-r--r-- | editor/editor_properties.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 33bba90c70..30c7d2b85f 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -4174,9 +4174,12 @@ struct EditorPropertyRangeHint { bool radians = false; }; -static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const String &p_hint_text, double p_default_step) { +static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const String &p_hint_text, double p_default_step, bool is_int = false) { EditorPropertyRangeHint hint; hint.step = p_default_step; + if (is_int) { + hint.hide_slider = false; // Always show slider for ints, unless specified in hint range. + } Vector<String> slices = p_hint_text.split(","); if (p_hint == PROPERTY_HINT_RANGE) { ERR_FAIL_COND_V_MSG(slices.size() < 2, hint, @@ -4294,7 +4297,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ } else { EditorPropertyInteger *editor = memnew(EditorPropertyInteger); - EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1); + EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true); editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.or_greater, hint.or_less, hint.suffix); return editor; @@ -4383,7 +4386,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ } break; case Variant::VECTOR2I: { EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i(p_wide)); - EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1); + EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true); editor->setup(hint.min, hint.max, p_hint == PROPERTY_HINT_LINK, hint.suffix); return editor; @@ -4396,7 +4399,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ } break; case Variant::RECT2I: { EditorPropertyRect2i *editor = memnew(EditorPropertyRect2i(p_wide)); - EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1); + EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true); editor->setup(hint.min, hint.max, hint.suffix); return editor; @@ -4410,7 +4413,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ } break; case Variant::VECTOR3I: { EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i(p_wide)); - EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1); + EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true); editor->setup(hint.min, hint.max, p_hint == PROPERTY_HINT_LINK, hint.suffix); return editor; @@ -4424,7 +4427,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ } break; case Variant::VECTOR4I: { EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i); - EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1); + EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true); editor->setup(hint.min, hint.max, hint.suffix); return editor; |