Set up an editor plugin.

This commit is contained in:
Relintai 2020-06-27 23:13:26 +02:00
parent e274c2d4f6
commit 8258fb7cfa
7 changed files with 115 additions and 0 deletions

2
SCsub
View File

@ -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':

View File

@ -24,6 +24,8 @@ def get_doc_classes():
"PropESSEntity",
"PropInstance",
"PropMeshUtils",
"PropUtils",
]
def get_doc_path():

View File

@ -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);
}

View File

@ -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

View File

@ -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<PropUtils>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton()));
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<PropEditorPlugin>();
#endif
}
void unregister_props_types() {

View File

@ -22,12 +22,18 @@ SOFTWARE.
#include "prop_utils.h"
#include "../props/prop_data.h"
PropUtils *PropUtils::_instance;
PropUtils *PropUtils::get_singleton() {
return _instance;
}
Ref<PropData> PropUtils::convert_tree(Node *root) {
return Ref<PropData>();
}
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);
}

View File

@ -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<PropData> convert_tree(Node *root);
PropUtils();
~PropUtils();