Skip to content

Commit

Permalink
Merge pull request #80462 from KoBeWi/tfw_your_bugfix_makes_things_worse
Browse files Browse the repository at this point in the history
Fix TileSet with TileMap handling
  • Loading branch information
akien-mga committed Aug 9, 2023
2 parents d76b97e + f02133a commit 013e8e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions editor/plugins/tiles/tiles_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/inspector_dock.h"
#include "editor/plugins/canvas_item_editor_plugin.h"

#include "scene/2d/tile_map.h"
Expand Down Expand Up @@ -326,8 +325,17 @@ void TileMapEditorPlugin::_tile_map_changed() {
}

void TileMapEditorPlugin::_update_tile_map() {
if (tile_map && tile_map->get_tileset().is_valid()) {
EditorNode::get_singleton()->edit_item(tile_map->get_tileset().ptr(), InspectorDock::get_inspector_singleton());
if (tile_map) {
Ref<TileSet> tile_set = tile_map->get_tileset();
if (tile_set.is_valid() && edited_tileset != tile_set->get_instance_id()) {
tile_set_plugin_singleton->edit(tile_map->get_tileset().ptr());
tile_set_plugin_singleton->make_visible(true);
edited_tileset = tile_set->get_instance_id();
} else if (tile_set.is_null()) {
tile_set_plugin_singleton->edit(nullptr);
tile_set_plugin_singleton->make_visible(false);
edited_tileset = ObjectID();
}
}
tile_map_changed_needs_update = false;
}
Expand All @@ -350,7 +358,9 @@ void TileMapEditorPlugin::edit(Object *p_object) {
tile_map->connect("changed", callable_mp(this, &TileMapEditorPlugin::_tile_map_changed));

if (tile_map->get_tileset().is_valid()) {
EditorNode::get_singleton()->edit_item(tile_map->get_tileset().ptr(), InspectorDock::get_inspector_singleton());
tile_set_plugin_singleton->edit(tile_map->get_tileset().ptr());
tile_set_plugin_singleton->make_visible(true);
edited_tileset = tile_map->get_tileset()->get_instance_id();
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/tiles/tiles_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class TileMapEditorPlugin : public EditorPlugin {
TileMap *tile_map = nullptr;

bool tile_map_changed_needs_update = false;
ObjectID edited_tileset;

void _tile_map_changed();
void _update_tile_map();

Expand Down

0 comments on commit 013e8e3

Please sign in to comment.