diff options
author | Michael Alexsander Silva Dias <michaelalexsander@protonmail.com> | 2018-08-21 01:35:48 -0300 |
---|---|---|
committer | Michael Alexsander Silva Dias <michaelalexsander@protonmail.com> | 2018-08-22 19:18:23 -0300 |
commit | 6fa1b5eca7bfcc32c4f9284819a7c3e87b08ad3c (patch) | |
tree | 2388d6941760bdbce6a21aa62dd85384586c1595 | |
parent | 9c696716118b7a190bff3b85a0e0863e521cfba3 (diff) |
Add option to move Tile/GridMap editors to another side
-rw-r--r-- | editor/editor_plugin.cpp | 28 | ||||
-rw-r--r-- | editor/editor_plugin.h | 6 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 27 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.h | 3 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | modules/gridmap/grid_map_editor_plugin.cpp | 49 | ||||
-rw-r--r-- | modules/gridmap/grid_map_editor_plugin.h | 7 | ||||
-rw-r--r-- | scene/resources/material.cpp | 2 |
8 files changed, 97 insertions, 31 deletions
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 137e710c5c..6818de8281 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -353,12 +353,18 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C SpatialEditor::get_singleton()->add_control_to_menu_panel(p_control); } break; - case CONTAINER_SPATIAL_EDITOR_SIDE: { + case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: { SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control); SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 0); } break; + case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: { + + SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control); + SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 1); + + } break; case CONTAINER_SPATIAL_EDITOR_BOTTOM: { SpatialEditor::get_singleton()->get_shader_split()->add_child(p_control); @@ -369,12 +375,18 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C CanvasItemEditor::get_singleton()->add_control_to_menu_panel(p_control); } break; - case CONTAINER_CANVAS_EDITOR_SIDE: { + case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: { CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control); CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 0); } break; + case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: { + + CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control); + CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 1); + + } break; case CONTAINER_CANVAS_EDITOR_BOTTOM: { CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control); @@ -403,7 +415,8 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati SpatialEditor::get_singleton()->remove_control_from_menu_panel(p_control); } break; - case CONTAINER_SPATIAL_EDITOR_SIDE: { + case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: + case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: { SpatialEditor::get_singleton()->get_palette_split()->remove_child(p_control); @@ -418,7 +431,8 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control); } break; - case CONTAINER_CANVAS_EDITOR_SIDE: { + case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: + case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: { CanvasItemEditor::get_singleton()->get_palette_split()->remove_child(p_control); @@ -785,10 +799,12 @@ void EditorPlugin::_bind_methods() { BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR); BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU); - BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE); + BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_LEFT); + BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT); BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_BOTTOM); BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_MENU); - BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE); + BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_LEFT); + BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT); BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_BOTTOM); BIND_ENUM_CONSTANT(CONTAINER_PROPERTY_EDITOR_BOTTOM); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 903b82937f..1ebddbe2b0 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -127,10 +127,12 @@ public: enum CustomControlContainer { CONTAINER_TOOLBAR, CONTAINER_SPATIAL_EDITOR_MENU, - CONTAINER_SPATIAL_EDITOR_SIDE, + CONTAINER_SPATIAL_EDITOR_SIDE_LEFT, + CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, CONTAINER_SPATIAL_EDITOR_BOTTOM, CONTAINER_CANVAS_EDITOR_MENU, - CONTAINER_CANVAS_EDITOR_SIDE, + CONTAINER_CANVAS_EDITOR_SIDE_LEFT, + CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, CONTAINER_CANVAS_EDITOR_BOTTOM, CONTAINER_PROPERTY_EDITOR_BOTTOM }; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 0ba42cb101..0a421bdffe 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -1909,6 +1909,21 @@ TileMapEditor::~TileMapEditor() { /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// +void TileMapEditorPlugin::_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. + CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 0); + } break; + case 1: { // Right. + CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 1); + } break; + } + } +} + void TileMapEditorPlugin::edit(Object *p_object) { tile_map_editor->edit(Object::cast_to<Node>(p_object)); @@ -1942,11 +1957,19 @@ TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) { EDITOR_DEF("editors/tile_map/sort_tiles_by_name", true); EDITOR_DEF("editors/tile_map/bucket_fill_preview", true); EDITOR_DEF("editors/tile_map/show_tile_info_on_hover", true); + EDITOR_DEF("editors/tile_map/editor_side", 1); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/tile_map/editor_side", PROPERTY_HINT_ENUM, "Left,Right")); tile_map_editor = memnew(TileMapEditor(p_node)); - add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE, tile_map_editor); + switch ((int)EditorSettings::get_singleton()->get("editors/tile_map/editor_side")) { + case 0: { // Left. + add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_LEFT, tile_map_editor); + } break; + case 1: { // Right. + add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, tile_map_editor); + } break; + } tile_map_editor->hide(); - tile_map_editor->set_process(true); } TileMapEditorPlugin::~TileMapEditorPlugin() { diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index bb76879b02..d72224263a 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -220,6 +220,9 @@ class TileMapEditorPlugin : public EditorPlugin { TileMapEditor *tile_map_editor; +protected: + void _notification(int p_what); + public: virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return tile_map_editor->forward_gui_input(p_event); } virtual void forward_draw_over_viewport(Control *p_overlay) { tile_map_editor->forward_draw_over_viewport(p_overlay); } diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 1f891fe0fd..55a04a51b3 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -2382,11 +2382,9 @@ TileSetEditorPlugin::TileSetEditorPlugin(EditorNode *p_node) { editor = p_node; tileset_editor = memnew(TileSetEditor(p_node)); - tileset_editor_button = - p_node->add_bottom_panel_item(TTR("Tile Set"), tileset_editor); - tileset_editor_button->set_tooltip(TTR("Tile Set Editor")); - tileset_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE); tileset_editor->hide(); + + tileset_editor_button = p_node->add_bottom_panel_item(TTR("Tile Set"), tileset_editor); tileset_editor_button->hide(); } 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() { diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index c6e3eb87e5..663274f46e 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -226,11 +226,14 @@ class GridMapEditorPlugin : public EditorPlugin { GDCLASS(GridMapEditorPlugin, EditorPlugin); - GridMapEditor *gridmap_editor; + GridMapEditor *grid_map_editor; EditorNode *editor; +protected: + void _notification(int p_what); + public: - virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return gridmap_editor->forward_spatial_input_event(p_camera, p_event); } + virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return grid_map_editor->forward_spatial_input_event(p_camera, p_event); } virtual String get_name() const { return "GridMap"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index d4e16d488b..b6d1916b2c 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1935,7 +1935,7 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "params_depth_draw_mode", PROPERTY_HINT_ENUM, "Opaque Only,Always,Never,Opaque Pre-Pass"), "set_depth_draw_mode", "get_depth_draw_mode"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_line_width", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_line_width", "get_line_width"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_point_size", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_point_size", "get_point_size"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "params_billboard_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard,Particle Billboard1"), "set_billboard_mode", "get_billboard_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "params_billboard_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard,Particle Billboard"), "set_billboard_mode", "get_billboard_mode"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "params_billboard_keep_scale"), "set_flag", "get_flag", FLAG_BILLBOARD_KEEP_SCALE); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "params_grow"), "set_grow_enabled", "is_grow_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_grow_amount", PROPERTY_HINT_RANGE, "-16,10,0.01"), "set_grow", "get_grow"); |