Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/scene/2d/tiles/tiles_editor_plugin.cpp
9913 views
1
/**************************************************************************/
2
/* tiles_editor_plugin.cpp */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#include "tiles_editor_plugin.h"
32
33
#include "tile_set_editor.h"
34
35
#include "core/os/mutex.h"
36
37
#include "editor/editor_interface.h"
38
#include "editor/editor_node.h"
39
#include "editor/editor_string_names.h"
40
#include "editor/gui/editor_bottom_panel.h"
41
#include "editor/inspector/multi_node_edit.h"
42
#include "editor/scene/canvas_item_editor_plugin.h"
43
#include "editor/settings/editor_command_palette.h"
44
#include "editor/settings/editor_settings.h"
45
#include "editor/themes/editor_scale.h"
46
#include "scene/2d/tile_map.h"
47
#include "scene/2d/tile_map_layer.h"
48
#include "scene/gui/button.h"
49
#include "scene/gui/control.h"
50
#include "scene/resources/2d/tile_set.h"
51
#include "scene/resources/image_texture.h"
52
53
TilesEditorUtils *TilesEditorUtils::singleton = nullptr;
54
TileMapEditorPlugin *tile_map_plugin_singleton = nullptr;
55
TileSetEditorPlugin *tile_set_plugin_singleton = nullptr;
56
57
void TilesEditorUtils::_preview_frame_started() {
58
RS::get_singleton()->request_frame_drawn_callback(callable_mp(this, &TilesEditorUtils::_pattern_preview_done));
59
}
60
61
void TilesEditorUtils::_pattern_preview_done() {
62
pattern_preview_done.post();
63
}
64
65
void TilesEditorUtils::_thread_func(void *ud) {
66
TilesEditorUtils *te = static_cast<TilesEditorUtils *>(ud);
67
set_current_thread_safe_for_nodes(true);
68
te->_thread();
69
}
70
71
void TilesEditorUtils::_thread() {
72
pattern_thread_exited.clear();
73
while (!pattern_thread_exit.is_set()) {
74
pattern_preview_sem.wait();
75
76
pattern_preview_mutex.lock();
77
if (pattern_preview_queue.is_empty()) {
78
pattern_preview_mutex.unlock();
79
} else {
80
QueueItem item = pattern_preview_queue.front()->get();
81
pattern_preview_queue.pop_front();
82
pattern_preview_mutex.unlock();
83
84
int thumbnail_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
85
thumbnail_size *= EDSCALE;
86
Vector2 thumbnail_size2 = Vector2(thumbnail_size, thumbnail_size);
87
88
if (item.pattern.is_valid() && !item.pattern->is_empty()) {
89
// Generate the pattern preview
90
SubViewport *viewport = memnew(SubViewport);
91
viewport->set_size(thumbnail_size2);
92
viewport->set_disable_input(true);
93
viewport->set_transparent_background(true);
94
viewport->set_update_mode(SubViewport::UPDATE_ONCE);
95
96
TileMapLayer *tile_map_layer = memnew(TileMapLayer);
97
tile_map_layer->set_tile_set(item.tile_set);
98
tile_map_layer->set_pattern(Vector2(), item.pattern);
99
viewport->add_child(tile_map_layer);
100
101
Rect2 encompassing_rect;
102
encompassing_rect.set_position(tile_map_layer->map_to_local(tile_map_layer->get_tile_map_layer_data().begin()->key));
103
for (KeyValue<Vector2i, CellData> kv : tile_map_layer->get_tile_map_layer_data()) {
104
Vector2i cell = kv.key;
105
Vector2 world_pos = tile_map_layer->map_to_local(cell);
106
encompassing_rect.expand_to(world_pos);
107
108
// Texture.
109
Ref<TileSetAtlasSource> atlas_source = item.tile_set->get_source(tile_map_layer->get_cell_source_id(cell));
110
if (atlas_source.is_valid()) {
111
Vector2i coords = tile_map_layer->get_cell_atlas_coords(cell);
112
int alternative = tile_map_layer->get_cell_alternative_tile(cell);
113
114
if (atlas_source->has_tile(coords) && atlas_source->has_alternative_tile(coords, alternative)) {
115
Vector2 center = world_pos - atlas_source->get_tile_data(coords, alternative)->get_texture_origin();
116
encompassing_rect.expand_to(center - atlas_source->get_tile_texture_region(coords).size / 2);
117
encompassing_rect.expand_to(center + atlas_source->get_tile_texture_region(coords).size / 2);
118
}
119
}
120
}
121
122
Vector2 scale = thumbnail_size2 / MAX(encompassing_rect.size.x, encompassing_rect.size.y);
123
tile_map_layer->set_scale(scale);
124
tile_map_layer->set_position(-(scale * encompassing_rect.get_center()) + thumbnail_size2 / 2);
125
126
// Add the viewport at the last moment to avoid rendering too early.
127
callable_mp((Node *)EditorNode::get_singleton(), &Node::add_child).call_deferred(viewport, false, Node::INTERNAL_MODE_DISABLED);
128
129
RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(this, &TilesEditorUtils::_preview_frame_started), Object::CONNECT_ONE_SHOT);
130
131
pattern_preview_done.wait();
132
133
Ref<Image> image = viewport->get_texture()->get_image();
134
135
// Find the index for the given pattern. TODO: optimize.
136
item.callback.call(item.pattern, ImageTexture::create_from_image(image));
137
138
viewport->queue_free();
139
}
140
}
141
}
142
pattern_thread_exited.set();
143
}
144
145
void TilesEditorUtils::queue_pattern_preview(Ref<TileSet> p_tile_set, Ref<TileMapPattern> p_pattern, Callable p_callback) {
146
ERR_FAIL_COND(p_tile_set.is_null());
147
ERR_FAIL_COND(p_pattern.is_null());
148
{
149
MutexLock lock(pattern_preview_mutex);
150
pattern_preview_queue.push_back({ p_tile_set, p_pattern, p_callback });
151
}
152
pattern_preview_sem.post();
153
}
154
155
void TilesEditorUtils::set_sources_lists_current(int p_current) {
156
atlas_sources_lists_current = p_current;
157
}
158
159
void TilesEditorUtils::synchronize_sources_list(Object *p_current_list, Object *p_current_sort_button) {
160
ItemList *item_list = Object::cast_to<ItemList>(p_current_list);
161
MenuButton *sorting_button = Object::cast_to<MenuButton>(p_current_sort_button);
162
ERR_FAIL_NULL(item_list);
163
ERR_FAIL_NULL(sorting_button);
164
165
if (sorting_button->is_visible_in_tree()) {
166
for (int i = 0; i != SOURCE_SORT_MAX; i++) {
167
sorting_button->get_popup()->set_item_checked(i, (i == (int)source_sort));
168
}
169
}
170
171
if (item_list->is_visible_in_tree()) {
172
// Make sure the selection is not overwritten after sorting.
173
int atlas_sources_lists_current_mem = atlas_sources_lists_current;
174
item_list->emit_signal(SNAME("sort_request"));
175
atlas_sources_lists_current = atlas_sources_lists_current_mem;
176
177
if (atlas_sources_lists_current < 0 || atlas_sources_lists_current >= item_list->get_item_count()) {
178
item_list->deselect_all();
179
} else {
180
item_list->set_current(atlas_sources_lists_current);
181
item_list->ensure_current_is_visible();
182
item_list->emit_signal(SceneStringName(item_selected), atlas_sources_lists_current);
183
}
184
}
185
}
186
187
void TilesEditorUtils::set_atlas_view_transform(float p_zoom, Vector2 p_scroll) {
188
atlas_view_zoom = p_zoom;
189
atlas_view_scroll = p_scroll;
190
}
191
192
void TilesEditorUtils::synchronize_atlas_view(Object *p_current) {
193
TileAtlasView *tile_atlas_view = Object::cast_to<TileAtlasView>(p_current);
194
ERR_FAIL_NULL(tile_atlas_view);
195
196
if (tile_atlas_view->is_visible_in_tree()) {
197
tile_atlas_view->set_transform(atlas_view_zoom, atlas_view_scroll);
198
}
199
}
200
201
void TilesEditorUtils::set_sorting_option(int p_option) {
202
source_sort = p_option;
203
}
204
205
List<int> TilesEditorUtils::get_sorted_sources(const Ref<TileSet> p_tile_set) const {
206
SourceNameComparator::tile_set = p_tile_set;
207
List<int> source_ids;
208
209
for (int i = 0; i < p_tile_set->get_source_count(); i++) {
210
source_ids.push_back(p_tile_set->get_source_id(i));
211
}
212
213
switch (source_sort) {
214
case SOURCE_SORT_ID_REVERSE:
215
// Already sorted.
216
source_ids.reverse();
217
break;
218
case SOURCE_SORT_NAME:
219
source_ids.sort_custom<SourceNameComparator>();
220
break;
221
case SOURCE_SORT_NAME_REVERSE:
222
source_ids.sort_custom<SourceNameComparator>();
223
source_ids.reverse();
224
break;
225
default: // SOURCE_SORT_ID
226
break;
227
}
228
229
SourceNameComparator::tile_set.unref();
230
return source_ids;
231
}
232
233
Ref<TileSet> TilesEditorUtils::SourceNameComparator::tile_set;
234
235
bool TilesEditorUtils::SourceNameComparator::operator()(const int &p_a, const int &p_b) const {
236
String name_a;
237
String name_b;
238
239
{
240
TileSetSource *source = *tile_set->get_source(p_a);
241
242
if (!source->get_name().is_empty()) {
243
name_a = source->get_name();
244
}
245
246
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
247
if (atlas_source) {
248
Ref<Texture2D> texture = atlas_source->get_texture();
249
if (name_a.is_empty() && texture.is_valid()) {
250
name_a = texture->get_path().get_file();
251
}
252
}
253
254
if (name_a.is_empty()) {
255
name_a = itos(p_a);
256
}
257
}
258
259
{
260
TileSetSource *source = *tile_set->get_source(p_b);
261
262
if (!source->get_name().is_empty()) {
263
name_b = source->get_name();
264
}
265
266
TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
267
if (atlas_source) {
268
Ref<Texture2D> texture = atlas_source->get_texture();
269
if (name_b.is_empty() && texture.is_valid()) {
270
name_b = texture->get_path().get_file();
271
}
272
}
273
274
if (name_b.is_empty()) {
275
name_b = itos(p_b);
276
}
277
}
278
279
return NaturalNoCaseComparator()(name_a, name_b);
280
}
281
282
void TilesEditorUtils::display_tile_set_editor_panel() {
283
tile_map_plugin_singleton->hide_editor();
284
tile_set_plugin_singleton->make_visible(true);
285
}
286
287
void TilesEditorUtils::draw_selection_rect(CanvasItem *p_ci, const Rect2 &p_rect, const Color &p_color) {
288
Ref<Texture2D> selection_texture = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("TileSelection"), EditorStringName(EditorIcons));
289
290
real_t scale = p_ci->get_global_transform().get_scale().x * 0.5;
291
p_ci->draw_set_transform(p_rect.position, 0, Vector2(1, 1) / scale);
292
RS::get_singleton()->canvas_item_add_nine_patch(
293
p_ci->get_canvas_item(), Rect2(Vector2(), p_rect.size * scale), Rect2(), selection_texture->get_rid(),
294
Vector2(2, 2), Vector2(2, 2), RS::NINE_PATCH_STRETCH, RS::NINE_PATCH_STRETCH, false, p_color);
295
p_ci->draw_set_transform_matrix(Transform2D());
296
}
297
298
TilesEditorUtils::TilesEditorUtils() {
299
singleton = this;
300
// Pattern preview generation thread.
301
pattern_preview_thread.start(_thread_func, this);
302
303
ED_SHORTCUT("tiles_editor/cut", TTRC("Cut"), KeyModifierMask::CMD_OR_CTRL | Key::X);
304
ED_SHORTCUT("tiles_editor/copy", TTRC("Copy"), KeyModifierMask::CMD_OR_CTRL | Key::C);
305
ED_SHORTCUT("tiles_editor/paste", TTRC("Paste"), KeyModifierMask::CMD_OR_CTRL | Key::V);
306
ED_SHORTCUT("tiles_editor/cancel", TTRC("Cancel"), Key::ESCAPE);
307
ED_SHORTCUT("tiles_editor/delete", TTRC("Delete"), Key::KEY_DELETE);
308
309
ED_SHORTCUT("tiles_editor/paint_tool", TTRC("Paint Tool"), Key::D);
310
ED_SHORTCUT("tiles_editor/line_tool", TTRC("Line Tool"), Key::L);
311
ED_SHORTCUT("tiles_editor/rect_tool", TTRC("Rect Tool"), Key::R);
312
ED_SHORTCUT("tiles_editor/bucket_tool", TTRC("Bucket Tool"), Key::B);
313
ED_SHORTCUT("tiles_editor/eraser", TTRC("Eraser Tool"), Key::E);
314
ED_SHORTCUT("tiles_editor/picker", TTRC("Picker Tool"), Key::P);
315
}
316
317
TilesEditorUtils::~TilesEditorUtils() {
318
if (pattern_preview_thread.is_started()) {
319
pattern_thread_exit.set();
320
pattern_preview_sem.post();
321
while (!pattern_thread_exited.is_set()) {
322
OS::get_singleton()->delay_usec(10000);
323
RenderingServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on visual server
324
}
325
pattern_preview_thread.wait_to_finish();
326
}
327
singleton = nullptr;
328
}
329
330
void TileMapEditorPlugin::_tile_map_layer_changed() {
331
if (tile_map_changed_needs_update) {
332
return;
333
}
334
tile_map_changed_needs_update = true;
335
callable_mp(this, &TileMapEditorPlugin::_update_tile_map).call_deferred();
336
}
337
338
void TileMapEditorPlugin::_tile_map_layer_removed() {
339
// Workaround for TileMap, making sure the editor stays open when you delete the currently edited layer.
340
TileMap *tile_map = ObjectDB::get_instance<TileMap>(tile_map_group_id);
341
if (tile_map) {
342
edit(tile_map);
343
}
344
}
345
346
void TileMapEditorPlugin::_update_tile_map() {
347
TileMapLayer *edited_layer = ObjectDB::get_instance<TileMapLayer>(tile_map_layer_id);
348
if (edited_layer) {
349
Ref<TileSet> tile_set = edited_layer->get_tile_set();
350
if (tile_set.is_valid() && tile_set_id != tile_set->get_instance_id()) {
351
tile_set_plugin_singleton->edit(tile_set.ptr());
352
tile_set_plugin_singleton->make_visible(true);
353
tile_set_id = tile_set->get_instance_id();
354
} else if (tile_set.is_null()) {
355
tile_set_plugin_singleton->edit(nullptr);
356
tile_set_plugin_singleton->make_visible(false);
357
tile_set_id = ObjectID();
358
}
359
}
360
tile_map_changed_needs_update = false;
361
}
362
363
void TileMapEditorPlugin::_select_layer(const StringName &p_name) {
364
TileMapLayer *edited_layer = ObjectDB::get_instance<TileMapLayer>(tile_map_layer_id);
365
ERR_FAIL_NULL(edited_layer);
366
367
Node *parent = edited_layer->get_parent();
368
if (parent) {
369
TileMapLayer *new_layer = Object::cast_to<TileMapLayer>(parent->get_node_or_null(String(p_name)));
370
edit(new_layer);
371
}
372
}
373
374
void TileMapEditorPlugin::_edit_tile_map_layer(TileMapLayer *p_tile_map_layer, bool p_show_layer_selector) {
375
ERR_FAIL_NULL(p_tile_map_layer);
376
377
editor->edit(p_tile_map_layer);
378
editor->set_show_layer_selector(p_show_layer_selector);
379
380
// Update the object IDs.
381
tile_map_layer_id = p_tile_map_layer->get_instance_id();
382
p_tile_map_layer->connect(CoreStringName(changed), callable_mp(this, &TileMapEditorPlugin::_tile_map_layer_changed));
383
p_tile_map_layer->connect(SceneStringName(tree_exited), callable_mp(this, &TileMapEditorPlugin::_tile_map_layer_removed));
384
385
// Update the edited tileset.
386
Ref<TileSet> tile_set = p_tile_map_layer->get_tile_set();
387
if (tile_set.is_valid()) {
388
tile_set_plugin_singleton->edit(tile_set.ptr());
389
tile_set_plugin_singleton->make_visible(true);
390
tile_set_id = tile_set->get_instance_id();
391
} else {
392
tile_set_plugin_singleton->edit(nullptr);
393
tile_set_plugin_singleton->make_visible(false);
394
}
395
}
396
397
void TileMapEditorPlugin::_edit_tile_map(TileMap *p_tile_map) {
398
ERR_FAIL_NULL(p_tile_map);
399
400
if (p_tile_map->get_layers_count() > 0) {
401
TileMapLayer *selected_layer = Object::cast_to<TileMapLayer>(p_tile_map->get_child(0));
402
_edit_tile_map_layer(selected_layer, true);
403
} else {
404
editor->edit(nullptr);
405
editor->set_show_layer_selector(false);
406
}
407
}
408
409
void TileMapEditorPlugin::_notification(int p_notification) {
410
if (p_notification == NOTIFICATION_EXIT_TREE) {
411
get_tree()->queue_delete(TilesEditorUtils::get_singleton());
412
}
413
}
414
415
void TileMapEditorPlugin::edit(Object *p_object) {
416
TileMapLayer *edited_layer = ObjectDB::get_instance<TileMapLayer>(tile_map_layer_id);
417
if (edited_layer) {
418
edited_layer->disconnect(CoreStringName(changed), callable_mp(this, &TileMapEditorPlugin::_tile_map_layer_changed));
419
edited_layer->disconnect(SceneStringName(tree_exited), callable_mp(this, &TileMapEditorPlugin::_tile_map_layer_removed));
420
}
421
422
tile_map_group_id = ObjectID();
423
tile_map_layer_id = ObjectID();
424
tile_set_id = ObjectID();
425
426
TileMap *tile_map = Object::cast_to<TileMap>(p_object);
427
TileMapLayer *tile_map_layer = Object::cast_to<TileMapLayer>(p_object);
428
MultiNodeEdit *multi_node_edit = Object::cast_to<MultiNodeEdit>(p_object);
429
if (tile_map) {
430
_edit_tile_map(tile_map);
431
} else if (tile_map_layer) {
432
_edit_tile_map_layer(tile_map_layer, false);
433
} else if (multi_node_edit) {
434
editor->edit(multi_node_edit);
435
} else {
436
editor->edit(nullptr);
437
}
438
}
439
440
bool TileMapEditorPlugin::handles(Object *p_object) const {
441
MultiNodeEdit *multi_node_edit = Object::cast_to<MultiNodeEdit>(p_object);
442
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
443
if (multi_node_edit && edited_scene) {
444
bool only_tile_map_layers = true;
445
for (int i = 0; i < multi_node_edit->get_node_count(); i++) {
446
if (!Object::cast_to<TileMapLayer>(edited_scene->get_node(multi_node_edit->get_node(i)))) {
447
only_tile_map_layers = false;
448
break;
449
}
450
}
451
return only_tile_map_layers;
452
}
453
return Object::cast_to<TileMapLayer>(p_object) != nullptr || Object::cast_to<TileMap>(p_object) != nullptr;
454
}
455
456
void TileMapEditorPlugin::make_visible(bool p_visible) {
457
if (p_visible) {
458
button->show();
459
EditorNode::get_bottom_panel()->make_item_visible(editor);
460
} else {
461
button->hide();
462
if (editor->is_visible_in_tree()) {
463
EditorNode::get_bottom_panel()->hide_bottom_panel();
464
}
465
}
466
}
467
468
bool TileMapEditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
469
return editor->forward_canvas_gui_input(p_event);
470
}
471
472
void TileMapEditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
473
editor->forward_canvas_draw_over_viewport(p_overlay);
474
}
475
476
void TileMapEditorPlugin::hide_editor() {
477
if (editor->is_visible_in_tree()) {
478
EditorNode::get_bottom_panel()->hide_bottom_panel();
479
}
480
}
481
482
bool TileMapEditorPlugin::is_editor_visible() const {
483
return editor->is_visible_in_tree();
484
}
485
486
TileMapEditorPlugin::TileMapEditorPlugin() {
487
if (!TilesEditorUtils::get_singleton()) {
488
memnew(TilesEditorUtils);
489
}
490
tile_map_plugin_singleton = this;
491
492
editor = memnew(TileMapLayerEditor);
493
editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
494
editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
495
editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
496
editor->hide();
497
498
button = EditorNode::get_bottom_panel()->add_item(TTRC("TileMap"), editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_tile_map_bottom_panel", TTRC("Toggle TileMap Bottom Panel")));
499
button->hide();
500
}
501
502
TileMapEditorPlugin::~TileMapEditorPlugin() {
503
tile_map_plugin_singleton = nullptr;
504
}
505
506
void TileSetEditorPlugin::edit(Object *p_object) {
507
editor->edit(Ref<TileSet>(p_object));
508
if (p_object) {
509
edited_tileset = p_object->get_instance_id();
510
} else {
511
edited_tileset = ObjectID();
512
}
513
}
514
515
bool TileSetEditorPlugin::handles(Object *p_object) const {
516
return Object::cast_to<TileSet>(p_object) != nullptr;
517
}
518
519
void TileSetEditorPlugin::make_visible(bool p_visible) {
520
if (p_visible) {
521
button->show();
522
if (!tile_map_plugin_singleton->is_editor_visible()) {
523
EditorNode::get_bottom_panel()->make_item_visible(editor);
524
}
525
} else {
526
button->hide();
527
if (editor->is_visible_in_tree()) {
528
EditorNode::get_bottom_panel()->hide_bottom_panel();
529
}
530
}
531
}
532
533
ObjectID TileSetEditorPlugin::get_edited_tileset() const {
534
return edited_tileset;
535
}
536
537
TileSetEditorPlugin::TileSetEditorPlugin() {
538
if (!TilesEditorUtils::get_singleton()) {
539
memnew(TilesEditorUtils);
540
}
541
tile_set_plugin_singleton = this;
542
543
editor = memnew(TileSetEditor);
544
editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
545
editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
546
editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
547
editor->hide();
548
549
button = EditorNode::get_bottom_panel()->add_item(TTRC("TileSet"), editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_tile_set_bottom_panel", TTRC("Toggle TileSet Bottom Panel")));
550
button->hide();
551
}
552
553
TileSetEditorPlugin::~TileSetEditorPlugin() {
554
tile_set_plugin_singleton = nullptr;
555
}
556
557