diff options
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r-- | editor/editor_inspector.cpp | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index a53938e3f1..a3538d3381 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -623,14 +623,17 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { if (property == "frame_coords" && (object->is_class("Sprite2D") || object->is_class("Sprite3D"))) { Vector2i new_coords = object->get(property); new_coords.x++; - if (new_coords.x >= object->get("hframes").operator int64_t()) { + if (new_coords.x >= int64_t(object->get("hframes"))) { new_coords.x = 0; new_coords.y++; } - - call_deferred(SNAME("emit_changed"), property, new_coords, "", false); + if (new_coords.x < int64_t(object->get("hframes")) && new_coords.y < int64_t(object->get("vframes"))) { + call_deferred(SNAME("emit_changed"), property, new_coords, "", false); + } } else { - call_deferred(SNAME("emit_changed"), property, object->get(property).operator int64_t() + 1, "", false); + if (int64_t(object->get(property)) + 1 < (int64_t(object->get("hframes")) * int64_t(object->get("vframes")))) { + call_deferred(SNAME("emit_changed"), property, object->get(property).operator int64_t() + 1, "", false); + } } call_deferred(SNAME("update_property")); @@ -861,10 +864,10 @@ String EditorProperty::get_tooltip_text() const { void EditorProperty::menu_option(int p_option) { switch (p_option) { case MENU_COPY_PROPERTY: { - EditorNode::get_singleton()->get_inspector()->set_property_clipboard(object->get(property)); + InspectorDock::get_inspector_singleton()->set_property_clipboard(object->get(property)); } break; case MENU_PASTE_PROPERTY: { - emit_changed(property, EditorNode::get_singleton()->get_inspector()->get_property_clipboard()); + emit_changed(property, InspectorDock::get_inspector_singleton()->get_property_clipboard()); } break; case MENU_COPY_PROPERTY_PATH: { DisplayServer::get_singleton()->clipboard_set(property); @@ -1799,7 +1802,7 @@ Array EditorInspectorArray::_extract_properties_as_array(const List<PropertyInfo dict[format_string] = object->get(pi.name); output[array_index] = dict; } else { - WARN_PRINT(vformat("Array element %s has an index too high. Array allocaiton failed.", pi.name)); + WARN_PRINT(vformat("Array element %s has an index too high. Array allocation failed.", pi.name)); } } } @@ -2766,7 +2769,7 @@ void EditorInspector::update_tree() { doc_hint = descr; } - // Seach for the inspector plugin that will handle the properties. Then add the correct property editor to it. + // Search for the inspector plugin that will handle the properties. Then add the correct property editor to it. for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage, wide_editors); @@ -2905,6 +2908,7 @@ void EditorInspector::edit(Object *p_object) { object->connect("property_list_changed", callable_mp(this, &EditorInspector::_changed_callback)); update_tree(); } + emit_signal("edited_object_changed"); } void EditorInspector::set_keying(bool p_active) { @@ -3205,7 +3209,10 @@ void EditorInspector::_property_keyed(const String &p_path, bool p_advance) { return; } - emit_signal(SNAME("property_keyed"), p_path, object->get(p_path), p_advance); //second param is deprecated + // The second parameter could be null, causing the event to fire with less arguments, so use the pointer call which preserves it. + const Variant args[3] = { p_path, object->get(p_path), p_advance }; + const Variant *argp[3] = { &args[0], &args[1], &args[2] }; + emit_signal(SNAME("property_keyed"), argp, 3); } void EditorInspector::_property_deleted(const String &p_path) { @@ -3213,7 +3220,7 @@ void EditorInspector::_property_deleted(const String &p_path) { return; } - emit_signal(SNAME("property_deleted"), p_path); //second param is deprecated + emit_signal(SNAME("property_deleted"), p_path); } void EditorInspector::_property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance) { @@ -3221,7 +3228,10 @@ void EditorInspector::_property_keyed_with_value(const String &p_path, const Var return; } - emit_signal(SNAME("property_keyed"), p_path, p_value, p_advance); //second param is deprecated + // The second parameter could be null, causing the event to fire with less arguments, so use the pointer call which preserves it. + const Variant args[3] = { p_path, p_value, p_advance }; + const Variant *argp[3] = { &args[0], &args[1], &args[2] }; + emit_signal(SNAME("property_keyed"), argp, 3); } void EditorInspector::_property_checked(const String &p_path, bool p_checked) { @@ -3349,7 +3359,7 @@ void EditorInspector::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { if (update_scroll_request >= 0) { - get_v_scrollbar()->call_deferred(SNAME("set_value"), update_scroll_request); + get_v_scroll_bar()->call_deferred(SNAME("set_value"), update_scroll_request); update_scroll_request = -1; } if (refresh_countdown > 0) { @@ -3531,12 +3541,13 @@ void EditorInspector::_bind_methods() { ClassDB::bind_method("_edit_request_change", &EditorInspector::_edit_request_change); ADD_SIGNAL(MethodInfo("property_selected", PropertyInfo(Variant::STRING, "property"))); - ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property"))); + ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), PropertyInfo(Variant::BOOL, "advance"))); ADD_SIGNAL(MethodInfo("property_deleted", PropertyInfo(Variant::STRING, "property"))); ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop"))); ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::INT, "id"))); ADD_SIGNAL(MethodInfo("property_edited", PropertyInfo(Variant::STRING, "property"))); ADD_SIGNAL(MethodInfo("property_toggled", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::BOOL, "checked"))); + ADD_SIGNAL(MethodInfo("edited_object_changed")); ADD_SIGNAL(MethodInfo("restart_requested")); } @@ -3570,7 +3581,7 @@ EditorInspector::EditorInspector() { deletable_properties = false; property_clipboard = Variant(); - get_v_scrollbar()->connect("value_changed", callable_mp(this, &EditorInspector::_vscroll_changed)); + get_v_scroll_bar()->connect("value_changed", callable_mp(this, &EditorInspector::_vscroll_changed)); update_scroll_request = -1; if (EditorSettings::get_singleton()) { refresh_countdown = float(EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval")); |