mirror of
https://github.com/Relintai/skeleton_editor.git
synced 2024-11-12 19:17:18 +01:00
Added an editor plugin that removes and destroys the built in skeleton editor plugin after editor startup.
This commit is contained in:
parent
8780d017aa
commit
1ab0676815
3
SCsub
3
SCsub
@ -2,4 +2,5 @@ Import('env')
|
||||
|
||||
env.add_source_files(env.modules_sources,"register_types.cpp")
|
||||
|
||||
#env.add_source_files(env.modules_sources,"touch_button.cpp")
|
||||
if env["tools"]:
|
||||
env.add_source_files(env.modules_sources, "bskeleton_editor.cpp")
|
||||
|
85
bskeleton_editor.cpp
Normal file
85
bskeleton_editor.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
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 "bskeleton_editor.h"
|
||||
|
||||
#include "editor/editor_data.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "editor/editor_scale.h"
|
||||
#include "editor/editor_settings.h"
|
||||
|
||||
|
||||
void BSkeletonEditorPlugin::edit(Object *p_object) {
|
||||
}
|
||||
|
||||
bool BSkeletonEditorPlugin::handles(Object *p_object) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void BSkeletonEditorPlugin::make_visible(bool p_visible) {
|
||||
}
|
||||
|
||||
void BSkeletonEditorPlugin::remove_built_in_editor_plugin() {
|
||||
EditorData &data = EditorNode::get_editor_data();
|
||||
|
||||
for (int i = 0; i < data.get_editor_plugin_count(); ++i) {
|
||||
EditorPlugin *p = data.get_editor_plugin(i);
|
||||
|
||||
if (p->is_class("SkeletonEditorPlugin")) {
|
||||
EditorNode::get_singleton()->remove_editor_plugin(p);
|
||||
|
||||
print_error("remed");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Control *vp = EditorNode::get_singleton()->get_viewport();
|
||||
|
||||
for (int i = 0; i < vp->get_child_count(); ++i) {
|
||||
Node *n = vp->get_child(i);
|
||||
|
||||
if (n->is_class("SkeletonEditor")) {
|
||||
n->queue_delete();
|
||||
|
||||
print_error("quedel");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BSkeletonEditorPlugin::BSkeletonEditorPlugin(EditorNode *p_node) {
|
||||
editor = p_node;
|
||||
|
||||
//note calling remove_built_int_editor_plugin here, or in code before this will cause a crash because
|
||||
//not all classes that are used in EditorNode::get_singleton()->remove_editor_plugin() initialized yet!
|
||||
call_deferred("remove_built_in_editor_plugin");
|
||||
}
|
||||
|
||||
BSkeletonEditorPlugin::~BSkeletonEditorPlugin() {
|
||||
}
|
||||
|
||||
void BSkeletonEditorPlugin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("remove_built_in_editor_plugin"), &BSkeletonEditorPlugin::remove_built_in_editor_plugin);
|
||||
}
|
51
bskeleton_editor.h
Normal file
51
bskeleton_editor.h
Normal file
@ -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 B_SKELETON_EDITOR_H
|
||||
#define B_SKELETON_EDITOR_H
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
|
||||
class BSkeletonEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(BSkeletonEditorPlugin, EditorPlugin);
|
||||
|
||||
EditorNode *editor;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return false; }
|
||||
virtual String get_name() const { return "BSkeletonEditorPlugin"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
virtual void edit(Object *p_object);
|
||||
virtual bool handles(Object *p_object) const;
|
||||
virtual void make_visible(bool p_visible);
|
||||
|
||||
void remove_built_in_editor_plugin();
|
||||
|
||||
BSkeletonEditorPlugin(EditorNode *p_node);
|
||||
~BSkeletonEditorPlugin();
|
||||
};
|
||||
|
||||
#endif
|
@ -22,8 +22,14 @@ SOFTWARE.
|
||||
|
||||
#include "register_types.h"
|
||||
|
||||
void register_skeleton_editor_types() {
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "bskeleton_editor.h"
|
||||
#endif
|
||||
|
||||
void register_skeleton_editor_types() {
|
||||
#ifdef TOOLS_ENABLED
|
||||
EditorPlugins::add_by_type<BSkeletonEditorPlugin>();
|
||||
#endif
|
||||
}
|
||||
|
||||
void unregister_skeleton_editor_types() {
|
||||
|
Loading…
Reference in New Issue
Block a user