diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_properties.cpp | 33 | ||||
-rw-r--r-- | editor/project_settings_editor.cpp | 22 |
2 files changed, 38 insertions, 17 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index dea76ac997..34d553b5f9 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -946,14 +946,11 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { } float val = get_edited_object()->get(get_edited_property()); - if (val == 0) { - return; - } bool sg = val < 0; val = Math::absf(val); val = Math::log(val) / Math::log((float)2.0); - //logspace + // Logarithmic space. val += rel * 0.05; val = Math::pow(2.0f, val); @@ -961,6 +958,16 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { val = -val; } + // 0 is a singularity, but both positive and negative values + // are otherwise allowed. Enforce 0+ as workaround. + if (Math::is_zero_approx(val)) { + val = 0.00001; + } + + // Limit to a reasonable value to prevent the curve going into infinity, + // which can cause crashes and other issues. + val = CLAMP(val, -1'000'000, 1'000'000); + emit_changed(get_edited_property(), val); easing_draw->update(); } @@ -1003,7 +1010,18 @@ void EditorPropertyEasing::_draw_easing() { } easing_draw->draw_multiline(lines, line_color, 1.0); - f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), font_color); + // Draw more decimals for small numbers since higher precision is usually required for fine adjustments. + int decimals; + if (Math::abs(exp) < 0.1 - CMP_EPSILON) { + decimals = 4; + } else if (Math::abs(exp) < 1 - CMP_EPSILON) { + decimals = 3; + } else if (Math::abs(exp) < 10 - CMP_EPSILON) { + decimals = 2; + } else { + decimals = 1; + } + f->draw(ci, Point2(10, 10 + f->get_ascent()), rtos(exp).pad_decimals(decimals), font_color); } void EditorPropertyEasing::update_property() { @@ -1035,6 +1053,11 @@ void EditorPropertyEasing::_spin_value_changed(double p_value) { if (Math::is_zero_approx(p_value)) { p_value = 0.00001; } + + // Limit to a reasonable value to prevent the curve going into infinity, + // which can cause crashes and other issues. + p_value = CLAMP(p_value, -1'000'000, 1'000'000); + emit_changed(get_edited_property(), p_value); _spin_focus_exited(); } diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 9be1a7c2fe..89feb436d8 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -171,7 +171,7 @@ void ProjectSettingsEditor::_update_advanced_bar() { } } - disable_add = !bad_category; + disable_add = bad_category; if (!property_text.is_valid_identifier()) { disable_add = true; @@ -327,11 +327,9 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { header->add_child(search_bar); search_box = memnew(LineEdit); - search_box->set_custom_minimum_size(Size2(300, 0)); + search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_bar->add_child(search_box); - search_bar->add_spacer(); - advanced = memnew(CheckButton); advanced->set_text(TTR("Advanced")); advanced->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_advanced_pressed)); @@ -345,12 +343,14 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { advanced_bar->hide(); header->add_child(advanced_bar); + advanced_bar->add_child(memnew(HSeparator)); + HBoxContainer *hbc = memnew(HBoxContainer); hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); - advanced_bar->add_margin_child(TTR("Add or remove custom project settings."), hbc, true); + advanced_bar->add_margin_child(TTR("Add or Remove Custom Project Settings:"), hbc, true); category_box = memnew(LineEdit); - category_box->set_custom_minimum_size(Size2(140, 0) * EDSCALE); + category_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); category_box->connect("text_changed", callable_mp(this, &ProjectSettingsEditor::_text_field_changed)); category_box->set_placeholder(TTR("Category")); hbc->add_child(category_box); @@ -370,7 +370,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { hbc->add_child(l); type = memnew(OptionButton); - type->set_custom_minimum_size(Size2(70, 0) * EDSCALE); + type->set_custom_minimum_size(Size2(100, 0) * EDSCALE); hbc->add_child(type); // Start at 1 to avoid adding "Nil" as an option @@ -383,17 +383,17 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { hbc->add_child(l); feature_override = memnew(OptionButton); - feature_override->set_custom_minimum_size(Size2(70, 0) * EDSCALE); + feature_override->set_custom_minimum_size(Size2(100, 0) * EDSCALE); feature_override->connect("item_selected", callable_mp(this, &ProjectSettingsEditor::_feature_selected)); hbc->add_child(feature_override); - hbc->add_spacer(); - add_button = memnew(Button); + add_button->set_flat(true); add_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_add_setting)); hbc->add_child(add_button); del_button = memnew(Button); + del_button->set_flat(true); del_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_delete_setting)); hbc->add_child(del_button); @@ -401,8 +401,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { advanced_bar->add_child(error_label); } - header->add_child(memnew(HSeparator)); - inspector = memnew(SectionedInspector); inspector->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo()); inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL); |