mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 04:16:50 +01:00
Added a new plugin_refresher module. It's only a skeleton for now. Same idea as the godot-plugin-refresher addon, but done a bit differently.
This commit is contained in:
parent
fb02d16983
commit
69f3a5229d
11
modules/plugin_refresher/SCsub
Normal file
11
modules/plugin_refresher/SCsub
Normal file
@ -0,0 +1,11 @@
|
||||
import os
|
||||
|
||||
Import('env')
|
||||
|
||||
module_env = env.Clone()
|
||||
|
||||
module_env.add_source_files(env.modules_sources,"register_types.cpp")
|
||||
|
||||
if env["tools"]:
|
||||
module_env.add_source_files(env.modules_sources,"plugin_refresher_editor_plugin.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"plugin_refresher.cpp")
|
16
modules/plugin_refresher/config.py
Normal file
16
modules/plugin_refresher/config.py
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
def can_build(env, platform):
|
||||
return True
|
||||
|
||||
|
||||
def configure(env):
|
||||
pass
|
||||
|
||||
|
||||
def get_doc_classes():
|
||||
return [
|
||||
]
|
||||
|
||||
def get_doc_path():
|
||||
return "doc_classes"
|
61
modules/plugin_refresher/plugin_refresher.cpp
Normal file
61
modules/plugin_refresher/plugin_refresher.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
#include "plugin_refresher.h"
|
||||
#include "core/os/input_event.h"
|
||||
|
||||
#include "editor/editor_settings.h"
|
||||
#include "scene/gui/check_box.h"
|
||||
|
||||
void PluginRefresher::set_enabled(const bool p_enabled) {
|
||||
if (_enabler_check_box) {
|
||||
_enabler_check_box->set_pressed(p_enabled);
|
||||
}
|
||||
|
||||
_set_enabled(p_enabled);
|
||||
}
|
||||
|
||||
void PluginRefresher::set_enabler_check_box(CheckBox *cb) {
|
||||
_enabler_check_box = cb;
|
||||
|
||||
if (_enabler_check_box) {
|
||||
_enabler_check_box->connect("toggled", this, "_set_enabled");
|
||||
}
|
||||
}
|
||||
|
||||
void PluginRefresher::_set_enabled(const bool p_enabled) {
|
||||
set_visible(p_enabled);
|
||||
|
||||
bool sett_enabled = EditorSettings::get_singleton()->get_project_metadata("plugin_refresher", "enabled", false);
|
||||
|
||||
if (sett_enabled != p_enabled) {
|
||||
EditorSettings::get_singleton()->set_project_metadata("plugin_refresher", "enabled", p_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void PluginRefresher::pressed() {
|
||||
if (_button == BUTTON_LEFT) {
|
||||
} else if (_button == BUTTON_RIGHT) {
|
||||
}
|
||||
}
|
||||
void PluginRefresher::_gui_input(Ref<InputEvent> p_event) {
|
||||
Ref<InputEventMouseButton> mouse_button = p_event;
|
||||
|
||||
if (mouse_button.is_valid()) {
|
||||
_button = mouse_button->get_button_index();
|
||||
}
|
||||
|
||||
BaseButton::_gui_input(p_event);
|
||||
}
|
||||
|
||||
PluginRefresher::PluginRefresher() {
|
||||
_button = 0;
|
||||
set_button_mask(BUTTON_MASK_LEFT | BUTTON_MASK_RIGHT);
|
||||
set_enabled_focus_mode(FOCUS_NONE);
|
||||
set_tooltip("Left click: Refresh selected plugin.\nRight click: Settings.");
|
||||
}
|
||||
|
||||
PluginRefresher::~PluginRefresher() {
|
||||
}
|
||||
|
||||
void PluginRefresher::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_set_enabled", "enabled"), &PluginRefresher::_set_enabled);
|
||||
}
|
36
modules/plugin_refresher/plugin_refresher.h
Normal file
36
modules/plugin_refresher/plugin_refresher.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef PLUGIN_REFRESHER_H
|
||||
#define PLUGIN_REFRESHER_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/ustring.h"
|
||||
#include "core/variant.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "scene/gui/tool_button.h"
|
||||
|
||||
class CheckBox;
|
||||
|
||||
class PluginRefresher : public ToolButton {
|
||||
GDCLASS(PluginRefresher, ToolButton);
|
||||
|
||||
public:
|
||||
void set_enabled(const bool p_enabled);
|
||||
|
||||
void set_enabler_check_box(CheckBox *cb);
|
||||
|
||||
PluginRefresher();
|
||||
~PluginRefresher();
|
||||
|
||||
protected:
|
||||
void _set_enabled(const bool p_enabled);
|
||||
|
||||
void pressed();
|
||||
void _gui_input(Ref<InputEvent> p_event);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
int _button;
|
||||
CheckBox *_enabler_check_box;
|
||||
};
|
||||
|
||||
#endif
|
58
modules/plugin_refresher/plugin_refresher_editor_plugin.cpp
Normal file
58
modules/plugin_refresher/plugin_refresher_editor_plugin.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 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 "plugin_refresher_editor_plugin.h"
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin_settings.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/project_settings_editor.h"
|
||||
#include "plugin_refresher.h"
|
||||
#include "scene/gui/check_box.h"
|
||||
|
||||
String PluginRefresherEditorPlugin::get_name() const {
|
||||
return "PluginRefresherEditorPlugin";
|
||||
}
|
||||
|
||||
PluginRefresherEditorPlugin::PluginRefresherEditorPlugin(EditorNode *p_node) {
|
||||
editor = p_node;
|
||||
|
||||
_enable_check_box = memnew(CheckBox);
|
||||
_enable_check_box->set_text(TTR("Show Refresher"));
|
||||
|
||||
_plugin_refresher = memnew(PluginRefresher);
|
||||
_plugin_refresher->set_icon(get_editor_interface()->get_base_control()->get_icon("Reload", "EditorIcons"));
|
||||
|
||||
_plugin_refresher->set_enabler_check_box(_enable_check_box);
|
||||
|
||||
add_control_to_container(CONTAINER_TOOLBAR, _plugin_refresher);
|
||||
ProjectSettingsEditor::get_singleton()->get_plugin_settings()->add_control_to_top_bar(_enable_check_box);
|
||||
|
||||
bool enabled = EditorSettings::get_singleton()->get_project_metadata("plugin_refresher", "enabled", false);
|
||||
_plugin_refresher->set_enabled(enabled);
|
||||
}
|
||||
|
||||
PluginRefresherEditorPlugin::~PluginRefresherEditorPlugin() {
|
||||
}
|
||||
|
||||
void PluginRefresherEditorPlugin::_bind_methods() {
|
||||
}
|
50
modules/plugin_refresher/plugin_refresher_editor_plugin.h
Normal file
50
modules/plugin_refresher/plugin_refresher_editor_plugin.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef PLUGIN_REFRESHER_EDITOR_PLUGIN_H
|
||||
#define PLUGIN_REFRESHER_EDITOR_PLUGIN_H
|
||||
|
||||
/*
|
||||
Copyright (c) 2019-2022 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 "core/reference.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
|
||||
class CheckBox;
|
||||
class PluginRefresher;
|
||||
|
||||
class PluginRefresherEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(PluginRefresherEditorPlugin, EditorPlugin);
|
||||
|
||||
public:
|
||||
String get_name() const;
|
||||
|
||||
PluginRefresherEditorPlugin(EditorNode *p_node);
|
||||
~PluginRefresherEditorPlugin();
|
||||
|
||||
EditorNode *editor;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
CheckBox *_enable_check_box;
|
||||
PluginRefresher *_plugin_refresher;
|
||||
};
|
||||
|
||||
#endif
|
36
modules/plugin_refresher/register_types.cpp
Normal file
36
modules/plugin_refresher/register_types.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright (c) 2022 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 "register_types.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "plugin_refresher_editor_plugin.h"
|
||||
#endif
|
||||
|
||||
void register_plugin_refresher_types() {
|
||||
#ifdef TOOLS_ENABLED
|
||||
EditorPlugins::add_by_type<PluginRefresherEditorPlugin>();
|
||||
#endif
|
||||
}
|
||||
|
||||
void unregister_plugin_refresher_types() {
|
||||
}
|
24
modules/plugin_refresher/register_types.h
Normal file
24
modules/plugin_refresher/register_types.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
void register_plugin_refresher_types();
|
||||
void unregister_plugin_refresher_types();
|
Loading…
Reference in New Issue
Block a user