You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-16 14:00:40 +00:00
EditorProperty: Fix range hint parsing with optional step
This could lead to have a step of 0 when parsing e.g. "1,10,is_greater".
This commit is contained in:
@@ -2642,18 +2642,20 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
||||
int min = 0, max = 65535, step = 1;
|
||||
bool greater = true, lesser = true;
|
||||
|
||||
if (p_hint == PROPERTY_HINT_RANGE && p_hint_text.get_slice_count(",") >= 2) {
|
||||
greater = false; //if using ranged, assume false by default
|
||||
Vector<String> slices = p_hint_text.split(",");
|
||||
if (p_hint == PROPERTY_HINT_RANGE && slices.size() >= 2) {
|
||||
greater = false; // If using ranged, assume false by default.
|
||||
lesser = false;
|
||||
min = p_hint_text.get_slice(",", 0).to_int();
|
||||
max = p_hint_text.get_slice(",", 1).to_int();
|
||||
min = slices[0].to_int();
|
||||
max = slices[1].to_int();
|
||||
|
||||
if (p_hint_text.get_slice_count(",") >= 3) {
|
||||
step = p_hint_text.get_slice(",", 2).to_int();
|
||||
if (slices.size() >= 3 && slices[2].is_valid_integer()) {
|
||||
// Step is optional, could be something else if not a number.
|
||||
step = slices[2].to_int();
|
||||
}
|
||||
|
||||
for (int i = 2; i < p_hint_text.get_slice_count(","); i++) {
|
||||
String slice = p_hint_text.get_slice(",", i).strip_edges();
|
||||
for (int i = 2; i < slices.size(); i++) {
|
||||
String slice = slices[i].strip_edges();
|
||||
if (slice == "or_greater") {
|
||||
greater = true;
|
||||
}
|
||||
@@ -2694,18 +2696,23 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
||||
bool exp_range = false;
|
||||
bool greater = true, lesser = true;
|
||||
|
||||
if ((p_hint == PROPERTY_HINT_RANGE || p_hint == PROPERTY_HINT_EXP_RANGE) && p_hint_text.get_slice_count(",") >= 2) {
|
||||
greater = false; //if using ranged, assume false by default
|
||||
Vector<String> slices = p_hint_text.split(",");
|
||||
if ((p_hint == PROPERTY_HINT_RANGE || p_hint == PROPERTY_HINT_EXP_RANGE) && slices.size() >= 2) {
|
||||
greater = false; // If using ranged, assume false by default.
|
||||
lesser = false;
|
||||
min = p_hint_text.get_slice(",", 0).to_double();
|
||||
max = p_hint_text.get_slice(",", 1).to_double();
|
||||
if (p_hint_text.get_slice_count(",") >= 3) {
|
||||
step = p_hint_text.get_slice(",", 2).to_double();
|
||||
min = slices[0].to_double();
|
||||
max = slices[1].to_double();
|
||||
|
||||
if (slices.size() >= 3 && slices[2].is_valid_float()) {
|
||||
// Step is optional, could be something else if not a number.
|
||||
step = slices[2].to_double();
|
||||
}
|
||||
|
||||
hide_slider = false;
|
||||
exp_range = p_hint == PROPERTY_HINT_EXP_RANGE;
|
||||
for (int i = 2; i < p_hint_text.get_slice_count(","); i++) {
|
||||
String slice = p_hint_text.get_slice(",", i).strip_edges();
|
||||
|
||||
for (int i = 2; i < slices.size(); i++) {
|
||||
String slice = slices[i].strip_edges();
|
||||
if (slice == "or_greater") {
|
||||
greater = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user