Add inherit parameter to open_scene_from_path

This commit is contained in:
Robert Yevdokimov 2024-03-30 18:42:01 -04:00 committed by Robert Yevdokimov
parent 19e003bc08
commit 7f09804154
7 changed files with 23 additions and 9 deletions

View file

@ -247,8 +247,9 @@
<method name="open_scene_from_path">
<return type="void" />
<param index="0" name="scene_filepath" type="String" />
<param index="1" name="set_inherited" type="bool" default="false" />
<description>
Opens the scene at the given path.
Opens the scene at the given path. If [param set_inherited] is [code]true[/code], creates a new inherited scene.
</description>
</method>
<method name="play_current_scene">

View file

@ -40,9 +40,14 @@ void EditorInterface::_popup_property_selector_bind_compat_94323(Object *p_objec
popup_property_selector(p_object, p_callback, p_type_filter, String());
}
void EditorInterface::_open_scene_from_path_bind_compat_90057(const String &scene_path) {
return open_scene_from_path(scene_path, false);
}
void EditorInterface::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("popup_node_selector", "callback", "valid_types"), &EditorInterface::_popup_node_selector_bind_compat_94323, DEFVAL(TypedArray<StringName>()));
ClassDB::bind_compatibility_method(D_METHOD("popup_property_selector", "object", "callback", "type_filter"), &EditorInterface::_popup_property_selector_bind_compat_94323, DEFVAL(PackedInt32Array()));
ClassDB::bind_compatibility_method(D_METHOD("open_scene_from_path", "scene_path"), &EditorInterface::_open_scene_from_path_bind_compat_90057);
}
#endif

View file

@ -656,12 +656,12 @@ void EditorInterface::edit_script(const Ref<Script> &p_script, int p_line, int p
ScriptEditor::get_singleton()->edit(p_script, p_line - 1, p_col - 1, p_grab_focus);
}
void EditorInterface::open_scene_from_path(const String &scene_path) {
void EditorInterface::open_scene_from_path(const String &scene_path, bool p_set_inherited) {
if (EditorNode::get_singleton()->is_changing_scene()) {
return;
}
EditorNode::get_singleton()->open_request(scene_path);
EditorNode::get_singleton()->open_request(scene_path, p_set_inherited);
}
void EditorInterface::reload_scene_from_path(const String &scene_path) {
@ -839,7 +839,7 @@ void EditorInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorInterface::edit_resource);
ClassDB::bind_method(D_METHOD("edit_node", "node"), &EditorInterface::edit_node);
ClassDB::bind_method(D_METHOD("edit_script", "script", "line", "column", "grab_focus"), &EditorInterface::edit_script, DEFVAL(-1), DEFVAL(0), DEFVAL(true));
ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorInterface::open_scene_from_path);
ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath", "set_inherited"), &EditorInterface::open_scene_from_path, DEFVAL(false));
ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path);
ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes);

View file

@ -90,7 +90,7 @@ protected:
#ifndef DISABLE_DEPRECATED
void _popup_node_selector_bind_compat_94323(const Callable &p_callback, const TypedArray<StringName> &p_valid_types = TypedArray<StringName>());
void _popup_property_selector_bind_compat_94323(Object *p_object, const Callable &p_callback, const PackedInt32Array &p_type_filter = PackedInt32Array());
void _open_scene_from_path_bind_compat_90057(const String &scene_path);
static void _bind_compatibility_methods();
#endif
@ -167,7 +167,7 @@ public:
void edit_resource(const Ref<Resource> &p_resource);
void edit_node(Node *p_node);
void edit_script(const Ref<Script> &p_script, int p_line = -1, int p_col = 0, bool p_grab_focus = true);
void open_scene_from_path(const String &scene_path);
void open_scene_from_path(const String &scene_path, bool p_set_inherited = false);
void reload_scene_from_path(const String &scene_path);
PackedStringArray get_open_scenes() const;

View file

@ -4478,7 +4478,7 @@ void EditorNode::replace_history_reimported_nodes(Node *p_original_root_node, No
}
}
void EditorNode::open_request(const String &p_path) {
void EditorNode::open_request(const String &p_path, bool p_set_inherited) {
if (!opening_prev) {
List<String>::Element *prev_scene_item = previous_scenes.find(p_path);
if (prev_scene_item != nullptr) {
@ -4486,7 +4486,7 @@ void EditorNode::open_request(const String &p_path) {
}
}
load_scene(p_path); // As it will be opened in separate tab.
load_scene(p_path, false, p_set_inherited); // As it will be opened in separate tab.
}
bool EditorNode::has_previous_scenes() const {

View file

@ -768,7 +768,7 @@ public:
void replace_resources_in_scenes(
const Vector<Ref<Resource>> &p_source_resources,
const Vector<Ref<Resource>> &p_target_resource);
void open_request(const String &p_path);
void open_request(const String &p_path, bool p_set_inherited = false);
void edit_foreign_resource(Ref<Resource> p_resource);
bool is_resource_read_only(Ref<Resource> p_resource, bool p_foreign_resources_are_writable = false);

View file

@ -228,3 +228,11 @@ Validate extension JSON: Error: Field 'classes/NavigationServer3D/methods/map_ge
`query_path` and `map_get_path` methods changed to be non const due to internal compatibility and server changes.
Added optional callback parameters to `query_path` functions. Compatibility methods registered.
GH-90057
--------
Validate extension JSON: Error: Field 'classes/EditorInterface/methods/open_scene_from_path/arguments': size changed value in new API, from 1 to 2.
Added optional argument to open_scene_from_path to create a new inherited scene.
Compatibility method registered.