From 389070cfef387b69902e23e6c4ac53997b69e42e Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 30 Jan 2022 15:06:20 +0100 Subject: [PATCH] Fix compile for 3.x after recent changes. --- tile_map.cpp | 32 +++++++++++++++++++++++++++++++- tile_map.h | 5 +++++ tile_map_editor_plugin.cpp | 11 ++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/tile_map.cpp b/tile_map.cpp index 4703ca1..6c4f5a5 100644 --- a/tile_map.cpp +++ b/tile_map.cpp @@ -37,6 +37,10 @@ #include "scene/2d/collision_object_2d.h" #include "servers/physics_2d_server.h" +#if VERSION_MINOR >= 5 +#include "servers/navigation_2d_server.h" +#endif + int RTileMap::_get_quadrant_size() const { if (y_sort_mode) { return 1; @@ -79,7 +83,11 @@ void RTileMap::_notification(int p_what) { Quadrant &q = E->get(); if (navigation) { for (Map::Element *F = q.navpoly_ids.front(); F; F = F->next()) { +#if VERSION_MINOR < 5 navigation->navpoly_remove(F->get().id); +#else + Navigation2DServer::get_singleton()->region_set_map(F->get().region, RID()); +#endif } q.navpoly_ids.clear(); } @@ -163,7 +171,11 @@ void RTileMap::_update_quadrant_transform() { if (navigation) { for (Map::Element *F = q.navpoly_ids.front(); F; F = F->next()) { +#if VERSION_MINOR < 5 navigation->navpoly_set_transform(F->get().id, nav_rel * F->get().xform); +#else + Navigation2DServer::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform); +#endif } } @@ -390,7 +402,11 @@ void RTileMap::update_dirty_quadrants() { if (navigation) { for (Map::Element *E = q.navpoly_ids.front(); E; E = E->next()) { +#if VERSION_MINOR < 5 navigation->navpoly_remove(E->get().id); +#else + Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID()); +#endif } q.navpoly_ids.clear(); } @@ -637,10 +653,20 @@ void RTileMap::update_dirty_quadrants() { xform.set_origin(offset.floor() + q.pos); _fix_cell_transform(xform, c, npoly_ofs, s); +#if VERSION_MINOR < 5 int pid = navigation->navpoly_add(navpoly, nav_rel * xform); - +#else + RID region = Navigation2DServer::get_singleton()->region_create(); + Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid()); + Navigation2DServer::get_singleton()->region_set_transform(region, nav_rel * xform); + Navigation2DServer::get_singleton()->region_set_navpoly(region, navpoly); +#endif Quadrant::NavPoly np; +#if VERSION_MINOR < 5 np.id = pid; +#else + np.region = region; +#endif np.xform = xform; q.navpoly_ids[E->key()] = np; @@ -834,7 +860,11 @@ void RTileMap::_erase_quadrant(Map::Element *Q) { if (navigation) { for (Map::Element *E = q.navpoly_ids.front(); E; E = E->next()) { +#if VERSION_MINOR < 5 navigation->navpoly_remove(E->get().id); +#else + Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID()); +#endif } q.navpoly_ids.clear(); } diff --git a/tile_map.h b/tile_map.h index 2cc751f..406200b 100644 --- a/tile_map.h +++ b/tile_map.h @@ -36,6 +36,7 @@ #include "scene/2d/navigation_2d.h" #include "scene/2d/node_2d.h" #include "tile_set.h" +#include "core/version.h" #include "../fastnoise/noise.h" @@ -146,7 +147,11 @@ private: SelfList dirty_list; struct NavPoly { +#if VERSION_MINOR < 5 int id; +#else + RID region; +#endif Transform2D xform; }; diff --git a/tile_map_editor_plugin.cpp b/tile_map_editor_plugin.cpp index e151a8c..f42b2b3 100644 --- a/tile_map_editor_plugin.cpp +++ b/tile_map_editor_plugin.cpp @@ -30,12 +30,13 @@ #include "tile_map_editor_plugin.h" -#include "editor/plugins/canvas_item_editor_plugin.h" #include "core/math/math_funcs.h" #include "core/os/input.h" #include "core/os/keyboard.h" +#include "core/version.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/plugins/canvas_item_editor_plugin.h" #include "scene/gui/split_container.h" void RTileMapEditor::_node_removed(Node *p_node) { @@ -2132,10 +2133,18 @@ void RTileMapEditorPlugin::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { switch ((int)EditorSettings::get_singleton()->get("editors/tile_map/editor_side")) { case 0: { // Left. +#if VERSION_MINOR < 5 CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 0); +#else + CanvasItemEditor::get_singleton()->move_control_to_left_panel(tile_map_editor); +#endif } break; case 1: { // Right. +#if VERSION_MINOR < 5 CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 1); +#else + CanvasItemEditor::get_singleton()->move_control_to_right_panel(tile_map_editor); +#endif } break; } }