diff options
Diffstat (limited to 'editor')
25 files changed, 266 insertions, 378 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 79c22f667a..aeb304d3b9 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1039,6 +1039,8 @@ void CodeTextEditor::delete_lines() { int to_line = text_editor->get_selection_to_line(); int from_line = text_editor->get_selection_from_line(); int count = Math::abs(to_line - from_line) + 1; + + text_editor->cursor_set_line(to_line, false); while (count) { text_editor->set_line(text_editor->cursor_get_line(), ""); text_editor->backspace_at_cursor(); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 1374c8c9aa..64742ff74c 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -185,6 +185,7 @@ void EditorAutoloadSettings::_autoload_edited() { if (path.begins_with("*")) path = path.substr(1, path.length()); + // Singleton autoloads are represented with a leading "*" in their path. if (checked) path = "*" + path; @@ -651,6 +652,7 @@ void EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); undo_redo->create_action(TTR("Add AutoLoad")); + // Singleton autoloads are represented with a leading "*" in their path. undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + path); if (ProjectSettings::get_singleton()->has_setting(name)) { diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c5c78b2590..96d482f47e 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -477,33 +477,16 @@ EditorPropertyCheck::EditorPropertyCheck() { void EditorPropertyEnum::_option_selected(int p_which) { - String text = options->get_item_text(p_which); - Vector<String> text_split = text.split(":"); - if (text_split.size() == 1) { - emit_signal("property_changed", get_edited_property(), p_which); - return; - } - String name = text_split[1]; - emit_signal("property_changed", get_edited_property(), name.to_int()); + int val = options->get_item_metadata(p_which); + emit_signal("property_changed", get_edited_property(), val); } void EditorPropertyEnum::update_property() { int which = get_edited_object()->get(get_edited_property()); - if (which == 0) { - options->select(which); - return; - } for (int i = 0; i < options->get_item_count(); i++) { - String text = options->get_item_text(i); - Vector<String> text_split = text.split(":"); - if (text_split.size() == 1) { - options->select(which); - return; - } - String name = text_split[1]; - if (itos(which) == name) { + if (which == (int)options->get_item_metadata(i)) { options->select(i); return; } @@ -511,8 +494,15 @@ void EditorPropertyEnum::update_property() { } void EditorPropertyEnum::setup(const Vector<String> &p_options) { + + int current_val = 0; for (int i = 0; i < p_options.size(); i++) { - options->add_item(p_options[i], i); + Vector<String> text_split = p_options[i].split(":"); + if (text_split.size() != 1) + current_val = text_split[1].to_int(); + options->add_item(text_split[0]); + options->set_item_metadata(i, current_val); + current_val += 1; } } @@ -1779,7 +1769,7 @@ void EditorPropertyColor::_color_changed(const Color &p_color) { void EditorPropertyColor::_popup_closed() { - emit_signal("property_changed", get_edited_property(), picker->get_pick_color(), true); + emit_signal("property_changed", get_edited_property(), picker->get_pick_color(), false); } void EditorPropertyColor::_bind_methods() { @@ -2102,12 +2092,18 @@ void EditorPropertyResource::_menu_option(int p_which) { } } -void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture> &p_preview, ObjectID p_obj) { +void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, ObjectID p_obj) { RES p = get_edited_object()->get(get_edited_property()); if (p.is_valid() && p->get_instance_id() == p_obj) { + String type = p->get_class_name(); + + if (ClassDB::is_parent_class(type, "Script")) { + assign->set_text(p->get_path().get_file()); + return; + } + if (p_preview.is_valid()) { - String type = p->get_class_name(); preview->set_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_constant("hseparation", "Button")); if (type == "GradientTexture") { preview->set_stretch_mode(TextureRect::STRETCH_SCALE); @@ -2374,7 +2370,7 @@ void EditorPropertyResource::update_property() { if (res->get_name() != String()) { assign->set_text(res->get_name()); } else if (res->get_path().is_resource_file()) { - assign->set_text(res->get_name()); + assign->set_text(res->get_path().get_file()); assign->set_tooltip(res->get_path()); } else { assign->set_text(res->get_class()); diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 18e70345aa..35d8f4d306 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -548,7 +548,7 @@ class EditorPropertyResource : public EditorProperty { void _file_selected(const String &p_path); void _menu_option(int p_which); - void _resource_preview(const String &p_path, const Ref<Texture> &p_preview, ObjectID p_obj); + void _resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, ObjectID p_obj); void _resource_selected(); void _viewport_selected(const NodePath &p_path); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 4d386c1af6..b11c5c3bef 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1172,6 +1172,23 @@ void FileSystemDock::_update_project_settings_after_move(const Map<String, Strin } }; } + + // Also search for the file in autoload, as they are stored differently from normal files. + List<PropertyInfo> property_list; + ProjectSettings::get_singleton()->get_property_list(&property_list); + for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + if (E->get().name.begins_with("autoload/")) { + // If the autoload resource paths has a leading "*", it indicates that it is a Singleton, + // so we have to handle both cases when updating. + String autoload = GLOBAL_GET(E->get().name); + String autoload_singleton = autoload.substr(1, autoload.length()); + if (p_renames.has(autoload)) { + ProjectSettings::get_singleton()->set_setting(E->get().name, p_renames[autoload]); + } else if (autoload.begins_with("*") && p_renames.has(autoload_singleton)) { + ProjectSettings::get_singleton()->set_setting(E->get().name, "*" + p_renames[autoload_singleton]); + } + } + } ProjectSettings::get_singleton()->save(); } @@ -1200,7 +1217,8 @@ void FileSystemDock::_make_dir_confirm() { if (dir_name.length() == 0) { EditorNode::get_singleton()->show_warning(TTR("No name provided")); return; - } else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1 || dir_name.ends_with(".") || dir_name.ends_with(" ")) { + } else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1 || dir_name.find("*") != -1 || + dir_name.find("|") != -1 || dir_name.find(">") != -1 || dir_name.ends_with(".") || dir_name.ends_with(" ")) { EditorNode::get_singleton()->show_warning(TTR("Provided name contains invalid characters")); return; } diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index f88d1b24a6..0ccaa95fb7 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -336,12 +336,10 @@ FindInFilesDialog::FindInFilesDialog() { _whole_words_checkbox = memnew(CheckBox); _whole_words_checkbox->set_text(TTR("Whole Words")); - _whole_words_checkbox->set_pressed(true); hbc->add_child(_whole_words_checkbox); _match_case_checkbox = memnew(CheckBox); _match_case_checkbox->set_text(TTR("Match Case")); - _match_case_checkbox->set_pressed(true); hbc->add_child(_match_case_checkbox); gc->add_child(hbc); @@ -563,7 +561,7 @@ FindInFilesPanel::FindInFilesPanel() { _cancel_button = memnew(Button); _cancel_button->set_text(TTR("Cancel")); _cancel_button->connect("pressed", this, "_on_cancel_button_clicked"); - _cancel_button->set_disabled(true); + _cancel_button->hide(); hbc->add_child(_cancel_button); vbc->add_child(hbc); @@ -642,7 +640,7 @@ void FindInFilesPanel::start_search() { _finder->start(); update_replace_buttons(); - _cancel_button->set_disabled(false); + _cancel_button->show(); } void FindInFilesPanel::stop_search() { @@ -652,7 +650,7 @@ void FindInFilesPanel::stop_search() { _status_label->set_text(""); update_replace_buttons(); set_progress_visible(false); - _cancel_button->set_disabled(true); + _cancel_button->hide(); } void FindInFilesPanel::_notification(int p_what) { @@ -688,7 +686,7 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin // Do this first because it resets properties of the cell... item->set_cell_mode(text_index, TreeItem::CELL_MODE_CUSTOM); - String item_text = String::num_int64(line_number) + ": " + text.replace("\t", " "); + String item_text = vformat("%3s: %s", line_number, text.replace("\t", " ")); item->set_text(text_index, item_text); item->set_custom_draw(text_index, this, "_draw_result_text"); @@ -754,7 +752,7 @@ void FindInFilesPanel::_on_finished() { _status_label->set_text(TTR("Search complete")); update_replace_buttons(); set_progress_visible(false); - _cancel_button->set_disabled(true); + _cancel_button->hide(); } void FindInFilesPanel::_on_cancel_button_clicked() { diff --git a/editor/icons/icon_GUI_viewport_hdiagsplitter.svg b/editor/icons/icon_GUI_viewport_hdiagsplitter.svg index 36769768fd..90a0f56c43 100644 --- a/editor/icons/icon_GUI_viewport_hdiagsplitter.svg +++ b/editor/icons/icon_GUI_viewport_hdiagsplitter.svg @@ -1,64 +1,5 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="64" - height="34" - version="1.1" - viewBox="0 0 64 34" - id="svg6" - sodipodi:docname="icon_GUI_vsplitter1.svg" - inkscape:version="0.92.2 2405546, 2018-03-11"> - <metadata - id="metadata12"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> - </cc:Work> - </rdf:RDF> - </metadata> - <defs - id="defs10" /> - <sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1366" - inkscape:window-height="714" - id="namedview8" - showgrid="false" - inkscape:zoom="5.6568543" - inkscape:cx="37.006499" - inkscape:cy="15.680715" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="1" - inkscape:current-layer="svg6" /> - <g - transform="translate(0,-1018.4)" - id="g4" /> - <g - transform="rotate(90,541.2,539.2)" - id="g4-3"> - <path - id="path2-6" - style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-opacity:0.39216003" - d="M 4.0306826,1048.4 H 34 m -30,30 v -60" - inkscape:connector-curvature="0" - sodipodi:nodetypes="cccc" /> - </g> +<svg width="64" height="34" version="1.1" viewBox="0 0 64 34" xmlns="http://www.w3.org/2000/svg"> +<g transform="rotate(90,541.2,539.2)"> +<path d="m4.0307 1048.4h29.969m-30 30v-60" fill="none" stroke="#fff" stroke-linecap="round" stroke-opacity=".39216" stroke-width="2"/> +</g> </svg> diff --git a/editor/icons/icon_GUI_viewport_vdiagsplitter.svg b/editor/icons/icon_GUI_viewport_vdiagsplitter.svg index f23b4a0a74..481f895d46 100644 --- a/editor/icons/icon_GUI_viewport_vdiagsplitter.svg +++ b/editor/icons/icon_GUI_viewport_vdiagsplitter.svg @@ -1,68 +1,7 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="34" - height="64" - version="1.1" - viewBox="0 0 34 64" - id="svg6" - sodipodi:docname="icon_GUI_vsplitter2.svg" - inkscape:version="0.92.2 2405546, 2018-03-11"> - <metadata - id="metadata12"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> - </cc:Work> - </rdf:RDF> - </metadata> - <defs - id="defs10" /> - <sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1366" - inkscape:window-height="714" - id="namedview8" - showgrid="false" - inkscape:zoom="4" - inkscape:cx="32.245723" - inkscape:cy="44.255214" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="1" - inkscape:current-layer="svg6" /> - <g - transform="translate(0,-988.4)" - id="g4" /> - <g - id="g839" - transform="rotate(90,32.003536,32.003535)"> - <g - id="g4-3" - transform="rotate(90,526.2,554.2)"> - <path - sodipodi:nodetypes="cccc" - inkscape:connector-curvature="0" - d="M 4.0306826,1048.4 H 34 m -30,30 v -60" - style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-opacity:0.39216003" - id="path2-6" /> - </g> - </g> +<svg width="34" height="64" version="1.1" viewBox="0 0 34 64" xmlns="http://www.w3.org/2000/svg"> +<g transform="rotate(90 32.004 32.004)"> +<g transform="rotate(90,526.2,554.2)"> +<path d="m4.0307 1048.4h29.969m-30 30v-60" fill="none" stroke="#fff" stroke-linecap="round" stroke-opacity=".39216" stroke-width="2"/> +</g> +</g> </svg> diff --git a/editor/icons/icon_GUI_viewport_vhsplitter.svg b/editor/icons/icon_GUI_viewport_vhsplitter.svg index 429cf909ae..52d7d8f0b7 100644 --- a/editor/icons/icon_GUI_viewport_vhsplitter.svg +++ b/editor/icons/icon_GUI_viewport_vhsplitter.svg @@ -1,63 +1,5 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="64" - height="64" - version="1.1" - viewBox="0 0 64 64" - id="svg6" - sodipodi:docname="icon_GUI_vsplitter.svg" - inkscape:version="0.92.2 2405546, 2018-03-11"> - <metadata - id="metadata12"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> - </cc:Work> - </rdf:RDF> - </metadata> - <defs - id="defs10" /> - <sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1366" - inkscape:window-height="714" - id="namedview8" - showgrid="false" - inkscape:zoom="4.65625" - inkscape:cx="9.8488117" - inkscape:cy="20.04653" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="1" - inkscape:current-layer="svg6" /> - <g - transform="translate(0,-988.4)" - id="g4" /> - <g - transform="rotate(90,526.2,554.2)" - id="g4-3"> - <path - id="path2-6" - style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-opacity:0.39216003" - d="m -26,1048.4 h 60 m -30,30 v -60" - inkscape:connector-curvature="0" /> - </g> +<svg width="64" height="64" version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"> +<g transform="rotate(90,526.2,554.2)"> +<path d="m-26 1048.4h60m-30 30v-60" fill="none" stroke="#fff" stroke-linecap="round" stroke-opacity=".39216" stroke-width="2"/> +</g> </svg> diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 60ca66e464..e8bb772a64 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -321,7 +321,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { } else { //mesh since nothing else node = memnew(MeshInstance); - Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); + //Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); } } break; case Collada::Node::TYPE_SKELETON: { diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 6d72cb4909..c5a5980fc1 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -365,29 +365,37 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array return p_node; MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); if (mi) { - Node *col; + Node *col = NULL; if (_teststr(name, "colonly")) { col = mi->create_trimesh_collision_node(); - ERR_FAIL_COND_V(!col, NULL); + if (col == NULL) { + ERR_PRINTS("Error generating collision for mesh: " + name); + } else { - col->set_name(_fixstr(name, "colonly")); + col->set_name(_fixstr(name, "colonly")); + } } else { col = mi->create_convex_collision_node(); - ERR_FAIL_COND_V(!col, NULL); + if (col == NULL) { + ERR_PRINTS("Error generating collision for mesh: " + name); + } else { - col->set_name(_fixstr(name, "convcolonly")); + col->set_name(_fixstr(name, "convcolonly")); + } } - Object::cast_to<Spatial>(col)->set_transform(mi->get_transform()); - p_node->replace_by(col); - memdelete(p_node); - p_node = col; + if (col) { + Object::cast_to<Spatial>(col)->set_transform(mi->get_transform()); + p_node->replace_by(col); + memdelete(p_node); + p_node = col; - StaticBody *sb = Object::cast_to<StaticBody>(col); - CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0)); - colshape->set_name("shape"); - colshape->set_owner(p_node->get_owner()); + StaticBody *sb = Object::cast_to<StaticBody>(col); + CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0)); + colshape->set_name("shape"); + colshape->set_owner(p_node->get_owner()); + } } else if (p_node->has_meta("empty_draw_type")) { String empty_draw_type = String(p_node->get_meta("empty_draw_type")); StaticBody *sb = memnew(StaticBody); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index b046e2e975..b81a52ab70 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -116,7 +116,7 @@ class ResourceImporterScene : public ResourceImporter { enum LightBakeMode { LIGHT_BAKE_DISABLED, LIGHT_BAKE_ENABLE, - //LIGHT_BAKE_LIGHTMAPS + LIGHT_BAKE_LIGHTMAPS }; void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index f7e59e2beb..71a5d73b2f 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -132,8 +132,8 @@ Vector2 AbstractPolygon2DEditor::_get_offset(int p_idx) const { void AbstractPolygon2DEditor::_commit_action() { - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); } @@ -218,7 +218,7 @@ void AbstractPolygon2DEditor::_node_removed(Node *p_node) { edit(NULL); hide(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } @@ -334,7 +334,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) edited_point = PosVertex(closest, xform.affine_inverse().xform(closest.pos)); selected_point = closest; edge_point = PosVertex(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } else { @@ -403,7 +403,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) wip_active = true; _wip_changed(); edited_point = PosVertex(-1, 1, cpoint); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); hover_point = Vertex(); selected_point = Vertex(0); edge_point = PosVertex(); @@ -424,7 +424,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) _wip_changed(); edited_point = PosVertex(-1, wip.size(), cpoint); selected_point = Vertex(wip.size() - 1); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } @@ -453,7 +453,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) _set_polygon(edited_point.polygon, vertices); } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } else if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) { const PosVertex onEdgeVertex = closest_edge_point(gpoint); @@ -462,20 +462,20 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) hover_point = Vertex(); edge_point = onEdgeVertex; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } else { if (edge_point.valid()) { edge_point = PosVertex(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } const PosVertex new_hover_point = closest_point(gpoint); if (hover_point != new_hover_point) { hover_point = new_hover_point; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } } @@ -494,7 +494,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) wip.remove(selected_point.vertex); _wip_changed(); selected_point = wip.size() - 1; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } else { @@ -627,7 +627,7 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) { hover_point = Vertex(); selected_point = Vertex(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } else { diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 66770d98e5..138b8a491c 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -962,6 +962,9 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int HBoxContainer *hbc = memnew(HBoxContainer); + if (p_page_count < 2) + return hbc; + //do the mario int from = p_page - 5; if (from < 0) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index a9bc5e77ac..31dd20e453 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1025,8 +1025,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { // Scroll or pan down if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { view_offset.y += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor(); - _update_scrollbars(); - viewport->update(); + update_viewport(); } else { _zoom_on_position(zoom * (1 - (0.05 * b->get_factor())), b->get_position()); } @@ -1037,8 +1036,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { // Scroll or pan up if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { view_offset.y -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor(); - _update_scrollbars(); - viewport->update(); + update_viewport(); } else { _zoom_on_position(zoom * ((0.95 + (0.05 * b->get_factor())) / 0.95), b->get_position()); } @@ -1049,8 +1047,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { // Pan left if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { view_offset.x -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor(); - _update_scrollbars(); - viewport->update(); + update_viewport(); return true; } } @@ -1059,8 +1056,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { // Pan right if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) { view_offset.x += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor(); - _update_scrollbars(); - viewport->update(); + update_viewport(); return true; } } @@ -1112,8 +1108,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { } view_offset.x -= relative.x / zoom; view_offset.y -= relative.y / zoom; - _update_scrollbars(); - viewport->update(); + update_viewport(); return true; } } @@ -1131,8 +1126,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) { const Vector2 delta = (int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom) * pan_gesture->get_delta(); view_offset.x += delta.x; view_offset.y += delta.y; - _update_scrollbars(); - viewport->update(); + update_viewport(); return true; } @@ -3168,6 +3162,11 @@ void CanvasItemEditor::_draw_viewport() { _draw_hover(); } +void CanvasItemEditor::update_viewport() { + _update_scrollbars(); + viewport->update(); +} + void CanvasItemEditor::_notification(int p_what) { if (p_what == NOTIFICATION_PHYSICS_PROCESS) { @@ -3574,8 +3573,7 @@ void CanvasItemEditor::_zoom_on_position(float p_zoom, Point2 p_position) { view_offset.x = Math::round(view_offset.x + ofs.x); view_offset.y = Math::round(view_offset.y + ofs.y); - _update_scrollbars(); - viewport->update(); + update_viewport(); } void CanvasItemEditor::_button_zoom_minus() { @@ -4172,8 +4170,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { Vector2 offset = viewport->get_size() / 2 - editor->get_scene_root()->get_global_canvas_transform().xform(center); view_offset.x -= offset.x / zoom; view_offset.y -= offset.y / zoom; - _update_scrollbars(); - viewport->update(); + update_viewport(); } else { // VIEW_FRAME_TO_SELECTION @@ -4210,6 +4207,7 @@ void CanvasItemEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &CanvasItemEditor::_selection_result_pressed); ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &CanvasItemEditor::_selection_menu_hide); ClassDB::bind_method(D_METHOD("set_state"), &CanvasItemEditor::set_state); + ClassDB::bind_method(D_METHOD("update_viewport"), &CanvasItemEditor::update_viewport); ADD_SIGNAL(MethodInfo("item_lock_status_changed")); ADD_SIGNAL(MethodInfo("item_group_status_changed")); @@ -4608,6 +4606,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { skeleton_menu = memnew(MenuButton); hb->add_child(skeleton_menu); + skeleton_menu->set_tooltip(TTR("Skeleton Options")); p = skeleton_menu->get_popup(); p->set_hide_on_checkable_item_selection(false); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 4f8cc6ab5e..dc7b74112f 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -547,6 +547,8 @@ public: Control *get_viewport_control() { return viewport; } + void update_viewport(); + Tool get_current_tool() { return tool; } void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; } diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index d1a94f5b49..5d85a64b9c 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -129,7 +129,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { capsule->set_height(parameter * 2 - capsule->get_radius() * 2); } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } break; @@ -138,7 +138,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { Ref<CircleShape2D> circle = node->get_shape(); circle->set_radius(p_point.length()); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } break; @@ -160,7 +160,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { line->set_normal(p_point.normalized()); } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } break; @@ -170,7 +170,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { ray->set_length(Math::abs(p_point.y)); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } break; @@ -183,7 +183,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { rect->set_extents(extents.abs()); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } break; @@ -198,7 +198,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { seg->set_b(p_point); } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } break; @@ -207,7 +207,6 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { - Control *c = canvas_item_editor->get_viewport_control(); undo_redo->create_action(TTR("Set Handle")); switch (shape_type) { @@ -216,14 +215,14 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { if (idx == 0) { undo_redo->add_do_method(capsule.ptr(), "set_radius", capsule->get_radius()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(capsule.ptr(), "set_radius", p_org); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); } else if (idx == 1) { undo_redo->add_do_method(capsule.ptr(), "set_height", capsule->get_height()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(capsule.ptr(), "set_height", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } } break; @@ -232,9 +231,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<CircleShape2D> circle = node->get_shape(); undo_redo->add_do_method(circle.ptr(), "set_radius", circle->get_radius()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(circle.ptr(), "set_radius", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } break; @@ -251,14 +250,14 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { if (idx == 0) { undo_redo->add_do_method(line.ptr(), "set_d", line->get_d()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(line.ptr(), "set_d", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } else { undo_redo->add_do_method(line.ptr(), "set_normal", line->get_normal()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(line.ptr(), "set_normal", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } } break; @@ -267,9 +266,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<RayShape2D> ray = node->get_shape(); undo_redo->add_do_method(ray.ptr(), "set_length", ray->get_length()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(ray.ptr(), "set_length", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } break; @@ -277,9 +276,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<RectangleShape2D> rect = node->get_shape(); undo_redo->add_do_method(rect.ptr(), "set_extents", rect->get_extents()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(rect.ptr(), "set_extents", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } break; @@ -287,14 +286,14 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<SegmentShape2D> seg = node->get_shape(); if (idx == 0) { undo_redo->add_do_method(seg.ptr(), "set_a", seg->get_a()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(seg.ptr(), "set_a", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } else if (idx == 1) { undo_redo->add_do_method(seg.ptr(), "set_b", seg->get_b()); - undo_redo->add_do_method(c, "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(seg.ptr(), "set_b", p_org); - undo_redo->add_undo_method(c, "update"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } } break; @@ -411,7 +410,7 @@ void CollisionShape2DEditor::_get_current_shape_type() { shape_type = -1; } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { @@ -538,7 +537,7 @@ void CollisionShape2DEditor::edit(Node *p_node) { node = NULL; } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } void CollisionShape2DEditor::_bind_methods() { diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index 2f2e1dae81..6a16cf0989 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -57,7 +57,7 @@ void LightOccluder2DEditor::_node_removed(Node *p_node) { if (p_node == node) { node = NULL; hide(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } @@ -88,8 +88,8 @@ void LightOccluder2DEditor::_wip_close(bool p_closed) { undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_closed", node->get_occluder_polygon()->is_closed()); undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_closed", p_closed); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); wip.clear(); wip_active = false; @@ -139,7 +139,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { wip.push_back(cpoint); wip_active = true; edited_point_pos = cpoint; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); edited_point = 1; return true; } else { @@ -158,7 +158,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { wip.push_back(cpoint); edited_point = wip.size(); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; //add wip point @@ -183,8 +183,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); poly.push_back(cpoint); undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } @@ -217,7 +217,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { edited_point = closest_idx + 1; edited_point_pos = xform.affine_inverse().xform(closest_pos); node->get_occluder_polygon()->set_polygon(Variant(poly)); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } else { @@ -244,7 +244,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { pre_move_edit = poly; edited_point = closest_idx; edited_point_pos = xform.affine_inverse().xform(closest_pos); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } @@ -259,8 +259,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", pre_move_edit); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); edited_point = -1; @@ -290,8 +290,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); poly.remove(closest_idx); undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } @@ -312,7 +312,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { cpoint = canvas_item_editor->snap_point(cpoint); edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint); - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } } @@ -369,7 +369,7 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) { wip.clear(); wip_active = false; edited_point = -1; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } else { node = NULL; } diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 88b3194490..c67c96798a 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -130,8 +130,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Remove Point from Curve")); undo_redo->add_do_method(curve.ptr(), "remove_point", i); undo_redo->add_undo_method(curve.ptr(), "add_point", curve->get_point_position(i), curve->get_point_in(i), curve->get_point_out(i), i); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } else if (dist_to_p_out < grab_threshold) { @@ -139,8 +139,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Remove Out-Control from Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_out", i, Vector2()); undo_redo->add_undo_method(curve.ptr(), "set_point_out", i, curve->get_point_out(i)); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } else if (dist_to_p_in < grab_threshold) { @@ -148,8 +148,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Remove In-Control from Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_in", i, Vector2()); undo_redo->add_undo_method(curve.ptr(), "set_point_in", i, curve->get_point_in(i)); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return true; } @@ -165,8 +165,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Add Point to Curve")); undo_redo->add_do_method(curve.ptr(), "add_point", cpoint); undo_redo->add_undo_method(curve.ptr(), "remove_point", curve->get_point_count()); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); action = ACTION_MOVING_POINT; @@ -174,7 +174,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { moving_from = curve->get_point_position(action_point); moving_screen_from = gpoint; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } @@ -196,8 +196,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->create_action(TTR("Move Point in Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_position", action_point, cpoint); undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); } break; @@ -212,8 +212,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_out_length)); undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_out_length)); } - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); } break; @@ -228,8 +228,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_in_length)); undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_in_length)); } - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); } break; @@ -280,7 +280,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } break; } - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); return true; } } @@ -331,7 +331,7 @@ void Path2DEditor::_node_visibility_changed() { if (!node) return; - canvas_item_editor->get_viewport_control()->update(); + canvas_item_editor->update_viewport(); } void Path2DEditor::edit(Node *p_path2d) { @@ -406,8 +406,8 @@ void Path2DEditor::_mode_selected(int p_mode) { undo_redo->create_action(TTR("Remove Point from Curve")); undo_redo->add_do_method(node->get_curve().ptr(), "add_point", begin); undo_redo->add_undo_method(node->get_curve().ptr(), "remove_point", node->get_curve()->get_point_count()); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update"); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); return; } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 9b968c3523..362b8543d4 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -817,6 +817,9 @@ void ScriptTextEditor::_edit_option(int p_op) { if (tx->get_selection_to_column() == 0) end -= 1; + int col_to = tx->get_selection_to_column(); + int cursor_pos = tx->cursor_get_column(); + // Check if all lines in the selected block are commented bool is_commented = true; for (int i = begin; i <= end; i++) { @@ -839,19 +842,42 @@ void ScriptTextEditor::_edit_option(int p_op) { } tx->set_line(i, line_text); } + + // Adjust selection & cursor position. + int offset = is_commented ? -1 : 1; + int col_from = tx->get_selection_from_column() > 0 ? tx->get_selection_from_column() + offset : 0; + + if (is_commented && tx->cursor_get_column() == tx->get_line(tx->cursor_get_line()).length() + 1) + cursor_pos += 1; + + if (tx->get_selection_to_column() != 0 && col_to != tx->get_line(tx->get_selection_to_line()).length() + 1) + col_to += offset; + + if (tx->cursor_get_column() != 0) + cursor_pos += offset; + + tx->select(begin, col_from, tx->get_selection_to_line(), col_to); + tx->cursor_set_column(cursor_pos); + } else { int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); - if (line_text.begins_with(delimiter)) + int col = tx->cursor_get_column(); + if (line_text.begins_with(delimiter)) { line_text = line_text.substr(delimiter.length(), line_text.length()); - else + col -= 1; + } else { line_text = delimiter + line_text; + col += 1; + } + tx->set_line(begin, line_text); + tx->cursor_set_column(col); } tx->end_complex_operation(); tx->update(); - //tx->deselect(); + } break; case EDIT_COMPLETE: { diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 27c3ff960b..ed1fa9b217 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -43,8 +43,8 @@ void TileMapEditor::_notification(int p_what) { case NOTIFICATION_PROCESS: { - if (bucket_queue.size() && canvas_item_editor_viewport) { - canvas_item_editor_viewport->update(); + if (bucket_queue.size()) { + CanvasItemEditor::get_singleton()->update_viewport(); } } break; @@ -97,27 +97,27 @@ void TileMapEditor::_menu_option(int p_option) { // immediately without pressing the left mouse button first tool = TOOL_NONE; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_BUCKET: { tool = TOOL_BUCKET; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_PICK_TILE: { tool = TOOL_PICKING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_SELECT: { tool = TOOL_SELECTING; selection_active = false; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_COPY: { @@ -126,7 +126,7 @@ void TileMapEditor::_menu_option(int p_option) { if (selection_active) { tool = TOOL_PASTING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } } break; case OPTION_ERASE_SELECTION: { @@ -141,7 +141,7 @@ void TileMapEditor::_menu_option(int p_option) { selection_active = false; copydata.clear(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_FIX_INVALID: { @@ -165,7 +165,7 @@ void TileMapEditor::_menu_option(int p_option) { tool = TOOL_PASTING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } } break; } @@ -182,13 +182,13 @@ void TileMapEditor::_palette_multi_selected(int index, bool selected) { void TileMapEditor::_canvas_mouse_enter() { mouse_over = true; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } void TileMapEditor::_canvas_mouse_exit() { mouse_over = false; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } Vector<int> TileMapEditor::get_selected_tiles() const { @@ -524,7 +524,7 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) { transp->set_pressed(node->is_cell_transposed(p_pos.x, p_pos.y)); _update_transform_buttons(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bool preview) { @@ -671,7 +671,7 @@ void TileMapEditor::_select(const Point2i &p_from, const Point2i &p_to) { rectangle.position = begin; rectangle.size = end - begin; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } void TileMapEditor::_erase_selection() { @@ -978,7 +978,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { paint_undo.clear(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } } else if (tool == TOOL_RECTANGLE_PAINT) { @@ -995,7 +995,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } _finish_undo(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } } else if (tool == TOOL_PASTING) { @@ -1011,12 +1011,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } _finish_undo(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; // We want to keep the Pasting tool } else if (tool == TOOL_SELECTING) { - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } else if (tool == TOOL_BUCKET) { @@ -1055,7 +1055,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_NONE; selection_active = false; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1065,7 +1065,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_NONE; copydata.clear(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1106,7 +1106,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { _finish_undo(); if (tool == TOOL_RECTANGLE_ERASE || tool == TOOL_LINE_ERASE) { - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } tool = TOOL_NONE; @@ -1149,7 +1149,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (new_over_tile != over_tile) { over_tile = new_over_tile; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } if (show_tile_info) { @@ -1235,7 +1235,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { _set_cell(points[i], invalid_cell); } - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } return true; @@ -1294,7 +1294,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_NONE; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1308,13 +1308,13 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { // NOTE: We do not set tool = TOOL_PAINTING as this begins painting // immediately without pressing the left mouse button first tool = TOOL_NONE; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } if (ED_IS_SHORTCUT("tile_map_editor/bucket_fill", p_event)) { tool = TOOL_BUCKET; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1327,7 +1327,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_SELECTING; selection_active = false; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1337,7 +1337,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (selection_active) { tool = TOOL_PASTING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } @@ -1354,7 +1354,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tool = TOOL_PASTING; - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } } @@ -1368,21 +1368,21 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { flip_h = !flip_h; mirror_x->set_pressed(flip_h); _update_transform_buttons(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } if (ED_IS_SHORTCUT("tile_map_editor/mirror_y", p_event)) { flip_v = !flip_v; mirror_y->set_pressed(flip_v); _update_transform_buttons(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } if (ED_IS_SHORTCUT("tile_map_editor/transpose", p_event)) { transpose = !transpose; transp->set_pressed(transpose); _update_transform_buttons(); - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); return true; } } @@ -1643,9 +1643,7 @@ void TileMapEditor::edit(Node *p_tile_map) { void TileMapEditor::_tileset_settings_changed() { _update_palette(); - - if (canvas_item_editor_viewport) - canvas_item_editor_viewport->update(); + CanvasItemEditor::get_singleton()->update_viewport(); } void TileMapEditor::_icon_size_changed(float p_value) { diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 3de2284cea..9988d82fb8 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -569,6 +569,10 @@ void TileSetEditor::_on_textures_added(const PoolStringArray &p_paths) { int invalid_count = 0; for (int i = 0; i < p_paths.size(); i++) { Ref<Texture> t = Ref<Texture>(ResourceLoader::load(p_paths[i])); + + ERR_EXPLAIN("'" + p_paths[i] + "' is not a valid texture."); + ERR_CONTINUE(!t.is_valid()); + if (texture_map.has(t->get_rid())) { invalid_count++; } else { @@ -577,9 +581,13 @@ void TileSetEditor::_on_textures_added(const PoolStringArray &p_paths) { texture_list->set_item_metadata(texture_list->get_item_count() - 1, t->get_rid()); } } - update_texture_list_icon(); - texture_list->select(texture_list->get_item_count() - 1); - _on_texture_list_selected(texture_list->get_item_count() - 1); + + if (texture_list->get_item_count() > 0) { + update_texture_list_icon(); + texture_list->select(texture_list->get_item_count() - 1); + _on_texture_list_selected(texture_list->get_item_count() - 1); + } + if (invalid_count > 0) { err_dialog->set_text(vformat(TTR("%s file(s) were not added because was already on the list."), String::num(invalid_count, 0))); err_dialog->popup_centered(Size2(300, 60)); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index c611327a31..9ef6e4332c 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -132,7 +132,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { emit_signal("variant_changed"); } else if (hint == PROPERTY_HINT_ENUM) { - v = p_which; + v = menu->get_item_metadata(p_which); emit_signal("variant_changed"); } } break; @@ -427,12 +427,14 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } else if (hint == PROPERTY_HINT_ENUM) { Vector<String> options = hint_text.split(","); + int current_val = 0; for (int i = 0; i < options.size(); i++) { - if (options[i].find(":") != -1) { - menu->add_item(options[i].get_slicec(':', 0), options[i].get_slicec(':', 1).to_int()); - } else { - menu->add_item(options[i], i); - } + Vector<String> text_split = options[i].split(":"); + if (text_split.size() != 1) + current_val = text_split[1].to_int(); + menu->add_item(text_split[0]); + menu->set_item_metadata(i, current_val); + current_val += 1; } menu->set_position(get_position()); menu->popup(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a6a014f3bd..8925804710 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -574,6 +574,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", node); editor_data->get_undo_redo().add_do_method(node, "set_filename", root->get_filename()); editor_data->get_undo_redo().add_do_method(root, "set_filename", String()); + editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)NULL); + editor_data->get_undo_redo().add_do_method(root, "set_owner", node); _node_replace_owner(root, root, node, MODE_DO); editor_data->get_undo_redo().add_undo_method(root, "set_filename", root->get_filename()); @@ -581,6 +583,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_undo_method(node, "remove_child", root); editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", root); editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node); + editor_data->get_undo_redo().add_undo_method(root, "set_owner", (Object *)NULL); + editor_data->get_undo_redo().add_undo_method(node, "set_owner", root); + _node_replace_owner(root, root, root, MODE_UNDO); editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); @@ -982,7 +987,7 @@ void SceneTreeDock::_notification(int p_what) { void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root, ReplaceOwnerMode p_mode) { - if (p_node->get_owner() == p_base || !p_node->get_owner()) { + if (p_node->get_owner() == p_base && p_node != p_root) { UndoRedo *undo_redo = &editor_data->get_undo_redo(); switch (p_mode) { case MODE_BIDI: { diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 07670bb420..848e4def6d 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -73,7 +73,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i undo_redo->create_action(TTR("Toggle Visible")); _toggle_visible(n); List<Node *> selection = editor_selection->get_selected_node_list(); - if (selection.size() > 1) { + if (selection.size() > 1 && selection.find(n) != NULL) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Node *nv = E->get(); ERR_FAIL_COND(!nv); |