From 68bdb32f92023022230284c52387ca0600315186 Mon Sep 17 00:00:00 2001 From: MakhamDev Date: Sun, 8 Oct 2023 20:12:20 +0700 Subject: [PATCH] - [Particle, VFX] Fix error when using custom distribution map. --- scripts/__VFX/__VFX.gml | 6 +- .../_node_VFX_spawner/_node_VFX_spawner.gml | 30 +++-- scripts/locale_data/locale_data.gml | 15 ++- scripts/node_value/node_value.gml | 3 +- scripts/preferences/preferences.gml | 2 + .../preview_overlay_area.gml | 105 +++++++++++------- 6 files changed, 91 insertions(+), 70 deletions(-) diff --git a/scripts/__VFX/__VFX.gml b/scripts/__VFX/__VFX.gml index 548dd5efc..68e1b4fc6 100644 --- a/scripts/__VFX/__VFX.gml +++ b/scripts/__VFX/__VFX.gml @@ -42,8 +42,6 @@ function __part(_node) constructor { //wig_rot = new wiggleMap(seed, 1, PROJECT.animator.frames_total); //wig_dir = new wiggleMap(seed, 1, PROJECT.animator.frames_total); - atlas = noone; - grav = 0; gravDir = -90; gravX = 0; @@ -81,7 +79,6 @@ function __part(_node) constructor { gml_pragma("forceinline"); surf = noone; - atlas = noone; prevx = undefined; prevy = undefined; @@ -260,8 +257,7 @@ function __part(_node) constructor { } } - var surface = atlas == noone? node.surface_cache[$ ss] : atlas.getSurface(); - //print($"VFX: {surface} ({is_surface(surface)}), {atlas}") + var surface = is_instanceof(ss, SurfaceAtlas)? ss.getSurface() : node.surface_cache[$ ss]; if(!is_surface(surface)) return; diff --git a/scripts/_node_VFX_spawner/_node_VFX_spawner.gml b/scripts/_node_VFX_spawner/_node_VFX_spawner.gml index b711d2440..76f24c7f8 100644 --- a/scripts/_node_VFX_spawner/_node_VFX_spawner.gml +++ b/scripts/_node_VFX_spawner/_node_VFX_spawner.gml @@ -15,7 +15,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co inputs[| 4] = nodeValue("Spawn distribution", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) .rejectArray() - .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Area", "Border", "Map", "Atlas" ] ); + .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Area", "Border", "Map" ] ); inputs[| 5] = nodeValue("Lifespan", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 20, 30 ] ) .setDisplay(VALUE_DISPLAY.range); @@ -153,7 +153,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co input_len = ds_list_size(inputs); input_display_list = [ 32, - ["Sprite", false], 0, 31, 22, 23, 26, + ["Sprite", false], 0, 22, 23, 26, ["Spawn", true], 27, 16, 44, 1, 2, 3, 4, 30, 24, 5, ["Movement", true], 29, 6, 18, ["Physics", true], 7, 19, 33, 34, 35, 36, @@ -197,7 +197,6 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co static spawn = function(_time = PROJECT.animator.current_frame, _pos = -1) { #region var _inSurf = current_data[ 0]; - var _atlas = current_data[31]; var _spawn_amount = current_data[ 2]; @@ -240,10 +239,10 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co if(_rotation[1] < _rotation[0]) _rotation[1] += 360; var _posDist = []; - if(_distrib == 2) _posDist = get_points_from_dist(_dist_map, _amo, seed); random_set_seed(seed); var _amo = irandom_range(_spawn_amount[0], _spawn_amount[1]); + if(_distrib == 2) _posDist = get_points_from_dist(_dist_map, _amo, seed); //print($"Frame {_time}: Spawning {_amo} particles, seed {seed}, {irandom(99999999)}"); for( var i = 0; i < _amo; i++ ) { @@ -271,8 +270,12 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co var yy = 0; if(_pos == -1) { - if(_distrib < 2) { - var sp = area_get_random_point(_spawn_area, _distrib, _scatter, spawn_index, _spawn_amount, seed); + if(is_instanceof(_spr, SurfaceAtlas)) { + xx = _spawn_area[0] + _spr.x + _spr.w / 2; + yy = _spawn_area[1] + _spr.y + _spr.h / 2; + part.atlas = _spr; + } else if(_distrib < 2) { + var sp = area_get_random_point(_spawn_area, _distrib, _scatter, spawn_index, _amo, seed); xx = sp[0]; yy = sp[1]; } else if(_distrib == 2) { @@ -281,13 +284,6 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co xx = _spawn_area[0] + _spawn_area[2] * (sp[0] * 2 - 1.); yy = _spawn_area[1] + _spawn_area[3] * (sp[1] * 2 - 1.); - } else if(_distrib == 3) { - sp = array_safe_get(_atlas, spawn_index,, ARRAY_OVERFLOW.loop); - - if(!is_instanceof(sp, SurfaceAtlas)) continue; - xx = sp.x + sp.w / 2; - yy = sp.y + sp.h / 2; - part.atlas = sp; } } else { xx = _pos[0]; @@ -454,9 +450,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co inputs[| 24].setVisible(_dist < 2); - inputs[| 0].setVisible(_dist != 3, _dist != 3); inputs[| 30].setVisible(_dist == 2, _dist == 2); - inputs[| 31].setVisible(_dist == 3, _dist == 3); inputs[| 35].setVisible(_turn[0] != 0 && _turn[1] != 0); inputs[| 36].setVisible(_turn[0] != 0 && _turn[1] != 0); @@ -488,7 +482,11 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co } #endregion static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region - inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + var _spr = getInputData(0); + if(is_array(_spr)) _spr = _spr[0]; + var _flag = is_instanceof(_spr, SurfaceAtlas)? 0b0001 : 0b0011; + + inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny, _flag); if(onDrawOverlay != -1) onDrawOverlay(active, _x, _y, _s, _mx, _my); } #endregion diff --git a/scripts/locale_data/locale_data.gml b/scripts/locale_data/locale_data.gml index 19ea1bcf3..51cf25ad6 100644 --- a/scripts/locale_data/locale_data.gml +++ b/scripts/locale_data/locale_data.gml @@ -1,7 +1,8 @@ #region locale - globalvar LOCALE, TEST_LOCALE; + globalvar LOCALE, TEST_LOCALE, LOCALE_USE_DEFAULT; LOCALE = {} TEST_LOCALE = false; + LOCALE_USE_DEFAULT = true; function __initLocale() { var lfile = $"data/locale/en.zip"; @@ -36,6 +37,8 @@ function __txtx(key, def = "") { gml_pragma("forceinline"); + if(LOCALE_USE_DEFAULT) return def; + if(TEST_LOCALE) { if(!struct_has(LOCALE.word, key) && !struct_has(LOCALE.ui, key)) { show_debug_message($"LOCALE: \"{key}\": \"{def}\","); @@ -56,6 +59,8 @@ function __txt(txt, prefix = "") { gml_pragma("forceinline"); + if(LOCALE_USE_DEFAULT) return txt; + var key = string_lower(txt); key = string_replace_all(key, " ", "_"); @@ -73,7 +78,7 @@ function __txt_node_name(node, def = "") { gml_pragma("forceinline"); - //if(TESTING) return def; + if(LOCALE_USE_DEFAULT) return def; if(!struct_has(LOCALE.node, node)) return def; @@ -85,7 +90,7 @@ function __txt_node_tooltip(node, def = "") { gml_pragma("forceinline"); - //if(TESTING) return def; + if(LOCALE_USE_DEFAULT) return def; if(!struct_has(LOCALE.node, node)) return def; @@ -97,7 +102,7 @@ function __txt_junction_name(node, type, index, def = "") { gml_pragma("forceinline"); - //if(TESTING) return def; + if(LOCALE_USE_DEFAULT) return def; if(!struct_has(LOCALE.node, node)) return def; @@ -113,7 +118,7 @@ function __txt_junction_tooltip(node, type, index, def = "") { gml_pragma("forceinline"); - //if(TESTING) return def; + if(LOCALE_USE_DEFAULT) return def; if(!struct_has(LOCALE.node, node)) return def; diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 439b3c5e0..6b0cd661a 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1858,7 +1858,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return preview_overlay_vector(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny, _spr); case VALUE_DISPLAY.area : - return preview_overlay_area(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny, struct_try_get(display_data, "onSurfaceSize")); + var _flag = argument_count > 8? argument[8] : 0b0011; + return preview_overlay_area(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag, struct_try_get(display_data, "onSurfaceSize")); case VALUE_DISPLAY.puppet_control : return preview_overlay_puppet(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny); diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index 6c17ed8cc..12aff575c 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -202,6 +202,8 @@ var f = json_load_struct(DIRECTORY + "key_nodes.json"); struct_override(HOTKEYS_CUSTOM, f); + + LOCALE_USE_DEFAULT = PREF_MAP[? "local"] == "en"; } function PREF_APPLY() { diff --git a/scripts/preview_overlay_area/preview_overlay_area.gml b/scripts/preview_overlay_area/preview_overlay_area.gml index d879d9c0e..9886064e8 100644 --- a/scripts/preview_overlay_area/preview_overlay_area.gml +++ b/scripts/preview_overlay_area/preview_overlay_area.gml @@ -1,4 +1,4 @@ -function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, display_data) { +function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag, display_data) { var _val = array_clone(getValue()); var hover = -1; @@ -20,20 +20,27 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s var xc = (x0 + x1) / 2; var yc = (y0 + y1) / 2; - draw_set_color(COLORS._main_accent); - draw_set_circle_precision(32); - switch(__at) { - case AREA_SHAPE.rectangle : draw_rectangle(x0, y0, x1, y1, true); break; - case AREA_SHAPE.elipse : draw_ellipse(x0, y0, x1, y1, true); break; + var drawPos = _flag & 0b0001; + var drawSize = _flag & 0b0010; + + if(drawSize) { + draw_set_color(COLORS._main_accent); + draw_set_circle_precision(32); + switch(__at) { + case AREA_SHAPE.rectangle : draw_rectangle(x0, y0, x1, y1, true); break; + case AREA_SHAPE.elipse : draw_ellipse(x0, y0, x1, y1, true); break; + } } if(!interact) return -1; - draw_sprite_colored(THEME.anchor, 0, xc, yc); - draw_sprite_colored(THEME.anchor_solid_hori, 0, xc, y0,, 0); - draw_sprite_colored(THEME.anchor_solid_hori, 0, xc, y1,, 0); - draw_sprite_colored(THEME.anchor_solid_hori, 0, x0, yc,, 90); - draw_sprite_colored(THEME.anchor_solid_hori, 0, x1, yc,, 90); + if(drawPos) draw_sprite_colored(THEME.anchor, 0, xc, yc); + if(drawSize) { + draw_sprite_colored(THEME.anchor_solid_hori, 0, xc, y0,, 0); + draw_sprite_colored(THEME.anchor_solid_hori, 0, xc, y1,, 0); + draw_sprite_colored(THEME.anchor_solid_hori, 0, x0, yc,, 90); + draw_sprite_colored(THEME.anchor_solid_hori, 0, x1, yc,, 90); + } if(drag_type == 1) { var _xx = value_snap(drag_sx - (_mx - drag_mx) / _s, _snx); @@ -81,7 +88,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s UNDO_HOLDING = false; } - if(active && point_in_circle(_mx, _my, xc, y0, 16)) { + if(drawSize && active && point_in_circle(_mx, _my, xc, y0, 16)) { draw_sprite_colored(THEME.anchor_solid_hori, 1, xc, y0); hover = 1; @@ -90,7 +97,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s drag_sy = _t; drag_my = _my; } - } else if(active && point_in_circle(_mx, _my, xc, y1, 16)) { + } else if(drawSize && active && point_in_circle(_mx, _my, xc, y1, 16)) { draw_sprite_colored(THEME.anchor_solid_hori, 1, xc, y1); hover = 3; @@ -99,7 +106,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s drag_sy = _b; drag_my = _my; } - } else if(active && point_in_circle(_mx, _my, x0, yc, 16)) { + } else if(drawSize && active && point_in_circle(_mx, _my, x0, yc, 16)) { draw_sprite_colored(THEME.anchor_solid_hori, 1, x0, yc,, 90); hover = 0; @@ -108,7 +115,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s drag_sx = _l; drag_mx = _mx; } - } else if(active && point_in_circle(_mx, _my, x1, yc, 16)) { + } else if(drawSize && active && point_in_circle(_mx, _my, x1, yc, 16)) { draw_sprite_colored(THEME.anchor_solid_hori, 1, x1, yc,, 90); hover = 2; @@ -117,7 +124,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s drag_sx = _r; drag_mx = _mx; } - } else if(active && point_in_rectangle(_mx, _my, x0, y0, x1, y1)) { + } else if(drawPos && active && point_in_rectangle(_mx, _my, x0, y0, x1, y1)) { draw_sprite_colored(THEME.anchor, 1, xc, yc); hover = 4; @@ -133,7 +140,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s return hover; } -function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my, _snx, _sny) { +function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag) { var _val = array_clone(getValue()); var hover = -1; @@ -151,18 +158,25 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my, var xc = (x0 + x1) / 2; var yc = (y0 + y1) / 2; - draw_set_color(COLORS._main_accent); - draw_set_circle_precision(32); - switch(__at) { - case AREA_SHAPE.rectangle : draw_rectangle(x0, y0, x1, y1, true); break; - case AREA_SHAPE.elipse : draw_ellipse(x0, y0, x1, y1, true); break; + var drawPos = _flag & 0b0001; + var drawSize = _flag & 0b0010; + + if(drawSize) { + draw_set_color(COLORS._main_accent); + draw_set_circle_precision(32); + switch(__at) { + case AREA_SHAPE.rectangle : draw_rectangle(x0, y0, x1, y1, true); break; + case AREA_SHAPE.elipse : draw_ellipse(x0, y0, x1, y1, true); break; + } } if(!interact) return -1; - draw_sprite_colored(THEME.anchor, 1, xc, yc); - draw_sprite_colored(THEME.anchor_selector, 0, x0, y0); - draw_sprite_colored(THEME.anchor_selector, 0, x1, y1); + if(drawPos) draw_sprite_colored(THEME.anchor, 1, xc, yc); + if(drawSize) { + draw_sprite_colored(THEME.anchor_selector, 0, x0, y0); + draw_sprite_colored(THEME.anchor_selector, 0, x1, y1); + } if(drag_type == 1) { var _xx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx); @@ -204,7 +218,7 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my, } } - if(active && point_in_circle(_mx, _my, x0, y0, 8)) { + if(drawSize && active && point_in_circle(_mx, _my, x0, y0, 8)) { draw_sprite_colored(THEME.anchor_selector, 1, x0, y0); hover = 1; @@ -215,7 +229,7 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my, drag_mx = _mx; drag_my = _my; } - } else if(active && point_in_circle(_mx, _my, x1, y1, 8)) { + } else if(drawSize && active && point_in_circle(_mx, _my, x1, y1, 8)) { draw_sprite_colored(THEME.anchor_selector, 1, x1, y1); hover = 2; @@ -226,7 +240,7 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my, drag_mx = _mx; drag_my = _my; } - } else if(active && point_in_rectangle(_mx, _my, x0, y0, x1, y1)) { + } else if(drawPos && active && point_in_rectangle(_mx, _my, x0, y0, x1, y1)) { draw_sprite_colored(THEME.anchor, 1, xc, yc); hover = 3; @@ -242,7 +256,7 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my, return hover; } -function preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx, _sny) { +function preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag) { var _val = array_clone(getValue()); var hover = -1; @@ -256,18 +270,23 @@ function preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx, var _ay = __ay * _s + _y; var _aw = __aw * _s; var _ah = __ah * _s; - - draw_set_color(COLORS._main_accent); - draw_set_circle_precision(32); - switch(__at) { - case AREA_SHAPE.rectangle : draw_rectangle(_ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah, true); break; - case AREA_SHAPE.elipse : draw_ellipse(_ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah, true); break; + + var drawPos = _flag & 0b0001; + var drawSize = _flag & 0b0010; + + if(drawSize) { + draw_set_color(COLORS._main_accent); + draw_set_circle_precision(32); + switch(__at) { + case AREA_SHAPE.rectangle : draw_rectangle(_ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah, true); break; + case AREA_SHAPE.elipse : draw_ellipse(_ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah, true); break; + } } if(!interact) return -1; - draw_sprite_colored(THEME.anchor, 0, _ax, _ay); - draw_sprite_colored(THEME.anchor_selector, 0, _ax + _aw, _ay + _ah); + if(drawPos) draw_sprite_colored(THEME.anchor, 0, _ax, _ay); + if(drawSize) draw_sprite_colored(THEME.anchor_selector, 0, _ax + _aw, _ay + _ah); if(point_in_circle(_mx, _my, _ax + _aw, _ay + _ah, 8)) draw_sprite_colored(THEME.anchor_selector, 1, _ax + _aw, _ay + _ah); @@ -319,14 +338,14 @@ function preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx, } } - if(active && point_in_circle(_mx, _my, _ax + _aw, _ay + _ah, 8)) { + if(drawSize && active && point_in_circle(_mx, _my, _ax + _aw, _ay + _ah, 8)) { hover = 2; if(mouse_press(mb_left)) { drag_type = 2; drag_mx = _ax; drag_my = _ay; } - } else if(active && point_in_rectangle(_mx, _my, _ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah)) { + } else if(drawPos && active && point_in_rectangle(_mx, _my, _ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah)) { hover = 1; if(mouse_press(mb_left)) { drag_type = 1; @@ -340,18 +359,18 @@ function preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx, return hover; } -function preview_overlay_area(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, display_data) { +function preview_overlay_area(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag, display_data) { var _val = array_clone(getValue()); var hover = -1; if(is_array(_val[0])) return hover; var mode = editWidget.mode; if(mode == AREA_MODE.area) - hover = preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx, _sny); + hover = preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag); else if(mode == AREA_MODE.padding) - hover = preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, display_data) + hover = preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag, display_data) else if(mode == AREA_MODE.two_point) - hover = preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my, _snx, _sny); + hover = preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag); return hover; } \ No newline at end of file