paint: add snippets button to script node
This commit is contained in:
@@ -3048,8 +3048,17 @@ void _kickstart() {
|
||||
.max = 1.0,
|
||||
.precision = 100,
|
||||
.height = 0}),
|
||||
GC_ALLOC_INIT(ui_node_button_t, {.name = "script_node_button",
|
||||
.type = "CUSTOM",
|
||||
.output = -1,
|
||||
.default_value = f32_array_create_x(0),
|
||||
.data = NULL,
|
||||
.min = 0.0,
|
||||
.max = 1.0,
|
||||
.precision = 100,
|
||||
.height = 1}),
|
||||
},
|
||||
1),
|
||||
2),
|
||||
.width = 0,
|
||||
.flags = 0});
|
||||
gc_root(script_node_def);
|
||||
@@ -5032,9 +5041,9 @@ void _kickstart() {
|
||||
gc_root(render_path_commands);
|
||||
}
|
||||
|
||||
#ifdef WITH_PLUGINS
|
||||
#ifdef WITH_PLUGINS
|
||||
plugins_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
base_init();
|
||||
iron_start();
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
void script_node_init() {
|
||||
any_array_push(nodes_material_input, script_node_def);
|
||||
any_map_set(parser_material_node_values, "SCRIPT_CPU", script_node_value);
|
||||
any_map_set(ui_nodes_custom_buttons, "script_node_button", script_node_button);
|
||||
}
|
||||
|
||||
char *script_node_value(ui_node_t *node, ui_node_socket_t *socket) {
|
||||
if (parser_material_script_links == NULL) {
|
||||
gc_unroot(parser_material_script_links);
|
||||
parser_material_script_links = any_map_create();
|
||||
gc_root(parser_material_script_links);
|
||||
}
|
||||
@@ -19,3 +19,23 @@ char *script_node_value(ui_node_t *node, ui_node_socket_t *socket) {
|
||||
node_shader_add_constant(parser_material_kong, string("%s: float", link), string("_%s", link));
|
||||
return string("constants.%s", link);
|
||||
}
|
||||
|
||||
ui_node_t *script_node_draw_snippets_node = NULL;
|
||||
|
||||
void script_node_draw_snippets() {
|
||||
if (ui_menu_button("sys_time()", "", ICON_DRAFT)) {
|
||||
ui_node_t *node = script_node_draw_snippets_node;
|
||||
node->buttons->buffer[0]->default_value->buffer = "sys_time()";
|
||||
}
|
||||
}
|
||||
|
||||
void script_node_button(i32 node_id) {
|
||||
ui_node_t *node = ui_get_node(ui_nodes_get_canvas(true)->nodes, node_id);
|
||||
char *node_name = parser_material_node_name(node, NULL);
|
||||
ui_handle_t *h = ui_handle(node_name);
|
||||
|
||||
if (ui_button(tr("Snippets"), UI_ALIGN_CENTER, "")) {
|
||||
script_node_draw_snippets_node = node;
|
||||
ui_menu_draw(&script_node_draw_snippets, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user