1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Merge pull request #80782 from KoBeWi/MessLibrary

Cleanup MeshLibrary changed signals
This commit is contained in:
Rémi Verschelde
2023-08-21 08:23:48 +02:00
5 changed files with 43 additions and 23 deletions

View File

@@ -32,6 +32,7 @@
#ifdef TOOLS_ENABLED
#include "core/core_string_names.h"
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "editor/editor_node.h"
@@ -341,7 +342,6 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
if (selected_palette < 0 && input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE) {
return false;
}
Ref<MeshLibrary> mesh_library = node->get_mesh_library();
if (mesh_library.is_null()) {
return false;
}
@@ -866,10 +866,7 @@ void GridMapEditor::update_palette() {
mesh_library_palette->set_fixed_icon_size(Size2(min_size, min_size));
mesh_library_palette->set_max_text_lines(2);
Ref<MeshLibrary> mesh_library = node->get_mesh_library();
if (mesh_library.is_null()) {
last_mesh_library = nullptr;
search_box->set_text("");
search_box->set_editable(false);
info_message->show();
@@ -922,13 +919,39 @@ void GridMapEditor::update_palette() {
item++;
}
}
last_mesh_library = *mesh_library;
void GridMapEditor::_update_mesh_library() {
ERR_FAIL_NULL(node);
Ref<MeshLibrary> new_mesh_library = node->get_mesh_library();
if (new_mesh_library != mesh_library) {
if (mesh_library.is_valid()) {
mesh_library->disconnect_changed(callable_mp(this, &GridMapEditor::update_palette));
}
mesh_library = new_mesh_library;
} else {
return;
}
if (mesh_library.is_valid()) {
mesh_library->connect_changed(callable_mp(this, &GridMapEditor::update_palette));
}
update_palette();
// Update the cursor and grid in case the library is changed or removed.
_update_cursor_instance();
update_grid();
}
void GridMapEditor::edit(GridMap *p_gridmap) {
if (node && node->is_connected("cell_size_changed", callable_mp(this, &GridMapEditor::_draw_grids))) {
node->disconnect("cell_size_changed", callable_mp(this, &GridMapEditor::_draw_grids));
if (node) {
node->disconnect(SNAME("cell_size_changed"), callable_mp(this, &GridMapEditor::_draw_grids));
node->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GridMapEditor::_update_mesh_library));
if (mesh_library.is_valid()) {
mesh_library->disconnect_changed(callable_mp(this, &GridMapEditor::update_palette));
mesh_library = Ref<MeshLibrary>();
}
}
node = p_gridmap;
@@ -961,7 +984,9 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
_draw_grids(node->get_cell_size());
update_grid();
node->connect("cell_size_changed", callable_mp(this, &GridMapEditor::_draw_grids));
node->connect(SNAME("cell_size_changed"), callable_mp(this, &GridMapEditor::_draw_grids));
node->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GridMapEditor::_update_mesh_library));
_update_mesh_library();
}
void GridMapEditor::update_grid() {
@@ -1092,13 +1117,6 @@ void GridMapEditor::_notification(int p_what) {
}
grid_xform = xf;
}
Ref<MeshLibrary> cgmt = node->get_mesh_library();
if (cgmt.operator->() != last_mesh_library) {
update_palette();
// Update the cursor and grid in case the library is changed or removed.
_update_cursor_instance();
update_grid();
}
} break;
case NOTIFICATION_THEME_CHANGED: {