summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_data.cpp1
-rw-r--r--editor/editor_node.cpp42
-rw-r--r--editor/editor_node.h11
-rw-r--r--editor/filesystem_dock.cpp31
-rw-r--r--editor/filesystem_dock.h1
-rw-r--r--editor/icons/icon_multi_mesh_instance_2d.svg4
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp65
-rw-r--r--editor/script_editor_debugger.cpp7
8 files changed, 117 insertions, 45 deletions
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index f61a831015..38f30df169 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -560,6 +560,7 @@ void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) {
ERR_FAIL_INDEX(p_to_idx, edited_scene.size());
SWAP(edited_scene.write[p_idx], edited_scene.write[p_to_idx]);
}
+
void EditorData::remove_scene(int p_idx) {
ERR_FAIL_INDEX(p_idx, edited_scene.size());
if (edited_scene[p_idx].root) {
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 43c8ef60aa..969e1affd7 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -523,6 +523,7 @@ void EditorNode::_fs_changed() {
void EditorNode::_resources_reimported(const Vector<String> &p_resources) {
List<String> scenes; //will load later
+ int current_tab = scene_tabs->get_current_tab();
for (int i = 0; i < p_resources.size(); i++) {
String file_type = ResourceLoader::get_resource_type(p_resources[i]);
@@ -545,6 +546,8 @@ void EditorNode::_resources_reimported(const Vector<String> &p_resources) {
for (List<String>::Element *E = scenes.front(); E; E = E->next()) {
reload_scene(E->get());
}
+
+ scene_tabs->set_current_tab(current_tab);
}
void EditorNode::_sources_changed(bool p_exist) {
@@ -1214,6 +1217,17 @@ void EditorNode::save_all_scenes() {
_save_all_scenes();
}
+void EditorNode::save_scene_list(Vector<String> p_scene_filenames) {
+
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+ Node *scene = editor_data.get_edited_scene_root(i);
+
+ if (scene && (p_scene_filenames.find(scene->get_filename()) >= 0)) {
+ _save_scene(scene->get_filename(), i);
+ }
+ }
+}
+
void EditorNode::restart_editor() {
exiting = true;
@@ -2859,7 +2873,7 @@ bool EditorNode::is_addon_plugin_enabled(const String &p_addon) const {
return plugin_addons.has(p_addon);
}
-void EditorNode::_remove_edited_scene() {
+void EditorNode::_remove_edited_scene(bool p_change_tab) {
int new_index = editor_data.get_edited_scene();
int old_index = new_index;
@@ -2875,18 +2889,19 @@ void EditorNode::_remove_edited_scene() {
if (editor_data.get_scene_path(old_index) != String()) {
ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(editor_data.get_scene_path(old_index));
}
- _scene_tab_changed(new_index);
+
+ if (p_change_tab) _scene_tab_changed(new_index);
editor_data.remove_scene(old_index);
editor_data.get_undo_redo().clear_history(false);
_update_title();
_update_scene_tabs();
}
-void EditorNode::_remove_scene(int index) {
+void EditorNode::_remove_scene(int index, bool p_change_tab) {
if (editor_data.get_edited_scene() == index) {
//Scene to remove is current scene
- _remove_edited_scene();
+ _remove_edited_scene(p_change_tab);
} else {
//Scene to remove is not active scene
editor_data.remove_scene(index);
@@ -4182,6 +4197,14 @@ bool EditorNode::ensure_main_scene(bool p_from_native) {
return true;
}
+int EditorNode::get_current_tab() {
+ return scene_tabs->get_current_tab();
+}
+
+void EditorNode::set_current_tab(int p_tab) {
+ scene_tabs->set_current_tab(p_tab);
+}
+
void EditorNode::_update_layouts_menu() {
editor_layouts->clear();
@@ -4809,8 +4832,7 @@ void EditorNode::reload_scene(const String &p_path) {
if (scene_idx == -1) {
if (get_edited_scene()) {
- //scene is not open, so at it might be instanced, just refresh, set tab to itself and it will reload
- set_current_scene(current_tab);
+ //scene is not open, so at it might be instanced. We'll refresh the whole scene later.
editor_data.get_undo_redo().clear_history();
}
return;
@@ -4820,17 +4842,19 @@ void EditorNode::reload_scene(const String &p_path) {
editor_data.apply_changes_in_editors();
_set_scene_metadata(p_path);
}
+
//remove scene
- _remove_scene(scene_idx);
- //reload scene
+ _remove_scene(scene_idx, false);
+ //reload scene
load_scene(p_path, true, false, true, true);
+
//adjust index so tab is back a the previous position
editor_data.move_edited_scene_to_index(scene_idx);
get_undo_redo()->clear_history();
+
//recover the tab
scene_tabs->set_current_tab(current_tab);
- _scene_tab_changed(current_tab);
}
int EditorNode::plugin_init_callback_count = 0;
diff --git a/editor/editor_node.h b/editor/editor_node.h
index ea988cb134..f3bc95c409 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -525,8 +525,8 @@ private:
static void _editor_file_dialog_unregister(EditorFileDialog *p_dialog);
void _cleanup_scene();
- void _remove_edited_scene();
- void _remove_scene(int index);
+ void _remove_edited_scene(bool p_change_tab = true);
+ void _remove_scene(int index, bool p_change_tab = true);
bool _find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags);
bool _find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags);
void _save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags);
@@ -644,6 +644,12 @@ protected:
void _notification(int p_what);
static void _bind_methods();
+protected:
+ friend class FileSystemDock;
+
+ int get_current_tab();
+ void set_current_tab(int p_tab);
+
public:
bool call_build();
@@ -815,6 +821,7 @@ public:
void remove_tool_menu_item(const String &p_name);
void save_all_scenes();
+ void save_scene_list(Vector<String> p_scene_filenames);
void restart_editor();
void dim_editor(bool p_dimming);
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 6a4d9fea0c..ee88b558c8 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1203,6 +1203,21 @@ void FileSystemDock::_update_favorites_list_after_move(const Map<String, String>
EditorSettings::get_singleton()->set_favorites(new_favorites);
}
+void FileSystemDock::_save_scenes_after_move(const Map<String, String> &p_renames) const {
+ Vector<String> remaps;
+ _find_remaps(EditorFileSystem::get_singleton()->get_filesystem(), p_renames, remaps);
+ Vector<String> new_filenames;
+
+ for (int i = 0; i < remaps.size(); ++i) {
+ String file = p_renames.has(remaps[i]) ? p_renames[remaps[i]] : remaps[i];
+ if (ResourceLoader::get_resource_type(file) == "PackedScene") {
+ new_filenames.push_back(file);
+ }
+ }
+
+ editor->save_scene_list(new_filenames);
+}
+
void FileSystemDock::_make_dir_confirm() {
String dir_name = make_dir_dialog_text->get_text().strip_edges();
@@ -1281,14 +1296,21 @@ void FileSystemDock::_rename_operation_confirm() {
Map<String, String> file_renames;
Map<String, String> folder_renames;
_try_move_item(to_rename, new_path, file_renames, folder_renames);
+
+ int current_tab = editor->get_current_tab();
+
_update_dependencies_after_move(file_renames);
_update_resource_paths_after_move(file_renames);
_update_project_settings_after_move(file_renames);
_update_favorites_list_after_move(file_renames, folder_renames);
- //Rescan everything
+ editor->set_current_tab(current_tab);
+
print_verbose("FileSystem: calling rescan.");
_rescan();
+
+ print_verbose("FileSystem: saving moved scenes.");
+ _save_scenes_after_move(file_renames);
}
void FileSystemDock::_duplicate_operation_confirm() {
@@ -1384,13 +1406,20 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool overw
}
if (is_moved) {
+ int current_tab = editor->get_current_tab();
+
_update_dependencies_after_move(file_renames);
_update_resource_paths_after_move(file_renames);
_update_project_settings_after_move(file_renames);
_update_favorites_list_after_move(file_renames, folder_renames);
+ editor->set_current_tab(current_tab);
+
print_verbose("FileSystem: calling rescan.");
_rescan();
+
+ print_verbose("FileSystem: saving moved scenes.");
+ _save_scenes_after_move(file_renames);
}
}
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 978235b328..46eaf71a8a 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -202,6 +202,7 @@ private:
void _try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const;
void _update_dependencies_after_move(const Map<String, String> &p_renames) const;
void _update_resource_paths_after_move(const Map<String, String> &p_renames) const;
+ void _save_scenes_after_move(const Map<String, String> &p_renames) const;
void _update_favorites_list_after_move(const Map<String, String> &p_files_renames, const Map<String, String> &p_folders_renames) const;
void _update_project_settings_after_move(const Map<String, String> &p_folders_renames) const;
diff --git a/editor/icons/icon_multi_mesh_instance_2d.svg b/editor/icons/icon_multi_mesh_instance_2d.svg
new file mode 100644
index 0000000000..07202ac659
--- /dev/null
+++ b/editor/icons/icon_multi_mesh_instance_2d.svg
@@ -0,0 +1,4 @@
+<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg">
+<rect x="-1" y="-1" width="582" height="402" fill="none"/>
+<path d="m3 1c-1.1046 0-2 0.89543-2 2 5.6e-4 0.71397 0.38169 1.3735 1 1.7305v6.541c-0.61771 0.35664-0.99874 1.0152-1 1.7285 0 1.1046 0.89543 2 2 2 0.71397-5.6e-4 1.3735-0.38169 1.7305-1h1.2695v-2h-1.2715c-0.17478-0.30301-0.42598-0.55488-0.72852-0.73047v-5.8555l3.5859 3.5859h1.4141v-1.4141l-3.5859-3.5859h5.8574c0.17532 0.30158 0.42647 0.55205 0.72852 0.72656v1.2734h2v-1.2695c0.61831-0.35698 0.99944-1.0165 1-1.7305 0-1.1046-0.89543-2-2-2-0.71397 5.6e-4 -1.3735 0.38169-1.7305 1h-6.541c-0.35664-0.61771-1.0152-0.99874-1.7285-1zm8 7v3h-3v2h3v3h2v-3h3v-2h-3v-3h-2z" fill="#a5b7f3" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
+</svg>
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 4ef2d17128..3f513de30f 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -299,9 +299,13 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p
Vector2 position;
int current = manual_palette->get_current();
if (current != -1) {
- position = manual_palette->get_item_metadata(current);
+ if (tool != TOOL_PASTING) {
+ position = manual_palette->get_item_metadata(current);
+ } else {
+ position = p_autotile_coord;
+ }
} else {
- // if there is no manual tile selected, that either means that
+ // If there is no manual tile selected, that either means that
// autotiling is enabled, or the given tile is not autotiling. Either
// way, the coordinate of the tile does not matter, so assigning it to
// the coordinate of the existing tile works fine.
@@ -309,7 +313,7 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p
}
if (p_value == prev_val && p_flip_h == prev_flip_h && p_flip_v == prev_flip_v && p_transpose == prev_transpose && prev_position == position)
- return; //check that it's actually different
+ return; // Check that it's actually different.
for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) {
for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) {
@@ -322,21 +326,19 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p
node->_set_celld(p_pos, _create_cell_dictionary(p_value, p_flip_h, p_flip_v, p_transpose, p_autotile_coord));
+ if (tool == TOOL_PASTING)
+ return;
+
if (manual_autotile || (p_value != -1 && node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE)) {
if (current != -1) {
node->set_cell_autotile_coord(p_pos.x, p_pos.y, position);
-
- } else if (tool != TOOL_PASTING && node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE && priority_atlastile) {
-
- // BIND_CENTER is used to indicate that bitmask should not update for this tile cell
+ } else if (node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE && priority_atlastile) {
+ // BIND_CENTER is used to indicate that bitmask should not update for this tile cell.
node->get_tileset()->autotile_set_bitmask(p_value, Vector2(p_pos.x, p_pos.y), TileSet::BIND_CENTER);
node->update_cell_bitmask(p_pos.x, p_pos.y);
}
} else {
- // manually placing tiles should not update bitmasks
- if (tool != TOOL_PASTING) {
- node->update_bitmask_area(Point2(p_pos));
- }
+ node->update_bitmask_area(Point2(p_pos));
}
}
@@ -396,6 +398,8 @@ void TileMapEditor::_update_palette() {
// Update the palette
Vector<int> selected = get_selected_tiles();
+ int selected_single = palette->get_current();
+ int selected_manual = manual_palette->get_current();
palette->clear();
manual_palette->clear();
manual_palette->hide();
@@ -503,7 +507,7 @@ void TileMapEditor::_update_palette() {
if (selected.get(0) != TileMap::INVALID_CELL) {
set_selected_tiles(selected);
sel_tile = selected.get(Math::rand() % selected.size());
- } else {
+ } else if (palette->get_item_count() > 0) {
palette->select(0);
}
@@ -545,9 +549,10 @@ void TileMapEditor::_update_palette() {
if (manual_palette->get_item_count() > 0) {
// Only show the manual palette if at least tile exists in it
- int selected2 = manual_palette->get_current();
- if (selected2 == -1) selected2 = 0;
- manual_palette->set_current(selected2);
+ if (selected_manual == -1 || selected_single != palette->get_current())
+ selected_manual = 0;
+ if (selected_manual < manual_palette->get_item_count())
+ manual_palette->set_current(selected_manual);
manual_palette->show();
}
@@ -759,15 +764,15 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
Rect2 r = node->get_tileset()->tile_get_region(p_cell);
if (node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::AUTO_TILE || node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::ATLAS_TILE) {
Vector2 offset;
- int selected = manual_palette->get_current();
- if ((manual_autotile || (node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::ATLAS_TILE && !priority_atlastile)) && selected != -1) {
- offset = manual_palette->get_item_metadata(selected);
- } else {
- if (tool != TOOL_PASTING) {
- offset = node->get_tileset()->autotile_get_icon_coordinate(p_cell);
+ if (tool != TOOL_PASTING) {
+ int selected = manual_palette->get_current();
+ if ((manual_autotile || (node->get_tileset()->tile_get_tile_mode(p_cell) == TileSet::ATLAS_TILE && !priority_atlastile)) && selected != -1) {
+ offset = manual_palette->get_item_metadata(selected);
} else {
- offset = p_autotile_coord;
+ offset = node->get_tileset()->autotile_get_icon_coordinate(p_cell);
}
+ } else {
+ offset = p_autotile_coord;
}
int spacing = node->get_tileset()->autotile_get_spacing(p_cell);
@@ -810,10 +815,11 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
Color modulate = node->get_tileset()->tile_get_modulate(p_cell);
modulate.a = 0.5;
- if (r.has_no_area())
+ if (r.has_no_area()) {
p_viewport->draw_texture_rect(t, rect, false, modulate, p_transpose);
- else
+ } else {
p_viewport->draw_texture_rect_region(t, rect, r, modulate, p_transpose);
+ }
}
void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i p_autotile_coord, const Transform2D &p_xform) {
@@ -848,7 +854,6 @@ void TileMapEditor::_update_copydata() {
TileData tcd;
tcd.cell = node->get_cell(j, i);
-
if (tcd.cell != TileMap::INVALID_CELL) {
tcd.pos = Point2i(j, i);
tcd.flip_h = node->is_cell_x_flipped(j, i);
@@ -1980,31 +1985,31 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
p->connect("id_pressed", this, "_menu_option");
rotate_left_button = memnew(ToolButton);
- rotate_left_button->set_tooltip(TTR("Rotate left"));
+ rotate_left_button->set_tooltip(TTR("Rotate Left"));
rotate_left_button->set_focus_mode(FOCUS_NONE);
rotate_left_button->connect("pressed", this, "_rotate", varray(-1));
tool_hb->add_child(rotate_left_button);
rotate_right_button = memnew(ToolButton);
- rotate_right_button->set_tooltip(TTR("Rotate right"));
+ rotate_right_button->set_tooltip(TTR("Rotate Right"));
rotate_right_button->set_focus_mode(FOCUS_NONE);
rotate_right_button->connect("pressed", this, "_rotate", varray(1));
tool_hb->add_child(rotate_right_button);
flip_horizontal_button = memnew(ToolButton);
- flip_horizontal_button->set_tooltip(TTR("Flip horizontally"));
+ flip_horizontal_button->set_tooltip(TTR("Flip Horizontally"));
flip_horizontal_button->set_focus_mode(FOCUS_NONE);
flip_horizontal_button->connect("pressed", this, "_flip_horizontal");
tool_hb->add_child(flip_horizontal_button);
flip_vertical_button = memnew(ToolButton);
- flip_vertical_button->set_tooltip(TTR("Flip vertically"));
+ flip_vertical_button->set_tooltip(TTR("Flip Vertically"));
flip_vertical_button->set_focus_mode(FOCUS_NONE);
flip_vertical_button->connect("pressed", this, "_flip_vertical");
tool_hb->add_child(flip_vertical_button);
clear_transform_button = memnew(ToolButton);
- clear_transform_button->set_tooltip(TTR("Clear transform"));
+ clear_transform_button->set_tooltip(TTR("Clear Transform"));
clear_transform_button->set_focus_mode(FOCUS_NONE);
clear_transform_button->connect("pressed", this, "_clear_transform");
tool_hb->add_child(clear_transform_button);
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 621ab039f4..c3b62810f1 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -1025,7 +1025,9 @@ void ScriptEditorDebugger::_performance_draw() {
int pi = which[i];
Color c = get_color("accent_color", "Editor");
float h = (float)which[i] / (float)(perf_items.size());
- c.set_hsv(Math::fmod(h + 0.4, 0.9), c.get_s() * 0.9, c.get_v() * 1.4);
+ // Use a darker color on light backgrounds for better visibility
+ float value_multiplier = EditorSettings::get_singleton()->is_dark_theme() ? 1.4 : 0.55;
+ c.set_hsv(Math::fmod(h + 0.4, 0.9), c.get_s() * 0.9, c.get_v() * value_multiplier);
c.a = 0.6;
perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x);
@@ -1045,9 +1047,8 @@ void ScriptEditorDebugger::_performance_draw() {
float h2 = E->get()[pi] / m;
h2 = (1.0 - h2) * r.size.y;
- c.a = 0.7;
if (E != perf_history.front())
- perf_draw->draw_line(r.position + Point2(from, h2), r.position + Point2(from + spacing, prev), c, 2.0);
+ perf_draw->draw_line(r.position + Point2(from, h2), r.position + Point2(from + spacing, prev), c, Math::round(EDSCALE), true);
prev = h2;
E = E->next();
from -= spacing;