diff options
Diffstat (limited to 'modules/gridmap')
-rw-r--r-- | modules/gridmap/doc_classes/GridMap.xml | 2 | ||||
-rw-r--r-- | modules/gridmap/grid_map_editor_plugin.cpp | 43 | ||||
-rw-r--r-- | modules/gridmap/grid_map_editor_plugin.h | 2 |
3 files changed, 37 insertions, 10 deletions
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index 44685220b3..bb652f3bdf 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GridMap" inherits="Spatial" category="Core" version="3.0-stable"> +<class name="GridMap" inherits="Spatial" category="Core" version="3.1"> <brief_description> Node for 3D tile-based maps. </brief_description> diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 7b7bc0fa2a..869492232c 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -99,6 +99,20 @@ void GridMapEditor::_menu_option(int p_option) { int idx = options->get_popup()->get_item_index(MENU_OPTION_X_AXIS + i); options->get_popup()->set_item_checked(idx, i == new_axis); } + + if (edit_axis != new_axis) { + int item1 = options->get_popup()->get_item_index(MENU_OPTION_NEXT_LEVEL); + int item2 = options->get_popup()->get_item_index(MENU_OPTION_PREV_LEVEL); + if (edit_axis == Vector3::AXIS_Y) { + options->get_popup()->set_item_text(item1, TTR("Next Plane")); + options->get_popup()->set_item_text(item2, TTR("Previous Plane")); + spin_box_label->set_text(TTR("Plane:")); + } else if (new_axis == Vector3::AXIS_Y) { + options->get_popup()->set_item_text(item1, TTR("Next Floor")); + options->get_popup()->set_item_text(item2, TTR("Previous Floor")); + spin_box_label->set_text(TTR("Floor:")); + } + } edit_axis = Vector3::Axis(new_axis); update_grid(); _update_clip(); @@ -627,12 +641,21 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu Ref<InputEventPanGesture> pan_gesture = p_event; if (pan_gesture.is_valid()) { - if (pan_gesture->get_command() || pan_gesture->get_shift()) { - const real_t delta = pan_gesture->get_delta().y; - floor->set_value(floor->get_value() + SGN(delta)); + if (pan_gesture->get_alt() && (pan_gesture->get_command() || pan_gesture->get_shift())) { + const real_t delta = pan_gesture->get_delta().y * 0.5; + accumulated_floor_delta += delta; + int step = 0; + if (ABS(accumulated_floor_delta) > 1.0) { + step = SGN(accumulated_floor_delta); + accumulated_floor_delta -= step; + } + if (step) { + floor->set_value(floor->get_value() + step); + } return true; } } + accumulated_floor_delta = 0.0; return false; } @@ -756,7 +779,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) { set_process(true); - Vector3 edited_floor = p_gridmap->get_meta("_editor_floor_"); + Vector3 edited_floor = p_gridmap->has_meta("_editor_floor_") ? p_gridmap->get_meta("_editor_floor_") : Variant(); clip_mode = p_gridmap->has_meta("_editor_clip_") ? ClipMode(p_gridmap->get_meta("_editor_clip_").operator int()) : CLIP_DISABLED; for (int i = 0; i < 3; i++) { @@ -998,9 +1021,9 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { spatial_editor_hb->set_alignment(BoxContainer::ALIGN_END); SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb); - Label *fl = memnew(Label); - fl->set_text(TTR("Floor:")); - spatial_editor_hb->add_child(fl); + spin_box_label = memnew(Label); + spin_box_label->set_text(TTR("Floor:")); + spatial_editor_hb->add_child(spin_box_label); floor = memnew(SpinBox); floor->set_min(-32767); @@ -1233,6 +1256,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { selection.active = false; updating = false; + accumulated_floor_delta = 0.0; } GridMapEditor::~GridMapEditor() { @@ -1245,9 +1269,10 @@ GridMapEditor::~GridMapEditor() { VisualServer::get_singleton()->free(grid_instance[i]); if (cursor_instance.is_valid()) VisualServer::get_singleton()->free(cursor_instance); - if (selection_level_instance[i].is_valid()) { + if (selection_level_instance[i].is_valid()) VisualServer::get_singleton()->free(selection_level_instance[i]); - } + if (selection_level_mesh[i].is_valid()) + VisualServer::get_singleton()->free(selection_level_mesh[i]); } VisualServer::get_singleton()->free(selection_mesh); diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 3fc92bf7aa..f79d9aefa0 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -76,12 +76,14 @@ class GridMapEditor : public VBoxContainer { Panel *panel; MenuButton *options; SpinBox *floor; + double accumulated_floor_delta; ToolButton *mode_thumbnail; ToolButton *mode_list; HBoxContainer *spatial_editor_hb; ConfirmationDialog *settings_dialog; VBoxContainer *settings_vbc; SpinBox *settings_pick_distance; + Label *spin_box_label; struct SetItem { |