Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2600,6 +2600,11 @@ void EditorNode::_dialog_action(String p_file) {
}
} 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: {
const Dictionary &fd_options = file_export_lib->get_selected_options();
bool merge_with_existing_library = fd_options.get(TTR("Merge With Existing"), true);
Expand Down Expand Up @@ -3332,6 +3337,19 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {

} 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: {
_save_all_scenes();
} break;
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class EditorNode : public Node {
SCENE_SAVE_SCENE,
SCENE_SAVE_AS_SCENE,
SCENE_SAVE_ALL_SCENES,
SCENE_SET_MAIN_SCENE,
SCENE_MULTI_SAVE_AS_SCENE,
SCENE_QUICK_OPEN,
SCENE_QUICK_OPEN_SCENE,
Expand Down Expand Up @@ -216,6 +217,7 @@ class EditorNode : public Node {
SCENE_TAB_CLOSE,
SAVE_AND_RUN,
SAVE_AND_RUN_MAIN_SCENE,
SAVE_AND_SET_MAIN_SCENE,
RESOURCE_SAVE,
RESOURCE_SAVE_AS,
SETTINGS_PICK_MAIN_SCENE,
Expand Down
8 changes: 7 additions & 1 deletion editor/scene/editor_scene_tabs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "editor_scene_tabs.h"

#include "core/config/project_settings.h"
#include "editor/docks/inspector_dock.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h"
Expand Down Expand Up @@ -192,11 +193,16 @@ void EditorSceneTabs::_update_context_menu() {
DISABLE_LAST_OPTION_IF(!can_save_all_scenes);

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_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);
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_shortcut(ED_GET_SHORTCUT("editor/close_scene"), EditorNode::SCENE_CLOSE);
Expand Down