You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Merge pull request #107652 from vaner-org/set-tab-as-main-scene
Add "Set as Main Scene" option to EditorSceneTabs context menu
This commit is contained in:
@@ -2612,6 +2612,11 @@ void EditorNode::_dialog_action(String p_file) {
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case SAVE_AND_SET_MAIN_SCENE: {
|
||||||
|
_save_scene(p_file);
|
||||||
|
_menu_option_confirm(SCENE_SET_MAIN_SCENE, true);
|
||||||
|
} break;
|
||||||
|
|
||||||
case FILE_EXPORT_MESH_LIBRARY: {
|
case FILE_EXPORT_MESH_LIBRARY: {
|
||||||
const Dictionary &fd_options = file_export_lib->get_selected_options();
|
const Dictionary &fd_options = file_export_lib->get_selected_options();
|
||||||
bool merge_with_existing_library = fd_options.get(TTR("Merge With Existing"), true);
|
bool merge_with_existing_library = fd_options.get(TTR("Merge With Existing"), true);
|
||||||
@@ -3344,6 +3349,19 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case SCENE_SET_MAIN_SCENE: {
|
||||||
|
const String scene_path = editor_data.get_scene_path(editor_data.get_edited_scene());
|
||||||
|
if (scene_path.is_empty()) {
|
||||||
|
current_menu_option = SAVE_AND_SET_MAIN_SCENE;
|
||||||
|
_menu_option_confirm(SCENE_SAVE_AS_SCENE, true);
|
||||||
|
file->set_title(TTR("Save new main scene..."));
|
||||||
|
} else {
|
||||||
|
ProjectSettings::get_singleton()->set("application/run/main_scene", ResourceUID::path_to_uid(scene_path));
|
||||||
|
ProjectSettings::get_singleton()->save();
|
||||||
|
FileSystemDock::get_singleton()->update_all();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
case SCENE_SAVE_ALL_SCENES: {
|
case SCENE_SAVE_ALL_SCENES: {
|
||||||
_save_all_scenes();
|
_save_all_scenes();
|
||||||
} break;
|
} break;
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ public:
|
|||||||
SCENE_SAVE_SCENE,
|
SCENE_SAVE_SCENE,
|
||||||
SCENE_SAVE_AS_SCENE,
|
SCENE_SAVE_AS_SCENE,
|
||||||
SCENE_SAVE_ALL_SCENES,
|
SCENE_SAVE_ALL_SCENES,
|
||||||
|
SCENE_SET_MAIN_SCENE,
|
||||||
SCENE_MULTI_SAVE_AS_SCENE,
|
SCENE_MULTI_SAVE_AS_SCENE,
|
||||||
SCENE_QUICK_OPEN,
|
SCENE_QUICK_OPEN,
|
||||||
SCENE_QUICK_OPEN_SCENE,
|
SCENE_QUICK_OPEN_SCENE,
|
||||||
@@ -216,6 +217,7 @@ public:
|
|||||||
SCENE_TAB_CLOSE,
|
SCENE_TAB_CLOSE,
|
||||||
SAVE_AND_RUN,
|
SAVE_AND_RUN,
|
||||||
SAVE_AND_RUN_MAIN_SCENE,
|
SAVE_AND_RUN_MAIN_SCENE,
|
||||||
|
SAVE_AND_SET_MAIN_SCENE,
|
||||||
RESOURCE_SAVE,
|
RESOURCE_SAVE,
|
||||||
RESOURCE_SAVE_AS,
|
RESOURCE_SAVE_AS,
|
||||||
SETTINGS_PICK_MAIN_SCENE,
|
SETTINGS_PICK_MAIN_SCENE,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "editor_scene_tabs.h"
|
#include "editor_scene_tabs.h"
|
||||||
|
|
||||||
|
#include "core/config/project_settings.h"
|
||||||
#include "editor/docks/inspector_dock.h"
|
#include "editor/docks/inspector_dock.h"
|
||||||
#include "editor/editor_main_screen.h"
|
#include "editor/editor_main_screen.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
@@ -195,11 +196,16 @@ void EditorSceneTabs::_update_context_menu() {
|
|||||||
DISABLE_LAST_OPTION_IF(!can_save_all_scenes);
|
DISABLE_LAST_OPTION_IF(!can_save_all_scenes);
|
||||||
|
|
||||||
if (tab_id >= 0) {
|
if (tab_id >= 0) {
|
||||||
|
const String scene_path = EditorNode::get_editor_data().get_scene_path(tab_id);
|
||||||
|
const String main_scene_path = GLOBAL_GET("application/run/main_scene");
|
||||||
|
|
||||||
scene_tabs_context_menu->add_separator();
|
scene_tabs_context_menu->add_separator();
|
||||||
scene_tabs_context_menu->add_item(TTR("Show in FileSystem"), SCENE_SHOW_IN_FILESYSTEM);
|
scene_tabs_context_menu->add_item(TTR("Show in FileSystem"), SCENE_SHOW_IN_FILESYSTEM);
|
||||||
DISABLE_LAST_OPTION_IF(!ResourceLoader::exists(EditorNode::get_editor_data().get_scene_path(tab_id)));
|
DISABLE_LAST_OPTION_IF(!ResourceLoader::exists(scene_path));
|
||||||
scene_tabs_context_menu->add_item(TTR("Play This Scene"), SCENE_RUN);
|
scene_tabs_context_menu->add_item(TTR("Play This Scene"), SCENE_RUN);
|
||||||
DISABLE_LAST_OPTION_IF(no_root_node);
|
DISABLE_LAST_OPTION_IF(no_root_node);
|
||||||
|
scene_tabs_context_menu->add_item(TTR("Set as Main Scene"), EditorNode::SCENE_SET_MAIN_SCENE);
|
||||||
|
DISABLE_LAST_OPTION_IF(no_root_node || (!main_scene_path.is_empty() && ResourceUID::ensure_path(main_scene_path) == scene_path));
|
||||||
|
|
||||||
scene_tabs_context_menu->add_separator();
|
scene_tabs_context_menu->add_separator();
|
||||||
scene_tabs_context_menu->add_shortcut(ED_GET_SHORTCUT("editor/close_scene"), EditorNode::SCENE_CLOSE);
|
scene_tabs_context_menu->add_shortcut(ED_GET_SHORTCUT("editor/close_scene"), EditorNode::SCENE_CLOSE);
|
||||||
|
|||||||
Reference in New Issue
Block a user