From 12b47f822d05ffbde62d8afdb290df7d6da31e2e Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 13 Apr 2020 19:15:07 +0200 Subject: [PATCH] Added an editor plugin to be able to add a few tools into the tools menu. Disabled for now/. --- SCsub | 2 ++ editor/ess_editor_plugin.cpp | 40 ++++++++++++++++++++++++++++ editor/ess_editor_plugin.h | 51 ++++++++++++++++++++++++++++++++++++ register_types.cpp | 6 +++++ 4 files changed, 99 insertions(+) create mode 100644 editor/ess_editor_plugin.cpp create mode 100644 editor/ess_editor_plugin.h diff --git a/SCsub b/SCsub index b1f160f..32238bd 100644 --- a/SCsub +++ b/SCsub @@ -117,6 +117,8 @@ sources = [ "singletons/profile_manager.cpp", "singletons/entity_data_manager.cpp", + + "editor/ess_editor_plugin.cpp", ] if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': diff --git a/editor/ess_editor_plugin.cpp b/editor/ess_editor_plugin.cpp new file mode 100644 index 0000000..b32f9e9 --- /dev/null +++ b/editor/ess_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 "ess_editor_plugin.h" + +void ESSEditorPlugin::fix_ids(Variant param) { +} + +ESSEditorPlugin::ESSEditorPlugin(EditorNode *p_node) { + + editor = p_node; + + editor->add_tool_menu_item("ESS: make ids unique", this, "fix_ids"); +} + +ESSEditorPlugin::~ESSEditorPlugin() { +} + +void ESSEditorPlugin::_bind_methods() { + ClassDB::bind_method(D_METHOD("fix_ids"), &ESSEditorPlugin::fix_ids); +} diff --git a/editor/ess_editor_plugin.h b/editor/ess_editor_plugin.h new file mode 100644 index 0000000..897475f --- /dev/null +++ b/editor/ess_editor_plugin.h @@ -0,0 +1,51 @@ +/* +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 ESS_EDITOR_PLUGIN_H +#define ESS_EDITOR_PLUGIN_H + +#include "editor/editor_node.h" +#include "editor/editor_plugin.h" + +#include "core/version.h" + +class ESSEditorPlugin : public EditorPlugin { + + GDCLASS(ESSEditorPlugin, EditorPlugin); + EditorNode *editor; + +protected: + static void _bind_methods(); + +public: + virtual String get_name() const { return "ESSEditorPlugin"; } + 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 fix_ids(Variant param); + + ESSEditorPlugin(EditorNode *p_node); + ~ESSEditorPlugin(); +}; + +#endif diff --git a/register_types.cpp b/register_types.cpp index b88fc15..d699cfd 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -133,6 +133,8 @@ SOFTWARE. #include "singletons/profile_manager.h" +#include "editor/ess_editor_plugin.h" + static EntityDataManager *entity_data_manager = NULL; static ProfileManager *profile_manager = NULL; @@ -267,6 +269,10 @@ void register_entity_spell_system_types() { profile_manager = memnew(ProfileManager); ClassDB::register_class(); Engine::get_singleton()->add_singleton(Engine::Singleton("ProfileManager", ProfileManager::get_instance())); + +#ifdef TOOLS_ENABLED + //EditorPlugins::add_by_type(); +#endif } void unregister_entity_spell_system_types() {