|
@@ -1,11 +1,5 @@
|
|
|
|
|
|
-///if is_paint
|
|
|
let ui_nodes_show: bool = false;
|
|
|
-///end
|
|
|
-///if is_lab
|
|
|
-let ui_nodes_show: bool = true;
|
|
|
-///end
|
|
|
-
|
|
|
let ui_nodes_wx: i32;
|
|
|
let ui_nodes_wy: i32;
|
|
|
let ui_nodes_ww: i32;
|
|
@@ -125,18 +119,12 @@ function ui_viewnodes_on_link_drag(link_drag_id: i32, is_new_link: bool) {
|
|
|
link_drag.from_socket = 0;
|
|
|
array_push(ui_nodes_get_canvas(true).links, link_drag);
|
|
|
}
|
|
|
- ///if is_lab
|
|
|
- parser_logic_parse(ui_nodes_get_canvas(true));
|
|
|
- context_raw.rdirty = 5;
|
|
|
- ///end
|
|
|
});
|
|
|
}
|
|
|
// Selecting which node socket to preview
|
|
|
else if (ui_nodes.nodes_selected_id.length > 0 && node.id == ui_nodes.nodes_selected_id[0]) {
|
|
|
context_raw.node_preview_socket = link_drag.from_id > -1 ? link_drag.from_socket : 0;
|
|
|
- ///if is_paint
|
|
|
context_raw.node_preview_dirty = true;
|
|
|
- ///end
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -257,9 +245,7 @@ function ui_viewnodes_on_socket_released(socket_id: i32) {
|
|
|
let i: i32 = array_index_of(node.outputs, socket);
|
|
|
if (i > -1) {
|
|
|
context_raw.node_preview_socket = i;
|
|
|
- ///if is_paint
|
|
|
context_raw.node_preview_dirty = true;
|
|
|
- ///end
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -303,9 +289,7 @@ function ui_viewnodes_on_canvas_released() {
|
|
|
|
|
|
ui._y += 1;
|
|
|
let is_protected: bool = selected == null ||
|
|
|
- ///if is_paint
|
|
|
selected.type == "OUTPUT_MATERIAL_PBR" ||
|
|
|
- ///end
|
|
|
selected.type == "GROUP_INPUT" ||
|
|
|
selected.type == "GROUP_OUTPUT" ||
|
|
|
selected.type == "brush_output_node";
|
|
@@ -474,7 +458,6 @@ function ui_nodes_tab_index(): i32 {
|
|
|
}
|
|
|
|
|
|
function ui_nodes_get_canvas(groups: bool = false): ui_node_canvas_t {
|
|
|
- ///if is_paint
|
|
|
if (ui_nodes_canvas_type == canvas_type_t.MATERIAL) {
|
|
|
if (groups && ui_nodes_group_stack.length > 0) {
|
|
|
return ui_nodes_group_stack[ui_nodes_group_stack.length - 1].canvas;
|
|
@@ -489,11 +472,6 @@ function ui_nodes_get_canvas(groups: bool = false): ui_node_canvas_t {
|
|
|
else {
|
|
|
return context_raw.brush.canvas;
|
|
|
}
|
|
|
- ///end
|
|
|
-
|
|
|
- ///if is_lab
|
|
|
- return project_canvas;
|
|
|
- ///end
|
|
|
}
|
|
|
|
|
|
function ui_nodes_get_canvas_material(): ui_node_canvas_t {
|
|
@@ -501,7 +479,6 @@ function ui_nodes_get_canvas_material(): ui_node_canvas_t {
|
|
|
}
|
|
|
|
|
|
function ui_nodes_get_nodes(): ui_nodes_t {
|
|
|
- ///if is_paint
|
|
|
if (ui_nodes_canvas_type == canvas_type_t.MATERIAL) {
|
|
|
if (ui_nodes_group_stack.length > 0) {
|
|
|
return ui_nodes_group_stack[ui_nodes_group_stack.length - 1].nodes;
|
|
@@ -516,16 +493,6 @@ function ui_nodes_get_nodes(): ui_nodes_t {
|
|
|
else {
|
|
|
return context_raw.brush.nodes;
|
|
|
}
|
|
|
- ///end
|
|
|
-
|
|
|
- ///if is_lab
|
|
|
- if (ui_nodes_group_stack.length > 0) {
|
|
|
- return ui_nodes_group_stack[ui_nodes_group_stack.length - 1].nodes;
|
|
|
- }
|
|
|
- else {
|
|
|
- return project_nodes;
|
|
|
- }
|
|
|
- ///end
|
|
|
}
|
|
|
|
|
|
function ui_nodes_update() {
|
|
@@ -533,12 +500,7 @@ function ui_nodes_update() {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- ///if is_paint
|
|
|
ui_nodes_wx = math_floor(sys_w()) + ui_toolbar_w(true);
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- ui_nodes_wx = math_floor(sys_w());
|
|
|
- ///end
|
|
|
ui_nodes_wy = ui_header_h * 2;
|
|
|
|
|
|
if (ui_view2d_show) {
|
|
@@ -547,10 +509,8 @@ function ui_nodes_update() {
|
|
|
|
|
|
let ww: i32 = config_raw.layout[layout_size_t.NODES_W];
|
|
|
if (!ui_base_show) {
|
|
|
- ///if is_paint
|
|
|
ww += config_raw.layout[layout_size_t.SIDEBAR_W] + ui_toolbar_w(true);
|
|
|
ui_nodes_wx -= ui_toolbar_w(true);
|
|
|
- ///end
|
|
|
ui_nodes_wy = 0;
|
|
|
}
|
|
|
|
|
@@ -650,12 +610,7 @@ function ui_nodes_node_search(x: i32 = -1, y: i32 = -1, done: ()=>void = null) {
|
|
|
let FILL_BUTTON_BG: bool = ui.ops.theme.FILL_BUTTON_BG;
|
|
|
ui.ops.theme.FILL_BUTTON_BG = true;
|
|
|
|
|
|
- ///if is_paint
|
|
|
let node_list: node_list_t[] = ui_nodes_canvas_type == canvas_type_t.MATERIAL ? nodes_material_list : nodes_brush_list;
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- let node_list: node_list_t[] = nodes_brush_list;
|
|
|
- ///end
|
|
|
|
|
|
for (let i: i32 = 0; i < node_list.length; ++i) {
|
|
|
let list: ui_node_t[] = node_list[i];
|
|
@@ -672,10 +627,6 @@ function ui_nodes_node_search(x: i32 = -1, y: i32 = -1, done: ()=>void = null) {
|
|
|
nodes.nodes_selected_id = [ui_nodes_node_search_spawn.id];
|
|
|
nodes.nodes_drag = true;
|
|
|
|
|
|
- ///if is_lab
|
|
|
- parser_logic_parse(canvas);
|
|
|
- ///end
|
|
|
-
|
|
|
ui_nodes_hwnd.redraws = 2;
|
|
|
if (enter) {
|
|
|
ui.changed = true;
|
|
@@ -714,11 +665,9 @@ function ui_nodes_get_node_y(): i32 {
|
|
|
function ui_nodes_draw_grid(zoom: f32): gpu_texture_t {
|
|
|
let ww: i32 = config_raw.layout[layout_size_t.NODES_W];
|
|
|
|
|
|
- ///if is_paint
|
|
|
if (!ui_base_show) {
|
|
|
ww += config_raw.layout[layout_size_t.SIDEBAR_W] + ui_toolbar_w(true);
|
|
|
}
|
|
|
- ///end
|
|
|
|
|
|
let wh: i32 = sys_h();
|
|
|
let step: f32 = ui_nodes_grid_cell_w * zoom;
|
|
@@ -772,7 +721,6 @@ let _ui_nodes_render_tmp: (col: i32)=>void;
|
|
|
|
|
|
function ui_nodes_recompile() {
|
|
|
if (ui_nodes_recompile_mat) {
|
|
|
- ///if is_paint
|
|
|
if (ui_nodes_canvas_type == canvas_type_t.BRUSH) {
|
|
|
make_material_parse_brush();
|
|
|
util_render_make_brush_preview();
|
|
@@ -801,16 +749,10 @@ function ui_nodes_recompile() {
|
|
|
if (context_raw.split_view) {
|
|
|
context_raw.ddirty = 2;
|
|
|
}
|
|
|
- ///end
|
|
|
-
|
|
|
- ///if is_lab
|
|
|
- parser_logic_parse(project_canvas);
|
|
|
- ///end
|
|
|
|
|
|
ui_nodes_recompile_mat = false;
|
|
|
}
|
|
|
else if (ui_nodes_recompile_mat_final) {
|
|
|
- ///if is_paint
|
|
|
make_material_parse_paint_material();
|
|
|
|
|
|
if (ui_nodes_canvas_type == canvas_type_t.MATERIAL && layers_is_fill_material()) {
|
|
@@ -825,7 +767,6 @@ function ui_nodes_recompile() {
|
|
|
|
|
|
ui_base_hwnds[tab_area_t.SIDEBAR0].redraws = 2;
|
|
|
context_raw.node_preview_dirty = true;
|
|
|
- ///end
|
|
|
|
|
|
ui_nodes_recompile_mat_final = false;
|
|
|
}
|
|
@@ -838,13 +779,7 @@ function ui_nodes_render() {
|
|
|
let nodes: ui_nodes_t = ui_nodes_get_nodes();
|
|
|
if (nodes.nodes_selected_id.length > 0 && nodes.nodes_selected_id[0] != ui_nodes_last_node_selected_id) {
|
|
|
ui_nodes_last_node_selected_id = nodes.nodes_selected_id[0];
|
|
|
- ///if is_paint
|
|
|
context_raw.node_preview_dirty = true;
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- context_raw.ddirty = 2; // Show selected node texture in viewport
|
|
|
- ui_header_handle.redraws = 2;
|
|
|
- ///end
|
|
|
context_raw.node_preview_socket = 0;
|
|
|
}
|
|
|
|
|
@@ -871,33 +806,22 @@ function ui_nodes_render() {
|
|
|
ui_nodes_grid_redraw = false;
|
|
|
}
|
|
|
|
|
|
- ///if is_paint
|
|
|
if (config_raw.node_preview && context_raw.node_preview_dirty) {
|
|
|
ui_nodes_make_node_preview();
|
|
|
}
|
|
|
- ///end
|
|
|
|
|
|
// Start with UI
|
|
|
ui_begin(ui);
|
|
|
|
|
|
// Make window
|
|
|
ui_nodes_ww = config_raw.layout[layout_size_t.NODES_W];
|
|
|
-
|
|
|
- ///if is_paint
|
|
|
ui_nodes_wx = math_floor(sys_w()) + ui_toolbar_w(true);
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- ui_nodes_wx = math_floor(sys_w());
|
|
|
- ///end
|
|
|
-
|
|
|
ui_nodes_wy = 0;
|
|
|
|
|
|
- ///if is_paint
|
|
|
if (!ui_base_show) {
|
|
|
ui_nodes_ww += config_raw.layout[layout_size_t.SIDEBAR_W] + ui_toolbar_w(true);
|
|
|
ui_nodes_wx -= ui_toolbar_w(true);
|
|
|
}
|
|
|
- ///end
|
|
|
|
|
|
let ew: i32 = math_floor(UI_ELEMENT_W() * 0.7);
|
|
|
ui_nodes_wh = sys_h();
|
|
@@ -936,11 +860,9 @@ function ui_nodes_render() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ///if is_paint
|
|
|
if (ui_tab(ui_nodes_htab, tr("+"))) {
|
|
|
array_push(ui_nodes_tabs, context_raw.material);
|
|
|
}
|
|
|
- ///end
|
|
|
}
|
|
|
|
|
|
// Grid
|
|
@@ -960,9 +882,7 @@ function ui_nodes_render() {
|
|
|
let header_h: i32 = UI_ELEMENT_H() * 2 + UI_ELEMENT_OFFSET() * 2;
|
|
|
let header_hover: bool = ui.input_y < ui._window_y + header_h;
|
|
|
ui.input_enabled = _input_enabled && !ui_nodes_show_menu && !header_hover;
|
|
|
- ///if is_paint
|
|
|
ui.window_border_right = config_raw.layout[layout_size_t.SIDEBAR_W];
|
|
|
- ///end
|
|
|
ui.window_border_top = ui_header_h * 2;
|
|
|
ui.window_border_bottom = config_raw.layout[layout_size_t.STATUS_H];
|
|
|
|
|
@@ -978,13 +898,7 @@ function ui_nodes_render() {
|
|
|
_ui_nodes_render_tmp(color.base);
|
|
|
ui_nodes_hwnd.redraws = 2;
|
|
|
|
|
|
- ///if is_paint
|
|
|
let material_live: bool = config_raw.material_live;
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- let material_live: bool = true;
|
|
|
- ///end
|
|
|
-
|
|
|
if (material_live) {
|
|
|
ui_nodes_canvas_changed();
|
|
|
}
|
|
@@ -994,12 +908,7 @@ function ui_nodes_render() {
|
|
|
|
|
|
// Remove nodes with unknown id for this canvas type
|
|
|
if (ui_is_paste) {
|
|
|
- ///if is_paint
|
|
|
let node_list: node_list_t[] = ui_nodes_canvas_type == canvas_type_t.MATERIAL ? nodes_material_list : nodes_brush_list;
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- let node_list: node_list_t[] = nodes_brush_list;
|
|
|
- ///end
|
|
|
|
|
|
let i: i32 = 0;
|
|
|
while (i++ < c.nodes.length) {
|
|
@@ -1041,12 +950,7 @@ function ui_nodes_render() {
|
|
|
|
|
|
// Recompile material on change
|
|
|
if (ui.changed) {
|
|
|
- ///if is_paint
|
|
|
ui_nodes_recompile_mat = (ui.input_dx != 0 || ui.input_dy != 0 || !ui_nodes_uichanged_last) && config_raw.material_live; // Instant preview
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- ui_nodes_recompile_mat = (ui.input_dx != 0 || ui.input_dy != 0 || !ui_nodes_uichanged_last); // Instant preview
|
|
|
- ///end
|
|
|
}
|
|
|
else if (ui_nodes_uichanged_last) {
|
|
|
ui_nodes_canvas_changed();
|
|
@@ -1059,15 +963,11 @@ function ui_nodes_render() {
|
|
|
let img: gpu_texture_t = null;
|
|
|
let sel: ui_node_t = ui_get_node(c.nodes, nodes.nodes_selected_id[0]);
|
|
|
|
|
|
- ///if is_paint
|
|
|
-
|
|
|
let single_channel: bool = sel.type == "LAYER_MASK";
|
|
|
if (sel.type == "LAYER" || sel.type == "LAYER_MASK") {
|
|
|
let id: i32 = sel.buttons[0].default_value[0];
|
|
|
if (id < project_layers.length) {
|
|
|
- ///if is_paint
|
|
|
img = project_layers[id].texpaint_preview;
|
|
|
- ///end
|
|
|
}
|
|
|
}
|
|
|
else if (sel.type == "MATERIAL") {
|
|
@@ -1086,40 +986,25 @@ function ui_nodes_render() {
|
|
|
img = context_raw.node_preview;
|
|
|
}
|
|
|
|
|
|
- ///else
|
|
|
-
|
|
|
- let brush_node: logic_node_ext_t = parser_logic_get_logic_node(sel);
|
|
|
- if (brush_node != null) {
|
|
|
- img = logic_node_get_cached_image(brush_node.base);
|
|
|
- }
|
|
|
-
|
|
|
- ///end
|
|
|
-
|
|
|
if (img != null) {
|
|
|
let tw: f32 = 128 * UI_SCALE();
|
|
|
let th: f32 = tw * (img.height / img.width);
|
|
|
let tx: f32 = ui_nodes_ww - tw - 8 * UI_SCALE();
|
|
|
let ty: f32 = ui_nodes_wh - th - 8 * UI_SCALE();
|
|
|
-
|
|
|
let invert_y: bool = false;
|
|
|
-
|
|
|
- ///if is_paint
|
|
|
if (single_channel) {
|
|
|
draw_set_pipeline(ui_view2d_pipe);
|
|
|
gpu_set_int(ui_view2d_channel_loc, 1);
|
|
|
}
|
|
|
- ///end
|
|
|
|
|
|
draw_set_color(0xffffffff);
|
|
|
invert_y ?
|
|
|
draw_scaled_image(img, tx, ty + th, tw, -th) :
|
|
|
draw_scaled_image(img, tx, ty, tw, th);
|
|
|
|
|
|
- ///if is_paint
|
|
|
if (single_channel) {
|
|
|
draw_set_pipeline(null);
|
|
|
}
|
|
|
- ///end
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1133,22 +1018,10 @@ function ui_nodes_render() {
|
|
|
ui_end();
|
|
|
|
|
|
if (ui_nodes_show_menu) {
|
|
|
- ///if is_paint
|
|
|
let list: node_list_t[] = ui_nodes_canvas_type == canvas_type_t.MATERIAL ? nodes_material_list : nodes_brush_list;
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- let list: node_list_t[] = nodes_brush_list;
|
|
|
- ///end
|
|
|
-
|
|
|
let category: ui_node_t[] = list[ui_nodes_menu_category];
|
|
|
let num_nodes: i32 = category.length;
|
|
|
-
|
|
|
- ///if is_paint
|
|
|
let is_group_category: bool = ui_nodes_canvas_type == canvas_type_t.MATERIAL && nodes_material_categories[ui_nodes_menu_category] == "Group";
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- let is_group_category: bool = nodes_material_categories[ui_nodes_menu_category] == "Group";
|
|
|
- ///end
|
|
|
|
|
|
if (is_group_category) {
|
|
|
num_nodes += project_material_groups.length;
|
|
@@ -1182,9 +1055,6 @@ function ui_nodes_render() {
|
|
|
array_push(canvas.nodes, node);
|
|
|
nodes.nodes_selected_id = [node.id];
|
|
|
nodes.nodes_drag = true;
|
|
|
- ///if is_lab
|
|
|
- parser_logic_parse(canvas);
|
|
|
- ///end
|
|
|
}
|
|
|
// Next column
|
|
|
if (ui._y - ui_nodes_wy + UI_ELEMENT_H() / 2 > ui_nodes_wh) {
|
|
@@ -1208,13 +1078,11 @@ function ui_nodes_render() {
|
|
|
nodes.nodes_drag = true;
|
|
|
}
|
|
|
|
|
|
- ///if is_paint
|
|
|
ui.enabled = !project_is_material_group_in_use(g);
|
|
|
if (ui_button("x", ui_align_t.CENTER)) {
|
|
|
history_delete_material_group(g);
|
|
|
array_remove(project_material_groups, g);
|
|
|
}
|
|
|
- ///end
|
|
|
|
|
|
ui.enabled = true;
|
|
|
}
|
|
@@ -1252,7 +1120,6 @@ function ui_nodes_draw_menubar() {
|
|
|
ui._y = 2 + start_y;
|
|
|
ui._w = ew;
|
|
|
|
|
|
- ///if is_paint
|
|
|
// Editable canvas name
|
|
|
let h: ui_handle_t = ui_handle(__ID__);
|
|
|
h.text = c.name;
|
|
@@ -1299,22 +1166,11 @@ function ui_nodes_draw_menubar() {
|
|
|
c.name = new_name;
|
|
|
}
|
|
|
}
|
|
|
- ///end
|
|
|
-
|
|
|
- ///if is_lab
|
|
|
- ui.window_border_top = 0;
|
|
|
- ui_nodes_ext_draw_buttons(ew, start_y);
|
|
|
- ///end
|
|
|
|
|
|
let _BUTTON_COL: i32 = ui.ops.theme.BUTTON_COL;
|
|
|
ui.ops.theme.BUTTON_COL = ui.ops.theme.SEPARATOR_COL;
|
|
|
|
|
|
- ///if is_paint
|
|
|
let cats: string[] = ui_nodes_canvas_type == canvas_type_t.MATERIAL ? nodes_material_categories : nodes_brush_categories;
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- let cats: string[] = nodes_brush_categories;
|
|
|
- ///end
|
|
|
|
|
|
for (let i: i32 = 0; i < cats.length; ++i) {
|
|
|
if ((_ui_menu_button(tr(cats[i]))) || (ui.is_hovered && ui_nodes_show_menu)) {
|
|
@@ -1421,22 +1277,13 @@ function ui_nodes_push_undo(last_canvas: ui_node_canvas_t = null) {
|
|
|
function ui_nodes_accept_asset_drag(index: i32) {
|
|
|
ui_nodes_push_undo();
|
|
|
let g: node_group_t = ui_nodes_group_stack.length > 0 ? ui_nodes_group_stack[ui_nodes_group_stack.length - 1] : null;
|
|
|
- ///if is_paint
|
|
|
let n: ui_node_t =
|
|
|
ui_nodes_canvas_type == canvas_type_t.MATERIAL ?
|
|
|
nodes_material_create_node("TEX_IMAGE", g) :
|
|
|
nodes_brush_create_node("TEX_IMAGE");
|
|
|
- ///end
|
|
|
- ///if is_lab
|
|
|
- let n: ui_node_t = nodes_brush_create_node("image_texture_node");
|
|
|
- ///end
|
|
|
|
|
|
n.buttons[0].default_value[0] = index;
|
|
|
ui_nodes_get_nodes().nodes_selected_id = [n.id];
|
|
|
-
|
|
|
- ///if is_lab
|
|
|
- parser_logic_parse(project_canvas);
|
|
|
- ///end
|
|
|
}
|
|
|
|
|
|
function ui_nodes_accept_layer_drag(index: i32) {
|
|
@@ -1459,7 +1306,6 @@ function ui_nodes_accept_material_drag(index: i32) {
|
|
|
}
|
|
|
|
|
|
function ui_nodes_accept_swatch_drag(swatch: swatch_color_t) {
|
|
|
- ///if is_paint
|
|
|
ui_nodes_push_undo();
|
|
|
let g: node_group_t = ui_nodes_group_stack.length > 0 ? ui_nodes_group_stack[ui_nodes_group_stack.length - 1] : null;
|
|
|
let n: ui_node_t = nodes_material_create_node("RGB", g);
|
|
@@ -1470,7 +1316,6 @@ function ui_nodes_accept_swatch_drag(swatch: swatch_color_t) {
|
|
|
color_get_ab(swatch.base) / 255
|
|
|
);
|
|
|
ui_nodes_get_nodes().nodes_selected_id = [n.id];
|
|
|
- ///end
|
|
|
}
|
|
|
|
|
|
function ui_nodes_make_node(n: ui_node_t, nodes: ui_nodes_t, canvas: ui_node_canvas_t): ui_node_t {
|