| 1017 | } |
| 1018 | |
| 1019 | void GridMapEditor::edit(GridMap *p_gridmap) { |
| 1020 | if (node) { |
| 1021 | node->disconnect(SNAME("cell_size_changed"), callable_mp(this, &GridMapEditor::_draw_grids)); |
| 1022 | node->disconnect(CoreStringName(changed), callable_mp(this, &GridMapEditor::_update_mesh_library)); |
| 1023 | if (mesh_library.is_valid()) { |
| 1024 | mesh_library->disconnect_changed(callable_mp(this, &GridMapEditor::update_palette)); |
| 1025 | mesh_library = Ref<MeshLibrary>(); |
| 1026 | } |
| 1027 | } |
| 1028 | |
| 1029 | node = p_gridmap; |
| 1030 | |
| 1031 | input_action = INPUT_NONE; |
| 1032 | selection.active = false; |
| 1033 | _update_selection_transform(); |
| 1034 | _update_paste_indicator(); |
| 1035 | |
| 1036 | spatial_editor = Object::cast_to<Node3DEditorPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_selected_plugin()); |
| 1037 | |
| 1038 | if (!node) { |
| 1039 | set_process(false); |
| 1040 | for (int i = 0; i < 3; i++) { |
| 1041 | RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], false); |
| 1042 | } |
| 1043 | |
| 1044 | if (cursor_instance.is_valid()) { |
| 1045 | RenderingServer::get_singleton()->instance_set_visible(cursor_instance, false); |
| 1046 | } |
| 1047 | |
| 1048 | return; |
| 1049 | } |
| 1050 | |
| 1051 | update_palette(); |
| 1052 | _update_cursor_instance(); |
| 1053 | |
| 1054 | set_process(true); |
| 1055 | |
| 1056 | _draw_grids(node->get_cell_size()); |
| 1057 | update_grid(); |
| 1058 | |
| 1059 | node->connect(SNAME("cell_size_changed"), callable_mp(this, &GridMapEditor::_draw_grids)); |
| 1060 | node->connect(CoreStringName(changed), callable_mp(this, &GridMapEditor::_update_mesh_library)); |
| 1061 | _update_mesh_library(); |
| 1062 | } |
| 1063 | |
| 1064 | void GridMapEditor::update_grid() { |
| 1065 | grid_xform.origin.x -= 1; /// @todo Force update in hackish way. |
no test coverage detected