mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-19 22:24:23 +01:00
Added MMNode registry to MMAlgos.
This commit is contained in:
parent
60d51b04d3
commit
7af9c93c3f
@ -5596,6 +5596,74 @@ Vector2 MMAlgos::custom_uv_transform(const Vector2 &uuv, const Vector2 &cst_scal
|
||||
return uv;
|
||||
}
|
||||
|
||||
void MMAlgos::register_node_class(const String &category, const String &cls) {
|
||||
for (int i = 0; i < mm_node_registry.size(); ++i) {
|
||||
const MMNodeRegistryCategory &categ = mm_node_registry[i];
|
||||
|
||||
if (categ.category_name == category) {
|
||||
for (int j = 0; j < categ.entries.size(); ++j) {
|
||||
ERR_FAIL_COND(categ.entries[j].data == cls);
|
||||
}
|
||||
|
||||
MMNodeRegistryEntry e;
|
||||
e.type = MMNODE_REGISTRY_TYPE_CLASS;
|
||||
e.data = cls;
|
||||
|
||||
mm_node_registry.write[i].entries.push_back(e);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void MMAlgos::unregister_node_class(const String &category, const String &cls) {
|
||||
for (int i = 0; i < mm_node_registry.size(); ++i) {
|
||||
const MMNodeRegistryCategory &categ = mm_node_registry[i];
|
||||
|
||||
if (categ.category_name == category) {
|
||||
for (int j = 0; j < categ.entries.size(); ++j) {
|
||||
if (categ.entries[j].data == cls) {
|
||||
mm_node_registry.write[j].entries.remove(j);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MMAlgos::register_node_script(const String &category, const String &file_path) {
|
||||
for (int i = 0; i < mm_node_registry.size(); ++i) {
|
||||
const MMNodeRegistryCategory &categ = mm_node_registry[i];
|
||||
|
||||
if (categ.category_name == category) {
|
||||
for (int j = 0; j < categ.entries.size(); ++j) {
|
||||
ERR_FAIL_COND(categ.entries[j].data == file_path);
|
||||
}
|
||||
|
||||
MMNodeRegistryEntry e;
|
||||
e.type = MMNODE_REGISTRY_TYPE_SCRIPT;
|
||||
e.data = file_path;
|
||||
|
||||
mm_node_registry.write[i].entries.push_back(e);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void MMAlgos::unregister_node_script(const String &category, const String &file_path) {
|
||||
for (int i = 0; i < mm_node_registry.size(); ++i) {
|
||||
const MMNodeRegistryCategory &categ = mm_node_registry[i];
|
||||
|
||||
if (categ.category_name == category) {
|
||||
for (int j = 0; j < categ.entries.size(); ++j) {
|
||||
if (categ.entries[j].data == file_path) {
|
||||
mm_node_registry.write[j].entries.remove(j);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MMAlgos::MMAlgos() {
|
||||
}
|
||||
|
||||
@ -5604,3 +5672,5 @@ MMAlgos::~MMAlgos() {
|
||||
|
||||
void MMAlgos::_bind_methods() {
|
||||
}
|
||||
|
||||
Vector<MMAlgos::MMNodeRegistryCategory> MMAlgos::mm_node_registry;
|
||||
|
@ -285,6 +285,44 @@ public:
|
||||
static Vector2 get_from_tileset(const float count, const float pseed, const Vector2 &uv);
|
||||
static Vector2 custom_uv_transform(const Vector2 &uv, const Vector2 &cst_scale, const float rnd_rotate, const float rnd_scale, const Vector2 &pseed);
|
||||
|
||||
static void register_node_class(const String &category, const String &cls);
|
||||
static void unregister_node_class(const String &category, const String &cls);
|
||||
|
||||
static void register_node_script(const String &category, const String &file_path);
|
||||
static void unregister_node_script(const String &category, const String &file_path);
|
||||
|
||||
enum MMNodeRegistryType {
|
||||
MMNODE_REGISTRY_TYPE_CLASS = 0,
|
||||
MMNODE_REGISTRY_TYPE_SCRIPT
|
||||
};
|
||||
|
||||
struct MMNodeRegistryEntry {
|
||||
MMNodeRegistryType type;
|
||||
String data;
|
||||
};
|
||||
|
||||
struct MMNodeRegistryCategory {
|
||||
String category_name;
|
||||
Vector<MMNodeRegistryEntry> entries;
|
||||
};
|
||||
|
||||
static Vector<MMNodeRegistryCategory> mm_node_registry;
|
||||
|
||||
//register, unregister etc.
|
||||
|
||||
// Add it to the MMAlgos bing class instead.;
|
||||
// Not a perfect fit, but a better fit.;
|
||||
//func editor_register_node_class(category : String, cls : String);
|
||||
// -> c++ method, adds node to the editor gui (add button);
|
||||
// in gdscript a plugin should instance an MMNode and call it to populate the add menu;
|
||||
// with MMNodes;
|
||||
// in c++ it should have a static counterpart.;
|
||||
// register_types should populate c++ types with this;
|
||||
//func editor_unregister_node_class(category : String, cls : String);
|
||||
//func editor_register_node_script(category : String, script_path : String);
|
||||
// same as the above, but for scripts;
|
||||
//func editor_unregister_node_script(category : String, cls : String);
|
||||
|
||||
MMAlgos();
|
||||
~MMAlgos();
|
||||
|
||||
|
@ -1012,6 +1012,20 @@ Vector2 _MMAlgos::custom_uv_transform(const Vector2 &uv, const Vector2 &cst_scal
|
||||
return MMAlgos::custom_uv_transform(uv, cst_scale, rnd_rotate, rnd_scale, pseed);
|
||||
}
|
||||
|
||||
void _MMAlgos::register_node_class(const String &category, const String &cls) {
|
||||
MMAlgos::register_node_class(category, cls);
|
||||
}
|
||||
void _MMAlgos::unregister_node_class(const String &category, const String &cls) {
|
||||
MMAlgos::unregister_node_class(category, cls);
|
||||
}
|
||||
|
||||
void _MMAlgos::register_node_script(const String &category, const String &file_path) {
|
||||
MMAlgos::register_node_class(category, file_path);
|
||||
}
|
||||
void _MMAlgos::unregister_node_script(const String &category, const String &file_path) {
|
||||
MMAlgos::unregister_node_class(category, file_path);
|
||||
}
|
||||
|
||||
_MMAlgos *_MMAlgos::get_singleton() {
|
||||
return self;
|
||||
}
|
||||
@ -1277,6 +1291,12 @@ void _MMAlgos::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("kal_rotate", "uv", "count", "offset"), &_MMAlgos::kal_rotate);
|
||||
ClassDB::bind_method(D_METHOD("get_from_tileset", "count", "pseed", "uv"), &_MMAlgos::get_from_tileset);
|
||||
ClassDB::bind_method(D_METHOD("custom_uv_transform", "uv", "cst_scale", "rnd_rotate", "rnd_scale", "pseed"), &_MMAlgos::custom_uv_transform);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("register_node_class", "category", "cls"), &_MMAlgos::register_node_class);
|
||||
ClassDB::bind_method(D_METHOD("unregister_node_class", "category", "cls"), &_MMAlgos::unregister_node_class);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("register_node_script", "category", "file_path"), &_MMAlgos::register_node_script);
|
||||
ClassDB::bind_method(D_METHOD("unregister_node_script", "category", "file_path"), &_MMAlgos::unregister_node_script);
|
||||
}
|
||||
|
||||
_MMAlgos *_MMAlgos::self = nullptr;
|
||||
|
@ -266,6 +266,12 @@ public:
|
||||
Vector2 get_from_tileset(const float count, const float pseed, const Vector2 &uv);
|
||||
Vector2 custom_uv_transform(const Vector2 &uv, const Vector2 &cst_scale, const float rnd_rotate, const float rnd_scale, const Vector2 &pseed);
|
||||
|
||||
void register_node_class(const String &category, const String &cls);
|
||||
void unregister_node_class(const String &category, const String &cls);
|
||||
|
||||
void register_node_script(const String &category, const String &file_path);
|
||||
void unregister_node_script(const String &category, const String &file_path);
|
||||
|
||||
static _MMAlgos *get_singleton();
|
||||
|
||||
_MMAlgos();
|
||||
|
@ -216,19 +216,6 @@ Vector2 MMNode::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
return Vector2();
|
||||
}
|
||||
|
||||
// Add it to the MMAlgos bing class instead.;
|
||||
// Not a perfect fit, but a better fit.;
|
||||
//func editor_register_node_class(category : String, cls : String);
|
||||
// -> c++ method, adds node to the editor gui (add button);
|
||||
// in gdscript a plugin should instance an MMNode and call it to populate the add menu;
|
||||
// with MMNodes;
|
||||
// in c++ it should have a static counterpart.;
|
||||
// register_types should populate c++ types with this;
|
||||
//func editor_unregister_node_class(category : String, cls : String);
|
||||
//func editor_register_node_script(category : String, script_path : String);
|
||||
// same as the above, but for scripts;
|
||||
//func editor_unregister_node_script(category : String, cls : String);
|
||||
|
||||
MMNode::MMNode() {
|
||||
properties_initialized = false;
|
||||
dirty = true;
|
||||
|
Loading…
Reference in New Issue
Block a user