/**************************************************************************/1/* editor_script.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "editor_script.h"3132#include "editor/editor_interface.h"33#include "editor/editor_node.h"34#include "editor/editor_undo_redo_manager.h"35#include "editor/scene/editor_scene_tabs.h"36#include "scene/main/node.h"37#include "scene/resources/packed_scene.h"3839#ifndef DISABLE_DEPRECATED40void EditorScript::add_root_node(Node *p_node) {41WARN_DEPRECATED_MSG("EditorScript::add_root_node is deprecated. Use EditorInterface::add_root_node instead.");42EditorInterface::get_singleton()->add_root_node(p_node);43}4445Node *EditorScript::get_scene() const {46WARN_DEPRECATED_MSG("EditorScript::get_scene is deprecated. Use EditorInterface::get_edited_scene_root instead.");47if (!EditorNode::get_singleton()) {48EditorNode::add_io_error("EditorScript::get_scene: " + TTR("Write your logic in the _run() method."));49return nullptr;50}5152return EditorNode::get_singleton()->get_edited_scene();53}5455EditorInterface *EditorScript::get_editor_interface() const {56WARN_DEPRECATED_MSG("EditorInterface is a global singleton and can be accessed directly by its name.");57return EditorInterface::get_singleton();58}59#endif // DISABLE_DEPRECATED6061void EditorScript::run() {62GDVIRTUAL_CALL(_run);63}6465void EditorScript::_bind_methods() {66#ifndef DISABLE_DEPRECATED67ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);6869ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);7071ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface);72#endif // DISABLE_DEPRECATED7374GDVIRTUAL_BIND(_run);75}767778