diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/create_dialog.cpp | 47 | ||||
-rw-r--r-- | editor/create_dialog.h | 5 | ||||
-rw-r--r-- | editor/editor_fonts.cpp | 2 | ||||
-rw-r--r-- | editor/editor_node.cpp | 17 | ||||
-rw-r--r-- | editor/editor_node.h | 1 | ||||
-rw-r--r-- | editor/editor_plugin.cpp | 20 | ||||
-rw-r--r-- | editor/editor_plugin.h | 4 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 2 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 14 | ||||
-rw-r--r-- | editor/filesystem_dock.h | 1 | ||||
-rw-r--r-- | editor/plugins/sprite_editor_plugin.cpp | 36 | ||||
-rw-r--r-- | editor/plugins/sprite_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 53 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 1 | ||||
-rw-r--r-- | editor/project_export.cpp | 9 | ||||
-rw-r--r-- | editor/project_settings_editor.cpp | 10 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 74 | ||||
-rw-r--r-- | editor/scene_tree_dock.h | 5 | ||||
-rw-r--r-- | editor/settings_config_dialog.cpp | 9 |
20 files changed, 180 insertions, 141 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index ac42f15f7f..604a050fcd 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -38,7 +38,7 @@ #include "editor_settings.h" #include "scene/gui/box_container.h" -void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) { +void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const String &p_select_type) { type_list.clear(); ClassDB::get_class_list(&type_list); @@ -93,14 +93,7 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) { if (saved_size != Rect2()) { popup(saved_size); } else { - - Size2 popup_size = Size2(900, 700) * editor_get_scale(); - Size2 window_size = get_viewport_rect().size; - - popup_size.x = MIN(window_size.x * 0.8, popup_size.x); - popup_size.y = MIN(window_size.y * 0.8, popup_size.y); - - popup_centered(popup_size); + popup_centered_clamped(Size2(900, 700) * EDSCALE, 0.8); } if (p_dont_clear) { @@ -116,6 +109,7 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) { is_replace_mode = p_replace_mode; if (p_replace_mode) { + select_type(p_select_type); set_title(vformat(TTR("Change %s Type"), base_type)); get_ok()->set_text(TTR("Change")); } else { @@ -258,6 +252,27 @@ bool CreateDialog::_is_class_disabled_by_feature_profile(const StringName &p_cla return false; } +void CreateDialog::select_type(const String &p_type) { + TreeItem *to_select; + if (search_options_types.has(p_type)) { + to_select = search_options_types[p_type]; + } else { + to_select = search_options->get_root(); + } + + // uncollapse from selected type to top level + // TODO: should this be in tree? + TreeItem *cur = to_select; + while (cur) { + cur->set_collapsed(false); + cur = cur->get_parent(); + } + + to_select->select(0); + + search_options->scroll_to_item(to_select); +} + void CreateDialog::_update_search() { search_options->clear(); @@ -269,7 +284,7 @@ void CreateDialog::_update_search() { _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); */ - HashMap<String, TreeItem *> types; + search_options_types.clear(); TreeItem *root = search_options->create_item(); EditorData &ed = EditorNode::get_editor_data(); @@ -307,7 +322,7 @@ void CreateDialog::_update_search() { } if (search_box->get_text() == "") { - add_type(type, types, root, &to_select); + add_type(type, search_options_types, root, &to_select); } else { bool found = false; @@ -323,7 +338,7 @@ void CreateDialog::_update_search() { } if (found) - add_type(I->get(), types, root, &to_select); + add_type(I->get(), search_options_types, root, &to_select); } if (EditorNode::get_editor_data().get_custom_types().has(type) && ClassDB::is_parent_class(type, base_type)) { @@ -337,12 +352,12 @@ void CreateDialog::_update_search() { if (!show) continue; - if (!types.has(type)) - add_type(type, types, root, &to_select); + if (!search_options_types.has(type)) + add_type(type, search_options_types, root, &to_select); TreeItem *ti; - if (types.has(type)) - ti = types[type]; + if (search_options_types.has(type)) + ti = search_options_types[type]; else ti = search_options->get_root(); diff --git a/editor/create_dialog.h b/editor/create_dialog.h index d859f7cbe4..03c4b25f5c 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -53,6 +53,7 @@ class CreateDialog : public ConfirmationDialog { Button *favorite; LineEdit *search_box; Tree *search_options; + HashMap<String, TreeItem *> search_options_types; bool is_replace_mode; String base_type; String preferred_search_result_type; @@ -82,6 +83,8 @@ class CreateDialog : public ConfirmationDialog { void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select); + void select_type(const String &p_type); + Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); @@ -104,7 +107,7 @@ public: void set_preferred_search_result_type(const String &p_preferred_type); String get_preferred_search_result_type(); - void popup_create(bool p_dont_clear, bool p_replace_mode = false); + void popup_create(bool p_dont_clear, bool p_replace_mode = false, const String &p_select_type = "Node"); CreateDialog(); }; diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 5b16b8f6d5..cddabbc4e4 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -228,7 +228,7 @@ void editor_register_fonts(Ref<Theme> p_theme) { p_theme->set_font("doc", "EditorFonts", df_doc); p_theme->set_font("doc_title", "EditorFonts", df_doc_title); - MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE); + MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); p_theme->set_font("doc_source", "EditorFonts", df_doc_code); // Ruler font diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 82e7a37f19..90604a36f1 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1921,6 +1921,12 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { file->popup_centered_ratio(); } break; + case FILE_QUICK_OPEN: { + + quick_open->popup_dialog("Resource", true); + quick_open->set_title(TTR("Quick Open...")); + + } break; case FILE_QUICK_OPEN_SCENE: { quick_open->popup_dialog("PackedScene", true); @@ -2454,14 +2460,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case SETTINGS_MANAGE_FEATURE_PROFILES: { - Size2 popup_size = Size2(900, 800) * editor_get_scale(); - Size2 window_size = get_viewport()->get_size(); - - popup_size.x = MIN(window_size.x * 0.8, popup_size.x); - popup_size.y = MIN(window_size.y * 0.8, popup_size.y); - - feature_profile_manager->popup_centered(popup_size); - + feature_profile_manager->popup_centered_clamped(Size2(900, 800) * EDSCALE, 0.8); } break; case SETTINGS_TOGGLE_FULLSCREEN: { @@ -5702,6 +5701,7 @@ EditorNode::EditorNode() { p->add_separator(); p->add_submenu_item(TTR("Open Recent"), "RecentScenes", FILE_OPEN_RECENT); p->add_separator(); + p->add_shortcut(ED_SHORTCUT("editor/quick_open", TTR("Quick Open..."), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_O), FILE_QUICK_OPEN); p->add_shortcut(ED_SHORTCUT("editor/quick_open_scene", TTR("Quick Open Scene..."), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_O), FILE_QUICK_OPEN_SCENE); p->add_shortcut(ED_SHORTCUT("editor/quick_open_script", TTR("Quick Open Script..."), KEY_MASK_ALT + KEY_MASK_CMD + KEY_O), FILE_QUICK_OPEN_SCRIPT); p->add_separator(); @@ -6242,7 +6242,6 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(TextureEditorPlugin(this))); add_editor_plugin(memnew(AudioStreamEditorPlugin(this))); add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); - add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); add_editor_plugin(memnew(SkeletonEditorPlugin(this))); add_editor_plugin(memnew(SkeletonIKEditorPlugin(this))); add_editor_plugin(memnew(PhysicalBonePlugin(this))); diff --git a/editor/editor_node.h b/editor/editor_node.h index cfe8bf9ec4..6e7b2b2443 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -146,6 +146,7 @@ private: FILE_SAVE_OPTIMIZED, FILE_OPEN_RECENT, FILE_OPEN_OLD_SCENE, + FILE_QUICK_OPEN, FILE_QUICK_OPEN_SCENE, FILE_QUICK_OPEN_SCRIPT, FILE_OPEN_PREV, diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 8af4ee8017..56fc1f87a5 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -400,6 +400,18 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C EditorNode::get_singleton()->get_inspector_dock_addon_area()->add_child(p_control); } break; + case CONTAINER_PROJECT_SETTING_TAB_LEFT: { + + ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control); + ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 0); + + } break; + case CONTAINER_PROJECT_SETTING_TAB_RIGHT: { + + ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control); + ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 1); + + } break; } } @@ -450,6 +462,12 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati EditorNode::get_singleton()->get_inspector_dock_addon_area()->remove_child(p_control); } break; + case CONTAINER_PROJECT_SETTING_TAB_LEFT: + case CONTAINER_PROJECT_SETTING_TAB_RIGHT: { + + ProjectSettingsEditor::get_singleton()->get_tabs()->remove_child(p_control); + + } break; } } @@ -863,6 +881,8 @@ void EditorPlugin::_bind_methods() { BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT); BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_BOTTOM); BIND_ENUM_CONSTANT(CONTAINER_PROPERTY_EDITOR_BOTTOM); + BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_LEFT); + BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_RIGHT); BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UL); BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BL); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 2fcc487377..ba4df35e66 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -137,7 +137,9 @@ public: CONTAINER_CANVAS_EDITOR_SIDE_LEFT, CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, CONTAINER_CANVAS_EDITOR_BOTTOM, - CONTAINER_PROPERTY_EDITOR_BOTTOM + CONTAINER_PROPERTY_EDITOR_BOTTOM, + CONTAINER_PROJECT_SETTING_TAB_LEFT, + CONTAINER_PROJECT_SETTING_TAB_RIGHT, }; enum DockSlot { diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 79dcbca7a2..c0dc231ea9 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -487,6 +487,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Help _initial_set("text_editor/help/show_help_index", true); + _initial_set("text_editor/help_source_font_size", 14); + hints["text_editor/help/help_source_font_size"] = PropertyInfo(Variant::REAL, "text_editor/help/help_source_font_size", PROPERTY_HINT_RANGE, "10, 50, 1"); /* Editors */ diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 52ed94e428..194a131095 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2160,6 +2160,18 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) { } } +void FileSystemDock::_tree_rmb_empty(const Vector2 &p_pos) { + // Right click is pressed in the empty space of the tree + path = "res://"; + tree_popup->clear(); + tree_popup->set_size(Size2(1, 1)); + tree_popup->add_item(TTR("New Folder..."), FILE_NEW_FOLDER); + tree_popup->add_item(TTR("New Script..."), FILE_NEW_SCRIPT); + tree_popup->add_item(TTR("New Resource..."), FILE_NEW_RESOURCE); + tree_popup->set_position(tree->get_global_position() + p_pos); + tree_popup->popup(); +} + void FileSystemDock::_tree_empty_selected() { tree->deselect_all(); } @@ -2353,6 +2365,7 @@ void FileSystemDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_file_list_rmb_option", "option"), &FileSystemDock::_file_list_rmb_option); ClassDB::bind_method(D_METHOD("_file_list_rmb_select"), &FileSystemDock::_file_list_rmb_select); ClassDB::bind_method(D_METHOD("_file_list_rmb_pressed"), &FileSystemDock::_file_list_rmb_pressed); + ClassDB::bind_method(D_METHOD("_tree_rmb_empty"), &FileSystemDock::_tree_rmb_empty); ClassDB::bind_method(D_METHOD("_file_deleted"), &FileSystemDock::_file_deleted); ClassDB::bind_method(D_METHOD("_folder_deleted"), &FileSystemDock::_folder_deleted); @@ -2485,6 +2498,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { tree->connect("item_activated", this, "_tree_activate_file"); tree->connect("multi_selected", this, "_tree_multi_selected"); tree->connect("item_rmb_selected", this, "_tree_rmb_select"); + tree->connect("empty_rmb", this, "_tree_rmb_empty"); tree->connect("nothing_selected", this, "_tree_empty_selected"); tree->connect("gui_input", this, "_tree_gui_input"); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 9d20544ac2..978235b328 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -236,6 +236,7 @@ private: void _file_and_folders_fill_popup(PopupMenu *p_popup, Vector<String> p_paths, bool p_display_path_dependent_options = true); void _tree_rmb_select(const Vector2 &p_pos); + void _tree_rmb_empty(const Vector2 &p_pos); void _file_list_rmb_select(int p_item, const Vector2 &p_pos); void _file_list_rmb_pressed(const Vector2 &p_pos); void _tree_empty_selected(); diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp index 7642bfaf04..2deb2090e2 100644 --- a/editor/plugins/sprite_editor_plugin.cpp +++ b/editor/plugins/sprite_editor_plugin.cpp @@ -327,7 +327,14 @@ void SpriteEditor::_convert_to_mesh_2d_node() { MeshInstance2D *mesh_instance = memnew(MeshInstance2D); mesh_instance->set_mesh(mesh); - EditorNode::get_singleton()->get_scene_tree_dock()->replace_node(node, mesh_instance); + + UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Convert to Mesh2D")); + ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", node, mesh_instance, true, false); + ur->add_do_reference(mesh_instance); + ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", mesh_instance, node, false, false); + ur->add_undo_reference(node); + ur->commit_action(); } void SpriteEditor::_convert_to_polygon_2d_node() { @@ -379,7 +386,13 @@ void SpriteEditor::_convert_to_polygon_2d_node() { polygon_2d_instance->set_polygon(polygon); polygon_2d_instance->set_polygons(polys); - EditorNode::get_singleton()->get_scene_tree_dock()->replace_node(node, polygon_2d_instance); + UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Convert to Polygon2D")); + ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", node, polygon_2d_instance, true, false); + ur->add_do_reference(polygon_2d_instance); + ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", polygon_2d_instance, node, false, false); + ur->add_undo_reference(node); + ur->commit_action(); } void SpriteEditor::_create_collision_polygon_2d_node() { @@ -396,7 +409,12 @@ void SpriteEditor::_create_collision_polygon_2d_node() { CollisionPolygon2D *collision_polygon_2d_instance = memnew(CollisionPolygon2D); collision_polygon_2d_instance->set_polygon(outline); - _add_as_sibling_or_child(node, collision_polygon_2d_instance); + UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Create CollisionPolygon2D Sibling")); + ur->add_do_method(this, "_add_as_sibling_or_child", node, collision_polygon_2d_instance); + ur->add_do_reference(collision_polygon_2d_instance); + ur->add_undo_method(node != this->get_tree()->get_edited_scene_root() ? node->get_parent() : this->get_tree()->get_edited_scene_root(), "remove_child", collision_polygon_2d_instance); + ur->commit_action(); } } @@ -425,15 +443,20 @@ void SpriteEditor::_create_light_occluder_2d_node() { LightOccluder2D *light_occluder_2d_instance = memnew(LightOccluder2D); light_occluder_2d_instance->set_occluder_polygon(polygon); - _add_as_sibling_or_child(node, light_occluder_2d_instance); + UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Create LightOccluder2D Sibling")); + ur->add_do_method(this, "_add_as_sibling_or_child", node, light_occluder_2d_instance); + ur->add_do_reference(light_occluder_2d_instance); + ur->add_undo_method(node != this->get_tree()->get_edited_scene_root() ? node->get_parent() : this->get_tree()->get_edited_scene_root(), "remove_child", light_occluder_2d_instance); + ur->commit_action(); } } -void SpriteEditor::_add_as_sibling_or_child(Node2D *p_own_node, Node2D *p_new_node) { +void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node) { // Can't make sibling if own node is scene root if (p_own_node != this->get_tree()->get_edited_scene_root()) { p_own_node->get_parent()->add_child(p_new_node, true); - p_new_node->set_transform(p_own_node->get_transform()); + Object::cast_to<Node2D>(p_new_node)->set_transform(Object::cast_to<Node2D>(p_own_node)->get_transform()); } else { p_own_node->add_child(p_new_node, true); } @@ -534,6 +557,7 @@ void SpriteEditor::_bind_methods() { ClassDB::bind_method("_debug_uv_draw", &SpriteEditor::_debug_uv_draw); ClassDB::bind_method("_update_mesh_data", &SpriteEditor::_update_mesh_data); ClassDB::bind_method("_create_node", &SpriteEditor::_create_node); + ClassDB::bind_method("_add_as_sibling_or_child", &SpriteEditor::_add_as_sibling_or_child); } SpriteEditor::SpriteEditor() { diff --git a/editor/plugins/sprite_editor_plugin.h b/editor/plugins/sprite_editor_plugin.h index 460f5a5707..81be4a19e9 100644 --- a/editor/plugins/sprite_editor_plugin.h +++ b/editor/plugins/sprite_editor_plugin.h @@ -84,7 +84,7 @@ class SpriteEditor : public Control { void _create_collision_polygon_2d_node(); void _create_light_occluder_2d_node(); - void _add_as_sibling_or_child(Node2D *p_own_node, Node2D *p_new_node); + void _add_as_sibling_or_child(Node *p_own_node, Node *p_new_node); protected: void _node_removed(Node *p_node); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 29a54f815d..772e47ac3a 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -760,7 +760,7 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p r.position += (r.size + Vector2(spacing, spacing)) * offset; } Size2 sc = p_xform.get_scale(); - + Size2 cell_size = node->get_cell_size(); Rect2 rect = Rect2(); rect.position = node->map_to_world(p_point) + node->get_cell_draw_offset(); @@ -770,62 +770,25 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p rect.size = r.size; } - if (rect.size.y > rect.size.x) { - if ((p_flip_h && (p_flip_v || p_transpose)) || (p_flip_v && !p_transpose)) - tile_ofs.y += rect.size.y - rect.size.x; - } else if (rect.size.y < rect.size.x) { - if ((p_flip_v && (p_flip_h || p_transpose)) || (p_flip_h && !p_transpose)) - tile_ofs.x += rect.size.x - rect.size.y; - } - if (p_transpose) { SWAP(tile_ofs.x, tile_ofs.y); + rect.position.x += cell_size.x / 2 - rect.size.y / 2; + rect.position.y += cell_size.y / 2 - rect.size.x / 2; + } else { + rect.position += cell_size / 2 - rect.size / 2; } + if (p_flip_h) { sc.x *= -1.0; tile_ofs.x *= -1.0; } + if (p_flip_v) { sc.y *= -1.0; tile_ofs.y *= -1.0; } - if (node->get_tile_origin() == TileMap::TILE_ORIGIN_TOP_LEFT) { - - rect.position += tile_ofs; - } else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_BOTTOM_LEFT) { - Size2 cell_size = node->get_cell_size(); - - rect.position += tile_ofs; - - if (p_transpose) { - if (p_flip_h) - rect.position.x -= cell_size.x; - else - rect.position.x += cell_size.x; - } else { - if (p_flip_v) - rect.position.y -= cell_size.y; - else - rect.position.y += cell_size.y; - } - - } else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_CENTER) { - Size2 cell_size = node->get_cell_size(); - - rect.position += tile_ofs; - - if (p_flip_h) - rect.position.x -= cell_size.x / 2; - else - rect.position.x += cell_size.x / 2; - - if (p_flip_v) - rect.position.y -= cell_size.y / 2; - else - rect.position.y += cell_size.y / 2; - } - + rect.position += tile_ofs; rect.position = p_xform.xform(rect.position); rect.size *= sc; diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 93c6614841..a00be3c0ce 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -372,6 +372,15 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { tool_editmode[EDITMODE_COLLISION]->set_pressed(true); edit_mode = EDITMODE_COLLISION; + tool_editmode[EDITMODE_REGION]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_region", TTR("Region Mode"), KEY_1)); + tool_editmode[EDITMODE_COLLISION]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_collision", TTR("Collision Mode"), KEY_2)); + tool_editmode[EDITMODE_OCCLUSION]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_occlusion", TTR("Occlusion Mode"), KEY_3)); + tool_editmode[EDITMODE_NAVIGATION]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_navigation", TTR("Navigation Mode"), KEY_4)); + tool_editmode[EDITMODE_BITMASK]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_bitmask", TTR("Bitmask Mode"), KEY_5)); + tool_editmode[EDITMODE_PRIORITY]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_priority", TTR("Priority Mode"), KEY_6)); + tool_editmode[EDITMODE_ICON]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_icon", TTR("Icon Mode"), KEY_7)); + tool_editmode[EDITMODE_Z_INDEX]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_z_index", TTR("Z Index Mode"), KEY_8)); + main_vb->add_child(tool_hb); separator_editmode = memnew(HSeparator); main_vb->add_child(separator_editmode); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index c2e847f211..a1b903576e 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -69,6 +69,7 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) { } } visual_shader = Ref<VisualShader>(p_visual_shader); + visual_shader->set_graph_offset(graph->get_scroll_ofs() / EDSCALE); } else { visual_shader.unref(); } diff --git a/editor/project_export.cpp b/editor/project_export.cpp index cc110f309c..ee78b240a4 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -88,14 +88,7 @@ void ProjectExportDialog::popup_export() { if (saved_size != Rect2()) { popup(saved_size); } else { - - Size2 popup_size = Size2(900, 700) * editor_get_scale(); - Size2 window_size = get_viewport_rect().size; - - popup_size.x = MIN(window_size.x * 0.8, popup_size.x); - popup_size.y = MIN(window_size.y * 0.8, popup_size.y); - - popup_centered(popup_size); + popup_centered_clamped(Size2(900, 700) * EDSCALE, 0.8); } } diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 71bddebcf5..872f8fcd2c 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -793,15 +793,9 @@ void ProjectSettingsEditor::popup_project_settings() { if (saved_size != Rect2()) { popup(saved_size); } else { - - Size2 popup_size = Size2(900, 700) * editor_get_scale(); - Size2 window_size = get_viewport_rect().size; - - popup_size.x = MIN(window_size.x * 0.8, popup_size.x); - popup_size.y = MIN(window_size.y * 0.8, popup_size.y); - - popup_centered(popup_size); + popup_centered_clamped(Size2(900, 700) * EDSCALE, 0.8); } + globals_editor->update_category_list(); _update_translations(); autoload_settings->update_autoload(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 1f5300e351..ce2795f37b 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -31,6 +31,7 @@ #include "scene_tree_dock.h" #include "core/io/resource_saver.h" +#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/project_settings.h" @@ -347,7 +348,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!profile_allow_editing) { break; } - create_dialog->popup_create(false, true); + create_dialog->popup_create(false, true, scene_tree->get_selected()->get_class()); } break; case TOOL_ATTACH_SCRIPT: { @@ -517,6 +518,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(editor_selection, "clear"); Node *dupsingle = NULL; + List<Node *> editable_children; for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -529,6 +531,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Map<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap); + if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node)) + editable_children.push_back(dup); + ERR_CONTINUE(!dup); if (selection.size() == 1) @@ -561,6 +566,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (dupsingle) editor->push_item(dupsingle); + for (List<Node *>::Element *E = editable_children.front(); E; E = E->next()) + _toggle_editable_children(E->get()); + } break; case TOOL_REPARENT: { @@ -796,7 +804,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editable_instance_remove_dialog->popup_centered_minsize(); break; } - _toggle_editable_children(); + _toggle_editable_children(node); } } } break; @@ -1612,30 +1620,27 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) { _update_script_button(); } -void SceneTreeDock::_toggle_editable_children() { +void SceneTreeDock::_toggle_editable_children_from_selection() { + List<Node *> selection = editor_selection->get_selected_node_list(); List<Node *>::Element *e = selection.front(); - if (e) { - Node *node = e->get(); - if (node) { - bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node); - int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children")); - int placeholder_item_idx = menu->get_item_idx_from_text(TTR("Load As Placeholder")); - editable = !editable; + if (e) { + _toggle_editable_children(e->get()); + } +} - EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, editable); +void SceneTreeDock::_toggle_editable_children(Node *p_node) { - menu->set_item_checked(editable_item_idx, editable); - if (editable) { - node->set_scene_instance_load_placeholder(false); - menu->set_item_checked(placeholder_item_idx, false); - } + if (p_node) { + bool editable = !EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node); + EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(p_node, editable); + if (editable) + p_node->set_scene_instance_load_placeholder(false); - SpatialEditor::get_singleton()->update_all_gizmos(node); + SpatialEditor::get_singleton()->update_all_gizmos(p_node); - scene_tree->update_tree(); - } + scene_tree->update_tree(); } } @@ -1853,7 +1858,7 @@ void SceneTreeDock::_create() { scene_tree->get_scene_tree()->call_deferred("grab_focus"); } -void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties) { +void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties, bool p_remove_old) { Node *n = p_node; Node *newnode = p_by_node; @@ -1917,16 +1922,20 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop Node *c = newnode->get_child(i); c->call("set_transform", c->call("get_transform")); } - editor_data->get_undo_redo().clear_history(); + //p_remove_old was added to support undo + if (p_remove_old) + editor_data->get_undo_redo().clear_history(); newnode->set_name(newname); editor->push_item(newnode); - memdelete(n); + if (p_remove_old) { + memdelete(n); - while (to_erase.front()) { - memdelete(to_erase.front()->get()); - to_erase.pop_front(); + while (to_erase.front()) { + memdelete(to_erase.front()->get()); + to_erase.pop_front(); + } } } @@ -1942,13 +1951,7 @@ void SceneTreeDock::set_selected(Node *p_node, bool p_emit_selected) { void SceneTreeDock::import_subscene() { - Size2 popup_size = Size2(500, 800) * editor_get_scale(); - Size2 window_size = get_viewport_rect().size; - - popup_size.x = MIN(window_size.x * 0.8, popup_size.x); - popup_size.y = MIN(window_size.y * 0.8, popup_size.y); - - import_subscene_dialog->popup_centered(popup_size); + import_subscene_dialog->popup_centered_clamped(Size2(500, 800) * EDSCALE, 0.8); } void SceneTreeDock::_import_subscene() { @@ -2132,7 +2135,7 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) { int to_pos = -1; _normalize_drop(to_node, to_pos, p_type); - _do_reparent(to_node, to_pos, nodes, true); + _do_reparent(to_node, to_pos, nodes, !Input::get_singleton()->is_key_pressed(KEY_SHIFT)); } void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { @@ -2481,7 +2484,7 @@ void SceneTreeDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_input"), &SceneTreeDock::_input); ClassDB::bind_method(D_METHOD("_nodes_drag_begin"), &SceneTreeDock::_nodes_drag_begin); ClassDB::bind_method(D_METHOD("_delete_confirm"), &SceneTreeDock::_delete_confirm); - ClassDB::bind_method(D_METHOD("_toggle_editable_children"), &SceneTreeDock::_toggle_editable_children); + ClassDB::bind_method(D_METHOD("_toggle_editable_children_from_selection"), &SceneTreeDock::_toggle_editable_children_from_selection); ClassDB::bind_method(D_METHOD("_node_prerenamed"), &SceneTreeDock::_node_prerenamed); ClassDB::bind_method(D_METHOD("_import_subscene"), &SceneTreeDock::_import_subscene); ClassDB::bind_method(D_METHOD("_selection_changed"), &SceneTreeDock::_selection_changed); @@ -2501,6 +2504,7 @@ void SceneTreeDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_feature_profile_changed"), &SceneTreeDock::_feature_profile_changed); ClassDB::bind_method(D_METHOD("instance"), &SceneTreeDock::instance); + ClassDB::bind_method(D_METHOD("replace_node"), &SceneTreeDock::replace_node); ADD_SIGNAL(MethodInfo("remote_tree_selected")); } @@ -2649,7 +2653,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel editable_instance_remove_dialog = memnew(ConfirmationDialog); add_child(editable_instance_remove_dialog); - editable_instance_remove_dialog->connect("confirmed", this, "_toggle_editable_children"); + editable_instance_remove_dialog->connect("confirmed", this, "_toggle_editable_children_from_selection"); import_subscene_dialog = memnew(EditorSubScene); add_child(import_subscene_dialog); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index e66525d721..9f9e93f2df 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -172,7 +172,8 @@ class SceneTreeDock : public VBoxContainer { void _delete_confirm(); - void _toggle_editable_children(); + void _toggle_editable_children_from_selection(); + void _toggle_editable_children(Node *p_node); void _node_prerenamed(Node *p_node, const String &p_new_name); @@ -243,7 +244,7 @@ public: void show_tab_buttons(); void hide_tab_buttons(); - void replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties = true); + void replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties = true, bool p_remove_old = true); void open_script_dialog(Node *p_for_node); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 68a1117364..b4643231d7 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -98,14 +98,7 @@ void EditorSettingsDialog::popup_edit_settings() { if (saved_size != Rect2()) { popup(saved_size); } else { - - Size2 popup_size = Size2(900, 700) * editor_get_scale(); - Size2 window_size = get_viewport_rect().size; - - popup_size.x = MIN(window_size.x * 0.8, popup_size.x); - popup_size.y = MIN(window_size.y * 0.8, popup_size.y); - - popup_centered(popup_size); + popup_centered_clamped(Size2(900, 700) * EDSCALE, 0.8); } _focus_current_search_box(); |