From f25897527ef0dd37187f26b54d1805c24d38a97a Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Sun, 10 Jan 2016 21:59:12 +0100 Subject: [PATCH 1/2] Remember Transform menu settings for the Spatial Editor --- .../editor/plugins/spatial_editor_plugin.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 0fac1346fc0..73bc97a29ca 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -2629,6 +2629,13 @@ Dictionary SpatialEditor::get_state() const { Dictionary d; + d["snap_enabled"]=snap_enabled; + d["translate_snap"]=get_translate_snap(); + d["rotate_snap"]=get_rotate_snap(); + d["scale_snap"]=get_scale_snap(); + + int local_coords_index=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS); + d["local_coords"]=transform_menu->get_popup()->is_item_checked( local_coords_index ); int vc=0; if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT) )) @@ -2679,6 +2686,27 @@ void SpatialEditor::set_state(const Dictionary& p_state) { ERR_FAIL_COND(!d.has("znear")); ERR_FAIL_COND(!d.has("zfar")); + if (d.has("snap_enabled")) { + snap_enabled=d["snap_enabled"]; + int snap_enabled_idx=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_USE_SNAP); + transform_menu->get_popup()->set_item_checked( snap_enabled_idx, snap_enabled ); + } + + if (d.has("translate_snap")) + snap_translate->set_text(d["translate_snap"]); + + if (d.has("rotate_snap")) + snap_rotate->set_text(d["rotate_snap"]); + + if (d.has("scale_snap")) + snap_scale->set_text(d["scale_snap"]); + + if (d.has("local_coords")) { + int local_coords_idx=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS); + transform_menu->get_popup()->set_item_checked( local_coords_idx, d["local_coords"] ); + update_transform_gizmo(); + } + int vc = d["viewport_mode"]; if (vc==1) From aa9c2e68c620ba9e7358f83c8202a7cea025eafb Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Mon, 11 Jan 2016 14:35:11 +0100 Subject: [PATCH 2/2] Remove unnecessary fail conditions when loading SpatialEditor state --- .../editor/plugins/spatial_editor_plugin.cpp | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 73bc97a29ca..29d2a7774c5 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -2677,15 +2677,6 @@ void SpatialEditor::set_state(const Dictionary& p_state) { Dictionary d = p_state; - ERR_FAIL_COND(!d.has("viewport_mode")); - ERR_FAIL_COND(!d.has("viewports")); - ERR_FAIL_COND(!d.has("default_light")); - ERR_FAIL_COND(!d.has("show_grid")); - ERR_FAIL_COND(!d.has("show_origin")); - ERR_FAIL_COND(!d.has("fov")); - ERR_FAIL_COND(!d.has("znear")); - ERR_FAIL_COND(!d.has("zfar")); - if (d.has("snap_enabled")) { snap_enabled=d["snap_enabled"]; int snap_enabled_idx=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_USE_SNAP); @@ -2707,28 +2698,31 @@ void SpatialEditor::set_state(const Dictionary& p_state) { update_transform_gizmo(); } - int vc = d["viewport_mode"]; + if (d.has("viewport_mode")) { + int vc = d["viewport_mode"]; - if (vc==1) - _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT); - else if (vc==2) - _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS); - else if (vc==3) - _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS); - else if (vc==4) - _menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS); - else if (vc==5) - _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT); - else if (vc==6) - _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT); - - Array vp = d["viewports"]; - ERR_FAIL_COND(vp.size()>4); - - for(int i=0;i<4;i++) { - viewports[i]->set_state(vp[i]); + if (vc==1) + _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT); + else if (vc==2) + _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS); + else if (vc==3) + _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS); + else if (vc==4) + _menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS); + else if (vc==5) + _menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT); + else if (vc==6) + _menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT); } + if (d.has("viewports")) { + Array vp = d["viewports"]; + ERR_FAIL_COND(vp.size()>4); + + for(int i=0;i<4;i++) { + viewports[i]->set_state(vp[i]); + } + } if (d.has("zfar")) settings_zfar->set_val(float(d["zfar"]));