diff --git a/SCsub b/SCsub index 287ed44..436fb63 100644 --- a/SCsub +++ b/SCsub @@ -31,6 +31,8 @@ sources = [ "prop_instance_job.cpp", "singleton/prop_utils.cpp", + + "editor/prop_editor_plugin.cpp", ] if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': diff --git a/config.py b/config.py index 8424c8c..e188b47 100644 --- a/config.py +++ b/config.py @@ -24,6 +24,8 @@ def get_doc_classes(): "PropESSEntity", "PropInstance", "PropMeshUtils", + + "PropUtils", ] def get_doc_path(): diff --git a/editor/prop_editor_plugin.cpp b/editor/prop_editor_plugin.cpp new file mode 100644 index 0000000..b7f3504 --- /dev/null +++ b/editor/prop_editor_plugin.cpp @@ -0,0 +1,40 @@ +/* +Copyright (c) 2020 Péter Magyar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "prop_editor_plugin.h" + +void PropEditorPlugin::convert_scene_to_prop_data(Variant param) { +} + +PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) { + + editor = p_node; + + editor->add_tool_menu_item("Convert current scene to PropData", this, "convert_scene_to_prop_data"); +} + +PropEditorPlugin::~PropEditorPlugin() { +} + +void PropEditorPlugin::_bind_methods() { + ClassDB::bind_method(D_METHOD("convert_scene_to_prop_data"), &PropEditorPlugin::convert_scene_to_prop_data); +} diff --git a/editor/prop_editor_plugin.h b/editor/prop_editor_plugin.h new file mode 100644 index 0000000..2079869 --- /dev/null +++ b/editor/prop_editor_plugin.h @@ -0,0 +1,52 @@ +/* +Copyright (c) 2020 Péter Magyar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef PROP_EDITOR_PLUGIN_H +#define PROP_EDITOR_PLUGIN_H + +#include "editor/editor_node.h" +#include "editor/editor_plugin.h" + +#include "core/version.h" + +class PropEditorPlugin : public EditorPlugin { + + GDCLASS(PropEditorPlugin, EditorPlugin); + EditorNode *editor; + +protected: + static void _bind_methods(); + +public: + virtual String get_name() const { return "PropEditorPlugin"; } + bool has_main_screen() const { return false; } + virtual void edit(Object *p_object) {} + virtual bool handles(Object *p_object) const { return false; } + virtual void make_visible(bool p_visible) {} + + void convert_scene_to_prop_data(Variant param); + + PropEditorPlugin(EditorNode *p_node); + ~PropEditorPlugin(); +}; + +#endif diff --git a/register_types.cpp b/register_types.cpp index f13f798..b98e653 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -41,6 +41,8 @@ SOFTWARE. #include "core/engine.h" #include "singleton/prop_utils.h" +#include "./editor/prop_editor_plugin.h" + static PropUtils *prop_utils = NULL; void register_props_types() { @@ -64,6 +66,10 @@ void register_props_types() { prop_utils = memnew(PropUtils); ClassDB::register_class(); Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton())); + +#ifdef TOOLS_ENABLED + EditorPlugins::add_by_type(); +#endif } void unregister_props_types() { diff --git a/singleton/prop_utils.cpp b/singleton/prop_utils.cpp index 48c46c7..5275f89 100644 --- a/singleton/prop_utils.cpp +++ b/singleton/prop_utils.cpp @@ -22,12 +22,18 @@ SOFTWARE. #include "prop_utils.h" +#include "../props/prop_data.h" + PropUtils *PropUtils::_instance; PropUtils *PropUtils::get_singleton() { return _instance; } +Ref PropUtils::convert_tree(Node *root) { + return Ref(); +} + PropUtils::PropUtils() { _instance = this; } @@ -37,4 +43,5 @@ PropUtils::~PropUtils() { } void PropUtils::_bind_methods() { + ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils::convert_tree); } diff --git a/singleton/prop_utils.h b/singleton/prop_utils.h index b770d1c..878a026 100644 --- a/singleton/prop_utils.h +++ b/singleton/prop_utils.h @@ -25,12 +25,18 @@ SOFTWARE. #include "core/object.h" +#include "core/reference.h" + +class PropData; + class PropUtils : public Object { GDCLASS(PropUtils, Object); public: static PropUtils *get_singleton(); + Ref convert_tree(Node *root); + PropUtils(); ~PropUtils();