From ad10a5961f3ac3b5e2e9b0b062d9b8c0f7a02734 Mon Sep 17 00:00:00 2001 From: willnationsdev Date: Sun, 27 Dec 2020 22:24:31 -0600 Subject: [PATCH] Add ScriptServer and export all custom resources. --- core/bind/core_bind.cpp | 84 ++++++++++++ core/bind/core_bind.h | 27 ++++ core/io/resource_loader.cpp | 8 +- core/register_core_types.cpp | 6 + core/script_language.cpp | 67 +++++++++- core/script_language.h | 12 +- doc/classes/@GlobalScope.xml | 3 + doc/classes/EditorInterface.xml | 18 +++ doc/classes/ScriptServer.xml | 72 ++++++++++ editor/create_dialog.cpp | 21 +-- editor/editor_data.cpp | 93 ++++++++----- editor/editor_data.h | 17 +-- editor/editor_file_system.cpp | 85 ++++++++++-- editor/editor_file_system.h | 9 +- editor/editor_node.cpp | 19 +-- editor/editor_plugin.cpp | 11 ++ editor/editor_plugin.h | 3 + editor/editor_properties.cpp | 3 +- editor/editor_properties.h | 1 + editor/editor_resource_picker.cpp | 67 ++++++---- editor/import/resource_importer_scene.cpp | 2 +- editor/scene_tree_dock.cpp | 123 ++++++++++++++---- editor/scene_tree_dock.h | 1 + editor/scene_tree_editor.cpp | 11 +- .../include/pluginscript/godot_pluginscript.h | 1 + .../pluginscript/pluginscript_language.cpp | 4 + .../pluginscript/pluginscript_language.h | 1 + modules/gdscript/gdscript_parser.cpp | 111 +++++++++++++--- modules/mono/csharp_script.cpp | 100 +++++++++++++- modules/mono/csharp_script.h | 17 ++- .../Core/Attributes/ExportAttribute.cs | 15 +++ .../Core/Attributes/GlobalAttribute.cs | 17 +++ .../GodotSharp/GodotSharp/GodotSharp.csproj | 1 + modules/mono/mono_gd/gd_mono_cache.cpp | 6 + modules/mono/mono_gd/gd_mono_cache.h | 3 + .../doc_classes/VisualScript.xml | 26 ++++ .../doc_classes/VisualScriptScriptClass.xml | 20 +++ modules/visual_script/register_types.cpp | 1 + modules/visual_script/visual_script.cpp | 59 +++++++++ modules/visual_script/visual_script.h | 10 ++ .../visual_script/visual_script_editor.cpp | 91 +++++++++++++ modules/visual_script/visual_script_editor.h | 12 ++ modules/visual_script/visual_script_nodes.cpp | 113 ++++++++++++++++ modules/visual_script/visual_script_nodes.h | 35 +++++ 44 files changed, 1252 insertions(+), 154 deletions(-) create mode 100644 doc/classes/ScriptServer.xml create mode 100644 modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/GlobalAttribute.cs create mode 100644 modules/visual_script/doc_classes/VisualScriptScriptClass.xml diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 0b2b59dc87..6863c3817f 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -39,6 +39,7 @@ #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/project_settings.h" +#include "core/script_language.h" /** * Time constants borrowed from loc_time.h @@ -2989,6 +2990,89 @@ _ClassDB::~_ClassDB() { } /////////////////////////////// +bool _ScriptServer::_set(const StringName &p_name, const Variant &p_value) { + return false; +} + +bool _ScriptServer::_get(const StringName &p_name, Variant &r_ret) const { + if (ScriptServer::is_global_class(p_name)) { + r_ret = ResourceLoader::load(ScriptServer::get_global_class_path(p_name), "Script"); + return true; + } + return false; +} + +void _ScriptServer::_get_property_list(List *p_list) const { + ERR_FAIL_COND(!p_list); + List names; + ScriptServer::get_global_class_list(&names); + for (List::Element *E = names.front(); E; E = E->next()) { + StringName n = E->get(); + String class_name = String(n).get_file().get_extension(); + p_list->push_back(PropertyInfo(Variant::OBJECT, class_name, PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_NETWORK, ResourceLoader::get_resource_type(ScriptServer::get_global_class_path(n)))); + } +} + +bool _ScriptServer::is_global_class(const StringName &p_class) const { + return ScriptServer::is_global_class(p_class); +} + +String _ScriptServer::get_global_class_path(const String &p_class) const { + return ScriptServer::get_global_class_path(p_class); +} + +StringName _ScriptServer::get_global_class_base(const String &p_class) const { + return ScriptServer::get_global_class_base(p_class); +} + +StringName _ScriptServer::get_global_class_native_base(const String &p_class) const { + return ScriptServer::get_global_class_native_base(p_class); +} + +StringName _ScriptServer::get_global_class_name(const String &p_path) const { + return ScriptServer::get_global_class_name(p_path); +} + +Ref