Skip to content

Commit f7f2361

Browse files
committed
Merge pull request #90057 from ryevdokimov/fix-inherit2
Add ability to create a new inherited scene from code
2 parents dc5f1b7 + 7f09804 commit f7f2361

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

doc/classes/EditorInterface.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@
247247
<method name="open_scene_from_path">
248248
<return type="void" />
249249
<param index="0" name="scene_filepath" type="String" />
250+
<param index="1" name="set_inherited" type="bool" default="false" />
250251
<description>
251-
Opens the scene at the given path.
252+
Opens the scene at the given path. If [param set_inherited] is [code]true[/code], creates a new inherited scene.
252253
</description>
253254
</method>
254255
<method name="play_current_scene">

editor/editor_interface.compat.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ void EditorInterface::_popup_property_selector_bind_compat_94323(Object *p_objec
4040
popup_property_selector(p_object, p_callback, p_type_filter, String());
4141
}
4242

43+
void EditorInterface::_open_scene_from_path_bind_compat_90057(const String &scene_path) {
44+
return open_scene_from_path(scene_path, false);
45+
}
46+
4347
void EditorInterface::_bind_compatibility_methods() {
4448
ClassDB::bind_compatibility_method(D_METHOD("popup_node_selector", "callback", "valid_types"), &EditorInterface::_popup_node_selector_bind_compat_94323, DEFVAL(TypedArray<StringName>()));
4549
ClassDB::bind_compatibility_method(D_METHOD("popup_property_selector", "object", "callback", "type_filter"), &EditorInterface::_popup_property_selector_bind_compat_94323, DEFVAL(PackedInt32Array()));
50+
ClassDB::bind_compatibility_method(D_METHOD("open_scene_from_path", "scene_path"), &EditorInterface::_open_scene_from_path_bind_compat_90057);
4651
}
4752

4853
#endif

editor/editor_interface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,12 +656,12 @@ void EditorInterface::edit_script(const Ref<Script> &p_script, int p_line, int p
656656
ScriptEditor::get_singleton()->edit(p_script, p_line - 1, p_col - 1, p_grab_focus);
657657
}
658658

659-
void EditorInterface::open_scene_from_path(const String &scene_path) {
659+
void EditorInterface::open_scene_from_path(const String &scene_path, bool p_set_inherited) {
660660
if (EditorNode::get_singleton()->is_changing_scene()) {
661661
return;
662662
}
663663

664-
EditorNode::get_singleton()->open_request(scene_path);
664+
EditorNode::get_singleton()->open_request(scene_path, p_set_inherited);
665665
}
666666

667667
void EditorInterface::reload_scene_from_path(const String &scene_path) {
@@ -839,7 +839,7 @@ void EditorInterface::_bind_methods() {
839839
ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorInterface::edit_resource);
840840
ClassDB::bind_method(D_METHOD("edit_node", "node"), &EditorInterface::edit_node);
841841
ClassDB::bind_method(D_METHOD("edit_script", "script", "line", "column", "grab_focus"), &EditorInterface::edit_script, DEFVAL(-1), DEFVAL(0), DEFVAL(true));
842-
ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorInterface::open_scene_from_path);
842+
ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath", "set_inherited"), &EditorInterface::open_scene_from_path, DEFVAL(false));
843843
ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path);
844844

845845
ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes);

editor/editor_interface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class EditorInterface : public Object {
9090
#ifndef DISABLE_DEPRECATED
9191
void _popup_node_selector_bind_compat_94323(const Callable &p_callback, const TypedArray<StringName> &p_valid_types = TypedArray<StringName>());
9292
void _popup_property_selector_bind_compat_94323(Object *p_object, const Callable &p_callback, const PackedInt32Array &p_type_filter = PackedInt32Array());
93-
93+
void _open_scene_from_path_bind_compat_90057(const String &scene_path);
9494
static void _bind_compatibility_methods();
9595
#endif
9696

@@ -167,7 +167,7 @@ class EditorInterface : public Object {
167167
void edit_resource(const Ref<Resource> &p_resource);
168168
void edit_node(Node *p_node);
169169
void edit_script(const Ref<Script> &p_script, int p_line = -1, int p_col = 0, bool p_grab_focus = true);
170-
void open_scene_from_path(const String &scene_path);
170+
void open_scene_from_path(const String &scene_path, bool p_set_inherited = false);
171171
void reload_scene_from_path(const String &scene_path);
172172

173173
PackedStringArray get_open_scenes() const;

editor/editor_node.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4478,15 +4478,15 @@ void EditorNode::replace_history_reimported_nodes(Node *p_original_root_node, No
44784478
}
44794479
}
44804480

4481-
void EditorNode::open_request(const String &p_path) {
4481+
void EditorNode::open_request(const String &p_path, bool p_set_inherited) {
44824482
if (!opening_prev) {
44834483
List<String>::Element *prev_scene_item = previous_scenes.find(p_path);
44844484
if (prev_scene_item != nullptr) {
44854485
prev_scene_item->erase();
44864486
}
44874487
}
44884488

4489-
load_scene(p_path); // As it will be opened in separate tab.
4489+
load_scene(p_path, false, p_set_inherited); // As it will be opened in separate tab.
44904490
}
44914491

44924492
bool EditorNode::has_previous_scenes() const {

editor/editor_node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ class EditorNode : public Node {
768768
void replace_resources_in_scenes(
769769
const Vector<Ref<Resource>> &p_source_resources,
770770
const Vector<Ref<Resource>> &p_target_resource);
771-
void open_request(const String &p_path);
771+
void open_request(const String &p_path, bool p_set_inherited = false);
772772
void edit_foreign_resource(Ref<Resource> p_resource);
773773

774774
bool is_resource_read_only(Ref<Resource> p_resource, bool p_foreign_resources_are_writable = false);

misc/extension_api_validation/4.3-stable.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,11 @@ Validate extension JSON: Error: Field 'classes/NavigationServer3D/methods/map_ge
228228

229229
`query_path` and `map_get_path` methods changed to be non const due to internal compatibility and server changes.
230230
Added optional callback parameters to `query_path` functions. Compatibility methods registered.
231+
232+
233+
GH-90057
234+
--------
235+
Validate extension JSON: Error: Field 'classes/EditorInterface/methods/open_scene_from_path/arguments': size changed value in new API, from 1 to 2.
236+
237+
Added optional argument to open_scene_from_path to create a new inherited scene.
238+
Compatibility method registered.

0 commit comments

Comments
 (0)