Store lock view rotation whether its on or off

This commit is contained in:
Jakub Sygnowski 2023-04-23 15:06:22 +01:00
parent 24cb43a874
commit 07258c3984
2 changed files with 16 additions and 14 deletions

View File

@ -3327,13 +3327,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_LOCK_ROTATION: {
int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION);
bool current = view_menu->get_popup()->is_item_checked(idx);
lock_rotation = !current;
view_menu->get_popup()->set_item_checked(idx, !current);
if (lock_rotation) {
locked_label->show();
} else {
locked_label->hide();
}
_set_lock_view_rotation(!current);
} break;
case VIEW_AUDIO_LISTENER: {
@ -3808,10 +3802,7 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) {
}
}
if (p_state.has("lock_rotation")) {
lock_rotation = p_state["lock_rotation"];
int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION);
view_menu->get_popup()->set_item_checked(idx, lock_rotation);
_set_lock_view_rotation(p_state["lock_rotation"]);
}
if (p_state.has("use_environment")) {
bool env = p_state["use_environment"];
@ -3918,9 +3909,7 @@ Dictionary Node3DEditorViewport::get_state() const {
if (previewing) {
d["previewing"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing);
}
if (lock_rotation) {
d["lock_rotation"] = lock_rotation;
}
d["lock_rotation"] = lock_rotation;
return d;
}
@ -4925,6 +4914,17 @@ void Node3DEditorViewport::shortcut_changed_callback(const Ref<Shortcut> p_short
}
}
void Node3DEditorViewport::_set_lock_view_rotation(bool p_lock_rotation) {
lock_rotation = p_lock_rotation;
int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION);
view_menu->get_popup()->set_item_checked(idx, p_lock_rotation);
if (p_lock_rotation) {
locked_label->show();
} else {
locked_label->hide();
}
}
Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p_index) {
cpu_time_history_index = 0;
gpu_time_history_index = 0;

View File

@ -445,6 +445,8 @@ private:
void register_shortcut_action(const String &p_path, const String &p_name, Key p_keycode, bool p_physical = false);
void shortcut_changed_callback(const Ref<Shortcut> p_shortcut, const String &p_shortcut_path);
void _set_lock_view_rotation(bool p_lock_rotation);
protected:
void _notification(int p_what);
static void _bind_methods();