Merge pull request #73361 from akien-mga/your-ints-aint-gonna-increment-themselves
EditorProperty: Fix missing increment buttons for integers
This commit is contained in:
commit
9f07643c8c
1 changed files with 9 additions and 6 deletions
|
@ -4174,9 +4174,12 @@ struct EditorPropertyRangeHint {
|
||||||
bool radians = false;
|
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;
|
EditorPropertyRangeHint hint;
|
||||||
hint.step = p_default_step;
|
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(",");
|
Vector<String> slices = p_hint_text.split(",");
|
||||||
if (p_hint == PROPERTY_HINT_RANGE) {
|
if (p_hint == PROPERTY_HINT_RANGE) {
|
||||||
ERR_FAIL_COND_V_MSG(slices.size() < 2, hint,
|
ERR_FAIL_COND_V_MSG(slices.size() < 2, hint,
|
||||||
|
@ -4294,7 +4297,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
|
||||||
} else {
|
} else {
|
||||||
EditorPropertyInteger *editor = memnew(EditorPropertyInteger);
|
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);
|
editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.or_greater, hint.or_less, hint.suffix);
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
|
@ -4383,7 +4386,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
|
||||||
} break;
|
} break;
|
||||||
case Variant::VECTOR2I: {
|
case Variant::VECTOR2I: {
|
||||||
EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i(p_wide));
|
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);
|
editor->setup(hint.min, hint.max, p_hint == PROPERTY_HINT_LINK, hint.suffix);
|
||||||
return editor;
|
return editor;
|
||||||
|
|
||||||
|
@ -4396,7 +4399,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
|
||||||
} break;
|
} break;
|
||||||
case Variant::RECT2I: {
|
case Variant::RECT2I: {
|
||||||
EditorPropertyRect2i *editor = memnew(EditorPropertyRect2i(p_wide));
|
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);
|
editor->setup(hint.min, hint.max, hint.suffix);
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
|
@ -4410,7 +4413,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
|
||||||
} break;
|
} break;
|
||||||
case Variant::VECTOR3I: {
|
case Variant::VECTOR3I: {
|
||||||
EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i(p_wide));
|
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);
|
editor->setup(hint.min, hint.max, p_hint == PROPERTY_HINT_LINK, hint.suffix);
|
||||||
return editor;
|
return editor;
|
||||||
|
|
||||||
|
@ -4424,7 +4427,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
|
||||||
} break;
|
} break;
|
||||||
case Variant::VECTOR4I: {
|
case Variant::VECTOR4I: {
|
||||||
EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i);
|
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);
|
editor->setup(hint.min, hint.max, hint.suffix);
|
||||||
return editor;
|
return editor;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue