More fixes.

This commit is contained in:
Relintai 2021-12-11 23:13:05 +01:00
parent b54dec5622
commit 10a95cb467
7 changed files with 239 additions and 239 deletions

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "../rtile_map.h" #include "../rtile_map.h"
#include "scene/gui/box_container.h" #include "scene/gui/box_container.h"
#include "scene/gui/tab_bar.h" #include "scene/gui/tabs.h"
class RTileMapEditorPlugin : public Object { class RTileMapEditorPlugin : public Object {
public: public:
@ -122,10 +122,10 @@ private:
///// Selection system. ///// ///// Selection system. /////
Set<Vector2i> tile_map_selection; Set<Vector2i> tile_map_selection;
Ref<TileMapPattern> tile_map_clipboard; Ref<RTileMapPattern> tile_map_clipboard;
Ref<TileMapPattern> selection_pattern; Ref<RTileMapPattern> selection_pattern;
void _set_tile_map_selection(const TypedArray<Vector2i> &p_selection); void _set_tile_map_selection(const Vector<Vector2i> &p_selection);
TypedArray<Vector2i> _get_tile_map_selection() const; Vector<Vector2i> _get_tile_map_selection() const;
Set<RTileMapCell> tile_set_selection; Set<RTileMapCell> tile_set_selection;
@ -184,7 +184,7 @@ private:
ItemList *patterns_item_list; ItemList *patterns_item_list;
Label *patterns_help_label; Label *patterns_help_label;
void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event); void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event);
void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture> p_texture); void _pattern_preview_done(Ref<RTileMapPattern> p_pattern, Ref<Texture> p_texture);
bool select_last_pattern = false; bool select_last_pattern = false;
void _update_patterns_list(); void _update_patterns_list();
@ -322,7 +322,7 @@ private:
// Bottom panel. // Bottom panel.
Label *missing_tileset_label; Label *missing_tileset_label;
TabBar *tabs_bar; Tabs *tabs_bar;
LocalVector<RTileMapEditorPlugin::TabData> tabs_data; LocalVector<RTileMapEditorPlugin::TabData> tabs_data;
LocalVector<RTileMapEditorPlugin *> tabs_plugins; LocalVector<RTileMapEditorPlugin *> tabs_plugins;
void _update_bottom_panel(); void _update_bottom_panel();

View File

@ -294,7 +294,7 @@ class REditorPropertyTilePolygon : public EditorProperty {
void _add_focusable_children(Node *p_node); void _add_focusable_children(Node *p_node);
GenericTilePolygonEditor *generic_tile_polygon_editor; RGenericTilePolygonEditor *generic_tile_polygon_editor;
void _polygons_changed(); void _polygons_changed();
public: public:
@ -312,7 +312,7 @@ class REditorInspectorPluginTileData : public EditorInspectorPlugin {
public: public:
virtual bool can_handle(Object *p_object) override; virtual bool can_handle(Object *p_object) override;
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false) override; virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide = false);
}; };
#endif // TILE_SET_ATLAS_SOURCE_EDITOR_H #endif // TILE_SET_ATLAS_SOURCE_EDITOR_H

View File

@ -50,7 +50,7 @@ void RTileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data,
if (p_from == sources_list) { if (p_from == sources_list) {
// Handle dropping a texture in the list of atlas resources. // Handle dropping a texture in the list of atlas resources.
int source_id = TileSet::INVALID_SOURCE; int source_id = RTileSet::INVALID_SOURCE;
int added = 0; int added = 0;
Dictionary d = p_data; Dictionary d = p_data;
Vector<String> files = d["files"]; Vector<String> files = d["files"];
@ -61,7 +61,7 @@ void RTileSetEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data,
source_id = tile_set->get_next_source_id(); source_id = tile_set->get_next_source_id();
// Actually create the new source. // Actually create the new source.
Ref<TileSetAtlasSource> atlas_source = memnew(TileSetAtlasSource); Ref<RTileSetAtlasSource> atlas_source = memnew(RTileSetAtlasSource);
atlas_source->set_texture(resource); atlas_source->set_texture(resource);
undo_redo->create_action(TTR("Add a new atlas source")); undo_redo->create_action(TTR("Add a new atlas source"));
undo_redo->add_do_method(*tile_set, "add_source", atlas_source, source_id); undo_redo->add_do_method(*tile_set, "add_source", atlas_source, source_id);
@ -118,7 +118,7 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) {
ERR_FAIL_COND(!tile_set.is_valid()); ERR_FAIL_COND(!tile_set.is_valid());
// Get the previously selected id. // Get the previously selected id.
int old_selected = TileSet::INVALID_SOURCE; int old_selected = RTileSet::INVALID_SOURCE;
if (sources_list->get_current() >= 0) { if (sources_list->get_current() >= 0) {
int source_id = sources_list->get_item_metadata(sources_list->get_current()); int source_id = sources_list->get_item_metadata(sources_list->get_current());
if (tile_set->has_source(source_id)) { if (tile_set->has_source(source_id)) {
@ -126,7 +126,7 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) {
} }
} }
int to_select = TileSet::INVALID_SOURCE; int to_select = RTileSet::INVALID_SOURCE;
if (force_selected_id >= 0) { if (force_selected_id >= 0) {
to_select = force_selected_id; to_select = force_selected_id;
} else if (old_selected >= 0) { } else if (old_selected >= 0) {
@ -140,7 +140,7 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) {
for (int i = 0; i < tile_set->get_source_count(); i++) { for (int i = 0; i < tile_set->get_source_count(); i++) {
int source_id = tile_set->get_source_id(i); int source_id = tile_set->get_source_id(i);
TileSetSource *source = *tile_set->get_source(source_id); RTileSetSource *source = *tile_set->get_source(source_id);
Ref<Texture> texture; Ref<Texture> texture;
String item_text; String item_text;
@ -151,7 +151,7 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) {
} }
// Atlas source. // Atlas source.
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source); RTileSetAtlasSource *atlas_source = Object::cast_to<RTileSetAtlasSource>(source);
if (atlas_source) { if (atlas_source) {
texture = atlas_source->get_texture(); texture = atlas_source->get_texture();
if (item_text.is_empty()) { if (item_text.is_empty()) {
@ -164,16 +164,16 @@ void RTileSetEditor::_update_sources_list(int force_selected_id) {
} }
// Scene collection source. // Scene collection source.
TileSetScenesCollectionSource *scene_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source); RTileSetScenesCollectionSource *scene_collection_source = Object::cast_to<RTileSetScenesCollectionSource>(source);
if (scene_collection_source) { if (scene_collection_source) {
texture = get_theme_icon(("PackedScene"), ("EditorIcons")); texture = get_icon(("PackedScene"), ("EditorIcons"));
if (item_text.is_empty()) { if (item_text.empty()) {
item_text = vformat(TTR("Scene Collection Source (ID:%d)"), source_id); item_text = vformat(TTR("Scene Collection Source (ID:%d)"), source_id);
} }
} }
// Use default if not valid. // Use default if not valid.
if (item_text.is_empty()) { if (item_text.empty()) {
item_text = vformat(TTR("Unknown Type Source (ID:%d)"), source_id); item_text = vformat(TTR("Unknown Type Source (ID:%d)"), source_id);
} }
if (!texture.is_valid()) { if (!texture.is_valid()) {
@ -220,8 +220,8 @@ void RTileSetEditor::_source_selected(int p_source_index) {
if (p_source_index >= 0) { if (p_source_index >= 0) {
int source_id = sources_list->get_item_metadata(p_source_index); int source_id = sources_list->get_item_metadata(p_source_index);
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(*tile_set->get_source(source_id)); RTileSetAtlasSource *atlas_source = Object::cast_to<RTileSetAtlasSource>(*tile_set->get_source(source_id));
TileSetScenesCollectionSource *scenes_collection_source = Object::cast_to<TileSetScenesCollectionSource>(*tile_set->get_source(source_id)); RTileSetScenesCollectionSource *scenes_collection_source = Object::cast_to<RTileSetScenesCollectionSource>(*tile_set->get_source(source_id));
if (atlas_source) { if (atlas_source) {
no_source_selected_label->hide(); no_source_selected_label->hide();
tile_set_atlas_source_editor->edit(*tile_set, atlas_source, source_id); tile_set_atlas_source_editor->edit(*tile_set, atlas_source, source_id);
@ -250,7 +250,7 @@ void RTileSetEditor::_source_delete_pressed() {
// Update the selected source. // Update the selected source.
int to_delete = sources_list->get_item_metadata(sources_list->get_current()); int to_delete = sources_list->get_item_metadata(sources_list->get_current());
Ref<TileSetSource> source = tile_set->get_source(to_delete); Ref<RTileSetSource> source = tile_set->get_source(to_delete);
// Remove the source. // Remove the source.
undo_redo->create_action(TTR("Remove source")); undo_redo->create_action(TTR("Remove source"));
@ -268,7 +268,7 @@ void RTileSetEditor::_source_add_id_pressed(int p_id_pressed) {
case 0: { case 0: {
int source_id = tile_set->get_next_source_id(); int source_id = tile_set->get_next_source_id();
Ref<TileSetAtlasSource> atlas_source = memnew(TileSetAtlasSource); Ref<RTileSetAtlasSource> atlas_source = memnew(RTileSetAtlasSource);
// Add a new source. // Add a new source.
undo_redo->create_action(TTR("Add atlas source")); undo_redo->create_action(TTR("Add atlas source"));
@ -282,7 +282,7 @@ void RTileSetEditor::_source_add_id_pressed(int p_id_pressed) {
case 1: { case 1: {
int source_id = tile_set->get_next_source_id(); int source_id = tile_set->get_next_source_id();
Ref<TileSetScenesCollectionSource> scene_collection_source = memnew(TileSetScenesCollectionSource); Ref<RTileSetScenesCollectionSource> scene_collection_source = memnew(RTileSetScenesCollectionSource);
// Add a new source. // Add a new source.
undo_redo->create_action(TTR("Add atlas source")); undo_redo->create_action(TTR("Add atlas source"));
@ -316,10 +316,10 @@ void RTileSetEditor::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_THEME_CHANGED:
sources_delete_button->set_icon(get_theme_icon(("Remove"), ("EditorIcons"))); sources_delete_button->set_icon(get_icon(("Remove"), ("EditorIcons")));
sources_add_button->set_icon(get_theme_icon(("Add"), ("EditorIcons"))); sources_add_button->set_icon(get_icon(("Add"), ("EditorIcons")));
sources_advanced_menu_button->set_icon(get_theme_icon(("GuiTabMenuHl"), ("EditorIcons"))); sources_advanced_menu_button->set_icon(get_icon(("GuiTabMenuHl"), ("EditorIcons")));
missing_texture_texture = get_theme_icon(("TileSet"), ("EditorIcons")); missing_texture_texture = get_icon(("TileSet"), ("EditorIcons"));
break; break;
case NOTIFICATION_INTERNAL_PROCESS: case NOTIFICATION_INTERNAL_PROCESS:
if (tile_set_changed_needs_update) { if (tile_set_changed_needs_update) {
@ -352,7 +352,7 @@ void RTileSetEditor::_patterns_item_list_gui_input(const Ref<InputEvent> &p_even
} }
} }
void RTileSetEditor::_pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture> p_texture) { void RTileSetEditor::_pattern_preview_done(Ref<RTileMapPattern> p_pattern, Ref<Texture> p_texture) {
// TODO optimize ? // TODO optimize ?
for (int i = 0; i < patterns_item_list->get_item_count(); i++) { for (int i = 0; i < patterns_item_list->get_item_count(); i++) {
if (patterns_item_list->get_item_metadata(i) == p_pattern) { if (patterns_item_list->get_item_metadata(i) == p_pattern) {
@ -390,7 +390,7 @@ void RTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p
UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo); UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
ERR_FAIL_COND(!undo_redo); ERR_FAIL_COND(!undo_redo);
TileSet *tile_set = Object::cast_to<TileSet>(p_edited); RTileSet *tile_set = Object::cast_to<RTileSet>(p_edited);
if (!tile_set) { if (!tile_set) {
return; return;
} }
@ -459,13 +459,13 @@ void RTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p
for (int i = 0; i < tile_set->get_source_count(); i++) { for (int i = 0; i < tile_set->get_source_count(); i++) {
int source_id = tile_set->get_source_id(i); int source_id = tile_set->get_source_id(i);
Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id); Ref<RTileSetAtlasSource> tas = tile_set->get_source(source_id);
if (tas.is_valid()) { if (tas.is_valid()) {
for (int j = 0; j < tas->get_tiles_count(); j++) { for (int j = 0; j < tas->get_tiles_count(); j++) {
Vector2i tile_id = tas->get_tile_id(j); Vector2i tile_id = tas->get_tile_id(j);
for (int k = 0; k < tas->get_alternative_tiles_count(tile_id); k++) { for (int k = 0; k < tas->get_alternative_tiles_count(tile_id); k++) {
int alternative_id = tas->get_alternative_tile_id(tile_id, k); int alternative_id = tas->get_alternative_tile_id(tile_id, k);
TileData *tile_data = Object::cast_to<TileData>(tas->get_tile_data(tile_id, alternative_id)); RTileData *tile_data = Object::cast_to<RTileData>(tas->get_tile_data(tile_id, alternative_id));
ERR_FAIL_COND(!tile_data); ERR_FAIL_COND(!tile_data);
// Actually saving stuff. // Actually saving stuff.
@ -485,16 +485,16 @@ void RTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p
} else if (p_array_prefix == "terrain_set_") { } else if (p_array_prefix == "terrain_set_") {
ADD_UNDO(tile_data, "terrain_set"); ADD_UNDO(tile_data, "terrain_set");
for (int terrain_set_index = begin; terrain_set_index < end; terrain_set_index++) { for (int terrain_set_index = begin; terrain_set_index < end; terrain_set_index++) {
for (int l = 0; l < TileSet::CELL_NEIGHBOR_MAX; l++) { for (int l = 0; l < RTileSet::CELL_NEIGHBOR_MAX; l++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(l); RTileSet::CellNeighbor bit = RTileSet::CellNeighbor(l);
if (tile_data->is_valid_peering_bit_terrain(bit)) { if (tile_data->is_valid_peering_bit_terrain(bit)) {
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l])); ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
} }
} }
} }
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") { } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
for (int terrain_index = 0; terrain_index < TileSet::CELL_NEIGHBOR_MAX; terrain_index++) { for (int terrain_index = 0; terrain_index < RTileSet::CELL_NEIGHBOR_MAX; terrain_index++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(terrain_index); RTileSet::CellNeighbor bit = RTileSet::CellNeighbor(terrain_index);
if (tile_data->is_valid_peering_bit_terrain(bit)) { if (tile_data->is_valid_peering_bit_terrain(bit)) {
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[terrain_index])); ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[terrain_index]));
} }
@ -572,31 +572,31 @@ void RTileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *
ERR_FAIL_COND(!undo_redo); ERR_FAIL_COND(!undo_redo);
#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); #define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
TileSet *tile_set = Object::cast_to<TileSet>(p_edited); RTileSet *tile_set = Object::cast_to<RTileSet>(p_edited);
if (tile_set) { if (tile_set) {
Vector<String> components = p_property.split("/", true, 3); Vector<String> components = p_property.split("/", true, 3);
for (int i = 0; i < tile_set->get_source_count(); i++) { for (int i = 0; i < tile_set->get_source_count(); i++) {
int source_id = tile_set->get_source_id(i); int source_id = tile_set->get_source_id(i);
Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id); Ref<RTileSetAtlasSource> tas = tile_set->get_source(source_id);
if (tas.is_valid()) { if (tas.is_valid()) {
for (int j = 0; j < tas->get_tiles_count(); j++) { for (int j = 0; j < tas->get_tiles_count(); j++) {
Vector2i tile_id = tas->get_tile_id(j); Vector2i tile_id = tas->get_tile_id(j);
for (int k = 0; k < tas->get_alternative_tiles_count(tile_id); k++) { for (int k = 0; k < tas->get_alternative_tiles_count(tile_id); k++) {
int alternative_id = tas->get_alternative_tile_id(tile_id, k); int alternative_id = tas->get_alternative_tile_id(tile_id, k);
TileData *tile_data = Object::cast_to<TileData>(tas->get_tile_data(tile_id, alternative_id)); RTileData *tile_data = Object::cast_to<RTileData>(tas->get_tile_data(tile_id, alternative_id));
ERR_FAIL_COND(!tile_data); ERR_FAIL_COND(!tile_data);
if (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "mode") { if (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "mode") {
ADD_UNDO(tile_data, "terrain_set"); ADD_UNDO(tile_data, "terrain_set");
for (int l = 0; l < TileSet::CELL_NEIGHBOR_MAX; l++) { for (int l = 0; l < RTileSet::CELL_NEIGHBOR_MAX; l++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(l); RTileSet::CellNeighbor bit = RTileSet::CellNeighbor(l);
if (tile_data->is_valid_peering_bit_terrain(bit)) { if (tile_data->is_valid_peering_bit_terrain(bit)) {
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l])); ADD_UNDO(tile_data, "terrains_peering_bit/" + String(RTileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
} }
} }
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int() && components[1] == "type") { } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int() && components[1] == "type") {
int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_int(); int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_integer();
ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer)); ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer));
} }
} }
@ -612,7 +612,7 @@ void RTileSetEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_drop_data_fw"), &RTileSetEditor::_drop_data_fw); ClassDB::bind_method(D_METHOD("_drop_data_fw"), &RTileSetEditor::_drop_data_fw);
} }
void RTileSetEditor::edit(Ref<TileSet> p_tile_set) { void RTileSetEditor::edit(Ref<RTileSet> p_tile_set) {
if (p_tile_set == tile_set) { if (p_tile_set == tile_set) {
return; return;
} }
@ -677,7 +677,7 @@ RTileSetEditor::RTileSetEditor() {
sources_list->connect("item_selected", callable_mp(this, &RTileSetEditor::_source_selected)); sources_list->connect("item_selected", callable_mp(this, &RTileSetEditor::_source_selected));
sources_list->connect("item_selected", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::set_sources_lists_current)); sources_list->connect("item_selected", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::set_sources_lists_current));
sources_list->connect("visibility_changed", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::synchronize_sources_list), varray(sources_list)); sources_list->connect("visibility_changed", callable_mp(RTilesEditorPlugin::get_singleton(), &RTilesEditorPlugin::synchronize_sources_list), varray(sources_list));
sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); //sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
sources_list->set_drag_forwarding(this); sources_list->set_drag_forwarding(this);
split_container_left_side->add_child(sources_list); split_container_left_side->add_child(sources_list);

View File

@ -50,7 +50,7 @@ private:
// TabBar. // TabBar.
HBoxContainer *tile_set_toolbar; HBoxContainer *tile_set_toolbar;
TabBar *tabs_bar; Tabs *tabs_bar;
// Tiles. // Tiles.
Label *no_source_selected_label; Label *no_source_selected_label;
@ -99,7 +99,7 @@ protected:
public: public:
_FORCE_INLINE_ static RTileSetEditor *get_singleton() { return singleton; } _FORCE_INLINE_ static RTileSetEditor *get_singleton() { return singleton; }
void edit(Ref<TileSet> p_tile_set); void edit(Ref<RTileSet> p_tile_set);
RTileSetEditor(); RTileSetEditor();
~RTileSetEditor(); ~RTileSetEditor();

View File

@ -58,7 +58,7 @@ private:
void set_id(int p_id); void set_id(int p_id);
int get_id(); int get_id();
void edit(Ref<RTileSet> p_tile_set, TileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id); void edit(Ref<RTileSet> p_tile_set, RTileSetScenesCollectionSource *p_tile_set_scenes_collection_source, int p_source_id);
}; };
// -- Proxy object for a tile, needed by the inspector -- // -- Proxy object for a tile, needed by the inspector --

View File

@ -48,7 +48,7 @@
RTilesEditorPlugin *RTilesEditorPlugin::singleton = nullptr; RTilesEditorPlugin *RTilesEditorPlugin::singleton = nullptr;
void RTilesEditorPlugin::_preview_frame_started() { void RTilesEditorPlugin::_preview_frame_started() {
RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<RTilesEditorPlugin *>(this), &RTilesEditorPlugin::_pattern_preview_done)); VS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<RTilesEditorPlugin *>(this), &RTilesEditorPlugin::_pattern_preview_done));
} }
void RTilesEditorPlugin::_pattern_preview_done() { void RTilesEditorPlugin::_pattern_preview_done() {
@ -83,7 +83,7 @@ void RTilesEditorPlugin::_thread() {
viewport->set_transparent_background(true); viewport->set_transparent_background(true);
viewport->set_update_mode(SubViewport::UPDATE_ONCE); viewport->set_update_mode(SubViewport::UPDATE_ONCE);
TileMap *tile_map = memnew(TileMap); RTileMap *tile_map = memnew(RTileMap);
tile_map->set_tileset(item.tile_set); tile_map->set_tileset(item.tile_set);
tile_map->set_pattern(0, Vector2(), item.pattern); tile_map->set_pattern(0, Vector2(), item.pattern);
viewport->add_child(tile_map); viewport->add_child(tile_map);
@ -163,7 +163,7 @@ void RTilesEditorPlugin::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_INTERNAL_PROCESS: { case NOTIFICATION_INTERNAL_PROCESS: {
if (tile_map_changed_needs_update) { if (tile_map_changed_needs_update) {
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); RTileMap *tile_map = Object::cast_to<RTileMap>(ObjectDB::get_instance(tile_map_id));
if (tile_map) { if (tile_map) {
tile_set = tile_map->get_tileset(); tile_set = tile_map->get_tileset();
} }
@ -177,7 +177,7 @@ void RTilesEditorPlugin::_notification(int p_what) {
void RTilesEditorPlugin::make_visible(bool p_visible) { void RTilesEditorPlugin::make_visible(bool p_visible) {
if (p_visible) { if (p_visible) {
// Disable and hide invalid editors. // Disable and hide invalid editors.
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); RTileMap *tile_map = Object::cast_to<RTileMap>(ObjectDB::get_instance(tile_map_id));
tileset_editor_button->set_visible(tile_set.is_valid()); tileset_editor_button->set_visible(tile_set.is_valid());
tilemap_editor_button->set_visible(tile_map); tilemap_editor_button->set_visible(tile_map);
if (tile_map) { if (tile_map) {
@ -237,7 +237,7 @@ void RTilesEditorPlugin::synchronize_atlas_view(Object *p_current) {
void RTilesEditorPlugin::edit(Object *p_object) { void RTilesEditorPlugin::edit(Object *p_object) {
// Disconnect to changes. // Disconnect to changes.
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); RTileMap *tile_map = Object::cast_to<RTileMap>(ObjectDB::get_instance(tile_map_id));
if (tile_map) { if (tile_map) {
tile_map->disconnect("changed", callable_mp(this, &RTilesEditorPlugin::_tile_map_changed)); tile_map->disconnect("changed", callable_mp(this, &RTilesEditorPlugin::_tile_map_changed));
} }
@ -247,7 +247,7 @@ void RTilesEditorPlugin::edit(Object *p_object) {
if (p_object) { if (p_object) {
if (p_object->is_class("TileMap")) { if (p_object->is_class("TileMap")) {
tile_map_id = p_object->get_instance_id(); tile_map_id = p_object->get_instance_id();
tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); tile_map = Object::cast_to<RTileMap>(ObjectDB::get_instance(tile_map_id));
tile_set = tile_map->get_tileset(); tile_set = tile_map->get_tileset();
editor_node->make_bottom_panel_item_visible(tilemap_editor); editor_node->make_bottom_panel_item_visible(tilemap_editor);
} else if (p_object->is_class("RTileSet")) { } else if (p_object->is_class("RTileSet")) {