diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-08-23 09:04:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-23 09:04:12 +0200 |
commit | 18e1268cd74a22f78454bb6c270c761466504b54 (patch) | |
tree | dc30289213e9454e6c72237b16c4c53fb6546a40 /modules/gridmap/grid_map_editor_plugin.cpp | |
parent | 0c0aa5fc6f50374beb9add3a7f7bcdd5ddaeb287 (diff) | |
parent | 6fa1b5eca7bfcc32c4f9284819a7c3e87b08ad3c (diff) |
Merge pull request #21254 from YeldhamDev/tile_grid_map_side
Add option to move Tile/GridMap editors to another side
Diffstat (limited to 'modules/gridmap/grid_map_editor_plugin.cpp')
-rw-r--r-- | modules/gridmap/grid_map_editor_plugin.cpp | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 7d38a8b748..90e28129cc 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1315,9 +1315,24 @@ GridMapEditor::~GridMapEditor() { VisualServer::get_singleton()->free(duplicate_instance); } +void GridMapEditorPlugin::_notification(int p_what) { + + if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { + + switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) { + case 0: { // Left. + SpatialEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 0); + } break; + case 1: { // Right. + SpatialEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 1); + } break; + } + } +} + void GridMapEditorPlugin::edit(Object *p_object) { - gridmap_editor->edit(Object::cast_to<GridMap>(p_object)); + grid_map_editor->edit(Object::cast_to<GridMap>(p_object)); } bool GridMapEditorPlugin::handles(Object *p_object) const { @@ -1328,29 +1343,35 @@ bool GridMapEditorPlugin::handles(Object *p_object) const { void GridMapEditorPlugin::make_visible(bool p_visible) { if (p_visible) { - gridmap_editor->show(); - gridmap_editor->spatial_editor_hb->show(); - gridmap_editor->set_process(true); + grid_map_editor->show(); + grid_map_editor->spatial_editor_hb->show(); + grid_map_editor->set_process(true); } else { - gridmap_editor->spatial_editor_hb->hide(); - gridmap_editor->hide(); - gridmap_editor->edit(NULL); - gridmap_editor->set_process(false); + grid_map_editor->spatial_editor_hb->hide(); + grid_map_editor->hide(); + grid_map_editor->edit(NULL); + grid_map_editor->set_process(false); } } GridMapEditorPlugin::GridMapEditorPlugin(EditorNode *p_node) { editor = p_node; - gridmap_editor = memnew(GridMapEditor(editor)); - SpatialEditor::get_singleton()->get_palette_split()->add_child(gridmap_editor); - // TODO: make this configurable, so the user can choose were to put this, it makes more sense - // on the right, but some people might find it strange. - SpatialEditor::get_singleton()->get_palette_split()->move_child(gridmap_editor, 1); + EDITOR_DEF("editors/grid_map/editor_side", 1); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/grid_map/editor_side", PROPERTY_HINT_ENUM, "Left,Right")); - gridmap_editor->hide(); + grid_map_editor = memnew(GridMapEditor(editor)); + switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) { + case 0: { // Left. + add_control_to_container(CONTAINER_SPATIAL_EDITOR_SIDE_LEFT, grid_map_editor); + } break; + case 1: { // Right. + add_control_to_container(CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, grid_map_editor); + } break; + } + grid_map_editor->hide(); } GridMapEditorPlugin::~GridMapEditorPlugin() { |