From 153863a90486493bf991b5dbb841efe34f08ea5a Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sat, 15 Jun 2024 09:38:43 +0700 Subject: [PATCH] - [Canvas] Now show background array based on frame index. --- objects/o_dialog_add_node/Create_0.gml | 12 +++++++----- scripts/node_canvas/node_canvas.gml | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/objects/o_dialog_add_node/Create_0.gml b/objects/o_dialog_add_node/Create_0.gml index aa5279edb..960e49c47 100644 --- a/objects/o_dialog_add_node/Create_0.gml +++ b/objects/o_dialog_add_node/Create_0.gml @@ -659,12 +659,14 @@ event_inherited(); } if(PREFERENCES.dialog_add_node_grouping) { - gpu_set_blendmode(bm_subtract); - draw_set_color(c_white); - draw_rectangle(0, 0, content_pane.surface_w, ui(16 + 24 / 2), false); - gpu_set_blendmode(bm_normal); - var len = array_length(group_labels); + if(len) { + gpu_set_blendmode(bm_subtract); + draw_set_color(c_white); + draw_rectangle(0, 0, content_pane.surface_w, ui(16 + 24 / 2), false); + gpu_set_blendmode(bm_normal); + } + for( var i = 0; i < len; i++ ) { var lb = group_labels[i]; var _yy = max(lb.y, i == len - 1? ui(8) : min(ui(8), group_labels[i + 1].y - ui(32))); diff --git a/scripts/node_canvas/node_canvas.gml b/scripts/node_canvas/node_canvas.gml index 7047d9dde..d9c9e4c86 100644 --- a/scripts/node_canvas/node_canvas.gml +++ b/scripts/node_canvas/node_canvas.gml @@ -953,7 +953,13 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor var cDep = attrDepth(); - if(_bgDim && is_surface(_bg)) _dim = [ surface_get_width_safe(_bg), surface_get_height_safe(_bg) ]; + if(_bgDim) { + var _bgDim = _bg; + if(is_array(_bgDim) && !array_empty(_bgDim)) _bgDim = _bg[0]; + + if(is_surface(_bgDim)) + _dim = [ surface_get_width_safe(_bgDim), surface_get_height_safe(_bgDim) ]; + } attributes.dimension = _dim; apply_surfaces(); @@ -965,6 +971,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor if(_frames == 1) { var _canvas_surface = getCanvasSurface(0); + if(is_array(_bg) && !array_empty(_bg)) _bg = _bg[0]; + output_surface[0] = surface_verify(output_surface[0], _dim[0], _dim[1], cDep); surface_set_shader(output_surface[0], noone,, BLEND.alpha); @@ -977,11 +985,12 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor } else { for( var i = 0; i < _frames; i++ ) { var _canvas_surface = getCanvasSurface(i); - output_surface[i] = surface_verify(output_surface[i], _dim[0], _dim[1], cDep); + var _bgArray = is_array(_bg)? array_safe_get_fast(_bg, i, 0) : _bg; + output_surface[i] = surface_verify(output_surface[i], _dim[0], _dim[1], cDep); surface_set_shader(output_surface[i], noone,, BLEND.alpha); - if(_bgr && is_surface(_bg)) - draw_surface_stretched_ext(_bg, 0, 0, _dim[0], _dim[1], c_white, _bga); + if(_bgr && is_surface(_bgArray)) + draw_surface_stretched_ext(_bgArray, 0, 0, _dim[0], _dim[1], c_white, _bga); draw_surface_safe(_canvas_surface, 0, 0); surface_reset_shader(); }