You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
Merge pull request #105502 from tehKaiN/editor_interface_close_scene
Add `EditorInterface::close_scene()`
This commit is contained in:
@@ -19,6 +19,12 @@
|
|||||||
<tutorials>
|
<tutorials>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
<methods>
|
<methods>
|
||||||
|
<method name="close_scene">
|
||||||
|
<return type="int" enum="Error" />
|
||||||
|
<description>
|
||||||
|
Closes the currently active scene, discarding any pending changes in the process. Returns [constant OK] on success or [constant ERR_DOES_NOT_EXIST] if there is no scene to close.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="edit_node">
|
<method name="edit_node">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="node" type="Node" />
|
<param index="0" name="node" type="Node" />
|
||||||
|
|||||||
@@ -713,6 +713,10 @@ void EditorInterface::save_all_scenes() {
|
|||||||
EditorNode::get_singleton()->save_all_scenes();
|
EditorNode::get_singleton()->save_all_scenes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Error EditorInterface::close_scene() {
|
||||||
|
return EditorNode::get_singleton()->close_scene() ? OK : ERR_DOES_NOT_EXIST;
|
||||||
|
}
|
||||||
|
|
||||||
// Scene playback.
|
// Scene playback.
|
||||||
|
|
||||||
void EditorInterface::play_main_scene() {
|
void EditorInterface::play_main_scene() {
|
||||||
@@ -845,6 +849,7 @@ void EditorInterface::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene);
|
ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene);
|
||||||
ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true));
|
ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true));
|
||||||
ClassDB::bind_method(D_METHOD("save_all_scenes"), &EditorInterface::save_all_scenes);
|
ClassDB::bind_method(D_METHOD("save_all_scenes"), &EditorInterface::save_all_scenes);
|
||||||
|
ClassDB::bind_method(D_METHOD("close_scene"), &EditorInterface::close_scene);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("mark_scene_as_unsaved"), &EditorInterface::mark_scene_as_unsaved);
|
ClassDB::bind_method(D_METHOD("mark_scene_as_unsaved"), &EditorInterface::mark_scene_as_unsaved);
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ public:
|
|||||||
void save_scene_as(const String &p_scene, bool p_with_preview = true);
|
void save_scene_as(const String &p_scene, bool p_with_preview = true);
|
||||||
void mark_scene_as_unsaved();
|
void mark_scene_as_unsaved();
|
||||||
void save_all_scenes();
|
void save_all_scenes();
|
||||||
|
Error close_scene();
|
||||||
|
|
||||||
// Scene playback.
|
// Scene playback.
|
||||||
|
|
||||||
|
|||||||
@@ -4993,6 +4993,19 @@ bool EditorNode::_find_scene_in_use(Node *p_node, const String &p_path) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditorNode::close_scene() {
|
||||||
|
int tab_index = editor_data.get_edited_scene();
|
||||||
|
if (tab_index == 0 && get_edited_scene() == nullptr && editor_data.get_scene_path(tab_index).is_empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tab_closing_idx = tab_index;
|
||||||
|
current_menu_option = SCENE_CLOSE;
|
||||||
|
_discard_changes();
|
||||||
|
changing_scene = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool EditorNode::is_scene_in_use(const String &p_path) {
|
bool EditorNode::is_scene_in_use(const String &p_path) {
|
||||||
Node *es = get_edited_scene();
|
Node *es = get_edited_scene();
|
||||||
if (es) {
|
if (es) {
|
||||||
|
|||||||
@@ -944,6 +944,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool close_scene();
|
||||||
|
|
||||||
bool is_scene_in_use(const String &p_path);
|
bool is_scene_in_use(const String &p_path);
|
||||||
|
|
||||||
void save_editor_layout_delayed();
|
void save_editor_layout_delayed();
|
||||||
|
|||||||
Reference in New Issue
Block a user