Use new dock system for TileMap and TileSet
This commit is contained in:
1
editor/icons/TileMapDock.svg
Normal file
1
editor/icons/TileMapDock.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#e0e0e0" d="M8 2 6.25 3.375 8 4.75l1.75-1.375zm2.624 2.062-1.75 1.375 1.75 1.375 1.75-1.375Zm2.626 2.063L11.5 7.5l1.75 1.375L15 7.5ZM5.376 4.062l-1.75 1.375 1.75 1.375 1.75-1.375zM8 6.124 6.25 7.499 8 8.874l1.75-1.375zm2.626 2.063-1.75 1.375 1.75 1.375 1.75-1.375ZM2.75 6.125 1 7.5l1.75 1.375L4.5 7.5Zm2.624 2.062-1.75 1.375 1.75 1.375 1.75-1.375ZM8 10.25l-1.75 1.375L8 13l1.75-1.375z"/></svg>
|
||||||
|
After Width: | Height: | Size: 469 B |
@ -37,6 +37,7 @@
|
|||||||
#include "editor/inspector/editor_resource_preview.h"
|
#include "editor/inspector/editor_resource_preview.h"
|
||||||
#include "editor/inspector/multi_node_edit.h"
|
#include "editor/inspector/multi_node_edit.h"
|
||||||
#include "editor/scene/canvas_item_editor_plugin.h"
|
#include "editor/scene/canvas_item_editor_plugin.h"
|
||||||
|
#include "editor/settings/editor_command_palette.h"
|
||||||
#include "editor/settings/editor_settings.h"
|
#include "editor/settings/editor_settings.h"
|
||||||
#include "editor/themes/editor_scale.h"
|
#include "editor/themes/editor_scale.h"
|
||||||
#include "scene/2d/tile_map.h"
|
#include "scene/2d/tile_map.h"
|
||||||
@ -4397,6 +4398,16 @@ void TileMapLayerEditor::set_show_layer_selector(bool p_show_layer_selector) {
|
|||||||
|
|
||||||
TileMapLayerEditor::TileMapLayerEditor() {
|
TileMapLayerEditor::TileMapLayerEditor() {
|
||||||
set_process_internal(true);
|
set_process_internal(true);
|
||||||
|
set_name(TTRC("TileMap"));
|
||||||
|
set_icon_name("TileMapDock");
|
||||||
|
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_tile_map_bottom_panel", TTRC("Open TileMap Dock")));
|
||||||
|
set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
|
||||||
|
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
|
||||||
|
set_global(false);
|
||||||
|
set_transient(true);
|
||||||
|
|
||||||
|
VBoxContainer *main_box_container = memnew(VBoxContainer);
|
||||||
|
add_child(main_box_container);
|
||||||
|
|
||||||
// Shortcuts.
|
// Shortcuts.
|
||||||
ED_SHORTCUT("tiles_editor/select_next_layer", TTRC("Select Next Tile Map Layer"), Key::PAGEDOWN);
|
ED_SHORTCUT("tiles_editor/select_next_layer", TTRC("Select Next Tile Map Layer"), Key::PAGEDOWN);
|
||||||
@ -4422,7 +4433,7 @@ TileMapLayerEditor::TileMapLayerEditor() {
|
|||||||
// --- TileMap toolbar ---
|
// --- TileMap toolbar ---
|
||||||
tile_map_toolbar = memnew(HFlowContainer);
|
tile_map_toolbar = memnew(HFlowContainer);
|
||||||
tile_map_toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
|
tile_map_toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
add_child(tile_map_toolbar);
|
main_box_container->add_child(tile_map_toolbar);
|
||||||
|
|
||||||
// Tabs.
|
// Tabs.
|
||||||
tile_map_toolbar->add_child(tabs_bar);
|
tile_map_toolbar->add_child(tabs_bar);
|
||||||
@ -4509,10 +4520,10 @@ TileMapLayerEditor::TileMapLayerEditor() {
|
|||||||
cant_edit_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
|
cant_edit_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
|
||||||
cant_edit_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
|
cant_edit_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
|
||||||
cant_edit_label->hide();
|
cant_edit_label->hide();
|
||||||
add_child(cant_edit_label);
|
main_box_container->add_child(cant_edit_label);
|
||||||
|
|
||||||
for (unsigned int tab_index = 0; tab_index < tabs_data.size(); tab_index++) {
|
for (unsigned int tab_index = 0; tab_index < tabs_data.size(); tab_index++) {
|
||||||
add_child(tabs_data[tab_index].panel);
|
main_box_container->add_child(tabs_data[tab_index].panel);
|
||||||
tabs_data[tab_index].panel->set_v_size_flags(SIZE_EXPAND_FILL);
|
tabs_data[tab_index].panel->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
tabs_data[tab_index].panel->set_visible(tab_index == 0);
|
tabs_data[tab_index].panel->set_visible(tab_index == 0);
|
||||||
tabs_data[tab_index].panel->set_h_size_flags(SIZE_EXPAND_FILL);
|
tabs_data[tab_index].panel->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
#include "tile_atlas_view.h"
|
#include "tile_atlas_view.h"
|
||||||
|
|
||||||
#include "core/os/thread.h"
|
#include "core/os/thread.h"
|
||||||
|
#include "editor/docks/editor_dock.h"
|
||||||
#include "scene/gui/box_container.h"
|
#include "scene/gui/box_container.h"
|
||||||
#include "scene/gui/check_box.h"
|
#include "scene/gui/check_box.h"
|
||||||
#include "scene/gui/flow_container.h"
|
#include "scene/gui/flow_container.h"
|
||||||
@ -337,8 +338,8 @@ public:
|
|||||||
TileMapLayerEditorTerrainsPlugin();
|
TileMapLayerEditorTerrainsPlugin();
|
||||||
};
|
};
|
||||||
|
|
||||||
class TileMapLayerEditor : public VBoxContainer {
|
class TileMapLayerEditor : public EditorDock {
|
||||||
GDCLASS(TileMapLayerEditor, VBoxContainer);
|
GDCLASS(TileMapLayerEditor, EditorDock);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool tile_map_layer_changed_needs_update = false;
|
bool tile_map_layer_changed_needs_update = false;
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
#include "editor/file_system/editor_file_system.h"
|
#include "editor/file_system/editor_file_system.h"
|
||||||
#include "editor/gui/editor_file_dialog.h"
|
#include "editor/gui/editor_file_dialog.h"
|
||||||
#include "editor/inspector/editor_inspector.h"
|
#include "editor/inspector/editor_inspector.h"
|
||||||
|
#include "editor/settings/editor_command_palette.h"
|
||||||
#include "editor/settings/editor_settings.h"
|
#include "editor/settings/editor_settings.h"
|
||||||
#include "editor/themes/editor_scale.h"
|
#include "editor/themes/editor_scale.h"
|
||||||
|
|
||||||
@ -807,6 +808,13 @@ void TileSetEditor::register_split(SplitContainer *p_split) {
|
|||||||
|
|
||||||
TileSetEditor::TileSetEditor() {
|
TileSetEditor::TileSetEditor() {
|
||||||
singleton = this;
|
singleton = this;
|
||||||
|
set_name(TTRC("TileSet"));
|
||||||
|
set_icon_name("TileSet");
|
||||||
|
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_tile_set_bottom_panel", TTRC("Open TileSet Dock")));
|
||||||
|
set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
|
||||||
|
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
|
||||||
|
set_global(false);
|
||||||
|
set_transient(true);
|
||||||
|
|
||||||
set_process_internal(true);
|
set_process_internal(true);
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "atlas_merging_dialog.h"
|
#include "atlas_merging_dialog.h"
|
||||||
|
#include "editor/docks/editor_dock.h"
|
||||||
#include "scene/gui/tab_bar.h"
|
#include "scene/gui/tab_bar.h"
|
||||||
#include "scene/resources/2d/tile_set.h"
|
#include "scene/resources/2d/tile_set.h"
|
||||||
#include "tile_proxies_manager_dialog.h"
|
#include "tile_proxies_manager_dialog.h"
|
||||||
@ -45,8 +46,8 @@ class EditorFileDialog;
|
|||||||
class EditorInspectorPlugin;
|
class EditorInspectorPlugin;
|
||||||
class TileSetSourceItemList;
|
class TileSetSourceItemList;
|
||||||
|
|
||||||
class TileSetEditor : public MarginContainer {
|
class TileSetEditor : public EditorDock {
|
||||||
GDCLASS(TileSetEditor, MarginContainer);
|
GDCLASS(TileSetEditor, EditorDock);
|
||||||
|
|
||||||
static TileSetEditor *singleton;
|
static TileSetEditor *singleton;
|
||||||
|
|
||||||
|
|||||||
@ -280,7 +280,6 @@ bool TilesEditorUtils::SourceNameComparator::operator()(const int &p_a, const in
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TilesEditorUtils::display_tile_set_editor_panel() {
|
void TilesEditorUtils::display_tile_set_editor_panel() {
|
||||||
tile_map_plugin_singleton->hide_editor();
|
|
||||||
tile_set_plugin_singleton->make_visible(true);
|
tile_set_plugin_singleton->make_visible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,13 +480,9 @@ bool TileMapEditorPlugin::handles(Object *p_object) const {
|
|||||||
|
|
||||||
void TileMapEditorPlugin::make_visible(bool p_visible) {
|
void TileMapEditorPlugin::make_visible(bool p_visible) {
|
||||||
if (p_visible) {
|
if (p_visible) {
|
||||||
button->show();
|
editor->open();
|
||||||
EditorNode::get_bottom_panel()->make_item_visible(editor);
|
|
||||||
} else {
|
} else {
|
||||||
button->hide();
|
editor->close();
|
||||||
if (editor->is_visible_in_tree()) {
|
|
||||||
EditorNode::get_bottom_panel()->hide_bottom_panel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,12 +494,6 @@ void TileMapEditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay)
|
|||||||
editor->forward_canvas_draw_over_viewport(p_overlay);
|
editor->forward_canvas_draw_over_viewport(p_overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileMapEditorPlugin::hide_editor() {
|
|
||||||
if (editor->is_visible_in_tree()) {
|
|
||||||
EditorNode::get_bottom_panel()->hide_bottom_panel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TileMapEditorPlugin::is_editor_visible() const {
|
bool TileMapEditorPlugin::is_editor_visible() const {
|
||||||
return editor->is_visible_in_tree();
|
return editor->is_visible_in_tree();
|
||||||
}
|
}
|
||||||
@ -521,8 +510,8 @@ TileMapEditorPlugin::TileMapEditorPlugin() {
|
|||||||
editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
||||||
editor->hide();
|
editor->hide();
|
||||||
|
|
||||||
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")));
|
EditorDockManager::get_singleton()->add_dock(editor);
|
||||||
button->hide();
|
editor->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
TileMapEditorPlugin::~TileMapEditorPlugin() {
|
TileMapEditorPlugin::~TileMapEditorPlugin() {
|
||||||
@ -544,15 +533,9 @@ bool TileSetEditorPlugin::handles(Object *p_object) const {
|
|||||||
|
|
||||||
void TileSetEditorPlugin::make_visible(bool p_visible) {
|
void TileSetEditorPlugin::make_visible(bool p_visible) {
|
||||||
if (p_visible) {
|
if (p_visible) {
|
||||||
button->show();
|
editor->open();
|
||||||
if (!tile_map_plugin_singleton->is_editor_visible()) {
|
|
||||||
EditorNode::get_bottom_panel()->make_item_visible(editor);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
button->hide();
|
editor->close();
|
||||||
if (editor->is_visible_in_tree()) {
|
|
||||||
EditorNode::get_bottom_panel()->hide_bottom_panel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,8 +555,8 @@ TileSetEditorPlugin::TileSetEditorPlugin() {
|
|||||||
editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
||||||
editor->hide();
|
editor->hide();
|
||||||
|
|
||||||
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")));
|
EditorDockManager::get_singleton()->add_dock(editor);
|
||||||
button->hide();
|
editor->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSetEditorPlugin::~TileSetEditorPlugin() {
|
TileSetEditorPlugin::~TileSetEditorPlugin() {
|
||||||
|
|||||||
@ -122,7 +122,6 @@ class TileMapEditorPlugin : public EditorPlugin {
|
|||||||
GDCLASS(TileMapEditorPlugin, EditorPlugin);
|
GDCLASS(TileMapEditorPlugin, EditorPlugin);
|
||||||
|
|
||||||
TileMapLayerEditor *editor = nullptr;
|
TileMapLayerEditor *editor = nullptr;
|
||||||
Button *button = nullptr;
|
|
||||||
ObjectID tile_map_layer_id;
|
ObjectID tile_map_layer_id;
|
||||||
ObjectID tile_map_group_id; // Allow keeping the layer selector up to date.
|
ObjectID tile_map_group_id; // Allow keeping the layer selector up to date.
|
||||||
|
|
||||||
@ -148,7 +147,6 @@ public:
|
|||||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override;
|
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override;
|
||||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override;
|
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) override;
|
||||||
|
|
||||||
void hide_editor();
|
|
||||||
bool is_editor_visible() const;
|
bool is_editor_visible() const;
|
||||||
|
|
||||||
TileMapEditorPlugin();
|
TileMapEditorPlugin();
|
||||||
@ -159,7 +157,6 @@ class TileSetEditorPlugin : public EditorPlugin {
|
|||||||
GDCLASS(TileSetEditorPlugin, EditorPlugin);
|
GDCLASS(TileSetEditorPlugin, EditorPlugin);
|
||||||
|
|
||||||
TileSetEditor *editor = nullptr;
|
TileSetEditor *editor = nullptr;
|
||||||
Button *button = nullptr;
|
|
||||||
|
|
||||||
ObjectID edited_tileset;
|
ObjectID edited_tileset;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user