Ran the cpp conversion scripts on mat_maker_gd's core classes.

This commit is contained in:
Relintai 2022-06-06 22:04:36 +02:00
parent df9099e0ed
commit 5cb26e2b6b
12 changed files with 3633 additions and 0 deletions

View File

@ -0,0 +1,400 @@
#include "createnamepopup.h"
NodePath CreateNamePopup::get_line_edit_path() {
return line_edit_path;
}
void CreateNamePopup::set_line_edit_path(const NodePath &val) {
line_edit_path = val;
}
NodePath CreateNamePopup::get_tree_path() {
return tree_path;
}
void CreateNamePopup::set_tree_path(const NodePath &val) {
tree_path = val;
}
PoolStringArray CreateNamePopup::get_type_folders() {
return type_folders;
}
void CreateNamePopup::set_type_folders(const PoolStringArray &val) {
type_folders = val;
}
String CreateNamePopup::get__resource_type() {
return _resource_type;
}
void CreateNamePopup::set__resource_type(const String &val) {
_resource_type = val;
}
LineEdit CreateNamePopup::get_ *_line_edit() {
return *_line_edit;
}
void CreateNamePopup::set_ *_line_edit(const LineEdit &val) {
*_line_edit = val;
}
Tree CreateNamePopup::get_ *_tree() {
return *_tree;
}
void CreateNamePopup::set_ *_tree(const Tree &val) {
*_tree = val;
}
//tool;
signal ok_pressed;
//export(NodePath) ;
NodePath line_edit_path = ;
//export(NodePath) ;
NodePath tree_path = ;
//export(PoolStringArray) ;
PoolStringArray type_folders = ;
String _resource_type = "MMNode";
LineEdit *_line_edit;
Tree *_tree;
void CreateNamePopup::_ready() {
_line_edit = get_node(line_edit_path) as LineEdit;
_tree = get_node(tree_path) as Tree;
connect("confirmed", self, "_on_OK_pressed");
connect("about_to_show", self, "about_to_show");
}
void CreateNamePopup::set_resource_type(const String &resource_type) {
_resource_type = resource_type;
}
void CreateNamePopup::about_to_show() {
_tree.clear();
TreeItem *root = _tree.create_item();
for (s in type_folders) {
evaluate_folder(s, root);
}
}
void CreateNamePopup::evaluate_folder(const String &folder, const TreeItem &root) {
TreeItem *ti = _tree.create_item(root);
ti.set_text(0, folder.substr(folder.find_last("/") + 1));
Variant = Directory.new();
if (dir.open(folder) == OK) {
dir.list_dir_begin();
Variant = dir.get_next();
while (file_name != "") {
if (!dir.current_is_dir()) {
print("Found file: " + file_name);
TreeItem *e = _tree.create_item(ti);
e.set_text(0, file_name.get_file());
e.set_meta("file", folder + "/" + file_name);
}
file_name = dir.get_next();
}
}
else {
print("An error occurred when trying to access the path.");
}
}
void CreateNamePopup::_on_OK_pressed() {
TreeItem *selected = _tree.get_selected();
if (selected) {
if (!selected.has_meta("file")) {
hide();
return;
}
String file_name = selected.get_meta("file");
emit_signal("ok_pressed", file_name);
}
hide();
}
}
CreateNamePopup::CreateNamePopup() {
line_edit_path = ;
tree_path = ;
type_folders = ;
_resource_type = "MMNode";
*_line_edit;
*_tree;
//Script: res://addons/mat_maker_gd/editor/CreateNamePopup.gd
ConfirmationDialog *createnamepopup = memnew(ConfirmationDialog);
createnamepopup->set_name("CreateNamePopup");
createnamepopup->set_name("CreateNamePopup");
createnamepopup->set_filename("res://addons/mat_maker_gd/editor/CreateNamePopup.tscn");
createnamepopup->set_anchor_left(0.5);
createnamepopup->set_anchor_top(0.5);
createnamepopup->set_anchor_right(0.5);
createnamepopup->set_anchor_bottom(0.5);
createnamepopup->set_margin_left(-245.5);
createnamepopup->set_margin_top(-220);
createnamepopup->set_margin_right(245.5);
createnamepopup->set_margin_bottom(220);
createnamepopup->set_rect_position(Vector2(-245.5, -220));
createnamepopup->set_rect_global_position(Vector2(-245.5, -220));
createnamepopup->set_rect_size(Vector2(491, 440));
createnamepopup->set_window_title("Create New Resource");
//createnamepopup property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False}
//createnamepopup property line_edit_path TYPE_NODE_PATH value: VBoxContainer/LineEdit
//createnamepopup property tree_path TYPE_NODE_PATH value: VBoxContainer/Tree
TextureButton *texturebutton_createnamepopup = memnew(TextureButton);
texturebutton_createnamepopup->set_name("TextureButton");
createnamepopup->add_child(texturebutton_createnamepopup);
texturebutton_createnamepopup->set_name("TextureButton");
Label *label_createnamepopup = memnew(Label);
label_createnamepopup->set_name("Label");
createnamepopup->add_child(label_createnamepopup);
label_createnamepopup->set_name("Label");
label_createnamepopup->set_anchor_right(1);
label_createnamepopup->set_anchor_bottom(1);
label_createnamepopup->set_margin_left(8);
label_createnamepopup->set_margin_top(8);
label_createnamepopup->set_margin_right(-8);
label_createnamepopup->set_margin_bottom(-42);
label_createnamepopup->set_rect_position(Vector2(8, 8));
label_createnamepopup->set_rect_global_position(Vector2(8, 8));
label_createnamepopup->set_rect_size(Vector2(0, 14));
HBoxContainer *hboxcontainer_createnamepopup = memnew(HBoxContainer);
hboxcontainer_createnamepopup->set_name("HBoxContainer");
createnamepopup->add_child(hboxcontainer_createnamepopup);
hboxcontainer_createnamepopup->set_name("HBoxContainer");
Control *control3_hboxcontainer_createnamepopup = memnew(Control);
control3_hboxcontainer_createnamepopup->set_name("Control3");
hboxcontainer_createnamepopup->add_child(control3_hboxcontainer_createnamepopup);
control3_hboxcontainer_createnamepopup->set_name("Control3");
control3_hboxcontainer_createnamepopup->set_mouse_filter(1);
control3_hboxcontainer_createnamepopup->set_size_flags_horizontal(3);
Button *button2_hboxcontainer_createnamepopup = memnew(Button);
button2_hboxcontainer_createnamepopup->set_name("Button2");
hboxcontainer_createnamepopup->add_child(button2_hboxcontainer_createnamepopup);
button2_hboxcontainer_createnamepopup->set_name("Button2");
button2_hboxcontainer_createnamepopup->set_text("Cancel");
Control *control_hboxcontainer_createnamepopup = memnew(Control);
control_hboxcontainer_createnamepopup->set_name("Control");
hboxcontainer_createnamepopup->add_child(control_hboxcontainer_createnamepopup);
control_hboxcontainer_createnamepopup->set_name("Control");
control_hboxcontainer_createnamepopup->set_mouse_filter(1);
control_hboxcontainer_createnamepopup->set_size_flags_horizontal(3);
Button *button_hboxcontainer_createnamepopup = memnew(Button);
button_hboxcontainer_createnamepopup->set_name("Button");
hboxcontainer_createnamepopup->add_child(button_hboxcontainer_createnamepopup);
button_hboxcontainer_createnamepopup->set_name("Button");
button_hboxcontainer_createnamepopup->set_text("OK");
Control *control2_hboxcontainer_createnamepopup = memnew(Control);
control2_hboxcontainer_createnamepopup->set_name("Control2");
hboxcontainer_createnamepopup->add_child(control2_hboxcontainer_createnamepopup);
control2_hboxcontainer_createnamepopup->set_name("Control2");
control2_hboxcontainer_createnamepopup->set_mouse_filter(1);
control2_hboxcontainer_createnamepopup->set_size_flags_horizontal(3);
VBoxContainer *vboxcontainer_createnamepopup = memnew(VBoxContainer);
vboxcontainer_createnamepopup->set_name("VBoxContainer");
createnamepopup->add_child(vboxcontainer_createnamepopup);
vboxcontainer_createnamepopup->set_name("VBoxContainer");
//vboxcontainer_createnamepopup property owner TYPE_OBJECT value: CreateNamePopup:[ConfirmationDialog:280461]
vboxcontainer_createnamepopup->set_margin_left(8);
vboxcontainer_createnamepopup->set_margin_top(8);
vboxcontainer_createnamepopup->set_margin_right(483);
vboxcontainer_createnamepopup->set_margin_bottom(404);
vboxcontainer_createnamepopup->set_rect_position(Vector2(8, 8));
vboxcontainer_createnamepopup->set_rect_global_position(Vector2(8, 8));
vboxcontainer_createnamepopup->set_rect_size(Vector2(475, 396));
vboxcontainer_createnamepopup->set_size_flags_horizontal(3);
vboxcontainer_createnamepopup->set_size_flags_vertical(3);
//vboxcontainer_createnamepopup property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False}
Label *label2_vboxcontainer_createnamepopup = memnew(Label);
label2_vboxcontainer_createnamepopup->set_name("Label2");
vboxcontainer_createnamepopup->add_child(label2_vboxcontainer_createnamepopup);
label2_vboxcontainer_createnamepopup->set_name("Label2");
//label2_vboxcontainer_createnamepopup property owner TYPE_OBJECT value: CreateNamePopup:[ConfirmationDialog:280461]
label2_vboxcontainer_createnamepopup->set_margin_right(475);
label2_vboxcontainer_createnamepopup->set_margin_bottom(14);
label2_vboxcontainer_createnamepopup->set_rect_size(Vector2(475, 14));
label2_vboxcontainer_createnamepopup->set_size_flags_horizontal(3);
label2_vboxcontainer_createnamepopup->set_text("Type");
Tree *tree_vboxcontainer_createnamepopup = memnew(Tree);
tree_vboxcontainer_createnamepopup->set_name("Tree");
vboxcontainer_createnamepopup->add_child(tree_vboxcontainer_createnamepopup);
tree_vboxcontainer_createnamepopup->set_name("Tree");
//tree_vboxcontainer_createnamepopup property owner TYPE_OBJECT value: CreateNamePopup:[ConfirmationDialog:280461]
tree_vboxcontainer_createnamepopup->set_margin_top(18);
tree_vboxcontainer_createnamepopup->set_margin_right(475);
tree_vboxcontainer_createnamepopup->set_margin_bottom(350);
tree_vboxcontainer_createnamepopup->set_rect_position(Vector2(0, 18));
tree_vboxcontainer_createnamepopup->set_rect_global_position(Vector2(0, 18));
tree_vboxcontainer_createnamepopup->set_rect_size(Vector2(475, 332));
tree_vboxcontainer_createnamepopup->set_size_flags_horizontal(3);
tree_vboxcontainer_createnamepopup->set_size_flags_vertical(3);
tree_vboxcontainer_createnamepopup->set_hide_root(True);
PopupMenu *popupmenu_tree_vboxcontainer_createnamepopup = memnew(PopupMenu);
popupmenu_tree_vboxcontainer_createnamepopup->set_name("PopupMenu");
tree_vboxcontainer_createnamepopup->add_child(popupmenu_tree_vboxcontainer_createnamepopup);
popupmenu_tree_vboxcontainer_createnamepopup->set_name("PopupMenu");
Timer *timer_popupmenu_tree_vboxcontainer_createnamepopup = memnew(Timer);
timer_popupmenu_tree_vboxcontainer_createnamepopup->set_name("Timer");
popupmenu_tree_vboxcontainer_createnamepopup->add_child(timer_popupmenu_tree_vboxcontainer_createnamepopup);
timer_popupmenu_tree_vboxcontainer_createnamepopup->set_name("Timer");
timer_popupmenu_tree_vboxcontainer_createnamepopup->set_wait_time(0.3);
timer_popupmenu_tree_vboxcontainer_createnamepopup->set_one_shot(True);
LineEdit *lineedit_tree_vboxcontainer_createnamepopup = memnew(LineEdit);
lineedit_tree_vboxcontainer_createnamepopup->set_name("LineEdit");
tree_vboxcontainer_createnamepopup->add_child(lineedit_tree_vboxcontainer_createnamepopup);
lineedit_tree_vboxcontainer_createnamepopup->set_name("LineEdit");
lineedit_tree_vboxcontainer_createnamepopup->set_visible(False);
Timer *timer_lineedit_tree_vboxcontainer_createnamepopup = memnew(Timer);
timer_lineedit_tree_vboxcontainer_createnamepopup->set_name("Timer");
lineedit_tree_vboxcontainer_createnamepopup->add_child(timer_lineedit_tree_vboxcontainer_createnamepopup);
timer_lineedit_tree_vboxcontainer_createnamepopup->set_name("Timer");
timer_lineedit_tree_vboxcontainer_createnamepopup->set_wait_time(0.65);
PopupMenu *popupmenu_lineedit_tree_vboxcontainer_createnamepopup = memnew(PopupMenu);
popupmenu_lineedit_tree_vboxcontainer_createnamepopup->set_name("PopupMenu");
lineedit_tree_vboxcontainer_createnamepopup->add_child(popupmenu_lineedit_tree_vboxcontainer_createnamepopup);
popupmenu_lineedit_tree_vboxcontainer_createnamepopup->set_name("PopupMenu");
//popupmenu_lineedit_tree_vboxcontainer_createnamepopup property items TYPE_ARRAY value: [Cut, [Object:null], 0, False, False, 0, 268435544, Null, , False, Copy, [Object:null], 0, False, False, 1, 268435523, Null, , False, Paste, [Object:null], 0, False, False, 2, 268435542, Null, , False, , [Object:null], 0, False, False, -1, 0, Null, , True, Select All, [Object:null], 0, False, False, 4, 268435521, Null, , False, Clear, [Object:null], 0, False, False, 3, 0, Null, , False, , [Object:null], 0, False, False, -1, 0, Null, , True, Undo, [Object:null], 0, False, False, 5, 268435546, Null, , False, Redo, [Object:null], 0, False, False, 6, 301989978, Null, , False]
Timer *timer_popupmenu_lineedit_tree_vboxcontainer_createnamepopup = memnew(Timer);
timer_popupmenu_lineedit_tree_vboxcontainer_createnamepopup->set_name("Timer");
popupmenu_lineedit_tree_vboxcontainer_createnamepopup->add_child(timer_popupmenu_lineedit_tree_vboxcontainer_createnamepopup);
timer_popupmenu_lineedit_tree_vboxcontainer_createnamepopup->set_name("Timer");
timer_popupmenu_lineedit_tree_vboxcontainer_createnamepopup->set_wait_time(0.3);
timer_popupmenu_lineedit_tree_vboxcontainer_createnamepopup->set_one_shot(True);
HSlider *hslider_tree_vboxcontainer_createnamepopup = memnew(HSlider);
hslider_tree_vboxcontainer_createnamepopup->set_name("HSlider");
tree_vboxcontainer_createnamepopup->add_child(hslider_tree_vboxcontainer_createnamepopup);
hslider_tree_vboxcontainer_createnamepopup->set_name("HSlider");
hslider_tree_vboxcontainer_createnamepopup->set_visible(False);
HScrollBar *hscrollbar_tree_vboxcontainer_createnamepopup = memnew(HScrollBar);
hscrollbar_tree_vboxcontainer_createnamepopup->set_name("HScrollBar");
tree_vboxcontainer_createnamepopup->add_child(hscrollbar_tree_vboxcontainer_createnamepopup);
hscrollbar_tree_vboxcontainer_createnamepopup->set_name("HScrollBar");
VScrollBar *vscrollbar_tree_vboxcontainer_createnamepopup = memnew(VScrollBar);
vscrollbar_tree_vboxcontainer_createnamepopup->set_name("VScrollBar");
tree_vboxcontainer_createnamepopup->add_child(vscrollbar_tree_vboxcontainer_createnamepopup);
vscrollbar_tree_vboxcontainer_createnamepopup->set_name("VScrollBar");
vscrollbar_tree_vboxcontainer_createnamepopup->set_custom_step(14);
Timer *timer_tree_vboxcontainer_createnamepopup = memnew(Timer);
timer_tree_vboxcontainer_createnamepopup->set_name("Timer");
tree_vboxcontainer_createnamepopup->add_child(timer_tree_vboxcontainer_createnamepopup);
timer_tree_vboxcontainer_createnamepopup->set_name("Timer");
Label *label_vboxcontainer_createnamepopup = memnew(Label);
label_vboxcontainer_createnamepopup->set_name("Label");
vboxcontainer_createnamepopup->add_child(label_vboxcontainer_createnamepopup);
label_vboxcontainer_createnamepopup->set_name("Label");
//label_vboxcontainer_createnamepopup property owner TYPE_OBJECT value: CreateNamePopup:[ConfirmationDialog:280461]
label_vboxcontainer_createnamepopup->set_visible(False);
label_vboxcontainer_createnamepopup->set_margin_top(354);
label_vboxcontainer_createnamepopup->set_margin_right(475);
label_vboxcontainer_createnamepopup->set_margin_bottom(368);
label_vboxcontainer_createnamepopup->set_rect_position(Vector2(0, 354));
label_vboxcontainer_createnamepopup->set_rect_global_position(Vector2(0, 354));
label_vboxcontainer_createnamepopup->set_rect_size(Vector2(475, 14));
label_vboxcontainer_createnamepopup->set_size_flags_horizontal(3);
label_vboxcontainer_createnamepopup->set_text("Name");
LineEdit *lineedit_vboxcontainer_createnamepopup = memnew(LineEdit);
lineedit_vboxcontainer_createnamepopup->set_name("LineEdit");
vboxcontainer_createnamepopup->add_child(lineedit_vboxcontainer_createnamepopup);
lineedit_vboxcontainer_createnamepopup->set_name("LineEdit");
//lineedit_vboxcontainer_createnamepopup property owner TYPE_OBJECT value: CreateNamePopup:[ConfirmationDialog:280461]
lineedit_vboxcontainer_createnamepopup->set_visible(False);
lineedit_vboxcontainer_createnamepopup->set_margin_top(372);
lineedit_vboxcontainer_createnamepopup->set_margin_right(475);
lineedit_vboxcontainer_createnamepopup->set_margin_bottom(396);
lineedit_vboxcontainer_createnamepopup->set_rect_position(Vector2(0, 372));
lineedit_vboxcontainer_createnamepopup->set_rect_global_position(Vector2(0, 372));
lineedit_vboxcontainer_createnamepopup->set_rect_size(Vector2(475, 24));
lineedit_vboxcontainer_createnamepopup->set_size_flags_horizontal(3);
lineedit_vboxcontainer_createnamepopup->set_caret_blink(True);
Timer *timer_lineedit_vboxcontainer_createnamepopup = memnew(Timer);
timer_lineedit_vboxcontainer_createnamepopup->set_name("Timer");
lineedit_vboxcontainer_createnamepopup->add_child(timer_lineedit_vboxcontainer_createnamepopup);
timer_lineedit_vboxcontainer_createnamepopup->set_name("Timer");
timer_lineedit_vboxcontainer_createnamepopup->set_wait_time(0.65);
PopupMenu *popupmenu_lineedit_vboxcontainer_createnamepopup = memnew(PopupMenu);
popupmenu_lineedit_vboxcontainer_createnamepopup->set_name("PopupMenu");
lineedit_vboxcontainer_createnamepopup->add_child(popupmenu_lineedit_vboxcontainer_createnamepopup);
popupmenu_lineedit_vboxcontainer_createnamepopup->set_name("PopupMenu");
//popupmenu_lineedit_vboxcontainer_createnamepopup property items TYPE_ARRAY value: [Cut, [Object:null], 0, False, False, 0, 268435544, Null, , False, Copy, [Object:null], 0, False, False, 1, 268435523, Null, , False, Paste, [Object:null], 0, False, False, 2, 268435542, Null, , False, , [Object:null], 0, False, False, -1, 0, Null, , True, Select All, [Object:null], 0, False, False, 4, 268435521, Null, , False, Clear, [Object:null], 0, False, False, 3, 0, Null, , False, , [Object:null], 0, False, False, -1, 0, Null, , True, Undo, [Object:null], 0, False, False, 5, 268435546, Null, , False, Redo, [Object:null], 0, False, False, 6, 301989978, Null, , False]
Timer *timer_popupmenu_lineedit_vboxcontainer_createnamepopup = memnew(Timer);
timer_popupmenu_lineedit_vboxcontainer_createnamepopup->set_name("Timer");
popupmenu_lineedit_vboxcontainer_createnamepopup->add_child(timer_popupmenu_lineedit_vboxcontainer_createnamepopup);
timer_popupmenu_lineedit_vboxcontainer_createnamepopup->set_name("Timer");
timer_popupmenu_lineedit_vboxcontainer_createnamepopup->set_wait_time(0.3);
timer_popupmenu_lineedit_vboxcontainer_createnamepopup->set_one_shot(True);
}
CreateNamePopup::~CreateNamePopup() {
}
static void CreateNamePopup::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_line_edit_path"), &CreateNamePopup::get_line_edit_path);
ClassDB::bind_method(D_METHOD("set_line_edit_path", "value"), &CreateNamePopup::set_line_edit_path);
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "line_edit_path"), "set_line_edit_path", "get_line_edit_path");
ClassDB::bind_method(D_METHOD("get_tree_path"), &CreateNamePopup::get_tree_path);
ClassDB::bind_method(D_METHOD("set_tree_path", "value"), &CreateNamePopup::set_tree_path);
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "tree_path"), "set_tree_path", "get_tree_path");
ClassDB::bind_method(D_METHOD("get_type_folders"), &CreateNamePopup::get_type_folders);
ClassDB::bind_method(D_METHOD("set_type_folders", "value"), &CreateNamePopup::set_type_folders);
ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "type_folders"), "set_type_folders", "get_type_folders");
ClassDB::bind_method(D_METHOD("get__resource_type"), &CreateNamePopup::get__resource_type);
ClassDB::bind_method(D_METHOD("set__resource_type", "value"), &CreateNamePopup::set__resource_type);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "_resource_type"), "set__resource_type", "get__resource_type");
ClassDB::bind_method(D_METHOD("get_*_line_edit"), &CreateNamePopup::get_ * _line_edit);
ClassDB::bind_method(D_METHOD("set_*_line_edit", "value"), &CreateNamePopup::set_ * _line_edit);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_line_edit", PROPERTY_HINT_RESOURCE_TYPE, "LineEdit"), "set_*_line_edit", "get_*_line_edit");
ClassDB::bind_method(D_METHOD("get_*_tree"), &CreateNamePopup::get_ * _tree);
ClassDB::bind_method(D_METHOD("set_*_tree", "value"), &CreateNamePopup::set_ * _tree);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_tree", PROPERTY_HINT_RESOURCE_TYPE, "Tree"), "set_*_tree", "get_*_tree");
ClassDB::bind_method(D_METHOD("_ready"), &CreateNamePopup::_ready);
ClassDB::bind_method(D_METHOD("set_resource_type", "resource_type"), &CreateNamePopup::set_resource_type);
ClassDB::bind_method(D_METHOD("about_to_show"), &CreateNamePopup::about_to_show);
ClassDB::bind_method(D_METHOD("evaluate_folder", "folder", "root"), &CreateNamePopup::evaluate_folder);
ClassDB::bind_method(D_METHOD("_on_OK_pressed"), &CreateNamePopup::_on_OK_pressed);
}

View File

@ -0,0 +1,51 @@
#ifndef CREATENAMEPOPUP_H
#define CREATENAMEPOPUP_H
class CreateNamePopup : public ConfirmationDialog {
GDCLASS(CreateNamePopup, ConfirmationDialog);
public:
NodePath get_line_edit_path();
void set_line_edit_path(const NodePath &val);
NodePath get_tree_path();
void set_tree_path(const NodePath &val);
PoolStringArray get_type_folders();
void set_type_folders(const PoolStringArray &val);
String get__resource_type();
void set__resource_type(const String &val);
LineEdit get_ *_line_edit();
void set_ *_line_edit(const LineEdit &val);
Tree get_ *_tree();
void set_ *_tree(const Tree &val);
void _ready();
void set_resource_type(const String &resource_type);
void about_to_show();
void evaluate_folder(const String &folder, const TreeItem &root);
void _on_OK_pressed();
CreateNamePopup();
~CreateNamePopup();
protected:
static void _bind_methods();
//tool
signal ok_pressed;
//export(NodePath)
NodePath line_edit_path = ;
//export(NodePath)
NodePath tree_path = ;
//export(PoolStringArray)
PoolStringArray type_folders = ;
String _resource_type = "MMNode";
LineEdit *_line_edit;
Tree *_tree;
};
#endif

View File

@ -0,0 +1,689 @@
#include "matmakergdeditor.h"
Variant MatMakerGDEditor::get_Variant() {
return Variant;
}
void MatMakerGDEditor::set_Variant(const Variant &val) {
Variant = val;
}
NodePath MatMakerGDEditor::get_graph_edit_path() {
return graph_edit_path;
}
void MatMakerGDEditor::set_graph_edit_path(const NodePath &val) {
graph_edit_path = val;
}
NodePath MatMakerGDEditor::get_add_popup_path() {
return add_popup_path;
}
void MatMakerGDEditor::set_add_popup_path(const NodePath &val) {
add_popup_path = val;
}
GraphEdit MatMakerGDEditor::get_ *_graph_edit() {
return *_graph_edit;
}
void MatMakerGDEditor::set_ *_graph_edit(const GraphEdit &val) {
*_graph_edit = val;
}
MMMateial MatMakerGDEditor::get_ *_material() {
return *_material;
}
void MatMakerGDEditor::set_ *_material(const MMMateial &val) {
*_material = val;
}
int MatMakerGDEditor::get__ignore_material_change_event() const {
return _ignore_material_change_event;
}
void MatMakerGDEditor::set__ignore_material_change_event(const int val) {
_ignore_material_change_event = val;
}
bool MatMakerGDEditor::get__recreation_in_progress() const {
return _recreation_in_progress;
}
void MatMakerGDEditor::set__recreation_in_progress(const bool val) {
_recreation_in_progress = val;
}
EditorPlugin MatMakerGDEditor::get_ *_plugin() {
return *_plugin;
}
void MatMakerGDEditor::set_ *_plugin(const EditorPlugin &val) {
*_plugin = val;
}
UndoRedo MatMakerGDEditor::get_ *_undo_redo() {
return *_undo_redo;
}
void MatMakerGDEditor::set_ *_undo_redo(const UndoRedo &val) {
*_undo_redo = val;
}
//tool;
//var MMGraphNode = preload("res://addons/mat_maker_gd/editor/mm_graph_node.gd");
//export(NodePath) ;
NodePath graph_edit_path = "VBoxContainer/GraphEdit";
//export(NodePath) ;
NodePath add_popup_path = "Popups/AddPopup";
GraphEdit *_graph_edit = null;
MMMateial *_material;
int _ignore_material_change_event = 0;
bool _recreation_in_progress = false;
EditorPlugin *_plugin = null;
UndoRedo *_undo_redo = null;
void MatMakerGDEditor::_enter_tree() {
ensure_objs();
}
void MatMakerGDEditor::set_plugin(const EditorPlugin &plugin) {
_plugin = plugin;
_undo_redo = plugin.get_undo_redo();
}
UndoRedo MatMakerGDEditor::get_undo_redo() {
return _undo_redo;
}
void MatMakerGDEditor::ensure_objs() {
if (!_graph_edit) {
_graph_edit = get_node(graph_edit_path);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_INT, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR3, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_COLOR, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_INT);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR3);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_COLOR);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_INT, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_INT);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR3, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR3);
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_COLOR, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_COLOR);
_graph_edit.connect("connection_request", self, "on_graph_edit_connection_request");
_graph_edit.connect("disconnection_request", self, "on_graph_edit_disconnection_request");
}
}
void MatMakerGDEditor::recreate() {
ignore_changes(true);
if (_recreation_in_progress) {
return;
}
_recreation_in_progress = true;
ensure_objs();
_graph_edit.clear_connections();
for (c in _graph_edit.get_children()) {
if (c is GraphNode) {
_graph_edit.remove_child(c);
c.queue_free();
}
}
if (!_material) {
return;
}
_material.cancel_render_and_wait();
for (n in _material.nodes) {
GraphNode *gn = MMGraphNode.new();
gn.set_editor(self);
gn.set_node(_material, n);
_graph_edit.add_child(gn);
}
//connect them;
for (n in _material.nodes) {
if (n) {
for (ip in n.input_properties) {
if (ip.input_property) {
Node *input_node = find_graph_node_for(n);
Node *output_node = find_graph_node_for(ip.input_property.owner);
int to_slot = input_node.get_input_property_graph_node_slot_index(ip);
int from_slot = output_node.get_output_property_graph_node_slot_index(ip.input_property);
_graph_edit.connect_node(output_node.name, from_slot, input_node.name, to_slot);
}
}
}
}
_material.render();
_recreation_in_progress = false;
ignore_changes(false);
}
Node MatMakerGDEditor::find_graph_node_for(const Variant &nnode) {
for (c in _graph_edit.get_children()) {
if (c is GraphNode) {
if (c.has_method("get_material_node")) {
Variant = c.get_material_node();
if (n == nnode) {
return c;
}
}
}
}
return null;
}
void MatMakerGDEditor::set_mmmaterial(const MMMateial &object) {
if (_material) {
_material.disconnect("changed", self, "on_material_changed");
}
_material = object;
recreate();
if (_material) {
_material.connect("changed", self, "on_material_changed");
}
}
void MatMakerGDEditor::on_material_changed() {
if (_ignore_material_change_event > 0) {
return;
}
if (_recreation_in_progress) {
return;
}
call_deferred("recreate");
}
void MatMakerGDEditor::ignore_changes(const bool val) {
if (val) {
_ignore_material_change_event += 1;
}
else {
_ignore_material_change_event -= 1;
}
}
void MatMakerGDEditor::on_graph_edit_connection_request(const String &from, const int from_slot, const String &to, const int to_slot) {
GraphNode *from_node = _graph_edit.get_node(from);
GraphNode *to_node = _graph_edit.get_node(to);
ignore_changes(true);
_material.cancel_render_and_wait();
if (from_node.connect_slot(from_slot, to_node, to_slot)) {
_graph_edit.connect_node(from, from_slot, to, to_slot);
}
ignore_changes(false);
}
void MatMakerGDEditor::on_graph_edit_disconnection_request(const String &from, const int from_slot, const String &to, const int to_slot) {
GraphNode *from_node = _graph_edit.get_node(from);
GraphNode *to_node = _graph_edit.get_node(to);
ignore_changes(true);
_material.cancel_render_and_wait();
if (from_node.disconnect_slot(from_slot, to_node, to_slot)) {
_graph_edit.disconnect_node(from, from_slot, to, to_slot);
}
ignore_changes(false);
}
void MatMakerGDEditor::on_graph_node_close_request(const GraphNode &node) {
if (_material) {
ignore_changes(true);
_material.cancel_render_and_wait();
//_material.remove_node(node._node);
_undo_redo.create_action("MMGD: Remove Node");
_undo_redo.add_do_method(_material, "remove_node", node._node);
_undo_redo.add_undo_method(_material, "add_node", node._node);
_undo_redo.commit_action();
recreate();
ignore_changes(false);
}
}
void MatMakerGDEditor::_on_AddButton_pressed() {
get_node(add_popup_path).popup_centered();
}
void MatMakerGDEditor::_on_AddPopup_ok_pressed(const String &script_path) {
if (!_material) {
return;
}
ensure_objs();
_material.cancel_render_and_wait();
Variant = load(script_path);
MMNode *nnode = sc.new();
if (!nnode) {
print("_on_AddPopup_ok_pressed: Error !nnode! script: " + script_path);
return;
}
ignore_changes(true);
//_material.add_node(nnode);
_undo_redo.create_action("MMGD: Add Node");
_undo_redo.add_do_method(_material, "add_node", nnode);
_undo_redo.add_undo_method(_material, "remove_node", nnode);
_undo_redo.commit_action();
GraphNode *gn = MMGraphNode.new();
gn.set_editor(self);
gn.set_node(_material, nnode);
_graph_edit.add_child(gn);
ignore_changes(false);
}
}
MatMakerGDEditor::MatMakerGDEditor() {
//var MMGraphNode = preload("res://addons/mat_maker_gd/editor/mm_graph_node.gd");
graph_edit_path = "VBoxContainer/GraphEdit";
add_popup_path = "Popups/AddPopup";
*_graph_edit = null;
*_material;
_ignore_material_change_event = 0;
_recreation_in_progress = false;
*_plugin = null;
*_undo_redo = null;
//Script: res://addons/mat_maker_gd/editor/MatMakerGDEditor.gd
MarginContainer *matmakergdeditor = memnew(MarginContainer);
matmakergdeditor->set_name("MatMakerGDEditor");
matmakergdeditor->set_name("MatMakerGDEditor");
matmakergdeditor->set_filename("res://addons/mat_maker_gd/editor/MatMakerGDEditor.tscn");
matmakergdeditor->set_anchor_right(1);
matmakergdeditor->set_anchor_bottom(1);
matmakergdeditor->set_rect_min_size(Vector2(0, 200));
matmakergdeditor->set_size_flags_horizontal(3);
matmakergdeditor->set_size_flags_vertical(3);
VBoxContainer *vboxcontainer_matmakergdeditor = memnew(VBoxContainer);
vboxcontainer_matmakergdeditor->set_name("VBoxContainer");
matmakergdeditor->add_child(vboxcontainer_matmakergdeditor);
vboxcontainer_matmakergdeditor->set_name("VBoxContainer");
//vboxcontainer_matmakergdeditor property owner TYPE_OBJECT value: MatMakerGDEditor:[MarginContainer:280327]
vboxcontainer_matmakergdeditor->set_margin_right(1024);
vboxcontainer_matmakergdeditor->set_margin_bottom(600);
vboxcontainer_matmakergdeditor->set_rect_size(Vector2(1024, 600));
PanelContainer *panelcontainer_vboxcontainer_matmakergdeditor = memnew(PanelContainer);
panelcontainer_vboxcontainer_matmakergdeditor->set_name("PanelContainer");
vboxcontainer_matmakergdeditor->add_child(panelcontainer_vboxcontainer_matmakergdeditor);
panelcontainer_vboxcontainer_matmakergdeditor->set_name("PanelContainer");
//panelcontainer_vboxcontainer_matmakergdeditor property owner TYPE_OBJECT value: MatMakerGDEditor:[MarginContainer:280327]
panelcontainer_vboxcontainer_matmakergdeditor->set_margin_right(1024);
panelcontainer_vboxcontainer_matmakergdeditor->set_margin_bottom(34);
panelcontainer_vboxcontainer_matmakergdeditor->set_rect_size(Vector2(1024, 34));
HBoxContainer *hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor = memnew(HBoxContainer);
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_name("HBoxContainer");
panelcontainer_vboxcontainer_matmakergdeditor->add_child(hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor);
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_name("HBoxContainer");
//hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor property owner TYPE_OBJECT value: MatMakerGDEditor:[MarginContainer:280327]
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_margin_left(7);
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_margin_top(7);
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_margin_right(1017);
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_margin_bottom(27);
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_rect_position(Vector2(7, 7));
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_rect_global_position(Vector2(7, 7));
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_rect_size(Vector2(1010, 20));
Button *addbutton_hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor = memnew(Button);
addbutton_hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_name("AddButton");
hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->add_child(addbutton_hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor);
addbutton_hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_name("AddButton");
//addbutton_hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor property owner TYPE_OBJECT value: MatMakerGDEditor:[MarginContainer:280327]
addbutton_hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_margin_right(37);
addbutton_hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_margin_bottom(20);
addbutton_hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_rect_size(Vector2(37, 20));
addbutton_hboxcontainer_panelcontainer_vboxcontainer_matmakergdeditor->set_text("Add");
GraphEdit *graphedit_vboxcontainer_matmakergdeditor = memnew(GraphEdit);
graphedit_vboxcontainer_matmakergdeditor->set_name("GraphEdit");
vboxcontainer_matmakergdeditor->add_child(graphedit_vboxcontainer_matmakergdeditor);
graphedit_vboxcontainer_matmakergdeditor->set_name("GraphEdit");
//graphedit_vboxcontainer_matmakergdeditor property owner TYPE_OBJECT value: MatMakerGDEditor:[MarginContainer:280327]
graphedit_vboxcontainer_matmakergdeditor->set_margin_top(38);
graphedit_vboxcontainer_matmakergdeditor->set_margin_right(1024);
graphedit_vboxcontainer_matmakergdeditor->set_margin_bottom(600);
graphedit_vboxcontainer_matmakergdeditor->set_rect_position(Vector2(0, 38));
graphedit_vboxcontainer_matmakergdeditor->set_rect_global_position(Vector2(0, 38));
graphedit_vboxcontainer_matmakergdeditor->set_rect_size(Vector2(1024, 562));
graphedit_vboxcontainer_matmakergdeditor->set_size_flags_horizontal(3);
graphedit_vboxcontainer_matmakergdeditor->set_size_flags_vertical(3);
graphedit_vboxcontainer_matmakergdeditor->set_right_disconnects(True);
graphedit_vboxcontainer_matmakergdeditor->set_scroll_offset(Vector2(0, -20));
GraphEditFilter *grapheditfilter_graphedit_vboxcontainer_matmakergdeditor = memnew(GraphEditFilter);
grapheditfilter_graphedit_vboxcontainer_matmakergdeditor->set_name("GraphEditFilter");
graphedit_vboxcontainer_matmakergdeditor->add_child(grapheditfilter_graphedit_vboxcontainer_matmakergdeditor);
Control *clayer_graphedit_vboxcontainer_matmakergdeditor = memnew(Control);
clayer_graphedit_vboxcontainer_matmakergdeditor->set_name("CLAYER");
graphedit_vboxcontainer_matmakergdeditor->add_child(clayer_graphedit_vboxcontainer_matmakergdeditor);
clayer_graphedit_vboxcontainer_matmakergdeditor->set_name("CLAYER");
clayer_graphedit_vboxcontainer_matmakergdeditor->set_mouse_filter(2);
Control *popups_matmakergdeditor = memnew(Control);
popups_matmakergdeditor->set_name("Popups");
matmakergdeditor->add_child(popups_matmakergdeditor);
popups_matmakergdeditor->set_name("Popups");
//popups_matmakergdeditor property owner TYPE_OBJECT value: MatMakerGDEditor:[MarginContainer:280327]
popups_matmakergdeditor->set_margin_right(1024);
popups_matmakergdeditor->set_margin_bottom(600);
popups_matmakergdeditor->set_rect_size(Vector2(1024, 600));
popups_matmakergdeditor->set_mouse_filter(2);
//Script: res://addons/mat_maker_gd/editor/CreateNamePopup.gd
ConfirmationDialog *addpopup_popups_matmakergdeditor = memnew(ConfirmationDialog);
addpopup_popups_matmakergdeditor->set_name("AddPopup");
popups_matmakergdeditor->add_child(addpopup_popups_matmakergdeditor);
addpopup_popups_matmakergdeditor->set_name("AddPopup");
addpopup_popups_matmakergdeditor->set_filename("res://addons/mat_maker_gd/editor/CreateNamePopup.tscn");
//addpopup_popups_matmakergdeditor property owner TYPE_OBJECT value: MatMakerGDEditor:[MarginContainer:280327]
addpopup_popups_matmakergdeditor->set_anchor_left(0.5);
addpopup_popups_matmakergdeditor->set_anchor_top(0.5);
addpopup_popups_matmakergdeditor->set_anchor_right(0.5);
addpopup_popups_matmakergdeditor->set_anchor_bottom(0.5);
addpopup_popups_matmakergdeditor->set_margin_left(-245.5);
addpopup_popups_matmakergdeditor->set_margin_top(-220);
addpopup_popups_matmakergdeditor->set_margin_right(245.5);
addpopup_popups_matmakergdeditor->set_margin_bottom(220);
addpopup_popups_matmakergdeditor->set_rect_position(Vector2(-245.5, -220));
addpopup_popups_matmakergdeditor->set_rect_global_position(Vector2(-245.5, -220));
addpopup_popups_matmakergdeditor->set_rect_size(Vector2(491, 440));
addpopup_popups_matmakergdeditor->set_window_title("Create New Resource");
//addpopup_popups_matmakergdeditor property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False}
//addpopup_popups_matmakergdeditor property line_edit_path TYPE_NODE_PATH value: VBoxContainer/LineEdit
//addpopup_popups_matmakergdeditor property tree_path TYPE_NODE_PATH value: VBoxContainer/Tree
//addpopup_popups_matmakergdeditor property type_folders TYPE_STRING_ARRAY value: [res://addons/mat_maker_gd/nodes/uniform, res://addons/mat_maker_gd/nodes/noise, res://addons/mat_maker_gd/nodes/filter, res://addons/mat_maker_gd/nodes/gradient, res://addons/mat_maker_gd/nodes/pattern, res://addons/mat_maker_gd/nodes/sdf2d, res://addons/mat_maker_gd/nodes/sdf3d, res://addons/mat_maker_gd/nodes/transform, res://addons/mat_maker_gd/nodes/simple, res://addons/mat_maker_gd/nodes/other]
TextureButton *texturebutton_addpopup_popups_matmakergdeditor = memnew(TextureButton);
texturebutton_addpopup_popups_matmakergdeditor->set_name("TextureButton");
addpopup_popups_matmakergdeditor->add_child(texturebutton_addpopup_popups_matmakergdeditor);
texturebutton_addpopup_popups_matmakergdeditor->set_name("TextureButton");
Label *label_addpopup_popups_matmakergdeditor = memnew(Label);
label_addpopup_popups_matmakergdeditor->set_name("Label");
addpopup_popups_matmakergdeditor->add_child(label_addpopup_popups_matmakergdeditor);
label_addpopup_popups_matmakergdeditor->set_name("Label");
label_addpopup_popups_matmakergdeditor->set_anchor_right(1);
label_addpopup_popups_matmakergdeditor->set_anchor_bottom(1);
label_addpopup_popups_matmakergdeditor->set_margin_left(8);
label_addpopup_popups_matmakergdeditor->set_margin_top(8);
label_addpopup_popups_matmakergdeditor->set_margin_right(-8);
label_addpopup_popups_matmakergdeditor->set_margin_bottom(-42);
label_addpopup_popups_matmakergdeditor->set_rect_position(Vector2(8, 8));
label_addpopup_popups_matmakergdeditor->set_rect_global_position(Vector2(8, 8));
label_addpopup_popups_matmakergdeditor->set_rect_size(Vector2(0, 14));
HBoxContainer *hboxcontainer_addpopup_popups_matmakergdeditor = memnew(HBoxContainer);
hboxcontainer_addpopup_popups_matmakergdeditor->set_name("HBoxContainer");
addpopup_popups_matmakergdeditor->add_child(hboxcontainer_addpopup_popups_matmakergdeditor);
hboxcontainer_addpopup_popups_matmakergdeditor->set_name("HBoxContainer");
Control *control3_hboxcontainer_addpopup_popups_matmakergdeditor = memnew(Control);
control3_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Control3");
hboxcontainer_addpopup_popups_matmakergdeditor->add_child(control3_hboxcontainer_addpopup_popups_matmakergdeditor);
control3_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Control3");
control3_hboxcontainer_addpopup_popups_matmakergdeditor->set_mouse_filter(1);
control3_hboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_horizontal(3);
Button *button2_hboxcontainer_addpopup_popups_matmakergdeditor = memnew(Button);
button2_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Button2");
hboxcontainer_addpopup_popups_matmakergdeditor->add_child(button2_hboxcontainer_addpopup_popups_matmakergdeditor);
button2_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Button2");
button2_hboxcontainer_addpopup_popups_matmakergdeditor->set_text("Cancel");
Control *control_hboxcontainer_addpopup_popups_matmakergdeditor = memnew(Control);
control_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Control");
hboxcontainer_addpopup_popups_matmakergdeditor->add_child(control_hboxcontainer_addpopup_popups_matmakergdeditor);
control_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Control");
control_hboxcontainer_addpopup_popups_matmakergdeditor->set_mouse_filter(1);
control_hboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_horizontal(3);
Button *button_hboxcontainer_addpopup_popups_matmakergdeditor = memnew(Button);
button_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Button");
hboxcontainer_addpopup_popups_matmakergdeditor->add_child(button_hboxcontainer_addpopup_popups_matmakergdeditor);
button_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Button");
button_hboxcontainer_addpopup_popups_matmakergdeditor->set_text("OK");
Control *control2_hboxcontainer_addpopup_popups_matmakergdeditor = memnew(Control);
control2_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Control2");
hboxcontainer_addpopup_popups_matmakergdeditor->add_child(control2_hboxcontainer_addpopup_popups_matmakergdeditor);
control2_hboxcontainer_addpopup_popups_matmakergdeditor->set_name("Control2");
control2_hboxcontainer_addpopup_popups_matmakergdeditor->set_mouse_filter(1);
control2_hboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_horizontal(3);
VBoxContainer *vboxcontainer_addpopup_popups_matmakergdeditor = memnew(VBoxContainer);
vboxcontainer_addpopup_popups_matmakergdeditor->set_name("VBoxContainer");
addpopup_popups_matmakergdeditor->add_child(vboxcontainer_addpopup_popups_matmakergdeditor);
vboxcontainer_addpopup_popups_matmakergdeditor->set_name("VBoxContainer");
//vboxcontainer_addpopup_popups_matmakergdeditor property owner TYPE_OBJECT value: AddPopup:[ConfirmationDialog:280352]
vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_left(8);
vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_top(8);
vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_right(483);
vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_bottom(404);
vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_position(Vector2(8, 8));
vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_global_position(Vector2(8, 8));
vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_size(Vector2(475, 396));
vboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_horizontal(3);
vboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_vertical(3);
//vboxcontainer_addpopup_popups_matmakergdeditor property __meta__ TYPE_DICTIONARY value: {_edit_use_anchors_:False}
Label *label2_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(Label);
label2_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Label2");
vboxcontainer_addpopup_popups_matmakergdeditor->add_child(label2_vboxcontainer_addpopup_popups_matmakergdeditor);
label2_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Label2");
//label2_vboxcontainer_addpopup_popups_matmakergdeditor property owner TYPE_OBJECT value: AddPopup:[ConfirmationDialog:280352]
label2_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_right(475);
label2_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_bottom(14);
label2_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_size(Vector2(475, 14));
label2_vboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_horizontal(3);
label2_vboxcontainer_addpopup_popups_matmakergdeditor->set_text("Type");
Tree *tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(Tree);
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Tree");
vboxcontainer_addpopup_popups_matmakergdeditor->add_child(tree_vboxcontainer_addpopup_popups_matmakergdeditor);
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Tree");
//tree_vboxcontainer_addpopup_popups_matmakergdeditor property owner TYPE_OBJECT value: AddPopup:[ConfirmationDialog:280352]
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_top(18);
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_right(475);
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_bottom(350);
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_position(Vector2(0, 18));
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_global_position(Vector2(0, 18));
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_size(Vector2(475, 332));
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_horizontal(3);
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_vertical(3);
tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_hide_root(True);
PopupMenu *popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(PopupMenu);
popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("PopupMenu");
tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("PopupMenu");
Timer *timer_popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(Timer);
timer_popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(timer_popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
timer_popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
timer_popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_wait_time(0.3);
timer_popupmenu_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_one_shot(True);
LineEdit *lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(LineEdit);
lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("LineEdit");
tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("LineEdit");
lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_visible(False);
Timer *timer_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(Timer);
timer_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(timer_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
timer_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
timer_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_wait_time(0.65);
PopupMenu *popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(PopupMenu);
popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("PopupMenu");
lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("PopupMenu");
//popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor property items TYPE_ARRAY value: [Cut, [Object:null], 0, False, False, 0, 268435544, Null, , False, Copy, [Object:null], 0, False, False, 1, 268435523, Null, , False, Paste, [Object:null], 0, False, False, 2, 268435542, Null, , False, , [Object:null], 0, False, False, -1, 0, Null, , True, Select All, [Object:null], 0, False, False, 4, 268435521, Null, , False, Clear, [Object:null], 0, False, False, 3, 0, Null, , False, , [Object:null], 0, False, False, -1, 0, Null, , True, Undo, [Object:null], 0, False, False, 5, 268435546, Null, , False, Redo, [Object:null], 0, False, False, 6, 301989978, Null, , False]
Timer *timer_popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(Timer);
timer_popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(timer_popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
timer_popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
timer_popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_wait_time(0.3);
timer_popupmenu_lineedit_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_one_shot(True);
HSlider *hslider_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(HSlider);
hslider_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("HSlider");
tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(hslider_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
hslider_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("HSlider");
hslider_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_visible(False);
HScrollBar *hscrollbar_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(HScrollBar);
hscrollbar_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("HScrollBar");
tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(hscrollbar_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
hscrollbar_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("HScrollBar");
VScrollBar *vscrollbar_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(VScrollBar);
vscrollbar_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("VScrollBar");
tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(vscrollbar_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
vscrollbar_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("VScrollBar");
vscrollbar_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_custom_step(14);
Timer *timer_tree_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(Timer);
timer_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
tree_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(timer_tree_vboxcontainer_addpopup_popups_matmakergdeditor);
timer_tree_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
Label *label_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(Label);
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Label");
vboxcontainer_addpopup_popups_matmakergdeditor->add_child(label_vboxcontainer_addpopup_popups_matmakergdeditor);
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Label");
//label_vboxcontainer_addpopup_popups_matmakergdeditor property owner TYPE_OBJECT value: AddPopup:[ConfirmationDialog:280352]
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_visible(False);
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_top(354);
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_right(475);
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_bottom(368);
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_position(Vector2(0, 354));
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_global_position(Vector2(0, 354));
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_size(Vector2(475, 14));
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_horizontal(3);
label_vboxcontainer_addpopup_popups_matmakergdeditor->set_text("Name");
LineEdit *lineedit_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(LineEdit);
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("LineEdit");
vboxcontainer_addpopup_popups_matmakergdeditor->add_child(lineedit_vboxcontainer_addpopup_popups_matmakergdeditor);
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("LineEdit");
//lineedit_vboxcontainer_addpopup_popups_matmakergdeditor property owner TYPE_OBJECT value: AddPopup:[ConfirmationDialog:280352]
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_visible(False);
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_top(372);
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_right(475);
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_margin_bottom(396);
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_position(Vector2(0, 372));
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_global_position(Vector2(0, 372));
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_rect_size(Vector2(475, 24));
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_size_flags_horizontal(3);
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_caret_blink(True);
Timer *timer_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(Timer);
timer_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(timer_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor);
timer_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
timer_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_wait_time(0.65);
PopupMenu *popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(PopupMenu);
popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("PopupMenu");
lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor);
popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("PopupMenu");
//popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor property items TYPE_ARRAY value: [Cut, [Object:null], 0, False, False, 0, 268435544, Null, , False, Copy, [Object:null], 0, False, False, 1, 268435523, Null, , False, Paste, [Object:null], 0, False, False, 2, 268435542, Null, , False, , [Object:null], 0, False, False, -1, 0, Null, , True, Select All, [Object:null], 0, False, False, 4, 268435521, Null, , False, Clear, [Object:null], 0, False, False, 3, 0, Null, , False, , [Object:null], 0, False, False, -1, 0, Null, , True, Undo, [Object:null], 0, False, False, 5, 268435546, Null, , False, Redo, [Object:null], 0, False, False, 6, 301989978, Null, , False]
Timer *timer_popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor = memnew(Timer);
timer_popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->add_child(timer_popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor);
timer_popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_name("Timer");
timer_popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_wait_time(0.3);
timer_popupmenu_lineedit_vboxcontainer_addpopup_popups_matmakergdeditor->set_one_shot(True);
}
MatMakerGDEditor::~MatMakerGDEditor() {
}
static void MatMakerGDEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_Variant"), &MatMakerGDEditor::get_Variant);
ClassDB::bind_method(D_METHOD("set_Variant", "value"), &MatMakerGDEditor::set_Variant);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant");
ClassDB::bind_method(D_METHOD("get_graph_edit_path"), &MatMakerGDEditor::get_graph_edit_path);
ClassDB::bind_method(D_METHOD("set_graph_edit_path", "value"), &MatMakerGDEditor::set_graph_edit_path);
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "graph_edit_path"), "set_graph_edit_path", "get_graph_edit_path");
ClassDB::bind_method(D_METHOD("get_add_popup_path"), &MatMakerGDEditor::get_add_popup_path);
ClassDB::bind_method(D_METHOD("set_add_popup_path", "value"), &MatMakerGDEditor::set_add_popup_path);
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "add_popup_path"), "set_add_popup_path", "get_add_popup_path");
ClassDB::bind_method(D_METHOD("get_*_graph_edit"), &MatMakerGDEditor::get_ * _graph_edit);
ClassDB::bind_method(D_METHOD("set_*_graph_edit", "value"), &MatMakerGDEditor::set_ * _graph_edit);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_graph_edit", PROPERTY_HINT_RESOURCE_TYPE, "GraphEdit"), "set_*_graph_edit", "get_*_graph_edit");
ClassDB::bind_method(D_METHOD("get_*_material"), &MatMakerGDEditor::get_ * _material);
ClassDB::bind_method(D_METHOD("set_*_material", "value"), &MatMakerGDEditor::set_ * _material);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_material", PROPERTY_HINT_RESOURCE_TYPE, "MMMateial"), "set_*_material", "get_*_material");
ClassDB::bind_method(D_METHOD("get__ignore_material_change_event"), &MatMakerGDEditor::get__ignore_material_change_event);
ClassDB::bind_method(D_METHOD("set__ignore_material_change_event", "value"), &MatMakerGDEditor::set__ignore_material_change_event);
ADD_PROPERTY(PropertyInfo(Variant::INT, "_ignore_material_change_event"), "set__ignore_material_change_event", "get__ignore_material_change_event");
ClassDB::bind_method(D_METHOD("get__recreation_in_progress"), &MatMakerGDEditor::get__recreation_in_progress);
ClassDB::bind_method(D_METHOD("set__recreation_in_progress", "value"), &MatMakerGDEditor::set__recreation_in_progress);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "_recreation_in_progress"), "set__recreation_in_progress", "get__recreation_in_progress");
ClassDB::bind_method(D_METHOD("get_*_plugin"), &MatMakerGDEditor::get_ * _plugin);
ClassDB::bind_method(D_METHOD("set_*_plugin", "value"), &MatMakerGDEditor::set_ * _plugin);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_plugin", PROPERTY_HINT_RESOURCE_TYPE, "EditorPlugin"), "set_*_plugin", "get_*_plugin");
ClassDB::bind_method(D_METHOD("get_*_undo_redo"), &MatMakerGDEditor::get_ * _undo_redo);
ClassDB::bind_method(D_METHOD("set_*_undo_redo", "value"), &MatMakerGDEditor::set_ * _undo_redo);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_undo_redo", PROPERTY_HINT_RESOURCE_TYPE, "UndoRedo"), "set_*_undo_redo", "get_*_undo_redo");
ClassDB::bind_method(D_METHOD("_enter_tree"), &MatMakerGDEditor::_enter_tree);
ClassDB::bind_method(D_METHOD("set_plugin", "plugin"), &MatMakerGDEditor::set_plugin);
ClassDB::bind_method(D_METHOD("get_undo_redo"), &MatMakerGDEditor::get_undo_redo);
ClassDB::bind_method(D_METHOD("ensure_objs"), &MatMakerGDEditor::ensure_objs);
ClassDB::bind_method(D_METHOD("recreate"), &MatMakerGDEditor::recreate);
ClassDB::bind_method(D_METHOD("find_graph_node_for", "nnode"), &MatMakerGDEditor::find_graph_node_for);
ClassDB::bind_method(D_METHOD("set_mmmaterial", "object"), &MatMakerGDEditor::set_mmmaterial);
ClassDB::bind_method(D_METHOD("on_material_changed"), &MatMakerGDEditor::on_material_changed);
ClassDB::bind_method(D_METHOD("ignore_changes", "val"), &MatMakerGDEditor::ignore_changes);
ClassDB::bind_method(D_METHOD("on_graph_edit_connection_request", "from", "from_slot", "to", "to_slot"), &MatMakerGDEditor::on_graph_edit_connection_request);
ClassDB::bind_method(D_METHOD("on_graph_edit_disconnection_request", "from", "from_slot", "to", "to_slot"), &MatMakerGDEditor::on_graph_edit_disconnection_request);
ClassDB::bind_method(D_METHOD("on_graph_node_close_request", "node"), &MatMakerGDEditor::on_graph_node_close_request);
ClassDB::bind_method(D_METHOD("_on_AddButton_pressed"), &MatMakerGDEditor::_on_AddButton_pressed);
ClassDB::bind_method(D_METHOD("_on_AddPopup_ok_pressed", "script_path"), &MatMakerGDEditor::_on_AddPopup_ok_pressed);
}

View File

@ -0,0 +1,73 @@
#ifndef MATMAKERGDEDITOR_H
#define MATMAKERGDEDITOR_H
class MatMakerGDEditor : public MarginContainer {
GDCLASS(MatMakerGDEditor, MarginContainer);
public:
Variant get_Variant();
void set_Variant(const Variant &val);
NodePath get_graph_edit_path();
void set_graph_edit_path(const NodePath &val);
NodePath get_add_popup_path();
void set_add_popup_path(const NodePath &val);
GraphEdit get_*_graph_edit();
void set_*_graph_edit(const GraphEdit &val);
MMMateial get_*_material();
void set_*_material(const MMMateial &val);
int get__ignore_material_change_event() const;
void set__ignore_material_change_event(const int val);
bool get__recreation_in_progress() const;
void set__recreation_in_progress(const bool val);
EditorPlugin get_*_plugin();
void set_*_plugin(const EditorPlugin &val);
UndoRedo get_*_undo_redo();
void set_*_undo_redo(const UndoRedo &val);
void _enter_tree();
void set_plugin(const EditorPlugin &plugin);
UndoRedo get_undo_redo();
void ensure_objs();
void recreate();
Node find_graph_node_for(const Variant &nnode);
void set_mmmaterial(const MMMateial &object);
void on_material_changed();
void ignore_changes(const bool val);
void on_graph_edit_connection_request(const String &from, const int from_slot, const String &to, const int to_slot);
void on_graph_edit_disconnection_request(const String &from, const int from_slot, const String &to, const int to_slot);
void on_graph_node_close_request(const GraphNode &node);
void _on_AddButton_pressed();
void _on_AddPopup_ok_pressed(const String &script_path);
MatMakerGDEditor();
~MatMakerGDEditor();
protected:
static void _bind_methods();
//tool
Variant = preload("res://addons/mat_maker_gd/editor/mm_graph_node.gd");
//export(NodePath)
NodePath graph_edit_path = "VBoxContainer/GraphEdit";
//export(NodePath)
NodePath add_popup_path = "Popups/AddPopup";
GraphEdit *_graph_edit = null;
MMMateial *_material;
int _ignore_material_change_event = 0;
bool _recreation_in_progress = false;
EditorPlugin *_plugin = null;
UndoRedo *_undo_redo = null;
};
#endif

View File

@ -0,0 +1,888 @@
#include "mm_graph_node.h"
Ref<PackedScene> MmGraphNode::get_gradient_editor_scene() {
return gradient_editor_scene;
}
void MmGraphNode::set_gradient_editor_scene(const Ref<PackedScene> &val) {
gradient_editor_scene = val;
}
Ref<PackedScene> MmGraphNode::get_polygon_edit_scene() {
return polygon_edit_scene;
}
void MmGraphNode::set_polygon_edit_scene(const Ref<PackedScene> &val) {
polygon_edit_scene = val;
}
Ref<PackedScene> MmGraphNode::get_curve_edit_scene() {
return curve_edit_scene;
}
void MmGraphNode::set_curve_edit_scene(const Ref<PackedScene> &val) {
curve_edit_scene = val;
}
MMMateial MmGraphNode::get_ *_material() {
return *_material;
}
void MmGraphNode::set_ *_material(const MMMateial &val) {
*_material = val;
}
MMNode MmGraphNode::get_ *_node() {
return *_node;
}
void MmGraphNode::set_ *_node(const MMNode &val) {
*_node = val;
}
Array MmGraphNode::get_properties() {
return properties;
}
void MmGraphNode::set_properties(const Array &val) {
properties = val;
}
Variant MmGraphNode::get_Variant() {
return Variant;
}
void MmGraphNode::set_Variant(const Variant &val) {
Variant = val;
}
UndoRedo MmGraphNode::get_ *_undo_redo() {
return *_undo_redo;
}
void MmGraphNode::set_ *_undo_redo(const UndoRedo &val) {
*_undo_redo = val;
}
bool MmGraphNode::get__ignore_change_event() const {
return _ignore_change_event;
}
void MmGraphNode::set__ignore_change_event(const bool val) {
_ignore_change_event = val;
}
//tool;
//var gradient_editor_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn");
//var polygon_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn");
//var curve_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/curve_edit/curve_edit.tscn");
MMMateial *_material = null;
MMNode *_node = null;
Array properties = Array();
Variant;
UndoRedo *_undo_redo = null;
bool _ignore_change_event = false;
void MmGraphNode::_init() {
show_close = true;
connect("dragged", self, "on_dragged");
connect("close_request", self, "on_close_request");
}
void MmGraphNode::set_editor(const Variant &editor_node) {
_editor_node = editor_node;
_undo_redo = _editor_node.get_undo_redo();
}
void MmGraphNode::ignore_changes(const bool val) {
_ignore_change_event = val;
_editor_node.ignore_changes(val);
}
int MmGraphNode::add_slot_texture(const String &getter, const String &setter) {
TextureRect *t = TextureRect.new();
t.rect_min_size = Vector2(128, 128);
t.expand = true;
t.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED;
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, t);
t.texture = _node.call(getter, _material, slot_idx);
properties[slot_idx].append(t.texture);
return slot_idx;
}
int MmGraphNode::add_slot_texture_universal(const MMNodeUniversalProperty &property) {
TextureRect *t = TextureRect.new();
t.rect_min_size = Vector2(128, 128);
t.expand = true;
t.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED;
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", t);
Ref<Image> img = property.get_active_image();
Ref<ImageTexture> tex = ImageTexture.new();
if (img) {
tex.create_from_image(img, 0);
}
t.texture = tex;
properties[slot_idx].append(property);
property.connect("changed", self, "on_universal_texture_changed", [slot_idx]);
return slot_idx;
}
int MmGraphNode::add_slot_image_path_universal(const MMNodeUniversalProperty &property, const String &getter, const String &setter) {
TextureButton *t = load("res://addons/mat_maker_gd/widgets/image_picker_button/image_picker_button.tscn").instance();
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", t);
properties[slot_idx].append(property);
properties[slot_idx].append(getter);
properties[slot_idx].append(setter);
property.connect("changed", self, "on_universal_texture_changed_image_picker", [slot_idx]);
t.connect("on_file_selected", self, "on_universal_image_path_changed", [slot_idx]);
t.call_deferred("do_set_image_path", _node.call(getter));
return slot_idx;
}
int MmGraphNode::add_slot_gradient() {
Control *ge = gradient_editor_scene.instance();
ge.graph_node = self;
ge.set_undo_redo(_undo_redo);
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, "", "", ge);
ge.set_value(_node);
//ge.texture = _node.call(getter, _material, slot_idx);
//properties[slot_idx].append(ge.texture);
return slot_idx;
}
int MmGraphNode::add_slot_polygon() {
Control *ge = polygon_edit_scene.instance();
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, "", "", ge);
ge.set_value(_node);
//ge.texture = _node.call(getter, _material, slot_idx);
//properties[slot_idx].append(ge.texture);
return slot_idx;
}
int MmGraphNode::add_slot_curve() {
Control *ge = curve_edit_scene.instance();
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, "", "", ge);
ge.set_value(_node);
//ge.texture = _node.call(getter, _material, slot_idx);
//properties[slot_idx].append(ge.texture);
return slot_idx;
}
int MmGraphNode::add_slot_color(const String &getter, const String &setter) {
ColorPickerButton *cp = ColorPickerButton.new();
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, cp);
cp.color = _node.call(getter);
cp.connect("color_changed", _node, setter);
return slot_idx;
}
int MmGraphNode::add_slot_color_universal(const MMNodeUniversalProperty &property) {
ColorPickerButton *cp = ColorPickerButton.new();
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", cp);
cp.color = property.get_default_value();
properties[slot_idx].append(property);
cp.connect("color_changed", self, "on_universal_color_changed", [slot_idx]);
return slot_idx;
}
int MmGraphNode::add_slot_label(const String &getter, const String &setter, const String &slot_name) {
Label *l = Label.new();
l.text = slot_name;
return add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, l);
}
int MmGraphNode::add_slot_line_edit(const String &getter, const String &setter, const String &slot_name, const String &placeholder) {
VBoxContainer *bc = VBoxContainer.new();
Label *l = Label.new();
l.text = slot_name;
bc.add_child(l);
LineEdit *le = LineEdit.new();
le.placeholder_text = placeholder;
bc.add_child(le);
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, bc);
le.text = _node.call(getter);
le.connect("text_entered", self, "on_slot_line_edit_text_entered", [slot_idx]);
return slot_idx;
}
int MmGraphNode::add_slot_enum(const String &getter, const String &setter, const String &slot_name, const Array &values) {
VBoxContainer *bc = VBoxContainer.new();
if (slot_name) {
Label *l = Label.new();
l.text = slot_name;
bc.add_child(l);
}
OptionButton *mb = OptionButton.new();
for (v in values) {
mb.add_item(v);
}
bc.add_child(mb);
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, bc);
mb.selected = _node.call(getter);
mb.connect("item_selected", self, "on_slot_enum_item_selected", [slot_idx]);
return slot_idx;
}
int MmGraphNode::add_slot_int(const String &getter, const String &setter, const String &slot_name, const Vector2 &prange, const Variant & 1000)) {
VBoxContainer *bc = VBoxContainer.new();
Label *l = Label.new();
l.text = slot_name;
bc.add_child(l);
SpinBox *sb = SpinBox.new();
sb.rounded = true;
sb.min_value = prange.x;
sb.max_value = prange.y;
bc.add_child(sb);
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, bc);
sb.value = _node.call(getter);
sb.connect("value_changed", self, "on_int_spinbox_value_changed", [slot_idx]);
return slot_idx;
}
int MmGraphNode::add_slot_bool(const String &getter, const String &setter, const String &slot_name) {
CheckBox *cb = CheckBox.new();
cb.text = slot_name;
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, cb);
cb.pressed = _node.call(getter);
cb.connect("toggled", _node, setter);
return slot_idx;
}
int MmGraphNode::add_slot_label_universal(const MMNodeUniversalProperty &property) {
Label *l = Label.new();
l.text = property.slot_name;
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", l);
properties[slot_idx].append(property);
return slot_idx;
}
int MmGraphNode::add_slot_int_universal(const MMNodeUniversalProperty &property) {
VBoxContainer *bc = VBoxContainer.new();
Label *l = Label.new();
l.text = property.slot_name;
bc.add_child(l);
SpinBox *sb = SpinBox.new();
sb.rounded = true;
sb.min_value = property.value_range.x;
sb.max_value = property.value_range.y;
bc.add_child(sb);
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", bc);
sb.value = property.get_default_value();
sb.connect("value_changed", self, "on_int_universal_spinbox_value_changed", [slot_idx]);
properties[slot_idx].append(property);
return slot_idx;
}
int MmGraphNode::add_slot_float(const String &getter, const String &setter, const String &slot_name, const float step, const Vector2 &prange, const Variant & 1000)) {
VBoxContainer *bc = VBoxContainer.new();
Label *l = Label.new();
l.text = slot_name;
bc.add_child(l);
SpinBox *sb = SpinBox.new();
bc.add_child(sb);
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, bc);
sb.rounded = false;
sb.step = step;
sb.min_value = prange.x;
sb.max_value = prange.y;
sb.value = _node.call(getter);
sb.connect("value_changed", self, "on_float_spinbox_value_changed", [slot_idx]);
return slot_idx;
}
int MmGraphNode::add_slot_float_universal(const MMNodeUniversalProperty &property) {
VBoxContainer *bc = VBoxContainer.new();
Label *l = Label.new();
l.text = property.slot_name;
bc.add_child(l);
SpinBox *sb = SpinBox.new();
bc.add_child(sb);
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", bc);
sb.rounded = false;
sb.step = property.value_step;
sb.min_value = property.value_range.x;
sb.max_value = property.value_range.y;
sb.value = property.get_default_value();
properties[slot_idx].append(property);
sb.connect("value_changed", self, "on_float_universal_spinbox_value_changed", [slot_idx]);
return slot_idx;
}
int MmGraphNode::add_slot_vector2(const String &getter, const String &setter, const String &slot_name, const float step, const Vector2 &prange, const Variant & 1000)) {
VBoxContainer *bc = VBoxContainer.new();
Label *l = Label.new();
l.text = slot_name;
bc.add_child(l);
SpinBox *sbx = SpinBox.new();
bc.add_child(sbx);
SpinBox *sby = SpinBox.new();
bc.add_child(sby);
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, bc);
sbx.rounded = false;
sby.rounded = false;
sbx.step = step;
sby.step = step;
sbx.min_value = prange.x;
sbx.max_value = prange.y;
sby.min_value = prange.x;
sby.max_value = prange.y;
Vector2 val = _node.call(getter);
sbx.value = val.x;
sby.value = val.y;
sbx.connect("value_changed", self, "on_vector2_spinbox_value_changed", [ slot_idx, sbx, sby ]);
sby.connect("value_changed", self, "on_vector2_spinbox_value_changed", [ slot_idx, sbx, sby ]);
return slot_idx;
}
int MmGraphNode::add_slot_vector3(const String &getter, const String &setter, const String &slot_name, const float step, const Vector2 &prange, const Variant & 1000)) {
VBoxContainer *bc = VBoxContainer.new();
Label *l = Label.new();
l.text = slot_name;
bc.add_child(l);
SpinBox *sbx = SpinBox.new();
bc.add_child(sbx);
SpinBox *sby = SpinBox.new();
bc.add_child(sby);
SpinBox *sbz = SpinBox.new();
bc.add_child(sbz);
int slot_idx = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, getter, setter, bc);
sbx.rounded = false;
sby.rounded = false;
sbz.rounded = false;
sbx.step = step;
sby.step = step;
sbz.step = step;
sbx.min_value = prange.x;
sbx.max_value = prange.y;
sby.min_value = prange.x;
sby.max_value = prange.y;
sbz.min_value = prange.x;
sbz.max_value = prange.y;
Vector3 val = _node.call(getter);
sbx.value = val.x;
sby.value = val.y;
sbz.value = val.z;
sbx.connect("value_changed", self, "on_vector3_spinbox_value_changed", [ slot_idx, sbx, sby, sbz ]);
sby.connect("value_changed", self, "on_vector3_spinbox_value_changed", [ slot_idx, sbx, sby, sbz ]);
sbz.connect("value_changed", self, "on_vector3_spinbox_value_changed", [ slot_idx, sbx, sby, sbz ]);
return slot_idx;
}
int MmGraphNode::add_slot_vector2_universal(const MMNodeUniversalProperty &property) {
VBoxContainer *bc = VBoxContainer.new();
Label *l = Label.new();
l.text = property.slot_name;
bc.add_child(l);
SpinBox *sbx = SpinBox.new();
bc.add_child(sbx);
SpinBox *sby = SpinBox.new();
bc.add_child(sby);
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", bc);
sbx.rounded = false;
sby.rounded = false;
sbx.step = property.value_step;
sby.step = property.value_step;
sbx.min_value = property.value_range.x;
sbx.max_value = property.value_range.y;
sby.min_value = property.value_range.x;
sby.max_value = property.value_range.y;
Vector2 val = property.get_default_value();
sbx.value = val.x;
sby.value = val.y;
properties[slot_idx].append(property);
sbx.connect("value_changed", self, "on_vector2_universal_spinbox_value_changed", [ slot_idx, sbx, sby ]);
sby.connect("value_changed", self, "on_vector2_universal_spinbox_value_changed", [ slot_idx, sbx, sby ]);
return slot_idx;
}
int MmGraphNode::add_slot(const int input_type, const int output_type, const String &getter, const String &setter, const Control &control) {
add_child(control);
int slot_idx = get_child_count() - 1;
Array arr = Array();
arr.append(slot_idx);
arr.append(input_type);
arr.append(output_type);
arr.append(getter);
arr.append(setter);
arr.append(control);
properties.append(arr);
set_slot_enabled_left(slot_idx, input_type != -1);
set_slot_enabled_right(slot_idx, output_type != -1);
if (input_type != -1) {
set_slot_type_left(slot_idx, input_type);
set_slot_color_left(slot_idx, get_slot_color(input_type));
}
if (output_type != -1) {
set_slot_type_left(slot_idx, output_type);
set_slot_color_right(slot_idx, get_slot_color(output_type));
}
return slot_idx;
}
bool MmGraphNode::connect_slot(const int slot_idx, const Node &to_node, const int to_slot_idx) {
int from_property_index = -1;
int to_property_index = -1;
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
if (properties[i][2] != -1) {
from_property_index += 1;
if (from_property_index == slot_idx) {
from_property_index = i;
break;
}
}
}
for (int i = 0; i < to_node.properties.size(); ++i) { //i in range(to_node.properties.size())
if (to_node.properties[i][1] != -1) {
to_property_index += 1;
if (to_property_index == to_slot_idx) {
to_property_index = i;
break;
}
//to_node.properties[to_property_index][6].set_input_property(properties[from_property_index][6]);
}
}
_undo_redo.create_action("MMGD: connect_slot");
_undo_redo.add_do_method(to_node.properties[to_property_index][6], "set_input_property", properties[from_property_index][6]);
_undo_redo.add_undo_method(to_node.properties[to_property_index][6], "set_input_property", to_node.properties[to_property_index][6].input_property);
_undo_redo.commit_action();
return true;
}
bool MmGraphNode::disconnect_slot(const int slot_idx, const Node &to_node, const int to_slot_idx) {
int from_property_index = -1;
int to_property_index = -1;
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
if (properties[i][2] != -1) {
from_property_index += 1;
if (from_property_index == slot_idx) {
from_property_index = i;
break;
}
}
}
for (int i = 0; i < to_node.properties.size(); ++i) { //i in range(to_node.properties.size())
if (to_node.properties[i][1] != -1) {
to_property_index += 1;
if (to_property_index == to_slot_idx) {
to_property_index = i;
break;
}
//to_node.properties[to_property_index][6].set_input_property(null);
}
}
_undo_redo.create_action("MMGD: disconnect_slot");
_undo_redo.add_do_method(to_node.properties[to_property_index][6], "unset_input_property");
_undo_redo.add_undo_method(to_node.properties[to_property_index][6], "set_input_property", to_node.properties[to_property_index][6].input_property);
_undo_redo.commit_action();
return true;
}
int MmGraphNode::get_input_property_graph_node_slot_index(const Variant &property) {
int property_index = -1;
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
if (properties[i][1] != -1) {
property_index += 1;
if (properties[i][6] == property) {
break;
}
}
}
return property_index;
}
int MmGraphNode::get_output_property_graph_node_slot_index(const Variant &property) {
int property_index = -1;
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
if (properties[i][2] != -1) {
property_index += 1;
if (properties[i][6] == property) {
break;
}
}
}
return property_index;
}
Node MmGraphNode::get_property_control(const int slot_idx) {
return properties[slot_idx][5];
}
void MmGraphNode::set_node(const MMMateial &material, const MMNode &node) {
_node = node;
_material = material;
if (!_node) {
return;
}
title = _node.get_class();
if (_node.get_script()) {
title = _node.get_script().resource_path.get_file().get_basename();
}
_node.register_methods(self);
offset = _node.get_graph_position();
}
//_node.connect("changed", self, "on_node_changed");
void MmGraphNode::propagate_node_change() {
pass;
}
void MmGraphNode::on_dragged(const Vector2 &from, const Vector2 &to) {
if (_node) {
ignore_changes(true);
//_node.set_graph_position(offset);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(_node, "set_graph_position", to);
_undo_redo.add_undo_method(_node, "set_graph_position", from);
_undo_redo.commit_action();
ignore_changes(false);
}
//func on_node_changed():;
// if _ignore_change_event:;
// return;
//;
// _ignore_change_event = true;
// propagate_node_change();
// _ignore_change_event = false;
}
void MmGraphNode::on_int_spinbox_value_changed(const float val, const Variant &slot_idx) {
//_node.call(properties[slot_idx][4], int(val));
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(_node, properties[slot_idx][4], int(val));
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_float_spinbox_value_changed(const float val, const Variant &slot_idx) {
//_node.call(properties[slot_idx][4], val);
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(_node, properties[slot_idx][4], val);
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_vector2_spinbox_value_changed(const float val, const Variant &slot_idx, const Variant &spinbox_x, const Variant &spinbox_y) {
Vector2 vv = Vector2(spinbox_x.value, spinbox_y.value);
//_node.call(properties[slot_idx][4], vv);
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(_node, properties[slot_idx][4], vv);
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_vector3_spinbox_value_changed(const float val, const Variant &slot_idx, const Variant &spinbox_x, const Variant &spinbox_y, const Variant &spinbox_z) {
Vector3 vv = Vector3(spinbox_x.value, spinbox_y.value, spinbox_z.value);
//_node.call(properties[slot_idx][4], vv);
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(_node, properties[slot_idx][4], vv);
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_int_universal_spinbox_value_changed(const float val, const Variant &slot_idx) {
//properties[slot_idx][6].set_default_value(int(val));
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", int(val));
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_float_universal_spinbox_value_changed(const float val, const Variant &slot_idx) {
//properties[slot_idx][6].set_default_value(val);
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", val);
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_vector2_universal_spinbox_value_changed(const float val, const Variant &slot_idx, const Variant &spinbox_x, const Variant &spinbox_y) {
Vector2 vv = Vector2(spinbox_x.value, spinbox_y.value);
//properties[slot_idx][6].set_default_value(vv);
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", vv);
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_slot_enum_item_selected(const int val, const int slot_idx) {
//_node.call(properties[slot_idx][4], val);
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(_node, properties[slot_idx][4], val);
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_universal_texture_changed(const int slot_idx) {
ignore_changes(true);
Ref<Image> img = properties[slot_idx][6].get_active_image();
Ref<ImageTexture> tex = properties[slot_idx][5].texture;
if (img) {
properties[slot_idx][5].texture.create_from_image(img, 0);
}
else {
properties[slot_idx][5].texture = ImageTexture.new();
}
ignore_changes(false);
}
void MmGraphNode::on_universal_texture_changed_image_picker(const int slot_idx) {
ignore_changes(true);
Ref<Image> img = properties[slot_idx][6].get_active_image();
Ref<ImageTexture> tex = properties[slot_idx][5].texture_normal;
if (img) {
properties[slot_idx][5].texture_normal.create_from_image(img, 0);
}
else {
properties[slot_idx][5].texture_normal = ImageTexture.new();
}
ignore_changes(false);
}
void MmGraphNode::on_slot_line_edit_text_entered(const String &text, const int slot_idx) {
//_node.call(properties[slot_idx][4], text);
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(_node, properties[slot_idx][4], text);
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_universal_color_changed(const Color &c, const int slot_idx) {
//properties[slot_idx][6].set_default_value(c);
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", c);
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
_undo_redo.commit_action();
ignore_changes(false);
}
void MmGraphNode::on_universal_image_path_changed(const String &f, const int slot_idx) {
_node.call(properties[slot_idx][8], f);
ignore_changes(true);
_undo_redo.create_action("MMGD: value changed");
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", f);
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
_undo_redo.commit_action();
ignore_changes(false);
}
MMNode MmGraphNode::get_material_node() {
return _node;
}
void MmGraphNode::on_close_request() {
Node *n = get_parent();
while (n) {
if (n.has_method("on_graph_node_close_request")) {
n.call_deferred("on_graph_node_close_request", self);
return;
}
n = n.get_parent();
}
}
Color MmGraphNode::get_slot_color(const int slot_type) {
return _get_slot_color(slot_type);
}
Color MmGraphNode::_get_slot_color(const int slot_type) {
if (slot_type == 0) {
return Color(0.91, 0.06, 0.06);
}
else if (slot_type == 1) {
return Color(0.43, 0.04, 0.04);
}
else if (slot_type == 2) {
return Color(0.83, 0.38, 0.38);
}
else if (slot_type == 3) {
return Color(0.04, 0.48, 0.43);
}
else if (slot_type == 4) {
return Color(0.35, 0.04, 0.34);
}
else if (slot_type == 5) {
return Color(0.04, 0.05, 1);
}
else if (slot_type == 6) {
return Color(0.37, 0.37, 0.37);
}
return Color(1, 1, 1, 1);
}
}
MmGraphNode::MmGraphNode() {
//var gradient_editor_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn");
//var polygon_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn");
//var curve_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/curve_edit/curve_edit.tscn");
*_material = null;
*_node = null;
properties = Array();
;
*_undo_redo = null;
_ignore_change_event = false;
}
MmGraphNode::~MmGraphNode() {
}
static void MmGraphNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_gradient_editor_scene"), &MmGraphNode::get_gradient_editor_scene);
ClassDB::bind_method(D_METHOD("set_gradient_editor_scene", "value"), &MmGraphNode::set_gradient_editor_scene);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gradient_editor_scene", PROPERTY_HINT_RESOURCE_TYPE, "Ref<PackedScene>"), "set_gradient_editor_scene", "get_gradient_editor_scene");
ClassDB::bind_method(D_METHOD("get_polygon_edit_scene"), &MmGraphNode::get_polygon_edit_scene);
ClassDB::bind_method(D_METHOD("set_polygon_edit_scene", "value"), &MmGraphNode::set_polygon_edit_scene);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "polygon_edit_scene", PROPERTY_HINT_RESOURCE_TYPE, "Ref<PackedScene>"), "set_polygon_edit_scene", "get_polygon_edit_scene");
ClassDB::bind_method(D_METHOD("get_curve_edit_scene"), &MmGraphNode::get_curve_edit_scene);
ClassDB::bind_method(D_METHOD("set_curve_edit_scene", "value"), &MmGraphNode::set_curve_edit_scene);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve_edit_scene", PROPERTY_HINT_RESOURCE_TYPE, "Ref<PackedScene>"), "set_curve_edit_scene", "get_curve_edit_scene");
ClassDB::bind_method(D_METHOD("get_*_material"), &MmGraphNode::get_ * _material);
ClassDB::bind_method(D_METHOD("set_*_material", "value"), &MmGraphNode::set_ * _material);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_material", PROPERTY_HINT_RESOURCE_TYPE, "MMMateial"), "set_*_material", "get_*_material");
ClassDB::bind_method(D_METHOD("get_*_node"), &MmGraphNode::get_ * _node);
ClassDB::bind_method(D_METHOD("set_*_node", "value"), &MmGraphNode::set_ * _node);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_node", PROPERTY_HINT_RESOURCE_TYPE, "MMNode"), "set_*_node", "get_*_node");
ClassDB::bind_method(D_METHOD("get_properties"), &MmGraphNode::get_properties);
ClassDB::bind_method(D_METHOD("set_properties", "value"), &MmGraphNode::set_properties);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "properties"), "set_properties", "get_properties");
ClassDB::bind_method(D_METHOD("get_Variant"), &MmGraphNode::get_Variant);
ClassDB::bind_method(D_METHOD("set_Variant", "value"), &MmGraphNode::set_Variant);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant");
ClassDB::bind_method(D_METHOD("get_*_undo_redo"), &MmGraphNode::get_ * _undo_redo);
ClassDB::bind_method(D_METHOD("set_*_undo_redo", "value"), &MmGraphNode::set_ * _undo_redo);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_undo_redo", PROPERTY_HINT_RESOURCE_TYPE, "UndoRedo"), "set_*_undo_redo", "get_*_undo_redo");
ClassDB::bind_method(D_METHOD("get__ignore_change_event"), &MmGraphNode::get__ignore_change_event);
ClassDB::bind_method(D_METHOD("set__ignore_change_event", "value"), &MmGraphNode::set__ignore_change_event);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "_ignore_change_event"), "set__ignore_change_event", "get__ignore_change_event");
ClassDB::bind_method(D_METHOD("_init"), &MmGraphNode::_init);
ClassDB::bind_method(D_METHOD("set_editor", "editor_node"), &MmGraphNode::set_editor);
ClassDB::bind_method(D_METHOD("ignore_changes", "val"), &MmGraphNode::ignore_changes);
ClassDB::bind_method(D_METHOD("add_slot_texture", "getter", "setter"), &MmGraphNode::add_slot_texture);
ClassDB::bind_method(D_METHOD("add_slot_texture_universal", "property"), &MmGraphNode::add_slot_texture_universal);
ClassDB::bind_method(D_METHOD("add_slot_image_path_universal", "property", "getter", "setter"), &MmGraphNode::add_slot_image_path_universal);
ClassDB::bind_method(D_METHOD("add_slot_gradient"), &MmGraphNode::add_slot_gradient);
ClassDB::bind_method(D_METHOD("add_slot_polygon"), &MmGraphNode::add_slot_polygon);
ClassDB::bind_method(D_METHOD("add_slot_curve"), &MmGraphNode::add_slot_curve);
ClassDB::bind_method(D_METHOD("add_slot_color", "getter", "setter"), &MmGraphNode::add_slot_color);
ClassDB::bind_method(D_METHOD("add_slot_color_universal", "property"), &MmGraphNode::add_slot_color_universal);
ClassDB::bind_method(D_METHOD("add_slot_label", "getter", "setter", "slot_name"), &MmGraphNode::add_slot_label);
ClassDB::bind_method(D_METHOD("add_slot_line_edit", "getter", "setter", "slot_name", "placeholder"), &MmGraphNode::add_slot_line_edit, "");
ClassDB::bind_method(D_METHOD("add_slot_enum", "getter", "setter", "slot_name", "values"), &MmGraphNode::add_slot_enum);
ClassDB::bind_method(D_METHOD("add_slot_int", "getter", "setter", "slot_name", "prange", " 1000)"), &MmGraphNode::add_slot_int, Vector2(-1000);
ClassDB::bind_method(D_METHOD("add_slot_bool", "getter", "setter", "slot_name"), &MmGraphNode::add_slot_bool);
ClassDB::bind_method(D_METHOD("add_slot_label_universal", "property"), &MmGraphNode::add_slot_label_universal);
ClassDB::bind_method(D_METHOD("add_slot_int_universal", "property"), &MmGraphNode::add_slot_int_universal);
ClassDB::bind_method(D_METHOD("add_slot_float", "getter", "setter", "slot_name", "step", "prange", " 1000)"), &MmGraphNode::add_slot_float, 0.1, Vector2(-1000);
ClassDB::bind_method(D_METHOD("add_slot_float_universal", "property"), &MmGraphNode::add_slot_float_universal);
ClassDB::bind_method(D_METHOD("add_slot_vector2", "getter", "setter", "slot_name", "step", "prange", " 1000)"), &MmGraphNode::add_slot_vector2, 0.1, Vector2(-1000);
ClassDB::bind_method(D_METHOD("add_slot_vector3", "getter", "setter", "slot_name", "step", "prange", " 1000)"), &MmGraphNode::add_slot_vector3, 0.1, Vector2(-1000);
ClassDB::bind_method(D_METHOD("add_slot_vector2_universal", "property"), &MmGraphNode::add_slot_vector2_universal);
ClassDB::bind_method(D_METHOD("add_slot", "input_type", "output_type", "getter", "setter", "control"), &MmGraphNode::add_slot);
ClassDB::bind_method(D_METHOD("connect_slot", "slot_idx", "to_node", "to_slot_idx"), &MmGraphNode::connect_slot);
ClassDB::bind_method(D_METHOD("disconnect_slot", "slot_idx", "to_node", "to_slot_idx"), &MmGraphNode::disconnect_slot);
ClassDB::bind_method(D_METHOD("get_input_property_graph_node_slot_index", "property"), &MmGraphNode::get_input_property_graph_node_slot_index);
ClassDB::bind_method(D_METHOD("get_output_property_graph_node_slot_index", "property"), &MmGraphNode::get_output_property_graph_node_slot_index);
ClassDB::bind_method(D_METHOD("get_property_control", "slot_idx"), &MmGraphNode::get_property_control);
ClassDB::bind_method(D_METHOD("set_node", "material", "node"), &MmGraphNode::set_node);
ClassDB::bind_method(D_METHOD("propagate_node_change"), &MmGraphNode::propagate_node_change);
ClassDB::bind_method(D_METHOD("on_dragged", "from", "to"), &MmGraphNode::on_dragged);
ClassDB::bind_method(D_METHOD("on_int_spinbox_value_changed", "val", " slot_idx"), &MmGraphNode::on_int_spinbox_value_changed);
ClassDB::bind_method(D_METHOD("on_float_spinbox_value_changed", "val", " slot_idx"), &MmGraphNode::on_float_spinbox_value_changed);
ClassDB::bind_method(D_METHOD("on_vector2_spinbox_value_changed", "val", " slot_idx", " spinbox_x", " spinbox_y"), &MmGraphNode::on_vector2_spinbox_value_changed);
ClassDB::bind_method(D_METHOD("on_vector3_spinbox_value_changed", "val", " slot_idx", " spinbox_x", " spinbox_y", " spinbox_z"), &MmGraphNode::on_vector3_spinbox_value_changed);
ClassDB::bind_method(D_METHOD("on_int_universal_spinbox_value_changed", "val", " slot_idx"), &MmGraphNode::on_int_universal_spinbox_value_changed);
ClassDB::bind_method(D_METHOD("on_float_universal_spinbox_value_changed", "val", " slot_idx"), &MmGraphNode::on_float_universal_spinbox_value_changed);
ClassDB::bind_method(D_METHOD("on_vector2_universal_spinbox_value_changed", "val", " slot_idx", " spinbox_x", " spinbox_y"), &MmGraphNode::on_vector2_universal_spinbox_value_changed);
ClassDB::bind_method(D_METHOD("on_slot_enum_item_selected", "val", "slot_idx"), &MmGraphNode::on_slot_enum_item_selected);
ClassDB::bind_method(D_METHOD("on_universal_texture_changed", "slot_idx"), &MmGraphNode::on_universal_texture_changed);
ClassDB::bind_method(D_METHOD("on_universal_texture_changed_image_picker", "slot_idx"), &MmGraphNode::on_universal_texture_changed_image_picker);
ClassDB::bind_method(D_METHOD("on_slot_line_edit_text_entered", "text", "slot_idx"), &MmGraphNode::on_slot_line_edit_text_entered);
ClassDB::bind_method(D_METHOD("on_universal_color_changed", "c", "slot_idx"), &MmGraphNode::on_universal_color_changed);
ClassDB::bind_method(D_METHOD("on_universal_image_path_changed", "f", "slot_idx"), &MmGraphNode::on_universal_image_path_changed);
ClassDB::bind_method(D_METHOD("get_material_node"), &MmGraphNode::get_material_node);
ClassDB::bind_method(D_METHOD("on_close_request"), &MmGraphNode::on_close_request);
ClassDB::bind_method(D_METHOD("get_slot_color", "slot_type"), &MmGraphNode::get_slot_color);
ClassDB::bind_method(D_METHOD("_get_slot_color", "slot_type"), &MmGraphNode::_get_slot_color);
}

View File

@ -0,0 +1,104 @@
#ifndef MM_GRAPH_NODE_H
#define MM_GRAPH_NODE_H
class MmGraphNode : public GraphNode {
GDCLASS(MmGraphNode, GraphNode);
public:
Ref<PackedScene> get_gradient_editor_scene();
void set_gradient_editor_scene(const Ref<PackedScene> &val);
Ref<PackedScene> get_polygon_edit_scene();
void set_polygon_edit_scene(const Ref<PackedScene> &val);
Ref<PackedScene> get_curve_edit_scene();
void set_curve_edit_scene(const Ref<PackedScene> &val);
MMMateial get_ *_material();
void set_ *_material(const MMMateial &val);
MMNode get_ *_node();
void set_ *_node(const MMNode &val);
Array get_properties();
void set_properties(const Array &val);
Variant get_Variant();
void set_Variant(const Variant &val);
UndoRedo get_ *_undo_redo();
void set_ *_undo_redo(const UndoRedo &val);
bool get__ignore_change_event() const;
void set__ignore_change_event(const bool val);
void _init();
void set_editor(const Variant &editor_node);
void ignore_changes(const bool val);
int add_slot_texture(const String &getter, const String &setter);
int add_slot_texture_universal(const MMNodeUniversalProperty &property);
int add_slot_image_path_universal(const MMNodeUniversalProperty &property, const String &getter, const String &setter);
int add_slot_gradient();
int add_slot_polygon();
int add_slot_curve();
int add_slot_color(const String &getter, const String &setter);
int add_slot_color_universal(const MMNodeUniversalProperty &property);
int add_slot_label(const String &getter, const String &setter, const String &slot_name);
int add_slot_line_edit(const String &getter, const String &setter, const String &slot_name, const String &placeholder = "");
int add_slot_enum(const String &getter, const String &setter, const String &slot_name, const Array &values);
int add_slot_int(const String &getter, const String &setter, const String &slot_name, const Vector2 &prange = Vector2(-1000, const Variant & 1000));
int add_slot_bool(const String &getter, const String &setter, const String &slot_name);
int add_slot_label_universal(const MMNodeUniversalProperty &property);
int add_slot_int_universal(const MMNodeUniversalProperty &property);
int add_slot_float(const String &getter, const String &setter, const String &slot_name, const float step = 0.1, const Vector2 &prange = Vector2(-1000, const Variant & 1000));
int add_slot_float_universal(const MMNodeUniversalProperty &property);
int add_slot_vector2(const String &getter, const String &setter, const String &slot_name, const float step = 0.1, const Vector2 &prange = Vector2(-1000, const Variant & 1000));
int add_slot_vector3(const String &getter, const String &setter, const String &slot_name, const float step = 0.1, const Vector2 &prange = Vector2(-1000, const Variant & 1000));
int add_slot_vector2_universal(const MMNodeUniversalProperty &property);
int add_slot(const int input_type, const int output_type, const String &getter, const String &setter, const Control &control);
bool connect_slot(const int slot_idx, const Node &to_node, const int to_slot_idx);
bool disconnect_slot(const int slot_idx, const Node &to_node, const int to_slot_idx);
int get_input_property_graph_node_slot_index(const Variant &property);
int get_output_property_graph_node_slot_index(const Variant &property);
Node get_property_control(const int slot_idx);
void set_node(const MMMateial &material, const MMNode &node);
void propagate_node_change();
void on_dragged(const Vector2 &from, const Vector2 &to);
void on_int_spinbox_value_changed(const float val, const Variant &slot_idx);
void on_float_spinbox_value_changed(const float val, const Variant &slot_idx);
void on_vector2_spinbox_value_changed(const float val, const Variant &slot_idx, const Variant &spinbox_x, const Variant &spinbox_y);
void on_vector3_spinbox_value_changed(const float val, const Variant &slot_idx, const Variant &spinbox_x, const Variant &spinbox_y, const Variant &spinbox_z);
void on_int_universal_spinbox_value_changed(const float val, const Variant &slot_idx);
void on_float_universal_spinbox_value_changed(const float val, const Variant &slot_idx);
void on_vector2_universal_spinbox_value_changed(const float val, const Variant &slot_idx, const Variant &spinbox_x, const Variant &spinbox_y);
void on_slot_enum_item_selected(const int val, const int slot_idx);
void on_universal_texture_changed(const int slot_idx);
void on_universal_texture_changed_image_picker(const int slot_idx);
void on_slot_line_edit_text_entered(const String &text, const int slot_idx);
void on_universal_color_changed(const Color &c, const int slot_idx);
void on_universal_image_path_changed(const String &f, const int slot_idx);
MMNode get_material_node();
void on_close_request();
Color get_slot_color(const int slot_type);
Color _get_slot_color(const int slot_type);
MmGraphNode();
~MmGraphNode();
protected:
static void _bind_methods();
//tool
Ref<PackedScene> gradient_editor_scene = preload("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn");
Ref<PackedScene> polygon_edit_scene = preload("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn");
Ref<PackedScene> curve_edit_scene = preload("res://addons/mat_maker_gd/widgets/curve_edit/curve_edit.tscn");
MMMateial *_material = null;
MMNode *_node = null;
Array properties = Array();
Variant;
UndoRedo *_undo_redo = null;
bool _ignore_change_event = false;
//_node.connect("changed", self, "on_node_changed")
};
#endif

View File

@ -0,0 +1,238 @@
#include "mm_material.h"
Vector2 MMMateial::get_image_size() {
return image_size;
}
void MMMateial::set_image_size(const Vector2 &val) {
image_size = val;
}
Array MMMateial::get_nodes() {
return nodes;
}
void MMMateial::set_nodes(const Array &val) {
nodes = val;
}
bool MMMateial::get_initialized() const {
return initialized;
}
void MMMateial::set_initialized(const bool val) {
initialized = val;
}
bool MMMateial::get_rendering() const {
return rendering;
}
void MMMateial::set_rendering(const bool val) {
rendering = val;
}
bool MMMateial::get_queued_render() const {
return queued_render;
}
void MMMateial::set_queued_render(const bool val) {
queued_render = val;
}
Ref<ThreadPoolExecuteJob> MMMateial::get_job() {
return job;
}
void MMMateial::set_job(const Ref<ThreadPoolExecuteJob> &val) {
job = val;
}
//tool;
//threads are implemented using my thread pool engine module.;
//if you want to use this without that module in your engine set this to false,;
//and comment out the lines that give errors;
const USE_THREADS = true;
//export(Vector2) ;
Vector2 image_size = Vector2(128, 128);
//export(Array) ;
Array nodes = ;
bool initialized = false;
bool rendering = false;
bool queued_render = false;
Ref<ThreadPoolExecuteJob> job = ThreadPoolExecuteJob.new();
void MMMateial::initialize() {
if (!initialized) {
initialized = true;
job.setup(self, "_thread_func");
for (n in nodes) {
n.init_properties();
n.connect("changed", self, "on_node_changed");
}
}
}
void MMMateial::add_node(const MMNode &node) {
nodes.append(node);
node.connect("changed", self, "on_node_changed");
emit_changed();
}
void MMMateial::remove_node(const MMNode &node) {
if (!node) {
return;
}
for (op in node.output_properties) {
for (n in nodes) {
if (n) {
for (ip in n.input_properties) {
if (ip.input_property == op) {
ip.set_input_property(null);
}
}
}
}
}
nodes.erase(node);
node.disconnect("changed", self, "on_node_changed");
emit_changed();
}
void MMMateial::render() {
initialize();
if (rendering) {
queued_render = true;
return;
}
if (USE_THREADS) {
render_threaded();
}
else {
render_non_threaded();
}
}
void MMMateial::render_non_threaded() {
bool did_render = true;
while (did_render) {
did_render = false;
for (n in nodes) {
if (n && n.render(self)) {
did_render = true;
}
}
}
}
void MMMateial::render_threaded() {
job.cancelled = false;
if (!ThreadPool.has_job(job)) {
ThreadPool.add_job(job);
}
}
void MMMateial::_thread_func() {
if (job.cancelled) {
rendering = false;
return;
}
rendering = true;
job.cancelled = false;
bool did_render = true;
while (did_render) {
did_render = false;
for (n in nodes) {
if (n && n.render(self)) {
did_render = true;
}
if (job.cancelled) {
rendering = false;
return;
}
}
}
rendering = false;
if (queued_render) {
queued_render = false;
_thread_func();
}
}
void MMMateial::cancel_render_and_wait() {
if (rendering) {
ThreadPool.cancel_job_wait(job);
job.cancelled = false;
pass;
}
}
void MMMateial::on_node_changed() {
emit_changed();
call_deferred("render");
}
}
MMMateial::MMMateial() {
image_size = Vector2(128, 128);
nodes = ;
initialized = false;
rendering = false;
queued_render = false;
job = ThreadPoolExecuteJob.new();
}
MMMateial::~MMMateial() {
}
static void MMMateial::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image_size"), &MMMateial::get_image_size);
ClassDB::bind_method(D_METHOD("set_image_size", "value"), &MMMateial::set_image_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "image_size"), "set_image_size", "get_image_size");
ClassDB::bind_method(D_METHOD("get_nodes"), &MMMateial::get_nodes);
ClassDB::bind_method(D_METHOD("set_nodes", "value"), &MMMateial::set_nodes);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "nodes"), "set_nodes", "get_nodes");
ClassDB::bind_method(D_METHOD("get_initialized"), &MMMateial::get_initialized);
ClassDB::bind_method(D_METHOD("set_initialized", "value"), &MMMateial::set_initialized);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "initialized"), "set_initialized", "get_initialized");
ClassDB::bind_method(D_METHOD("get_rendering"), &MMMateial::get_rendering);
ClassDB::bind_method(D_METHOD("set_rendering", "value"), &MMMateial::set_rendering);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rendering"), "set_rendering", "get_rendering");
ClassDB::bind_method(D_METHOD("get_queued_render"), &MMMateial::get_queued_render);
ClassDB::bind_method(D_METHOD("set_queued_render", "value"), &MMMateial::set_queued_render);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "queued_render"), "set_queued_render", "get_queued_render");
ClassDB::bind_method(D_METHOD("get_job"), &MMMateial::get_job);
ClassDB::bind_method(D_METHOD("set_job", "value"), &MMMateial::set_job);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "job", PROPERTY_HINT_RESOURCE_TYPE, "Ref<ThreadPoolExecuteJob>"), "set_job", "get_job");
ClassDB::bind_method(D_METHOD("initialize"), &MMMateial::initialize);
ClassDB::bind_method(D_METHOD("add_node", "node"), &MMMateial::add_node);
ClassDB::bind_method(D_METHOD("remove_node", "node"), &MMMateial::remove_node);
ClassDB::bind_method(D_METHOD("render"), &MMMateial::render);
ClassDB::bind_method(D_METHOD("render_non_threaded"), &MMMateial::render_non_threaded);
ClassDB::bind_method(D_METHOD("render_threaded"), &MMMateial::render_threaded);
ClassDB::bind_method(D_METHOD("_thread_func"), &MMMateial::_thread_func);
ClassDB::bind_method(D_METHOD("cancel_render_and_wait"), &MMMateial::cancel_render_and_wait);
ClassDB::bind_method(D_METHOD("on_node_changed"), &MMMateial::on_node_changed);
}

View File

@ -0,0 +1,57 @@
#ifndef MM_MATERIAL_H
#define MM_MATERIAL_H
class MMMateial : public Resource {
GDCLASS(MMMateial, Resource);
public:
Vector2 get_image_size();
void set_image_size(const Vector2 &val);
Array get_nodes();
void set_nodes(const Array &val);
bool get_initialized() const;
void set_initialized(const bool val);
bool get_rendering() const;
void set_rendering(const bool val);
bool get_queued_render() const;
void set_queued_render(const bool val);
Ref<ThreadPoolExecuteJob> get_job();
void set_job(const Ref<ThreadPoolExecuteJob> &val);
void initialize();
void add_node(const MMNode &node);
void remove_node(const MMNode &node);
void render();
void render_non_threaded();
void render_threaded();
void _thread_func();
void cancel_render_and_wait();
void on_node_changed();
MMMateial();
~MMMateial();
protected:
static void _bind_methods();
//tool
//threads are implemented using my thread pool engine module.
//if you want to use this without that module in your engine set this to false,
//and comment out the lines that give errors
const USE_THREADS = true;
//export(Vector2)
Vector2 image_size = Vector2(128, 128);
//export(Array)
Array nodes = ;
bool initialized = false;
bool rendering = false;
bool queued_render = false;
Ref<ThreadPoolExecuteJob> job = ThreadPoolExecuteJob.new();
};
#endif

View File

@ -0,0 +1,240 @@
#include "mm_node.h"
Vector2 MMNode::get_graph_position() {
return graph_position;
}
void MMNode::set_graph_position(const Vector2 &val) {
graph_position = val;
}
Array MMNode::get_input_properties() {
return input_properties;
}
void MMNode::set_input_properties(const Array &val) {
input_properties = val;
}
Array MMNode::get_output_properties() {
return output_properties;
}
void MMNode::set_output_properties(const Array &val) {
output_properties = val;
}
bool MMNode::get_properties_initialized() const {
return properties_initialized;
}
void MMNode::set_properties_initialized(const bool val) {
properties_initialized = val;
}
bool MMNode::get_dirty() const {
return dirty;
}
void MMNode::set_dirty(const bool val) {
dirty = val;
}
//tool;
//export(Vector2) ;
Vector2 graph_position = Vector2();
Array input_properties = ;
Array output_properties = ;
bool properties_initialized = false;
bool dirty = true;
//MMMateial;
bool MMNode::render(const Variant &material) {
if (!dirty) {
return false;
}
for (p in input_properties) {
if (p.input_property && p.input_property.owner.dirty) {
return false;
}
}
_render(material);
dirty = false;
return true;
}
//MMMateial;
void MMNode::_render(const Variant &material) {
pass;
}
Image MMNode::render_image(const Variant &material) {
Ref<Image> image = Image.new();
image.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
image.lock();
float w = image.get_width();
float h = image.get_height();
float pseed = randf() + randi();
for (int x = 0; x < image.get_width(); ++x) { //x in range(image.get_width())
for (int y = 0; y < image.get_height(); ++y) { //y in range(image.get_height())
Vector2 v = Vector2(x / w, y / h);
Color col = get_value_for(v, pseed);
image.set_pixel(x, y, col);
}
}
image.unlock();
return image;
}
Color MMNode::get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
void MMNode::init_properties() {
if (!properties_initialized) {
properties_initialized = true;
_init_properties();
}
}
void MMNode::_init_properties() {
pass;
}
void MMNode::register_methods(const Variant &mm_graph_node) {
init_properties();
_register_methods(mm_graph_node);
}
void MMNode::_register_methods(const Variant &mm_graph_node) {
pass;
}
Vector2 MMNode::get_graph_position() {
return graph_position;
}
void MMNode::set_graph_position(const Vector2 &pos) {
graph_position = pos;
emit_changed();
}
void MMNode::register_input_property(const MMNodeUniversalProperty &prop) {
prop.owner = self;
if (!prop.is_connected("changed", self, "on_input_property_changed")) {
prop.connect("changed", self, "on_input_property_changed");
}
input_properties.append(prop);
}
void MMNode::unregister_input_property(const MMNodeUniversalProperty &prop) {
if (prop.owner == self) {
prop.owner = null;
}
if (prop.is_connected("changed", self, "on_input_property_changed")) {
prop.disconnect("changed", self, "on_input_property_changed");
}
input_properties.erase(prop);
}
void MMNode::register_output_property(const MMNodeUniversalProperty &prop) {
prop.owner = self;
output_properties.append(prop);
}
void MMNode::unregister_output_property(const MMNodeUniversalProperty &prop) {
if (prop.owner == self) {
prop.owner = null;
}
output_properties.erase(prop);
}
void MMNode::set_dirty(const bool val) {
bool changed = val != dirty;
dirty = val;
if (changed) {
emit_changed();
}
}
void MMNode::on_input_property_changed() {
set_dirty(true);
emit_changed();
}
// 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() {
graph_position = Vector2();
input_properties = ;
output_properties = ;
properties_initialized = false;
dirty = true;
}
MMNode::~MMNode() {
}
static void MMNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_graph_position"), &MMNode::get_graph_position);
ClassDB::bind_method(D_METHOD("set_graph_position", "value"), &MMNode::set_graph_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "graph_position"), "set_graph_position", "get_graph_position");
ClassDB::bind_method(D_METHOD("get_input_properties"), &MMNode::get_input_properties);
ClassDB::bind_method(D_METHOD("set_input_properties", "value"), &MMNode::set_input_properties);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "input_properties"), "set_input_properties", "get_input_properties");
ClassDB::bind_method(D_METHOD("get_output_properties"), &MMNode::get_output_properties);
ClassDB::bind_method(D_METHOD("set_output_properties", "value"), &MMNode::set_output_properties);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "output_properties"), "set_output_properties", "get_output_properties");
ClassDB::bind_method(D_METHOD("get_properties_initialized"), &MMNode::get_properties_initialized);
ClassDB::bind_method(D_METHOD("set_properties_initialized", "value"), &MMNode::set_properties_initialized);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "properties_initialized"), "set_properties_initialized", "get_properties_initialized");
ClassDB::bind_method(D_METHOD("get_dirty"), &MMNode::get_dirty);
ClassDB::bind_method(D_METHOD("set_dirty", "value"), &MMNode::set_dirty);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dirty"), "set_dirty", "get_dirty");
ClassDB::bind_method(D_METHOD("render", "material"), &MMNode::render);
ClassDB::bind_method(D_METHOD("_render", "material"), &MMNode::_render);
ClassDB::bind_method(D_METHOD("render_image", "material"), &MMNode::render_image);
ClassDB::bind_method(D_METHOD("get_value_for", "uv", "pseed"), &MMNode::get_value_for);
ClassDB::bind_method(D_METHOD("init_properties"), &MMNode::init_properties);
ClassDB::bind_method(D_METHOD("_init_properties"), &MMNode::_init_properties);
ClassDB::bind_method(D_METHOD("register_methods", "mm_graph_node"), &MMNode::register_methods);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &MMNode::_register_methods);
ClassDB::bind_method(D_METHOD("get_graph_position"), &MMNode::get_graph_position);
ClassDB::bind_method(D_METHOD("set_graph_position", "pos"), &MMNode::set_graph_position);
ClassDB::bind_method(D_METHOD("register_input_property", "prop"), &MMNode::register_input_property);
ClassDB::bind_method(D_METHOD("unregister_input_property", "prop"), &MMNode::unregister_input_property);
ClassDB::bind_method(D_METHOD("register_output_property", "prop"), &MMNode::register_output_property);
ClassDB::bind_method(D_METHOD("unregister_output_property", "prop"), &MMNode::unregister_output_property);
ClassDB::bind_method(D_METHOD("set_dirty", "val"), &MMNode::set_dirty);
ClassDB::bind_method(D_METHOD("on_input_property_changed"), &MMNode::on_input_property_changed);
}

View File

@ -0,0 +1,69 @@
#ifndef MM_NODE_H
#define MM_NODE_H
class MMNode : public Resource {
GDCLASS(MMNode, Resource);
public:
Vector2 get_graph_position();
void set_graph_position(const Vector2 &val);
Array get_input_properties();
void set_input_properties(const Array &val);
Array get_output_properties();
void set_output_properties(const Array &val);
bool get_properties_initialized() const;
void set_properties_initialized(const bool val);
bool get_dirty() const;
void set_dirty(const bool val);
bool render(const Variant &material);
void _render(const Variant &material);
Image render_image(const Variant &material);
Color get_value_for(const Vector2 &uv, const int pseed);
void init_properties();
void _init_properties();
void register_methods(const Variant &mm_graph_node);
void _register_methods(const Variant &mm_graph_node);
Vector2 get_graph_position();
void set_graph_position(const Vector2 &pos);
void register_input_property(const MMNodeUniversalProperty &prop);
void unregister_input_property(const MMNodeUniversalProperty &prop);
void register_output_property(const MMNodeUniversalProperty &prop);
void unregister_output_property(const MMNodeUniversalProperty &prop);
void set_dirty(const bool val);
void on_input_property_changed();
MMNode();
~MMNode();
protected:
static void _bind_methods();
//tool
//export(Vector2)
Vector2 graph_position = Vector2();
Array input_properties = ;
Array output_properties = ;
bool properties_initialized = false;
bool dirty = true;
//MMMateial
//MMMateial
// 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)
};
#endif

View File

@ -0,0 +1,681 @@
#include "mm_node_universal_property.h"
int MMNodeUniversalProperty::get_default_type() const {
return default_type;
}
void MMNodeUniversalProperty::set_default_type(const int val) {
default_type = val;
}
int MMNodeUniversalProperty::get_default_int() const {
return default_int;
}
void MMNodeUniversalProperty::set_default_int(const int val) {
default_int = val;
}
float MMNodeUniversalProperty::get_default_float() const {
return default_float;
}
void MMNodeUniversalProperty::set_default_float(const float val) {
default_float = val;
}
Vector2 MMNodeUniversalProperty::get_default_vector2() {
return default_vector2;
}
void MMNodeUniversalProperty::set_default_vector2(const Vector2 &val) {
default_vector2 = val;
}
Vector3 MMNodeUniversalProperty::get_default_vector3() {
return default_vector3;
}
void MMNodeUniversalProperty::set_default_vector3(const Vector3 &val) {
default_vector3 = val;
}
Color MMNodeUniversalProperty::get_default_color() {
return default_color;
}
void MMNodeUniversalProperty::set_default_color(const Color &val) {
default_color = val;
}
Ref<Image> MMNodeUniversalProperty::get_default_image() {
return default_image;
}
void MMNodeUniversalProperty::set_default_image(const Ref<Image> &val) {
default_image = val;
}
bool MMNodeUniversalProperty::get_get_value_from_owner() const {
return get_value_from_owner;
}
void MMNodeUniversalProperty::set_get_value_from_owner(const bool val) {
get_value_from_owner = val;
}
bool MMNodeUniversalProperty::get_force_override() const {
return force_override;
}
void MMNodeUniversalProperty::set_force_override(const bool val) {
force_override = val;
}
Ref<Image> MMNodeUniversalProperty::get_override_image() {
return override_image;
}
void MMNodeUniversalProperty::set_override_image(const Ref<Image> &val) {
override_image = val;
}
Ref<Resource> MMNodeUniversalProperty::get_input_property() {
return input_property;
}
void MMNodeUniversalProperty::set_input_property(const Ref<Resource> &val) {
input_property = val;
}
int MMNodeUniversalProperty::get_input_slot_type() const {
return input_slot_type;
}
void MMNodeUniversalProperty::set_input_slot_type(const int val) {
input_slot_type = val;
}
int MMNodeUniversalProperty::get_output_slot_type() const {
return output_slot_type;
}
void MMNodeUniversalProperty::set_output_slot_type(const int val) {
output_slot_type = val;
}
String MMNodeUniversalProperty::get_slot_name() {
return slot_name;
}
void MMNodeUniversalProperty::set_slot_name(const String &val) {
slot_name = val;
}
float MMNodeUniversalProperty::get_value_step() const {
return value_step;
}
void MMNodeUniversalProperty::set_value_step(const float val) {
value_step = val;
}
Vector2 MMNodeUniversalProperty::get_value_range() {
return value_range;
}
void MMNodeUniversalProperty::set_value_range(const Vector2 &val) {
value_range = val;
}
Variant MMNodeUniversalProperty::get_Variant() {
return Variant;
}
void MMNodeUniversalProperty::set_Variant(const Variant &val) {
Variant = val;
}
//tool;
}
;
}
;
//export(int, "Int,Float,Vector2,Vector3,Color,Image") ;
int default_type = ;
//export(int) ;
int default_int = ;
//export(float) ;
float default_float = ;
//export(Vector2) ;
Vector2 default_vector2 = ;
//export(Vector3) ;
Vector3 default_vector3 = ;
//export(Color) ;
Color default_color = ;
//export(Image) ;
Ref<Image> default_image;
bool get_value_from_owner = false;
bool force_override = false;
//This is not exported on purpose!;
Ref<Image> override_image;
//Should be a MMNodeUniversalProperty, but can't set it up like that;
//export(Resource) ;
Ref<Resource> input_property;
int input_slot_type = SlotTypes.SLOT_TYPE_NONE;
int output_slot_type = SlotTypes.SLOT_TYPE_NONE;
String slot_name = ;
float value_step = 0.1;
Vector2 value_range = Vector2(-1000, 1000);
//MMNode;
Variant;
void MMNodeUniversalProperty::_init() {
if (input_property) {
input_property.connect("changed", self, "on_input_property_changed");
}
}
void MMNodeUniversalProperty::get_value(const Vector2 &uv, const bool skip_owner_val) {
if (get_value_from_owner && !skip_owner_val) {
return get_owner_value(uv);
}
if (!input_property) {
return get_default_value(uv);
}
if (default_type == input_property.default_type) {
return input_property.get_value(uv);
}
if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT) {
return to_int(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT) {
return to_float(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2) {
return to_vector2(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3) {
return to_vector3(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR) {
return to_color(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE) {
return to_color(input_property.get_value(uv));
}
return input_property.get_value(uv);
}
void MMNodeUniversalProperty::get_owner_value(const Vector2 &uv) {
if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT) {
return to_int(owner.get_property_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT) {
return to_float(owner.get_property_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2) {
return to_vector2(owner.get_property_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3) {
return to_vector3(owner.get_property_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR) {
return to_color(owner.get_property_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE) {
return to_color(owner.get_property_value(uv));
}
}
void MMNodeUniversalProperty::get_value_or_zero(const Vector2 &uv, const bool skip_owner_val) {
if (get_value_from_owner && !skip_owner_val) {
return get_owner_value(uv);
}
if (!input_property) {
return get_zero_value();
}
if (default_type == input_property.default_type) {
return input_property.get_value(uv);
}
if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT) {
return to_int(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT) {
return to_float(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2) {
return to_vector2(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3) {
return to_vector3(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR) {
return to_color(input_property.get_value(uv));
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE) {
return to_color(input_property.get_value(uv));
}
return input_property.get_value(uv);
}
Vector2 MMNodeUniversalProperty::get_value_sdf3d(const Vector3 &uv3, const bool skip_owner_val) {
if (get_value_from_owner && !skip_owner_val) {
return owner.get_property_value_sdf3d(uv3);
}
if (!input_property) {
return default_vector2;
}
return input_property.get_value_sdf3d(uv3);
}
int MMNodeUniversalProperty::to_int(const Variant &val) {
if (val is int) {
return val;
}
if (val is float) {
return int(val);
}
if (val is Vector2) {
return int(val.x);
}
if (val is Vector3) {
return int(val.x);
}
if (val is Color) {
return int(val.r);
}
return 0;
}
float MMNodeUniversalProperty::to_float(const Variant &val) {
if (val is float) {
return val;
}
if (val is int) {
return float(val);
}
if (val is Vector2) {
return float(val.x);
}
if (val is Vector3) {
return float(val.x);
}
if (val is Color) {
return float(val.r);
}
return 0.0;
}
Vector2 MMNodeUniversalProperty::to_vector2(const Variant &val) {
if (val is Vector2) {
return val;
}
if (val is int) {
return Vector2(val, val);
}
if (val is float) {
return Vector2(val, val);
}
if (val is Vector3) {
return Vector2(val.x, val.y);
}
if (val is Color) {
return Vector2(val.r, val.g);
}
return Vector2();
}
Vector3 MMNodeUniversalProperty::to_vector3(const Variant &val) {
if (val is Vector3) {
return val;
}
if (val is int) {
return Vector3(val, val, val);
}
if (val is float) {
return Vector3(val, val, val);
}
if (val is Vector2) {
return Vector3(val.x, val.y, 0);
}
if (val is Color) {
return Vector3(val.r, val.g, val.b);
}
return Vector3();
}
Color MMNodeUniversalProperty::to_color(const Variant &val) {
if (val is Color) {
return val;
}
if (val is int) {
return Color(val, val, val, 1);
}
if (val is float) {
return Color(val, val, val, 1);
}
if (val is Vector2) {
return Color(val.x, val.y, 0, 1);
}
if (val is Vector3) {
return Color(val.x, val.y, val.z, 1);
}
return Color();
}
void MMNodeUniversalProperty::set_value(const Variant &val) {
if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE) {
override_image = val;
emit_changed();
return;
}
set_default_value(val);
}
void MMNodeUniversalProperty::get_zero_value() {
if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT) {
return 0;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT) {
return 0.0;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2) {
return Vector2();
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3) {
return Vector3();
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR) {
return Color();
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE) {
return Color();
}
return null;
}
void MMNodeUniversalProperty::get_default_value(const Vector2 &uv) {
if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT) {
return default_int;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT) {
return default_float;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2) {
return default_vector2;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3) {
return default_vector3;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR) {
return default_color;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE) {
Ref<Image> image = default_image;
if (override_image) {
image = override_image;
}
if (!image) {
return default_color;
}
image.lock();
int x = uv.x * image.get_width();
int y = uv.y * image.get_height();
x = clamp(x, 0, image.get_width() - 1);
y = clamp(y, 0, image.get_width() - 1);
Color c = image.get_pixel(x, y);
image.unlock();
return c;
}
return null;
}
void MMNodeUniversalProperty::set_default_value(const Variant &val) {
if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT) {
default_int = val;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT) {
default_float = val;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2) {
default_vector2 = val;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3) {
default_vector3 = val;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR) {
default_color = val;
}
else if (default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE) {
default_image = val;
}
emit_changed();
}
Image MMNodeUniversalProperty::get_active_image() {
if (!force_override && input_property) {
return input_property.get_active_image();
}
if (override_image) {
return override_image;
}
return default_image;
}
void MMNodeUniversalProperty::set_input_property(const MMNodeUniversalProperty &val) {
if (input_property == val) {
return;
}
if (input_property) {
input_property.disconnect("changed", self, "on_input_property_changed");
}
input_property = val;
if (input_property) {
input_property.connect("changed", self, "on_input_property_changed");
}
emit_changed();
}
// Because in UndiRedo if you pass null as the only argument it will look;
// for a method with no arguments;
void MMNodeUniversalProperty::unset_input_property() {
set_input_property(null);
}
void MMNodeUniversalProperty::on_input_property_changed() {
emit_changed();
}
}
MMNodeUniversalProperty::MMNodeUniversalProperty() {
default_type = ;
default_int = ;
default_float = ;
default_vector2 = ;
default_vector3 = ;
default_color = ;
default_image;
get_value_from_owner = false;
force_override = false;
override_image;
input_property;
input_slot_type = SlotTypes.SLOT_TYPE_NONE;
output_slot_type = SlotTypes.SLOT_TYPE_NONE;
slot_name = ;
value_step = 0.1;
value_range = Vector2(-1000, 1000);
;
}
MMNodeUniversalProperty::~MMNodeUniversalProperty() {
}
static void MMNodeUniversalProperty::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_default_type"), &MMNodeUniversalProperty::get_default_type);
ClassDB::bind_method(D_METHOD("set_default_type", "value"), &MMNodeUniversalProperty::set_default_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "default_type"), "set_default_type", "get_default_type");
ClassDB::bind_method(D_METHOD("get_default_int"), &MMNodeUniversalProperty::get_default_int);
ClassDB::bind_method(D_METHOD("set_default_int", "value"), &MMNodeUniversalProperty::set_default_int);
ADD_PROPERTY(PropertyInfo(Variant::INT, "default_int"), "set_default_int", "get_default_int");
ClassDB::bind_method(D_METHOD("get_default_float"), &MMNodeUniversalProperty::get_default_float);
ClassDB::bind_method(D_METHOD("set_default_float", "value"), &MMNodeUniversalProperty::set_default_float);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "default_float"), "set_default_float", "get_default_float");
ClassDB::bind_method(D_METHOD("get_default_vector2"), &MMNodeUniversalProperty::get_default_vector2);
ClassDB::bind_method(D_METHOD("set_default_vector2", "value"), &MMNodeUniversalProperty::set_default_vector2);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "default_vector2"), "set_default_vector2", "get_default_vector2");
ClassDB::bind_method(D_METHOD("get_default_vector3"), &MMNodeUniversalProperty::get_default_vector3);
ClassDB::bind_method(D_METHOD("set_default_vector3", "value"), &MMNodeUniversalProperty::set_default_vector3);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "default_vector3"), "set_default_vector3", "get_default_vector3");
ClassDB::bind_method(D_METHOD("get_default_color"), &MMNodeUniversalProperty::get_default_color);
ClassDB::bind_method(D_METHOD("set_default_color", "value"), &MMNodeUniversalProperty::set_default_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "default_color"), "set_default_color", "get_default_color");
ClassDB::bind_method(D_METHOD("get_default_image"), &MMNodeUniversalProperty::get_default_image);
ClassDB::bind_method(D_METHOD("set_default_image", "value"), &MMNodeUniversalProperty::set_default_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "default_image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Image>"), "set_default_image", "get_default_image");
ClassDB::bind_method(D_METHOD("get_get_value_from_owner"), &MMNodeUniversalProperty::get_get_value_from_owner);
ClassDB::bind_method(D_METHOD("set_get_value_from_owner", "value"), &MMNodeUniversalProperty::set_get_value_from_owner);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "get_value_from_owner"), "set_get_value_from_owner", "get_get_value_from_owner");
ClassDB::bind_method(D_METHOD("get_force_override"), &MMNodeUniversalProperty::get_force_override);
ClassDB::bind_method(D_METHOD("set_force_override", "value"), &MMNodeUniversalProperty::set_force_override);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "force_override"), "set_force_override", "get_force_override");
ClassDB::bind_method(D_METHOD("get_override_image"), &MMNodeUniversalProperty::get_override_image);
ClassDB::bind_method(D_METHOD("set_override_image", "value"), &MMNodeUniversalProperty::set_override_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "override_image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Image>"), "set_override_image", "get_override_image");
ClassDB::bind_method(D_METHOD("get_input_property"), &MMNodeUniversalProperty::get_input_property);
ClassDB::bind_method(D_METHOD("set_input_property", "value"), &MMNodeUniversalProperty::set_input_property);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input_property", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input_property", "get_input_property");
ClassDB::bind_method(D_METHOD("get_input_slot_type"), &MMNodeUniversalProperty::get_input_slot_type);
ClassDB::bind_method(D_METHOD("set_input_slot_type", "value"), &MMNodeUniversalProperty::set_input_slot_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "input_slot_type"), "set_input_slot_type", "get_input_slot_type");
ClassDB::bind_method(D_METHOD("get_output_slot_type"), &MMNodeUniversalProperty::get_output_slot_type);
ClassDB::bind_method(D_METHOD("set_output_slot_type", "value"), &MMNodeUniversalProperty::set_output_slot_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "output_slot_type"), "set_output_slot_type", "get_output_slot_type");
ClassDB::bind_method(D_METHOD("get_slot_name"), &MMNodeUniversalProperty::get_slot_name);
ClassDB::bind_method(D_METHOD("set_slot_name", "value"), &MMNodeUniversalProperty::set_slot_name);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "slot_name"), "set_slot_name", "get_slot_name");
ClassDB::bind_method(D_METHOD("get_value_step"), &MMNodeUniversalProperty::get_value_step);
ClassDB::bind_method(D_METHOD("set_value_step", "value"), &MMNodeUniversalProperty::set_value_step);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "value_step"), "set_value_step", "get_value_step");
ClassDB::bind_method(D_METHOD("get_value_range"), &MMNodeUniversalProperty::get_value_range);
ClassDB::bind_method(D_METHOD("set_value_range", "value"), &MMNodeUniversalProperty::set_value_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "value_range"), "set_value_range", "get_value_range");
ClassDB::bind_method(D_METHOD("get_Variant"), &MMNodeUniversalProperty::get_Variant);
ClassDB::bind_method(D_METHOD("set_Variant", "value"), &MMNodeUniversalProperty::set_Variant);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant");
ClassDB::bind_method(D_METHOD("_init"), &MMNodeUniversalProperty::_init);
ClassDB::bind_method(D_METHOD("get_value", "uv", "skip_owner_val"), &MMNodeUniversalProperty::get_value, false);
ClassDB::bind_method(D_METHOD("get_owner_value", "uv"), &MMNodeUniversalProperty::get_owner_value);
ClassDB::bind_method(D_METHOD("get_value_or_zero", "uv", "skip_owner_val"), &MMNodeUniversalProperty::get_value_or_zero, false);
ClassDB::bind_method(D_METHOD("get_value_sdf3d", "uv3", "skip_owner_val"), &MMNodeUniversalProperty::get_value_sdf3d, false);
ClassDB::bind_method(D_METHOD("to_int", "val"), &MMNodeUniversalProperty::to_int);
ClassDB::bind_method(D_METHOD("to_float", "val"), &MMNodeUniversalProperty::to_float);
ClassDB::bind_method(D_METHOD("to_vector2", "val"), &MMNodeUniversalProperty::to_vector2);
ClassDB::bind_method(D_METHOD("to_vector3", "val"), &MMNodeUniversalProperty::to_vector3);
ClassDB::bind_method(D_METHOD("to_color", "val"), &MMNodeUniversalProperty::to_color);
ClassDB::bind_method(D_METHOD("set_value", "val"), &MMNodeUniversalProperty::set_value);
ClassDB::bind_method(D_METHOD("get_zero_value"), &MMNodeUniversalProperty::get_zero_value);
ClassDB::bind_method(D_METHOD("get_default_value", "uv"), &MMNodeUniversalProperty::get_default_value, Vector2());
ClassDB::bind_method(D_METHOD("set_default_value", "val"), &MMNodeUniversalProperty::set_default_value);
ClassDB::bind_method(D_METHOD("get_active_image"), &MMNodeUniversalProperty::get_active_image);
ClassDB::bind_method(D_METHOD("set_input_property", "val"), &MMNodeUniversalProperty::set_input_property);
ClassDB::bind_method(D_METHOD("unset_input_property"), &MMNodeUniversalProperty::unset_input_property);
ClassDB::bind_method(D_METHOD("on_input_property_changed"), &MMNodeUniversalProperty::on_input_property_changed);
}

View File

@ -0,0 +1,143 @@
#ifndef MM_NODE_UNIVERSAL_PROPERTY_H
#define MM_NODE_UNIVERSAL_PROPERTY_H
class MMNodeUniversalProperty : public Resource {
GDCLASS(MMNodeUniversalProperty, Resource);
public:
int get_default_type() const;
void set_default_type(const int val);
int get_default_int() const;
void set_default_int(const int val);
float get_default_float() const;
void set_default_float(const float val);
Vector2 get_default_vector2();
void set_default_vector2(const Vector2 &val);
Vector3 get_default_vector3();
void set_default_vector3(const Vector3 &val);
Color get_default_color();
void set_default_color(const Color &val);
Ref<Image> get_default_image();
void set_default_image(const Ref<Image> &val);
bool get_get_value_from_owner() const;
void set_get_value_from_owner(const bool val);
bool get_force_override() const;
void set_force_override(const bool val);
Ref<Image> get_override_image();
void set_override_image(const Ref<Image> &val);
Ref<Resource> get_input_property();
void set_input_property(const Ref<Resource> &val);
int get_input_slot_type() const;
void set_input_slot_type(const int val);
int get_output_slot_type() const;
void set_output_slot_type(const int val);
String get_slot_name();
void set_slot_name(const String &val);
float get_value_step() const;
void set_value_step(const float val);
Vector2 get_value_range();
void set_value_range(const Vector2 &val);
Variant get_Variant();
void set_Variant(const Variant &val);
enum SlotTypes {
SLOT_TYPE_NONE = -1,
SLOT_TYPE_IMAGE = 0,
SLOT_TYPE_INT = 1,
SLOT_TYPE_FLOAT = 2,
SLOT_TYPE_VECTOR2 = 3,
SLOT_TYPE_VECTOR3 = 4,
SLOT_TYPE_COLOR = 5,
SLOT_TYPE_UNIVERSAL = 6,
};
enum MMNodeUniversalPropertyDefaultType {
DEFAULT_TYPE_INT = 0,
DEFAULT_TYPE_FLOAT = 1,
DEFAULT_TYPE_VECTOR2 = 2,
DEFAULT_TYPE_VECTOR3 = 3,
DEFAULT_TYPE_COLOR = 4,
DEFAULT_TYPE_IMAGE = 5,
};
void _init();
void get_value(const Vector2 &uv, const bool skip_owner_val = false);
void get_owner_value(const Vector2 &uv);
void get_value_or_zero(const Vector2 &uv, const bool skip_owner_val = false);
Vector2 get_value_sdf3d(const Vector3 &uv3, const bool skip_owner_val = false);
int to_int(const Variant &val);
float to_float(const Variant &val);
Vector2 to_vector2(const Variant &val);
Vector3 to_vector3(const Variant &val);
Color to_color(const Variant &val);
void set_value(const Variant &val);
void get_zero_value();
void get_default_value(const Vector2 &uv = Vector2());
void set_default_value(const Variant &val);
Image get_active_image();
void set_input_property(const MMNodeUniversalProperty &val);
void unset_input_property();
void on_input_property_changed();
MMNodeUniversalProperty();
~MMNodeUniversalProperty();
protected:
static void _bind_methods();
//tool
};
}
;
//export(int, "Int,Float,Vector2,Vector3,Color,Image")
int default_type = ;
//export(int)
int default_int = ;
//export(float)
float default_float = ;
//export(Vector2)
Vector2 default_vector2 = ;
//export(Vector3)
Vector3 default_vector3 = ;
//export(Color)
Color default_color = ;
//export(Image)
Ref<Image> default_image;
bool get_value_from_owner = false;
bool force_override = false;
//This is not exported on purpose!
Ref<Image> override_image;
//Should be a MMNodeUniversalProperty, but can't set it up like that
//export(Resource)
Ref<Resource> input_property;
int input_slot_type = SlotTypes.SLOT_TYPE_NONE;
int output_slot_type = SlotTypes.SLOT_TYPE_NONE;
String slot_name = ;
float value_step = 0.1;
Vector2 value_range = Vector2(-1000, 1000);
//MMNode
Variant;
// Because in UndiRedo if you pass null as the only argument it will look
// for a method with no arguments
}
;
#endif