mirror of
https://github.com/Relintai/props.git
synced 2025-02-04 16:05:54 +01:00
Set up an editor plugin.
This commit is contained in:
parent
e274c2d4f6
commit
8258fb7cfa
2
SCsub
2
SCsub
@ -31,6 +31,8 @@ sources = [
|
|||||||
"prop_instance_job.cpp",
|
"prop_instance_job.cpp",
|
||||||
|
|
||||||
"singleton/prop_utils.cpp",
|
"singleton/prop_utils.cpp",
|
||||||
|
|
||||||
|
"editor/prop_editor_plugin.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
|
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
|
||||||
|
@ -24,6 +24,8 @@ def get_doc_classes():
|
|||||||
"PropESSEntity",
|
"PropESSEntity",
|
||||||
"PropInstance",
|
"PropInstance",
|
||||||
"PropMeshUtils",
|
"PropMeshUtils",
|
||||||
|
|
||||||
|
"PropUtils",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_doc_path():
|
def get_doc_path():
|
||||||
|
40
editor/prop_editor_plugin.cpp
Normal file
40
editor/prop_editor_plugin.cpp
Normal 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);
|
||||||
|
}
|
52
editor/prop_editor_plugin.h
Normal file
52
editor/prop_editor_plugin.h
Normal 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
|
@ -41,6 +41,8 @@ SOFTWARE.
|
|||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#include "singleton/prop_utils.h"
|
#include "singleton/prop_utils.h"
|
||||||
|
|
||||||
|
#include "./editor/prop_editor_plugin.h"
|
||||||
|
|
||||||
static PropUtils *prop_utils = NULL;
|
static PropUtils *prop_utils = NULL;
|
||||||
|
|
||||||
void register_props_types() {
|
void register_props_types() {
|
||||||
@ -64,6 +66,10 @@ void register_props_types() {
|
|||||||
prop_utils = memnew(PropUtils);
|
prop_utils = memnew(PropUtils);
|
||||||
ClassDB::register_class<PropUtils>();
|
ClassDB::register_class<PropUtils>();
|
||||||
Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton()));
|
Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton()));
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
EditorPlugins::add_by_type<PropEditorPlugin>();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void unregister_props_types() {
|
void unregister_props_types() {
|
||||||
|
@ -22,12 +22,18 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "prop_utils.h"
|
#include "prop_utils.h"
|
||||||
|
|
||||||
|
#include "../props/prop_data.h"
|
||||||
|
|
||||||
PropUtils *PropUtils::_instance;
|
PropUtils *PropUtils::_instance;
|
||||||
|
|
||||||
PropUtils *PropUtils::get_singleton() {
|
PropUtils *PropUtils::get_singleton() {
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<PropData> PropUtils::convert_tree(Node *root) {
|
||||||
|
return Ref<PropData>();
|
||||||
|
}
|
||||||
|
|
||||||
PropUtils::PropUtils() {
|
PropUtils::PropUtils() {
|
||||||
_instance = this;
|
_instance = this;
|
||||||
}
|
}
|
||||||
@ -37,4 +43,5 @@ PropUtils::~PropUtils() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PropUtils::_bind_methods() {
|
void PropUtils::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils::convert_tree);
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,18 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "core/object.h"
|
#include "core/object.h"
|
||||||
|
|
||||||
|
#include "core/reference.h"
|
||||||
|
|
||||||
|
class PropData;
|
||||||
|
|
||||||
class PropUtils : public Object {
|
class PropUtils : public Object {
|
||||||
GDCLASS(PropUtils, Object);
|
GDCLASS(PropUtils, Object);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PropUtils *get_singleton();
|
static PropUtils *get_singleton();
|
||||||
|
|
||||||
|
Ref<PropData> convert_tree(Node *root);
|
||||||
|
|
||||||
PropUtils();
|
PropUtils();
|
||||||
~PropUtils();
|
~PropUtils();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user