diff options
Diffstat (limited to 'editor/property_editor.cpp')
-rw-r--r-- | editor/property_editor.cpp | 142 |
1 files changed, 65 insertions, 77 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 2dcbc4c14c..f4af50eb81 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -176,9 +176,9 @@ void CustomPropertyEditor::_menu_option(int p_which) { case OBJ_MENU_EDIT: { - RefPtr RefPtr = v; + REF r = v; - if (!RefPtr.is_null()) { + if (!r.is_null()) { emit_signal("resource_edit_request"); hide(); @@ -193,8 +193,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { case OBJ_MENU_MAKE_UNIQUE: { - RefPtr RefPtr = v; - Ref<Resource> res_orig = RefPtr; + Ref<Resource> res_orig = v; if (res_orig.is_null()) return; @@ -229,7 +228,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { res->set(p.first, p.second); } - v = res.get_ref_ptr(); + v = res; emit_signal("variant_changed"); hide(); } break; @@ -311,7 +310,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { res->call("set_instance_base_type", owner->get_class()); } - v = Ref<Resource>(res).get_ref_ptr(); + v = res; emit_signal("variant_changed"); } break; @@ -394,12 +393,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::INT: - case Variant::REAL: { + case Variant::FLOAT: { if (hint == PROPERTY_HINT_RANGE) { int c = hint_text.get_slice_count(","); - float min = 0, max = 100, step = type == Variant::REAL ? .01 : 1; + float min = 0, max = 100, step = type == Variant::FLOAT ? .01 : 1; if (c >= 1) { if (!hint_text.get_slice(",", 0).empty()) @@ -590,7 +589,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: if (!create_dialog) { create_dialog = memnew(CreateDialog); - create_dialog->connect("create", this, "_create_dialog_callback"); + create_dialog->connect("create", callable_mp(this, &CustomPropertyEditor::_create_dialog_callback)); add_child(create_dialog); } @@ -606,12 +605,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: return false; } else if (hint == PROPERTY_HINT_METHOD_OF_VARIANT_TYPE) { -#define MAKE_PROPSELECT \ - if (!property_select) { \ - property_select = memnew(PropertySelector); \ - property_select->connect("selected", this, "_create_selected_property"); \ - add_child(property_select); \ - } \ +#define MAKE_PROPSELECT \ + if (!property_select) { \ + property_select = memnew(PropertySelector); \ + property_select->connect("selected", callable_mp(this, &CustomPropertyEditor::_create_selected_property)); \ + add_child(property_select); \ + } \ hide(); MAKE_PROPSELECT; @@ -639,7 +638,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: MAKE_PROPSELECT - Object *instance = ObjectDB::get_instance(hint_text.to_int64()); + Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (instance) property_select->select_method_from_instance(instance, v); updating = false; @@ -648,7 +647,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } else if (hint == PROPERTY_HINT_METHOD_OF_SCRIPT) { MAKE_PROPSELECT - Object *obj = ObjectDB::get_instance(hint_text.to_int64()); + Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (Object::cast_to<Script>(obj)) { property_select->select_method_from_script(Object::cast_to<Script>(obj), v); } @@ -688,7 +687,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: MAKE_PROPSELECT - Object *instance = ObjectDB::get_instance(hint_text.to_int64()); + Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (instance) property_select->select_property_from_instance(instance, v); @@ -698,7 +697,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } else if (hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) { MAKE_PROPSELECT - Object *obj = ObjectDB::get_instance(hint_text.to_int64()); + Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (Object::cast_to<Script>(obj)) { property_select->select_property_from_script(Object::cast_to<Script>(obj), v); } @@ -866,7 +865,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: color_picker->set_deferred_mode(true); add_child(color_picker); color_picker->hide(); - color_picker->connect("color_changed", this, "_color_changed"); + color_picker->connect("color_changed", callable_mp(this, &CustomPropertyEditor::_color_changed)); // get default color picker mode from editor settings int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode"); @@ -935,7 +934,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: const String &t = j->get(); bool is_custom_resource = false; - Ref<Texture> icon; + Ref<Texture2D> icon; if (!custom_resources.empty()) { for (int k = 0; k < custom_resources.size(); k++) { if (custom_resources[k].name == t) { @@ -1023,7 +1022,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); - Ref<Texture> icon; + Ref<Texture2D> icon; if (has_icon(what, "EditorIcons")) { icon = get_icon(what, "EditorIcons"); @@ -1046,22 +1045,28 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: case Variant::DICTIONARY: { } break; - case Variant::POOL_BYTE_ARRAY: { + case Variant::PACKED_BYTE_ARRAY: { } break; - case Variant::POOL_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { } break; - case Variant::POOL_REAL_ARRAY: { + case Variant::PACKED_FLOAT32_ARRAY: { } break; - case Variant::POOL_STRING_ARRAY: { + case Variant::PACKED_INT64_ARRAY: { } break; - case Variant::POOL_VECTOR3_ARRAY: { + case Variant::PACKED_FLOAT64_ARRAY: { } break; - case Variant::POOL_COLOR_ARRAY: { + case Variant::PACKED_STRING_ARRAY: { + + } break; + case Variant::PACKED_VECTOR3_ARRAY: { + + } break; + case Variant::PACKED_COLOR_ARRAY: { } break; default: { @@ -1103,7 +1108,7 @@ void CustomPropertyEditor::_file_selected(String p_file) { error->popup_centered_minsize(); break; } - v = res.get_ref_ptr(); + v = res; emit_signal("variant_changed"); hide(); } break; @@ -1114,7 +1119,7 @@ void CustomPropertyEditor::_file_selected(String p_file) { void CustomPropertyEditor::_type_create_selected(int p_idx) { - if (type == Variant::INT || type == Variant::REAL) { + if (type == Variant::INT || type == Variant::FLOAT) { float newval = 0; switch (p_idx) { @@ -1168,7 +1173,7 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { Resource *res = Object::cast_to<Resource>(obj); ERR_FAIL_COND(!res); - v = Ref<Resource>(res).get_ref_ptr(); + v = res; emit_signal("variant_changed"); hide(); } @@ -1373,7 +1378,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { Resource *res = Object::cast_to<Resource>(obj); ERR_BREAK(!res); - v = Ref<Resource>(res).get_ref_ptr(); + v = res; emit_signal("variant_changed"); hide(); } @@ -1395,9 +1400,9 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } else if (p_which == 2) { - RefPtr RefPtr = v; + RES r = v; - if (!RefPtr.is_null()) { + if (!r.is_null()) { emit_signal("resource_edit_request"); hide(); @@ -1410,8 +1415,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { hide(); } else if (p_which == 4) { - RefPtr RefPtr = v; - Ref<Resource> res_orig = RefPtr; + Ref<Resource> res_orig = v; if (res_orig.is_null()) return; @@ -1442,7 +1446,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { res->set(p.first, p.second); } - v = res.get_ref_ptr(); + v = res; emit_signal("variant_changed"); hide(); } @@ -1565,7 +1569,7 @@ void CustomPropertyEditor::_modified(String p_string) { emit_signal("variant_changed"); } break; - case Variant::REAL: { + case Variant::FLOAT: { if (hint != PROPERTY_HINT_EXP_EASING) { String text = value_editor[0]->get_text(); @@ -1699,22 +1703,22 @@ void CustomPropertyEditor::_modified(String p_string) { case Variant::DICTIONARY: { } break; - case Variant::POOL_BYTE_ARRAY: { + case Variant::PACKED_BYTE_ARRAY: { } break; - case Variant::POOL_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { } break; - case Variant::POOL_REAL_ARRAY: { + case Variant::PACKED_FLOAT32_ARRAY: { } break; - case Variant::POOL_STRING_ARRAY: { + case Variant::PACKED_STRING_ARRAY: { } break; - case Variant::POOL_VECTOR3_ARRAY: { + case Variant::PACKED_VECTOR3_ARRAY: { } break; - case Variant::POOL_COLOR_ARRAY: { + case Variant::PACKED_COLOR_ARRAY: { } break; default: { @@ -1753,7 +1757,7 @@ void CustomPropertyEditor::_range_modified(double p_value) { void CustomPropertyEditor::_focus_enter() { switch (type) { - case Variant::REAL: + case Variant::FLOAT: case Variant::STRING: case Variant::VECTOR2: case Variant::RECT2: @@ -1779,7 +1783,7 @@ void CustomPropertyEditor::_focus_enter() { void CustomPropertyEditor::_focus_exit() { switch (type) { - case Variant::REAL: + case Variant::FLOAT: case Variant::STRING: case Variant::VECTOR2: case Variant::RECT2: @@ -1870,22 +1874,6 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int void CustomPropertyEditor::_bind_methods() { - ClassDB::bind_method("_focus_enter", &CustomPropertyEditor::_focus_enter); - ClassDB::bind_method("_focus_exit", &CustomPropertyEditor::_focus_exit); - ClassDB::bind_method("_modified", &CustomPropertyEditor::_modified); - ClassDB::bind_method("_range_modified", &CustomPropertyEditor::_range_modified); - ClassDB::bind_method("_action_pressed", &CustomPropertyEditor::_action_pressed); - ClassDB::bind_method("_file_selected", &CustomPropertyEditor::_file_selected); - ClassDB::bind_method("_type_create_selected", &CustomPropertyEditor::_type_create_selected); - ClassDB::bind_method("_node_path_selected", &CustomPropertyEditor::_node_path_selected); - ClassDB::bind_method("_color_changed", &CustomPropertyEditor::_color_changed); - ClassDB::bind_method("_draw_easing", &CustomPropertyEditor::_draw_easing); - ClassDB::bind_method("_drag_easing", &CustomPropertyEditor::_drag_easing); - ClassDB::bind_method("_text_edit_changed", &CustomPropertyEditor::_text_edit_changed); - ClassDB::bind_method("_menu_option", &CustomPropertyEditor::_menu_option); - ClassDB::bind_method("_create_dialog_callback", &CustomPropertyEditor::_create_dialog_callback); - ClassDB::bind_method("_create_selected_property", &CustomPropertyEditor::_create_selected_property); - ADD_SIGNAL(MethodInfo("variant_changed")); ADD_SIGNAL(MethodInfo("variant_field_changed", PropertyInfo(Variant::STRING, "field"))); ADD_SIGNAL(MethodInfo("resource_edit_request")); @@ -1904,9 +1892,9 @@ CustomPropertyEditor::CustomPropertyEditor() { add_child(value_label[i]); value_editor[i]->hide(); value_label[i]->hide(); - value_editor[i]->connect("text_entered", this, "_modified"); - value_editor[i]->connect("focus_entered", this, "_focus_enter"); - value_editor[i]->connect("focus_exited", this, "_focus_exit"); + value_editor[i]->connect("text_entered", callable_mp(this, &CustomPropertyEditor::_modified)); + value_editor[i]->connect("focus_entered", callable_mp(this, &CustomPropertyEditor::_focus_enter)); + value_editor[i]->connect("focus_exited", callable_mp(this, &CustomPropertyEditor::_focus_exit)); } focused_value_editor = -1; @@ -1936,7 +1924,7 @@ CustomPropertyEditor::CustomPropertyEditor() { checks20[i]->set_focus_mode(FOCUS_NONE); checks20gc->add_child(checks20[i]); checks20[i]->hide(); - checks20[i]->connect("pressed", this, "_action_pressed", make_binds(i)); + checks20[i]->connect("pressed", callable_mp(this, &CustomPropertyEditor::_action_pressed), make_binds(i)); checks20[i]->set_tooltip(vformat(TTR("Bit %d, val %d."), i, 1 << i)); } @@ -1946,7 +1934,7 @@ CustomPropertyEditor::CustomPropertyEditor() { text_edit->set_margin(MARGIN_BOTTOM, -30); text_edit->hide(); - text_edit->connect("text_changed", this, "_text_edit_changed"); + text_edit->connect("text_changed", callable_mp(this, &CustomPropertyEditor::_text_edit_changed)); for (int i = 0; i < MAX_ACTION_BUTTONS; i++) { @@ -1955,7 +1943,7 @@ CustomPropertyEditor::CustomPropertyEditor() { add_child(action_buttons[i]); Vector<Variant> binds; binds.push_back(i); - action_buttons[i]->connect("pressed", this, "_action_pressed", binds); + action_buttons[i]->connect("pressed", callable_mp(this, &CustomPropertyEditor::_action_pressed), binds); action_buttons[i]->set_flat(true); } @@ -1966,8 +1954,8 @@ CustomPropertyEditor::CustomPropertyEditor() { add_child(file); file->hide(); - file->connect("file_selected", this, "_file_selected"); - file->connect("dir_selected", this, "_file_selected"); + file->connect("file_selected", callable_mp(this, &CustomPropertyEditor::_file_selected)); + file->connect("dir_selected", callable_mp(this, &CustomPropertyEditor::_file_selected)); error = memnew(ConfirmationDialog); error->set_title(TTR("Error!")); @@ -1975,7 +1963,7 @@ CustomPropertyEditor::CustomPropertyEditor() { scene_tree = memnew(SceneTreeDialog); add_child(scene_tree); - scene_tree->connect("selected", this, "_node_path_selected"); + scene_tree->connect("selected", callable_mp(this, &CustomPropertyEditor::_node_path_selected)); scene_tree->get_scene_tree()->set_show_enabled_subscene(true); texture_preview = memnew(TextureRect); @@ -1985,31 +1973,31 @@ CustomPropertyEditor::CustomPropertyEditor() { easing_draw = memnew(Control); add_child(easing_draw); easing_draw->hide(); - easing_draw->connect("draw", this, "_draw_easing"); - easing_draw->connect("gui_input", this, "_drag_easing"); + easing_draw->connect("draw", callable_mp(this, &CustomPropertyEditor::_draw_easing)); + easing_draw->connect("gui_input", callable_mp(this, &CustomPropertyEditor::_drag_easing)); easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE); type_button = memnew(MenuButton); add_child(type_button); type_button->hide(); - type_button->get_popup()->connect("id_pressed", this, "_type_create_selected"); + type_button->get_popup()->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_type_create_selected)); menu = memnew(PopupMenu); menu->set_pass_on_modal_close_click(false); add_child(menu); - menu->connect("id_pressed", this, "_menu_option"); + menu->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_menu_option)); evaluator = NULL; spinbox = memnew(SpinBox); add_child(spinbox); spinbox->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); - spinbox->connect("value_changed", this, "_range_modified"); + spinbox->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified)); slider = memnew(HSlider); add_child(slider); slider->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); - slider->connect("value_changed", this, "_range_modified"); + slider->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified)); create_dialog = NULL; property_select = NULL; |