mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 22:46:19 +01:00
- [Particle, VFX] Fix error when using custom distribution map.
This commit is contained in:
parent
ea76ccf120
commit
68bdb32f92
6 changed files with 91 additions and 70 deletions
|
@ -42,8 +42,6 @@ function __part(_node) constructor {
|
||||||
//wig_rot = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
|
//wig_rot = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
|
||||||
//wig_dir = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
|
//wig_dir = new wiggleMap(seed, 1, PROJECT.animator.frames_total);
|
||||||
|
|
||||||
atlas = noone;
|
|
||||||
|
|
||||||
grav = 0;
|
grav = 0;
|
||||||
gravDir = -90;
|
gravDir = -90;
|
||||||
gravX = 0;
|
gravX = 0;
|
||||||
|
@ -81,7 +79,6 @@ function __part(_node) constructor {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
surf = noone;
|
surf = noone;
|
||||||
atlas = noone;
|
|
||||||
|
|
||||||
prevx = undefined;
|
prevx = undefined;
|
||||||
prevy = undefined;
|
prevy = undefined;
|
||||||
|
@ -260,8 +257,7 @@ function __part(_node) constructor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var surface = atlas == noone? node.surface_cache[$ ss] : atlas.getSurface();
|
var surface = is_instanceof(ss, SurfaceAtlas)? ss.getSurface() : node.surface_cache[$ ss];
|
||||||
//print($"VFX: {surface} ({is_surface(surface)}), {atlas}")
|
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
inputs[| 4] = nodeValue("Spawn distribution", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
|
||||||
.rejectArray()
|
.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 ] )
|
inputs[| 5] = nodeValue("Lifespan", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 20, 30 ] )
|
||||||
.setDisplay(VALUE_DISPLAY.range);
|
.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_len = ds_list_size(inputs);
|
||||||
|
|
||||||
input_display_list = [ 32,
|
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,
|
["Spawn", true], 27, 16, 44, 1, 2, 3, 4, 30, 24, 5,
|
||||||
["Movement", true], 29, 6, 18,
|
["Movement", true], 29, 6, 18,
|
||||||
["Physics", true], 7, 19, 33, 34, 35, 36,
|
["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
|
static spawn = function(_time = PROJECT.animator.current_frame, _pos = -1) { #region
|
||||||
var _inSurf = current_data[ 0];
|
var _inSurf = current_data[ 0];
|
||||||
var _atlas = current_data[31];
|
|
||||||
|
|
||||||
var _spawn_amount = current_data[ 2];
|
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;
|
if(_rotation[1] < _rotation[0]) _rotation[1] += 360;
|
||||||
|
|
||||||
var _posDist = [];
|
var _posDist = [];
|
||||||
if(_distrib == 2) _posDist = get_points_from_dist(_dist_map, _amo, seed);
|
|
||||||
|
|
||||||
random_set_seed(seed);
|
random_set_seed(seed);
|
||||||
var _amo = irandom_range(_spawn_amount[0], _spawn_amount[1]);
|
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)}");
|
//print($"Frame {_time}: Spawning {_amo} particles, seed {seed}, {irandom(99999999)}");
|
||||||
for( var i = 0; i < _amo; i++ ) {
|
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;
|
var yy = 0;
|
||||||
|
|
||||||
if(_pos == -1) {
|
if(_pos == -1) {
|
||||||
if(_distrib < 2) {
|
if(is_instanceof(_spr, SurfaceAtlas)) {
|
||||||
var sp = area_get_random_point(_spawn_area, _distrib, _scatter, spawn_index, _spawn_amount, seed);
|
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];
|
xx = sp[0];
|
||||||
yy = sp[1];
|
yy = sp[1];
|
||||||
} else if(_distrib == 2) {
|
} 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.);
|
xx = _spawn_area[0] + _spawn_area[2] * (sp[0] * 2 - 1.);
|
||||||
yy = _spawn_area[1] + _spawn_area[3] * (sp[1] * 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 {
|
} else {
|
||||||
xx = _pos[0];
|
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[| 24].setVisible(_dist < 2);
|
||||||
|
|
||||||
inputs[| 0].setVisible(_dist != 3, _dist != 3);
|
|
||||||
inputs[| 30].setVisible(_dist == 2, _dist == 2);
|
inputs[| 30].setVisible(_dist == 2, _dist == 2);
|
||||||
inputs[| 31].setVisible(_dist == 3, _dist == 3);
|
|
||||||
|
|
||||||
inputs[| 35].setVisible(_turn[0] != 0 && _turn[1] != 0);
|
inputs[| 35].setVisible(_turn[0] != 0 && _turn[1] != 0);
|
||||||
inputs[| 36].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
|
} #endregion
|
||||||
|
|
||||||
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
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)
|
if(onDrawOverlay != -1)
|
||||||
onDrawOverlay(active, _x, _y, _s, _mx, _my);
|
onDrawOverlay(active, _x, _y, _s, _mx, _my);
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#region locale
|
#region locale
|
||||||
globalvar LOCALE, TEST_LOCALE;
|
globalvar LOCALE, TEST_LOCALE, LOCALE_USE_DEFAULT;
|
||||||
LOCALE = {}
|
LOCALE = {}
|
||||||
TEST_LOCALE = false;
|
TEST_LOCALE = false;
|
||||||
|
LOCALE_USE_DEFAULT = true;
|
||||||
|
|
||||||
function __initLocale() {
|
function __initLocale() {
|
||||||
var lfile = $"data/locale/en.zip";
|
var lfile = $"data/locale/en.zip";
|
||||||
|
@ -36,6 +37,8 @@
|
||||||
function __txtx(key, def = "") {
|
function __txtx(key, def = "") {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
if(LOCALE_USE_DEFAULT) return def;
|
||||||
|
|
||||||
if(TEST_LOCALE) {
|
if(TEST_LOCALE) {
|
||||||
if(!struct_has(LOCALE.word, key) && !struct_has(LOCALE.ui, key)) {
|
if(!struct_has(LOCALE.word, key) && !struct_has(LOCALE.ui, key)) {
|
||||||
show_debug_message($"LOCALE: \"{key}\": \"{def}\",");
|
show_debug_message($"LOCALE: \"{key}\": \"{def}\",");
|
||||||
|
@ -56,6 +59,8 @@
|
||||||
function __txt(txt, prefix = "") {
|
function __txt(txt, prefix = "") {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
if(LOCALE_USE_DEFAULT) return txt;
|
||||||
|
|
||||||
var key = string_lower(txt);
|
var key = string_lower(txt);
|
||||||
key = string_replace_all(key, " ", "_");
|
key = string_replace_all(key, " ", "_");
|
||||||
|
|
||||||
|
@ -73,7 +78,7 @@
|
||||||
function __txt_node_name(node, def = "") {
|
function __txt_node_name(node, def = "") {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
//if(TESTING) return def;
|
if(LOCALE_USE_DEFAULT) return def;
|
||||||
|
|
||||||
if(!struct_has(LOCALE.node, node))
|
if(!struct_has(LOCALE.node, node))
|
||||||
return def;
|
return def;
|
||||||
|
@ -85,7 +90,7 @@
|
||||||
function __txt_node_tooltip(node, def = "") {
|
function __txt_node_tooltip(node, def = "") {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
//if(TESTING) return def;
|
if(LOCALE_USE_DEFAULT) return def;
|
||||||
|
|
||||||
if(!struct_has(LOCALE.node, node))
|
if(!struct_has(LOCALE.node, node))
|
||||||
return def;
|
return def;
|
||||||
|
@ -97,7 +102,7 @@
|
||||||
function __txt_junction_name(node, type, index, def = "") {
|
function __txt_junction_name(node, type, index, def = "") {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
//if(TESTING) return def;
|
if(LOCALE_USE_DEFAULT) return def;
|
||||||
|
|
||||||
if(!struct_has(LOCALE.node, node))
|
if(!struct_has(LOCALE.node, node))
|
||||||
return def;
|
return def;
|
||||||
|
@ -113,7 +118,7 @@
|
||||||
function __txt_junction_tooltip(node, type, index, def = "") {
|
function __txt_junction_tooltip(node, type, index, def = "") {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
//if(TESTING) return def;
|
if(LOCALE_USE_DEFAULT) return def;
|
||||||
|
|
||||||
if(!struct_has(LOCALE.node, node))
|
if(!struct_has(LOCALE.node, node))
|
||||||
return def;
|
return def;
|
||||||
|
|
|
@ -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);
|
return preview_overlay_vector(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny, _spr);
|
||||||
|
|
||||||
case VALUE_DISPLAY.area :
|
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 :
|
case VALUE_DISPLAY.puppet_control :
|
||||||
return preview_overlay_puppet(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
return preview_overlay_puppet(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||||
|
|
|
@ -202,6 +202,8 @@
|
||||||
|
|
||||||
var f = json_load_struct(DIRECTORY + "key_nodes.json");
|
var f = json_load_struct(DIRECTORY + "key_nodes.json");
|
||||||
struct_override(HOTKEYS_CUSTOM, f);
|
struct_override(HOTKEYS_CUSTOM, f);
|
||||||
|
|
||||||
|
LOCALE_USE_DEFAULT = PREF_MAP[? "local"] == "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
function PREF_APPLY() {
|
function PREF_APPLY() {
|
||||||
|
|
|
@ -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 _val = array_clone(getValue());
|
||||||
var hover = -1;
|
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 xc = (x0 + x1) / 2;
|
||||||
var yc = (y0 + y1) / 2;
|
var yc = (y0 + y1) / 2;
|
||||||
|
|
||||||
|
var drawPos = _flag & 0b0001;
|
||||||
|
var drawSize = _flag & 0b0010;
|
||||||
|
|
||||||
|
if(drawSize) {
|
||||||
draw_set_color(COLORS._main_accent);
|
draw_set_color(COLORS._main_accent);
|
||||||
draw_set_circle_precision(32);
|
draw_set_circle_precision(32);
|
||||||
switch(__at) {
|
switch(__at) {
|
||||||
case AREA_SHAPE.rectangle : draw_rectangle(x0, y0, x1, y1, true); break;
|
case AREA_SHAPE.rectangle : draw_rectangle(x0, y0, x1, y1, true); break;
|
||||||
case AREA_SHAPE.elipse : draw_ellipse(x0, y0, x1, y1, true); break;
|
case AREA_SHAPE.elipse : draw_ellipse(x0, y0, x1, y1, true); break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!interact) return -1;
|
if(!interact) return -1;
|
||||||
|
|
||||||
draw_sprite_colored(THEME.anchor, 0, xc, yc);
|
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, y0,, 0);
|
||||||
draw_sprite_colored(THEME.anchor_solid_hori, 0, xc, y1,, 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, x0, yc,, 90);
|
||||||
draw_sprite_colored(THEME.anchor_solid_hori, 0, x1, yc,, 90);
|
draw_sprite_colored(THEME.anchor_solid_hori, 0, x1, yc,, 90);
|
||||||
|
}
|
||||||
|
|
||||||
if(drag_type == 1) {
|
if(drag_type == 1) {
|
||||||
var _xx = value_snap(drag_sx - (_mx - drag_mx) / _s, _snx);
|
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;
|
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);
|
draw_sprite_colored(THEME.anchor_solid_hori, 1, xc, y0);
|
||||||
hover = 1;
|
hover = 1;
|
||||||
|
|
||||||
|
@ -90,7 +97,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s
|
||||||
drag_sy = _t;
|
drag_sy = _t;
|
||||||
drag_my = _my;
|
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);
|
draw_sprite_colored(THEME.anchor_solid_hori, 1, xc, y1);
|
||||||
hover = 3;
|
hover = 3;
|
||||||
|
|
||||||
|
@ -99,7 +106,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s
|
||||||
drag_sy = _b;
|
drag_sy = _b;
|
||||||
drag_my = _my;
|
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);
|
draw_sprite_colored(THEME.anchor_solid_hori, 1, x0, yc,, 90);
|
||||||
hover = 0;
|
hover = 0;
|
||||||
|
|
||||||
|
@ -108,7 +115,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s
|
||||||
drag_sx = _l;
|
drag_sx = _l;
|
||||||
drag_mx = _mx;
|
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);
|
draw_sprite_colored(THEME.anchor_solid_hori, 1, x1, yc,, 90);
|
||||||
hover = 2;
|
hover = 2;
|
||||||
|
|
||||||
|
@ -117,7 +124,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s
|
||||||
drag_sx = _r;
|
drag_sx = _r;
|
||||||
drag_mx = _mx;
|
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);
|
draw_sprite_colored(THEME.anchor, 1, xc, yc);
|
||||||
hover = 4;
|
hover = 4;
|
||||||
|
|
||||||
|
@ -133,7 +140,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s
|
||||||
return hover;
|
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 _val = array_clone(getValue());
|
||||||
var hover = -1;
|
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 xc = (x0 + x1) / 2;
|
||||||
var yc = (y0 + y1) / 2;
|
var yc = (y0 + y1) / 2;
|
||||||
|
|
||||||
|
var drawPos = _flag & 0b0001;
|
||||||
|
var drawSize = _flag & 0b0010;
|
||||||
|
|
||||||
|
if(drawSize) {
|
||||||
draw_set_color(COLORS._main_accent);
|
draw_set_color(COLORS._main_accent);
|
||||||
draw_set_circle_precision(32);
|
draw_set_circle_precision(32);
|
||||||
switch(__at) {
|
switch(__at) {
|
||||||
case AREA_SHAPE.rectangle : draw_rectangle(x0, y0, x1, y1, true); break;
|
case AREA_SHAPE.rectangle : draw_rectangle(x0, y0, x1, y1, true); break;
|
||||||
case AREA_SHAPE.elipse : draw_ellipse(x0, y0, x1, y1, true); break;
|
case AREA_SHAPE.elipse : draw_ellipse(x0, y0, x1, y1, true); break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!interact) return -1;
|
if(!interact) return -1;
|
||||||
|
|
||||||
draw_sprite_colored(THEME.anchor, 1, xc, yc);
|
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, x0, y0);
|
||||||
draw_sprite_colored(THEME.anchor_selector, 0, x1, y1);
|
draw_sprite_colored(THEME.anchor_selector, 0, x1, y1);
|
||||||
|
}
|
||||||
|
|
||||||
if(drag_type == 1) {
|
if(drag_type == 1) {
|
||||||
var _xx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
|
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);
|
draw_sprite_colored(THEME.anchor_selector, 1, x0, y0);
|
||||||
hover = 1;
|
hover = 1;
|
||||||
|
|
||||||
|
@ -215,7 +229,7 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my,
|
||||||
drag_mx = _mx;
|
drag_mx = _mx;
|
||||||
drag_my = _my;
|
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);
|
draw_sprite_colored(THEME.anchor_selector, 1, x1, y1);
|
||||||
hover = 2;
|
hover = 2;
|
||||||
|
|
||||||
|
@ -226,7 +240,7 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my,
|
||||||
drag_mx = _mx;
|
drag_mx = _mx;
|
||||||
drag_my = _my;
|
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);
|
draw_sprite_colored(THEME.anchor, 1, xc, yc);
|
||||||
hover = 3;
|
hover = 3;
|
||||||
|
|
||||||
|
@ -242,7 +256,7 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my,
|
||||||
return hover;
|
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 _val = array_clone(getValue());
|
||||||
var hover = -1;
|
var hover = -1;
|
||||||
|
|
||||||
|
@ -257,17 +271,22 @@ function preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx,
|
||||||
var _aw = __aw * _s;
|
var _aw = __aw * _s;
|
||||||
var _ah = __ah * _s;
|
var _ah = __ah * _s;
|
||||||
|
|
||||||
|
var drawPos = _flag & 0b0001;
|
||||||
|
var drawSize = _flag & 0b0010;
|
||||||
|
|
||||||
|
if(drawSize) {
|
||||||
draw_set_color(COLORS._main_accent);
|
draw_set_color(COLORS._main_accent);
|
||||||
draw_set_circle_precision(32);
|
draw_set_circle_precision(32);
|
||||||
switch(__at) {
|
switch(__at) {
|
||||||
case AREA_SHAPE.rectangle : draw_rectangle(_ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah, true); break;
|
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;
|
case AREA_SHAPE.elipse : draw_ellipse(_ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah, true); break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!interact) return -1;
|
if(!interact) return -1;
|
||||||
|
|
||||||
draw_sprite_colored(THEME.anchor, 0, _ax, _ay);
|
if(drawPos) draw_sprite_colored(THEME.anchor, 0, _ax, _ay);
|
||||||
draw_sprite_colored(THEME.anchor_selector, 0, _ax + _aw, _ay + _ah);
|
if(drawSize) draw_sprite_colored(THEME.anchor_selector, 0, _ax + _aw, _ay + _ah);
|
||||||
|
|
||||||
if(point_in_circle(_mx, _my, _ax + _aw, _ay + _ah, 8))
|
if(point_in_circle(_mx, _my, _ax + _aw, _ay + _ah, 8))
|
||||||
draw_sprite_colored(THEME.anchor_selector, 1, _ax + _aw, _ay + _ah);
|
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;
|
hover = 2;
|
||||||
if(mouse_press(mb_left)) {
|
if(mouse_press(mb_left)) {
|
||||||
drag_type = 2;
|
drag_type = 2;
|
||||||
drag_mx = _ax;
|
drag_mx = _ax;
|
||||||
drag_my = _ay;
|
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;
|
hover = 1;
|
||||||
if(mouse_press(mb_left)) {
|
if(mouse_press(mb_left)) {
|
||||||
drag_type = 1;
|
drag_type = 1;
|
||||||
|
@ -340,18 +359,18 @@ function preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx,
|
||||||
return hover;
|
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 _val = array_clone(getValue());
|
||||||
var hover = -1;
|
var hover = -1;
|
||||||
if(is_array(_val[0])) return hover;
|
if(is_array(_val[0])) return hover;
|
||||||
|
|
||||||
var mode = editWidget.mode;
|
var mode = editWidget.mode;
|
||||||
if(mode == AREA_MODE.area)
|
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)
|
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)
|
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;
|
return hover;
|
||||||
}
|
}
|
Loading…
Reference in a new issue