diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-07-06 16:59:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-06 16:59:12 +0200 |
commit | f56ae4045f73d7a532f0694860053f6356e9d29c (patch) | |
tree | 09f5027c506b67b6a69a1f2c45276a672f176021 | |
parent | 053198a5f34b7ce680e2fd1a3287a559cc2afc94 (diff) | |
parent | 2296b57739904a2d37dd469cc1038c88feff253b (diff) |
Merge pull request #37983 from EricEzaM/set-main-scene-add-select-current-option
Added 'Select Current' option when user is prompted to select main scene after clicking play
-rw-r--r-- | editor/editor_node.cpp | 25 | ||||
-rw-r--r-- | editor/editor_node.h | 3 |
2 files changed, 28 insertions, 0 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 0f8a645dfe..e7c0b02ae2 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3875,6 +3875,21 @@ Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) cons return nullptr; } +void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_name) { + if (p_custom_action_name == "select_current") { + Node *scene = editor_data.get_edited_scene_root(); + + if (!scene) { + show_accept(TTR("There is no defined scene to run."), TTR("OK")); + return; + } + + pick_main_scene->hide(); + current_option = SETTINGS_PICK_MAIN_SCENE; + _dialog_action(scene->get_filename()); + } +} + Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const { ERR_FAIL_COND_V(!p_object || !gui_base, nullptr); @@ -4669,6 +4684,14 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { current_option = -1; pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category.")); pick_main_scene->popup_centered(); + + if (editor_data.get_edited_scene_root()) { + select_current_scene_button->set_disabled(false); + select_current_scene_button->grab_focus(); + } else { + select_current_scene_button->set_disabled(true); + } + return false; } @@ -6946,6 +6969,8 @@ EditorNode::EditorNode() { gui_base->add_child(pick_main_scene); pick_main_scene->get_ok_button()->set_text(TTR("Select")); pick_main_scene->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SETTINGS_PICK_MAIN_SCENE)); + select_current_scene_button = pick_main_scene->add_button(TTR("Select Current"), true, "select_current"); + pick_main_scene->connect("custom_action", callable_mp(this, &EditorNode::_pick_main_scene_custom_action)); for (int i = 0; i < _init_callbacks.size(); i++) { _init_callbacks[i](); diff --git a/editor/editor_node.h b/editor/editor_node.h index dcb6ad6e94..07bed6999b 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -301,6 +301,7 @@ private: ConfirmationDialog *save_confirmation; ConfirmationDialog *import_confirmation; ConfirmationDialog *pick_main_scene; + Button *select_current_scene_button; AcceptDialog *accept; EditorAbout *about; AcceptDialog *warning; @@ -663,6 +664,8 @@ private: bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class); Ref<ImageTexture> _load_custom_class_icon(const String &p_path) const; + void _pick_main_scene_custom_action(const String &p_custom_action_name); + protected: void _notification(int p_what); |