1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-02 16:48:55 +00:00

Deprecate get_scene() in EditorScript class

This commit is contained in:
robert yevdokimov
2025-08-05 16:20:39 +04:00
committed by Robert Yevdokimov
parent 5950fca36c
commit 292772a143
3 changed files with 11 additions and 1 deletions

View File

@@ -53,7 +53,7 @@
Returns the [EditorInterface] singleton instance. Returns the [EditorInterface] singleton instance.
</description> </description>
</method> </method>
<method name="get_scene" qualifiers="const"> <method name="get_scene" qualifiers="const" deprecated="Use [method EditorInterface.get_edited_scene_root] instead.">
<return type="Node" /> <return type="Node" />
<description> <description>
Returns the edited (current) scene's root [Node]. Equivalent of [method EditorInterface.get_edited_scene_root]. Returns the edited (current) scene's root [Node]. Equivalent of [method EditorInterface.get_edited_scene_root].

View File

@@ -37,12 +37,14 @@
#include "scene/main/node.h" #include "scene/main/node.h"
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"
#ifndef DISABLE_DEPRECATED
void EditorScript::add_root_node(Node *p_node) { void EditorScript::add_root_node(Node *p_node) {
WARN_DEPRECATED_MSG("EditorScript::add_root_node is deprecated. Use EditorInterface::add_root_node instead."); WARN_DEPRECATED_MSG("EditorScript::add_root_node is deprecated. Use EditorInterface::add_root_node instead.");
EditorInterface::get_singleton()->add_root_node(p_node); EditorInterface::get_singleton()->add_root_node(p_node);
} }
Node *EditorScript::get_scene() const { Node *EditorScript::get_scene() const {
WARN_DEPRECATED_MSG("EditorScript::get_scene is deprecated. Use EditorInterface::get_edited_scene_root instead.");
if (!EditorNode::get_singleton()) { if (!EditorNode::get_singleton()) {
EditorNode::add_io_error("EditorScript::get_scene: " + TTR("Write your logic in the _run() method.")); EditorNode::add_io_error("EditorScript::get_scene: " + TTR("Write your logic in the _run() method."));
return nullptr; return nullptr;
@@ -52,17 +54,23 @@ Node *EditorScript::get_scene() const {
} }
EditorInterface *EditorScript::get_editor_interface() const { EditorInterface *EditorScript::get_editor_interface() const {
WARN_DEPRECATED_MSG("EditorInterface is a global singleton and can be accessed directly by its name.");
return EditorInterface::get_singleton(); return EditorInterface::get_singleton();
} }
#endif // DISABLE_DEPRECATED
void EditorScript::run() { void EditorScript::run() {
GDVIRTUAL_CALL(_run); GDVIRTUAL_CALL(_run);
} }
void EditorScript::_bind_methods() { void EditorScript::_bind_methods() {
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node); ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);
ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene); ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);
ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface); ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface);
#endif // DISABLE_DEPRECATED
GDVIRTUAL_BIND(_run); GDVIRTUAL_BIND(_run);
} }

View File

@@ -47,7 +47,9 @@ protected:
public: public:
void add_root_node(Node *p_node); void add_root_node(Node *p_node);
#ifndef DISABLE_DEPRECATED
Node *get_scene() const; Node *get_scene() const;
#endif // DISABLE_DEPRECATED
EditorInterface *get_editor_interface() const; EditorInterface *get_editor_interface() const;
virtual void run(); virtual void run();