2022-01-13 05:24:03 +01:00
|
|
|
enum JUNCTION_CONNECT {
|
|
|
|
input,
|
|
|
|
output
|
|
|
|
}
|
|
|
|
|
|
|
|
enum VALUE_TYPE {
|
|
|
|
integer = 0,
|
|
|
|
float = 1,
|
|
|
|
boolean = 2,
|
|
|
|
color = 3,
|
|
|
|
surface = 4,
|
|
|
|
|
|
|
|
path = 5,
|
|
|
|
curve = 6,
|
|
|
|
text = 7,
|
|
|
|
object = 8,
|
2022-01-25 14:13:47 +01:00
|
|
|
node = 9,
|
2022-12-13 09:20:36 +01:00
|
|
|
d3object = 10,
|
2022-01-25 10:58:11 +01:00
|
|
|
|
2022-01-25 14:13:47 +01:00
|
|
|
any = 11,
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
enum VALUE_DISPLAY {
|
|
|
|
_default,
|
|
|
|
range,
|
|
|
|
|
|
|
|
//Int
|
|
|
|
enum_scroll,
|
|
|
|
enum_button,
|
|
|
|
rotation,
|
|
|
|
rotation_range,
|
|
|
|
slider,
|
|
|
|
slider_range,
|
|
|
|
|
|
|
|
//Color
|
|
|
|
gradient,
|
|
|
|
palette,
|
|
|
|
|
|
|
|
//Int array
|
|
|
|
padding,
|
|
|
|
vector,
|
|
|
|
vector_range,
|
|
|
|
area,
|
2023-01-04 02:30:04 +01:00
|
|
|
kernel,
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
//Curve
|
|
|
|
curve,
|
|
|
|
|
|
|
|
//Misc
|
|
|
|
puppet_control,
|
|
|
|
button,
|
|
|
|
label,
|
|
|
|
|
|
|
|
//Array
|
|
|
|
path_array,
|
|
|
|
|
|
|
|
//Text
|
|
|
|
export_format,
|
2023-01-04 02:30:04 +01:00
|
|
|
code,
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
//path
|
|
|
|
path_save,
|
2022-09-27 06:37:28 +02:00
|
|
|
path_load,
|
2022-12-16 09:18:09 +01:00
|
|
|
path_font,
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
enum PADDING {
|
|
|
|
right,
|
|
|
|
up,
|
|
|
|
left,
|
|
|
|
down
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
enum VALUE_TAG {
|
|
|
|
_default = 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
function value_color(i) {
|
2023-01-01 02:06:02 +01:00
|
|
|
static JUNCTION_COLORS = [ $6691ff, $78e4ff, $5d3f8c, $5dde8f, $976bff, $4b00eb, $d1c2c2, $e3ff66, $b5b5ff, $ffa64d, #c1007c, $808080 ];
|
2022-01-13 05:24:03 +01:00
|
|
|
return JUNCTION_COLORS[safe_mod(max(0, i), array_length(JUNCTION_COLORS))];
|
|
|
|
}
|
|
|
|
|
|
|
|
function value_bit(i) {
|
|
|
|
switch(i) {
|
|
|
|
case VALUE_TYPE.integer : return 1 << 0 | 1 << 1;
|
2022-12-23 04:45:52 +01:00
|
|
|
case VALUE_TYPE.float : return 1 << 2 | 1 << 1;
|
|
|
|
case VALUE_TYPE.boolean : return 1 << 3 | 1 << 1;
|
|
|
|
case VALUE_TYPE.color : return 1 << 4;
|
|
|
|
case VALUE_TYPE.surface : return 1 << 5;
|
2022-01-13 05:24:03 +01:00
|
|
|
case VALUE_TYPE.path : return 1 << 10;
|
2023-01-01 02:06:02 +01:00
|
|
|
case VALUE_TYPE.text : return 1 << 10 | 1 << 1;
|
2022-01-25 14:13:47 +01:00
|
|
|
case VALUE_TYPE.node : return 1 << 12;
|
2022-01-13 05:24:03 +01:00
|
|
|
case VALUE_TYPE.object : return 1 << 20;
|
2023-01-01 02:06:02 +01:00
|
|
|
case VALUE_TYPE.d3object : return 1 << 21;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-25 14:13:47 +01:00
|
|
|
case VALUE_TYPE.any : return ~0;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function value_type_directional(f, t) {
|
2022-12-23 04:45:52 +01:00
|
|
|
if(f.type == VALUE_TYPE.surface && t.type == VALUE_TYPE.integer) return true;
|
|
|
|
if(f.type == VALUE_TYPE.surface && t.type == VALUE_TYPE.float) return true;
|
|
|
|
|
|
|
|
if(f.type == VALUE_TYPE.integer && t.type == VALUE_TYPE.color) return true;
|
|
|
|
if(f.type == VALUE_TYPE.float && t.type == VALUE_TYPE.color) return true;
|
|
|
|
|
|
|
|
if(f.type == VALUE_TYPE.integer && t.type == VALUE_TYPE.text) return true;
|
|
|
|
if(f.type == VALUE_TYPE.float && t.type == VALUE_TYPE.text) return true;
|
|
|
|
if(f.type == VALUE_TYPE.boolean && t.type == VALUE_TYPE.text) return true;
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function typeArray(_type) {
|
|
|
|
switch(_type) {
|
|
|
|
case VALUE_DISPLAY.range :
|
|
|
|
case VALUE_DISPLAY.vector_range :
|
|
|
|
case VALUE_DISPLAY.rotation_range :
|
|
|
|
case VALUE_DISPLAY.slider_range :
|
|
|
|
|
|
|
|
case VALUE_DISPLAY.vector :
|
|
|
|
case VALUE_DISPLAY.padding :
|
|
|
|
case VALUE_DISPLAY.area :
|
|
|
|
case VALUE_DISPLAY.puppet_control :
|
2023-01-04 02:30:04 +01:00
|
|
|
case VALUE_DISPLAY.kernel :
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
case VALUE_DISPLAY.curve :
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case VALUE_DISPLAY.path_array :
|
|
|
|
case VALUE_DISPLAY.palette :
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum KEYFRAME_END {
|
|
|
|
hold,
|
|
|
|
loop,
|
2023-01-09 03:14:20 +01:00
|
|
|
ping,
|
|
|
|
wrap,
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
globalvar ON_END_NAME;
|
|
|
|
ON_END_NAME = [ "Hold", "Loop", "Ping pong", "Wrap" ];
|
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
enum VALIDATION {
|
|
|
|
pass,
|
|
|
|
warning,
|
|
|
|
error
|
|
|
|
}
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
enum VALUE_UNIT {
|
|
|
|
constant,
|
|
|
|
reference
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
function isGraphable(type) {
|
|
|
|
switch(type) {
|
|
|
|
case VALUE_TYPE.integer :
|
|
|
|
case VALUE_TYPE.float : return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function nodeValue(_index, _name, _node, _connect, _type, _value, _tag = VALUE_TAG._default) {
|
|
|
|
return new NodeValue(_index, _name, _node, _connect, _type, _value, _tag);
|
|
|
|
}
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
function nodeValueUnit(value) constructor {
|
|
|
|
self.value = value;
|
|
|
|
|
|
|
|
mode = VALUE_UNIT.constant;
|
|
|
|
reference = noone;
|
|
|
|
triggerButton = button(function() {
|
|
|
|
mode = !mode;
|
|
|
|
value.unitConvert(mode);
|
|
|
|
});
|
|
|
|
triggerButton.icon_blend = COLORS._main_icon_light;
|
|
|
|
triggerButton.icon = THEME.unit_ref;
|
|
|
|
|
|
|
|
static draw = function(_x, _y, _w, _h, _m) {
|
|
|
|
triggerButton.icon_index = mode;
|
|
|
|
triggerButton.tooltip = (mode? "Fraction" : "Pixel") + " unit";
|
|
|
|
|
|
|
|
triggerButton.draw(_x, _y, _w, _h, _m, THEME.button_hide);
|
|
|
|
}
|
|
|
|
|
|
|
|
static invApply = function(value, index = 0) {
|
|
|
|
if(mode == VALUE_UNIT.constant)
|
|
|
|
return value;
|
|
|
|
if(reference == noone)
|
|
|
|
return value;
|
|
|
|
|
|
|
|
return convertUnit(value, VALUE_UNIT.reference, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static apply = function(value, index = 0) {
|
|
|
|
if(mode == VALUE_UNIT.constant)
|
|
|
|
return value;
|
|
|
|
if(reference == noone)
|
|
|
|
return value;
|
|
|
|
|
|
|
|
return convertUnit(value, VALUE_UNIT.constant, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static convertUnit = function(value, unitTo, index = 0) {
|
|
|
|
var disp = self.value.display_type;
|
|
|
|
var base = reference(index);
|
|
|
|
var inv = unitTo == VALUE_UNIT.reference;
|
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
if(!is_array(base) && !is_array(value))
|
2022-12-27 04:00:50 +01:00
|
|
|
return inv? value / base : value * base;
|
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
if(!is_array(base) && is_array(value)) {
|
2022-12-27 04:00:50 +01:00
|
|
|
for( var i = 0; i < array_length(value); i++ )
|
|
|
|
value[i] = inv? value[i] / base : value[i] * base;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
if(is_array(base) && !is_array(value)) {
|
2022-12-27 04:00:50 +01:00
|
|
|
return value;
|
2022-12-27 13:30:02 +01:00
|
|
|
}
|
2022-12-27 04:00:50 +01:00
|
|
|
|
|
|
|
switch(disp) {
|
|
|
|
case VALUE_DISPLAY.padding :
|
|
|
|
case VALUE_DISPLAY.vector :
|
|
|
|
case VALUE_DISPLAY.vector_range :
|
|
|
|
for( var i = 0; i < array_length(value); i++ )
|
|
|
|
value[i] = inv? value[i] / base[i % 2] : value[i] * base[i % 2];
|
|
|
|
return value;
|
|
|
|
case VALUE_DISPLAY.area :
|
|
|
|
for( var i = 0; i < 4; i++ )
|
|
|
|
value[i] = inv? value[i] / base[i % 2] : value[i] * base[i % 2];
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
function NodeValue(_index, _name, _node, _connect, _type, _value, _tag = VALUE_TAG._default) constructor {
|
|
|
|
name = _name;
|
|
|
|
node = _node;
|
2022-01-26 06:57:34 +01:00
|
|
|
x = node.x;
|
2022-01-13 05:24:03 +01:00
|
|
|
y = node.y;
|
|
|
|
index = _index;
|
|
|
|
type = _type;
|
|
|
|
|
|
|
|
tag = _tag;
|
|
|
|
|
|
|
|
connect_type = _connect;
|
|
|
|
value_from = noone;
|
|
|
|
value_to = ds_list_create();
|
|
|
|
accept_array = true;
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
def_val = _value;
|
|
|
|
animator = new valueAnimator(_value, self);
|
|
|
|
on_end = KEYFRAME_END.hold;
|
2022-12-27 04:00:50 +01:00
|
|
|
unit = new nodeValueUnit(self);
|
2022-09-23 13:28:42 +02:00
|
|
|
extra_data = ds_list_create();
|
2022-12-23 04:45:52 +01:00
|
|
|
dyna_depo = ds_list_create();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-21 06:38:44 +01:00
|
|
|
visible = _connect == JUNCTION_CONNECT.output || _type == VALUE_TYPE.surface || _type == VALUE_TYPE.path;
|
2022-01-13 05:24:03 +01:00
|
|
|
show_in_inspector = true;
|
|
|
|
|
|
|
|
display_type = VALUE_DISPLAY._default;
|
|
|
|
display_data = -1;
|
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
value_validation = VALIDATION.pass;
|
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
extract_node = "";
|
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
static setUnitRef = function(ref, mode = VALUE_UNIT.constant) {
|
2022-12-27 04:00:50 +01:00
|
|
|
unit.reference = ref;
|
2022-12-27 13:30:02 +01:00
|
|
|
unit.mode = mode;
|
2022-12-27 04:00:50 +01:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2022-01-19 03:05:13 +01:00
|
|
|
static setVisible = function(inspector) {
|
2022-01-13 05:24:03 +01:00
|
|
|
show_in_inspector = inspector;
|
2022-01-19 03:05:13 +01:00
|
|
|
visible = argument_count > 1? argument[1] : visible;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
static setDisplay = function(_type, _data = -1) {
|
|
|
|
display_type = _type;
|
|
|
|
display_data = _data;
|
|
|
|
resetDisplay();
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
static rejectArray = function() {
|
|
|
|
accept_array = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
static isAnimable = function() {
|
|
|
|
if(display_type == VALUE_DISPLAY.gradient)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static resetDisplay = function() {
|
|
|
|
editWidget = noone;
|
|
|
|
switch(display_type) {
|
|
|
|
case VALUE_DISPLAY.button :
|
|
|
|
editWidget = button(display_data[0]);
|
|
|
|
editWidget.text = display_data[1];
|
|
|
|
visible = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case VALUE_TYPE.float :
|
|
|
|
case VALUE_TYPE.integer :
|
|
|
|
var _txt = type == VALUE_TYPE.float? TEXTBOX_INPUT.float : TEXTBOX_INPUT.number;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
switch(display_type) {
|
|
|
|
case VALUE_DISPLAY._default :
|
2022-12-18 03:20:38 +01:00
|
|
|
editWidget = new textBox(_txt, function(val) {
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(val);
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
|
|
|
editWidget.slidable = true;
|
|
|
|
if(display_data != -1) editWidget.slide_speed = display_data;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Number";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.range :
|
|
|
|
editWidget = new rangeBox(_txt, function(index, val) {
|
2022-09-23 13:28:42 +02:00
|
|
|
var _val = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[index] = val;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(_val);
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
|
|
|
if(display_data != -1) editWidget.extras = display_data;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Number";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.vector :
|
2023-01-09 03:14:20 +01:00
|
|
|
var val = animator.getValue();
|
|
|
|
if(array_length(val) <= 4) {
|
2022-09-23 13:28:42 +02:00
|
|
|
editWidget = new vectorBox(array_length(animator.getValue()), _txt, function(index, val) {
|
|
|
|
var _val = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[index] = val;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(_val);
|
|
|
|
}, unit );
|
2022-01-13 05:24:03 +01:00
|
|
|
if(display_data != -1) editWidget.extras = display_data;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
if(array_length(val) == 2)
|
|
|
|
extract_node = "Node_Vector2";
|
|
|
|
else if(array_length(val) == 3)
|
|
|
|
extract_node = "Node_Vector3";
|
|
|
|
else if(array_length(val) == 4)
|
|
|
|
extract_node = "Node_Vector4";
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.vector_range :
|
2023-01-09 03:14:20 +01:00
|
|
|
var val = animator.getValue();
|
|
|
|
|
|
|
|
editWidget = new vectorRangeBox(array_length(val), _txt, function(index, val) {
|
2022-09-23 13:28:42 +02:00
|
|
|
var _val = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[index] = val;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(_val);
|
|
|
|
}, unit );
|
2022-01-13 05:24:03 +01:00
|
|
|
if(display_data != -1) editWidget.extras = display_data;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
if(array_length(val) == 2)
|
|
|
|
extract_node = "Node_Vector2";
|
|
|
|
else if(array_length(val) == 3)
|
|
|
|
extract_node = "Node_Vector3";
|
|
|
|
else if(array_length(val) == 4)
|
|
|
|
extract_node = "Node_Vector4";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.rotation :
|
2022-01-19 03:51:53 +01:00
|
|
|
editWidget = new rotator(function(val, _save) {
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(val, _save);
|
2022-12-16 09:18:09 +01:00
|
|
|
}, display_data );
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Number";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.rotation_range :
|
|
|
|
editWidget = new rotatorRange(function(index, val) {
|
2022-09-23 13:28:42 +02:00
|
|
|
var _val = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[index] = round(val);
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(_val);
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Vector2";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.slider :
|
|
|
|
editWidget = new slider(display_data[0], display_data[1], display_data[2], function(val) {
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(toNumber(val));
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Number";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.slider_range :
|
|
|
|
editWidget = new sliderRange(display_data[0], display_data[1], display_data[2], function(index, val) {
|
2022-09-23 13:28:42 +02:00
|
|
|
var _val = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[index] = val;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(_val);
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Vector2";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.area :
|
|
|
|
editWidget = new areaBox(function(index, val) {
|
2022-09-23 13:28:42 +02:00
|
|
|
var _val = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[index] = val;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(_val);
|
|
|
|
}, unit);
|
2022-01-13 05:24:03 +01:00
|
|
|
if(display_data != -1) editWidget.onSurfaceSize = display_data;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Area";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.padding :
|
|
|
|
editWidget = new paddingBox(function(index, val) {
|
2022-09-23 13:28:42 +02:00
|
|
|
var _val = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[index] = val;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(_val);
|
|
|
|
}, unit);
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Vector4";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.puppet_control :
|
2022-09-23 13:28:42 +02:00
|
|
|
editWidget = new controlPointBox(function(index, val) {
|
|
|
|
var _val = animator.getValue();
|
|
|
|
_val[index] = val;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(_val);
|
2022-09-23 13:28:42 +02:00
|
|
|
});
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.enum_scroll :
|
|
|
|
editWidget = new scrollBox(display_data, function(val) {
|
|
|
|
if(val == -1) return;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(toNumber(val));
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.enum_button :
|
|
|
|
editWidget = buttonGroup(display_data, function(val) {
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(val);
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
2023-01-04 02:30:04 +01:00
|
|
|
case VALUE_DISPLAY.kernel :
|
|
|
|
editWidget = new matrixGrid(_txt, function(index, val) {
|
|
|
|
var _val = animator.getValue();
|
|
|
|
_val[index] = val;
|
|
|
|
setValueDirect(_val);
|
|
|
|
}, unit );
|
|
|
|
if(display_data != -1) editWidget.extras = display_data;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "";
|
2023-01-04 02:30:04 +01:00
|
|
|
break;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VALUE_TYPE.boolean :
|
|
|
|
editWidget = new checkBox(function() {
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(!animator.getValue());
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Boolean";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_TYPE.color :
|
|
|
|
switch(display_type) {
|
|
|
|
case VALUE_DISPLAY._default :
|
|
|
|
editWidget = buttonColor(function(color) {
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(color);
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Color";
|
|
|
|
break;
|
2022-01-13 05:24:03 +01:00
|
|
|
case VALUE_DISPLAY.gradient :
|
|
|
|
editWidget = buttonGradient(function() {
|
2022-12-10 05:06:01 +01:00
|
|
|
node.triggerRender();
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
|
|
|
extra_data[| 0] = GRADIENT_INTER.smooth;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Gradient_Out";
|
|
|
|
break;
|
2022-01-13 05:24:03 +01:00
|
|
|
case VALUE_DISPLAY.palette :
|
|
|
|
editWidget = buttonPalette(function(color) {
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(color);
|
2022-01-13 05:24:03 +01:00
|
|
|
} );
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_Palette";
|
|
|
|
break;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VALUE_TYPE.path :
|
|
|
|
visible = false;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
switch(display_type) {
|
|
|
|
case VALUE_DISPLAY.path_array :
|
|
|
|
editWidget = button(function() {
|
|
|
|
var path = get_open_filename(display_data[0], display_data[1]);
|
|
|
|
if(path == "") return noone;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(path);
|
2023-01-01 02:06:02 +01:00
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VALUE_DISPLAY.path_load :
|
|
|
|
editWidget = new textBox(TEXTBOX_INPUT.text, function(str) { setValueDirect(str); },
|
|
|
|
button(function() {
|
|
|
|
var path = get_open_filename(display_data[0], display_data[1]);
|
|
|
|
if(path == "") return noone;
|
|
|
|
setValueDirect(path);
|
|
|
|
}, THEME.button_path_icon)
|
|
|
|
);
|
|
|
|
editWidget.align = fa_left;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_String";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.path_save :
|
2023-01-01 02:06:02 +01:00
|
|
|
editWidget = new textBox(TEXTBOX_INPUT.text, function(str) { setValueDirect(str); },
|
|
|
|
button(function() {
|
|
|
|
var path = get_save_filename(display_data[0], display_data[1]);
|
|
|
|
if(path == "") return noone;
|
|
|
|
setValueDirect(path);
|
|
|
|
}, THEME.button_path_icon)
|
|
|
|
);
|
|
|
|
editWidget.align = fa_left;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_String";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
case VALUE_DISPLAY.path_font :
|
|
|
|
editWidget = new scrollBox(
|
|
|
|
function() {
|
|
|
|
var pth = [];
|
|
|
|
var root = DIRECTORY + "Fonts/*";
|
|
|
|
var f = file_find_first(root, -1);
|
|
|
|
var filter = [ ".ttf", ".otf" ];
|
|
|
|
while(f != "") {
|
|
|
|
var ext = filename_ext(DIRECTORY + "Fonts/" + f);
|
|
|
|
if(array_exists(filter, string_lower(ext)))
|
|
|
|
array_push(pth, f);
|
|
|
|
f = file_find_next();
|
|
|
|
}
|
|
|
|
file_find_close();
|
|
|
|
array_push(pth, "Open font folder...");
|
|
|
|
return pth;
|
|
|
|
},
|
|
|
|
function(val) {
|
|
|
|
if(val == array_length(editWidget.data) - 1) {
|
|
|
|
shellOpenExplorer(DIRECTORY + "Fonts\\");
|
|
|
|
return;
|
|
|
|
}
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(DIRECTORY + "Fonts\\" + editWidget.data[val]);
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
editWidget.extra_button = button(function() {
|
|
|
|
var path = get_open_filename("*.ttf;*.otf", "");
|
|
|
|
if(path == "") return noone;
|
2022-12-27 04:00:50 +01:00
|
|
|
setValueDirect(path);
|
2022-12-16 09:18:09 +01:00
|
|
|
} ).setTooltip("Load font...").setIcon(THEME.folder_content, 0, COLORS._main_icon);
|
|
|
|
break;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VALUE_TYPE.curve :
|
|
|
|
visible = false;
|
|
|
|
display_type = VALUE_DISPLAY.curve;
|
2022-12-27 04:00:50 +01:00
|
|
|
editWidget = new curveBox(function(_modified) { setValueDirect(_modified); });
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case VALUE_TYPE.text :
|
2023-01-01 02:06:02 +01:00
|
|
|
editWidget = new textArea(TEXTBOX_INPUT.text, function(str) { setValueDirect(str); } );
|
2023-01-04 02:30:04 +01:00
|
|
|
|
|
|
|
if(display_type == VALUE_DISPLAY.code) {
|
|
|
|
editWidget.font = f_code;
|
|
|
|
editWidget.format = TEXT_AREA_FORMAT.code;
|
|
|
|
editWidget.min_lines = 4;
|
|
|
|
}
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
extract_node = "Node_String";
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
2022-09-27 06:37:28 +02:00
|
|
|
case VALUE_TYPE.surface :
|
2022-12-27 04:00:50 +01:00
|
|
|
editWidget = new surfaceBox(function(ind) { setValueDirect(ind); }, display_data );
|
2022-09-27 06:37:28 +02:00
|
|
|
show_in_inspector = true;
|
|
|
|
break;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
resetDisplay();
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
error_notification = noone;
|
2022-08-30 07:36:37 +02:00
|
|
|
static onValidate = function() {
|
2022-11-03 11:44:49 +01:00
|
|
|
var _val = value_validation, str = "";
|
2022-08-30 07:36:37 +02:00
|
|
|
value_validation = VALIDATION.pass;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case VALUE_TYPE.path:
|
|
|
|
switch(display_type) {
|
|
|
|
case VALUE_DISPLAY.path_load:
|
2022-09-23 13:28:42 +02:00
|
|
|
var path = animator.getValue();
|
2022-12-27 13:30:02 +01:00
|
|
|
if(is_array(path)) path = path[0];
|
2022-11-03 11:44:49 +01:00
|
|
|
if(try_get_path(path) == -1) {
|
2022-08-30 07:36:37 +02:00
|
|
|
value_validation = VALIDATION.error;
|
2023-01-04 02:30:04 +01:00
|
|
|
str = "File not exist: " + string(path);
|
2022-11-03 11:44:49 +01:00
|
|
|
}
|
2022-08-30 07:36:37 +02:00
|
|
|
break;
|
|
|
|
case VALUE_DISPLAY.path_array:
|
2022-09-23 13:28:42 +02:00
|
|
|
var paths = animator.getValue();
|
2022-09-21 06:09:40 +02:00
|
|
|
if(is_array(paths)) {
|
2022-08-30 07:36:37 +02:00
|
|
|
for( var i = 0; i < array_length(paths); i++ ) {
|
2022-12-27 13:30:02 +01:00
|
|
|
if(try_get_path(paths[i]) != -1) continue;
|
|
|
|
value_validation = VALIDATION.error;
|
2023-01-04 02:30:04 +01:00
|
|
|
str = "File not exist: " + string(paths[i]);
|
2022-08-30 07:36:37 +02:00
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
} else {
|
2022-08-30 07:36:37 +02:00
|
|
|
value_validation = VALIDATION.error;
|
2023-01-04 02:30:04 +01:00
|
|
|
str = "File not exist: " + string(paths);
|
2022-11-03 11:44:49 +01:00
|
|
|
}
|
2022-08-30 07:36:37 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2022-12-27 13:30:02 +01:00
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
node.onValidate();
|
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
if(_val == value_validation) return self;
|
|
|
|
|
|
|
|
#region notification
|
2022-11-03 11:44:49 +01:00
|
|
|
if(value_validation == VALIDATION.error && error_notification == noone) {
|
|
|
|
error_notification = noti_error(str);
|
|
|
|
error_notification.onClick = function() { PANEL_GRAPH.node_focus = node; };
|
|
|
|
}
|
|
|
|
|
|
|
|
if(value_validation == VALIDATION.pass && error_notification != noone) {
|
|
|
|
noti_remove(error_notification);
|
|
|
|
error_notification = noone;
|
|
|
|
}
|
2022-12-27 13:30:02 +01:00
|
|
|
#endregion
|
2022-11-03 11:44:49 +01:00
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
static valueProcess = function(value, typeFrom, display, applyUnit = true, arrIndex = 0) {
|
|
|
|
if(typeFrom == VALUE_TYPE.color) {
|
|
|
|
if(display_type == VALUE_DISPLAY.gradient && display == VALUE_DISPLAY._default) {
|
|
|
|
ds_list_clear(dyna_depo);
|
|
|
|
ds_list_add(dyna_depo, new valueKey(0, value));
|
|
|
|
return dyna_depo;
|
|
|
|
} else if(display_type == VALUE_DISPLAY.gradient && display == VALUE_DISPLAY.palette) {
|
|
|
|
ds_list_clear(dyna_depo);
|
|
|
|
var amo = array_length(value);
|
|
|
|
for( var i = 0; i < amo; i++ ) {
|
|
|
|
ds_list_add(dyna_depo, new valueKey(i / amo, value[i]));
|
2022-12-23 04:45:52 +01:00
|
|
|
}
|
2023-01-01 02:06:02 +01:00
|
|
|
return dyna_depo;
|
|
|
|
}
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
2023-01-01 02:06:02 +01:00
|
|
|
|
|
|
|
if(type == VALUE_TYPE.text)
|
|
|
|
return string(value);
|
|
|
|
|
|
|
|
if(typeFrom == VALUE_TYPE.integer && type == VALUE_TYPE.color)
|
|
|
|
return make_color_hsv(0, 0, value);
|
|
|
|
|
|
|
|
if(typeFrom == VALUE_TYPE.float && type == VALUE_TYPE.color)
|
|
|
|
return make_color_hsv(0, 0, value * 255);
|
|
|
|
|
|
|
|
if(typeFrom == VALUE_TYPE.boolean && type == VALUE_TYPE.text)
|
|
|
|
return value? "true" : "false";
|
2023-01-09 03:14:20 +01:00
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
if(type == VALUE_TYPE.integer || type == VALUE_TYPE.float) {
|
|
|
|
if(typeFrom == VALUE_TYPE.text)
|
|
|
|
value = toNumber(value);
|
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
if(applyUnit)
|
2023-01-01 02:06:02 +01:00
|
|
|
return unit.apply(value, arrIndex);
|
|
|
|
}
|
|
|
|
|
2022-12-23 04:45:52 +01:00
|
|
|
return value;
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
static getValue = function(_time = ANIMATOR.current_frame, applyUnit = true, arrIndex = 0) {
|
2022-12-10 05:06:01 +01:00
|
|
|
var _val = getValueRecursive(_time);
|
2022-01-18 05:31:19 +01:00
|
|
|
var val = _val[0];
|
2022-12-23 04:45:52 +01:00
|
|
|
var nod = _val[1];
|
|
|
|
var typ = nod.type;
|
|
|
|
var dis = nod.display_type;
|
2022-01-18 05:31:19 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
var _base = animator.getValue(_time);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
if(typ == VALUE_TYPE.surface && (type == VALUE_TYPE.integer || type == VALUE_TYPE.float)) { //Dimension conversion
|
2022-01-18 05:31:19 +01:00
|
|
|
if(is_array(val)) {
|
2023-01-01 02:06:02 +01:00
|
|
|
var eqSize = true;
|
|
|
|
var sArr = [];
|
|
|
|
var _osZ = 0;
|
|
|
|
|
|
|
|
for( var i = 0; i < array_length(val); i++ ) {
|
|
|
|
if(!is_surface(val[i])) continue;
|
|
|
|
|
|
|
|
var surfSz = [ surface_get_width(val[i]), surface_get_height(val[i]) ];
|
|
|
|
array_push(sArr, surfSz);
|
|
|
|
|
|
|
|
if(i && !array_equals(surfSz, _osZ))
|
|
|
|
eqSize = false;
|
|
|
|
|
|
|
|
_osZ = surfSz;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(eqSize) return _osZ;
|
|
|
|
return sArr;
|
|
|
|
} else if (is_surface(val))
|
2022-01-18 05:31:19 +01:00
|
|
|
return [ surface_get_width(val), surface_get_height(val) ];
|
2023-01-01 02:06:02 +01:00
|
|
|
return [1, 1];
|
|
|
|
}
|
2022-01-18 05:31:19 +01:00
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
if(is_array(_base)) { //Balance array (generate uniform array from single values)
|
2023-01-09 03:14:20 +01:00
|
|
|
if(!is_array(val)) {
|
|
|
|
val = array_create(array_length(_base), val);
|
|
|
|
return valueProcess(val, typ, dis, applyUnit, arrIndex);
|
|
|
|
} else if(array_length(val) < array_length(_base)) {
|
2022-12-16 09:18:09 +01:00
|
|
|
for( var i = array_length(val); i < array_length(_base); i++ )
|
2022-01-13 05:24:03 +01:00
|
|
|
val[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
if(nod.isArray(val)) { //Process data
|
2022-12-16 09:18:09 +01:00
|
|
|
for( var i = 0; i < array_length(val); i++ )
|
2022-12-27 04:00:50 +01:00
|
|
|
val[i] = valueProcess(val[i], typ, dis, applyUnit, arrIndex);
|
2022-12-16 09:18:09 +01:00
|
|
|
} else
|
2022-12-27 04:00:50 +01:00
|
|
|
val = valueProcess(val, typ, dis, applyUnit, arrIndex);
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
static getValueRecursive = function(_time = ANIMATOR.current_frame) {
|
2022-12-23 04:45:52 +01:00
|
|
|
var val = [ -1, VALUE_TYPE.any, VALUE_DISPLAY._default ];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(value_from == noone)
|
2022-12-23 04:45:52 +01:00
|
|
|
val = [animator.getValue(_time), self ];
|
2022-12-16 09:18:09 +01:00
|
|
|
else if(value_from != self)
|
2022-12-10 05:06:01 +01:00
|
|
|
val = value_from.getValueRecursive(_time);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static getExtraData = function() {
|
2022-12-23 04:45:52 +01:00
|
|
|
if(value_from != noone && value_from != self) {
|
|
|
|
if(display_type == VALUE_DISPLAY.gradient && value_from.display_type != VALUE_DISPLAY.gradient)
|
|
|
|
return extra_data;
|
|
|
|
return value_from.getExtraData();
|
|
|
|
}
|
|
|
|
return extra_data;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static __anim = function() {
|
2022-09-23 13:28:42 +02:00
|
|
|
return animator.is_anim || node.update_on_frame;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-12 09:08:03 +01:00
|
|
|
static isAnimated = function() {
|
2022-01-13 05:24:03 +01:00
|
|
|
if(value_from == noone) return __anim();
|
2022-12-12 09:08:03 +01:00
|
|
|
else return value_from.isAnimated() || value_from.__anim();
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static showValue = function() {
|
2022-12-27 04:00:50 +01:00
|
|
|
var val = getValue(, false);
|
2022-01-13 05:24:03 +01:00
|
|
|
if(isArray()) {
|
|
|
|
if(array_length(val) == 0) return 0;
|
2022-01-16 05:17:35 +01:00
|
|
|
return val[safe_mod(node.preview_index, array_length(val))];
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-12-23 04:45:52 +01:00
|
|
|
static isArray = function(val = getValue()) {
|
|
|
|
if(!is_array(val))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(!typeArray(display_type))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if(array_length(val) > 0)
|
|
|
|
return is_array(val[0]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
static setValue = function(val = 0, record = true, time = ANIMATOR.current_frame) {
|
|
|
|
val = unit.invApply(val);
|
|
|
|
setValueDirect(val, record, time);
|
|
|
|
}
|
|
|
|
|
|
|
|
static setValueDirect = function(val = 0, record = true, time = ANIMATOR.current_frame) {
|
2022-09-23 13:28:42 +02:00
|
|
|
var _o = animator.getValue();
|
|
|
|
animator.setValue(val, record, time);
|
|
|
|
var _n = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
var updated = false;
|
|
|
|
|
|
|
|
if(is_array(_o)) {
|
|
|
|
if(array_length(_o) != array_length(_n)) {
|
|
|
|
updated = true;
|
|
|
|
} else {
|
2023-01-04 02:30:04 +01:00
|
|
|
for(var i = 0; i < array_length(_o); i++)
|
2022-01-13 05:24:03 +01:00
|
|
|
updated = updated || (_o[i] != _n[i]);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
updated = _o != _n;
|
2023-01-04 02:30:04 +01:00
|
|
|
|
|
|
|
if(VALUE_DISPLAY.palette)
|
|
|
|
updated = true;
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(updated) {
|
2023-01-04 02:30:04 +01:00
|
|
|
if(connect_type == JUNCTION_CONNECT.input) {
|
2022-12-10 05:06:01 +01:00
|
|
|
node.triggerRender();
|
2023-01-09 03:14:20 +01:00
|
|
|
node.onValueUpdate(index);
|
2023-01-04 02:30:04 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(node.use_cache) node.clearCache();
|
2022-09-23 13:28:42 +02:00
|
|
|
node.onValueUpdate(index, _o);
|
2022-09-27 06:37:28 +02:00
|
|
|
MODIFIED = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
onValidate();
|
2022-01-13 05:24:03 +01:00
|
|
|
return updated;
|
|
|
|
}
|
|
|
|
|
|
|
|
static setFrom = function(_valueFrom, _update = true, checkRecur = true) {
|
2023-01-09 03:14:20 +01:00
|
|
|
if(_valueFrom == -1 || _valueFrom == undefined || _valueFrom == noone) {
|
2022-11-14 03:16:15 +01:00
|
|
|
noti_warning("LOAD: Cannot set node connection from " + string(_valueFrom) + " to " + string(name) + " of node " + string(node.name) + ".");
|
2022-01-16 05:17:35 +01:00
|
|
|
return false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-01-25 10:58:11 +01:00
|
|
|
if(_valueFrom == value_from) {
|
2022-01-16 05:17:35 +01:00
|
|
|
return false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(_valueFrom == self) {
|
2022-11-14 03:16:15 +01:00
|
|
|
noti_warning("setFrom: Self connection is not allowed.");
|
2022-01-16 05:17:35 +01:00
|
|
|
return false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(value_bit(type) & value_bit(_valueFrom.type) == 0 && !value_type_directional(_valueFrom, self)) {
|
2022-11-14 03:16:15 +01:00
|
|
|
noti_warning("setFrom: Type mismatch");
|
2022-01-16 05:17:35 +01:00
|
|
|
return false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(connect_type == _valueFrom.connect_type) {
|
2022-11-14 03:16:15 +01:00
|
|
|
noti_warning("setFrom: Connect type mismatch");
|
2022-01-16 05:17:35 +01:00
|
|
|
return false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(checkRecur && _valueFrom.searchNodeBackward(node)) {
|
2022-11-14 03:16:15 +01:00
|
|
|
noti_warning("setFrom: Cycle connection");
|
2022-01-16 05:17:35 +01:00
|
|
|
return false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!accept_array && _valueFrom.isArray()) {
|
2022-11-14 03:16:15 +01:00
|
|
|
noti_warning("setFrom: Array mismatch");
|
2022-01-16 05:17:35 +01:00
|
|
|
return false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-01-25 10:58:11 +01:00
|
|
|
if(value_from != noone) {
|
|
|
|
ds_list_remove(value_from.value_to, self);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_valueFrom == noone) {
|
|
|
|
removeFrom();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
var _o = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
recordAction(ACTION_TYPE.junction_connect, self, value_from);
|
|
|
|
value_from = _valueFrom;
|
|
|
|
ds_list_add(_valueFrom.value_to, self);
|
2022-01-16 05:17:35 +01:00
|
|
|
//show_debug_message("connected " + name + " to " + _valueFrom.name)
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
node.onValueUpdate(index, _o);
|
2023-01-04 02:30:04 +01:00
|
|
|
if(_update && connect_type == JUNCTION_CONNECT.input) {
|
2023-01-09 03:14:20 +01:00
|
|
|
node.onValueFromUpdate(index);
|
2022-12-12 09:08:03 +01:00
|
|
|
node.triggerRender();
|
|
|
|
if(node.use_cache) node.clearCache();
|
|
|
|
}
|
2022-01-16 05:17:35 +01:00
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
MODIFIED = true;
|
2022-01-16 05:17:35 +01:00
|
|
|
return true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-01-26 06:57:34 +01:00
|
|
|
static removeFrom = function(_remove_list = true) {
|
2022-01-13 05:24:03 +01:00
|
|
|
recordAction(ACTION_TYPE.junction_connect, self, value_from);
|
2022-01-26 06:57:34 +01:00
|
|
|
if(_remove_list && value_from != noone)
|
2022-01-25 10:58:11 +01:00
|
|
|
ds_list_remove(value_from.value_to, self);
|
2022-01-13 05:24:03 +01:00
|
|
|
value_from = noone;
|
|
|
|
|
2023-01-04 02:30:04 +01:00
|
|
|
if(connect_type == JUNCTION_CONNECT.input)
|
2023-01-09 03:14:20 +01:00
|
|
|
node.onValueFromUpdate(index);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static getShowString = function() {
|
|
|
|
var val = showValue();
|
|
|
|
return string(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static setString = function(str) {
|
2022-09-23 13:28:42 +02:00
|
|
|
var _o = animator.getValue();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(string_pos(",", str) > 0) {
|
|
|
|
string_replace(str, "[", "");
|
|
|
|
string_replace(str, "]", "");
|
|
|
|
|
|
|
|
var ss = str, pos, val = [], ind = 0;
|
|
|
|
|
|
|
|
while(string_length(ss) > 0) {
|
|
|
|
pos = string_pos(",", ss);
|
|
|
|
|
|
|
|
if(pos == 0) {
|
|
|
|
val[ind++] = toNumber(ss);
|
|
|
|
ss = "";
|
|
|
|
} else {
|
|
|
|
val[ind++] = toNumber(string_copy(ss, 1, pos - 1));
|
|
|
|
ss = string_copy(ss, pos + 1, string_length(ss) - pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var _t = typeArray(display_type);
|
|
|
|
if(_t) {
|
|
|
|
if(array_length(_o) == array_length(val) || _t == 2) {
|
|
|
|
setValue(val);
|
|
|
|
}
|
|
|
|
} else if(array_length(val) > 0) {
|
|
|
|
setValue(val[0]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(is_array(_o)) {
|
|
|
|
setValue(array_create(array_length(_o), toNumber(str)));
|
|
|
|
} else {
|
|
|
|
setValue(toNumber(str));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-26 06:57:34 +01:00
|
|
|
static checkConnection = function(_remove_list = true) {
|
|
|
|
if(value_from == noone) return;
|
|
|
|
if(value_from.node.active) return;
|
|
|
|
|
|
|
|
removeFrom(_remove_list);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static searchNodeBackward = function(_node) {
|
|
|
|
if(node == _node) return true;
|
|
|
|
for(var i = 0; i < ds_list_size(node.inputs); i++) {
|
|
|
|
var _in = node.inputs[| i].value_from;
|
|
|
|
if(_in && _in.searchNodeBackward(_node))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
static unitConvert = function(mode) {
|
|
|
|
var _v = animator.values;
|
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(_v); i++ )
|
|
|
|
_v[| i].value = unit.convertUnit(_v[| i].value, mode);
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 0;
|
|
|
|
drag_mx = 0;
|
|
|
|
drag_my = 0;
|
|
|
|
drag_sx = 0;
|
|
|
|
drag_sy = 0;
|
2022-12-19 13:35:30 +01:00
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
2023-01-01 02:06:02 +01:00
|
|
|
if(value_from != noone) return;
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
var _val = getValue();
|
|
|
|
var hover = -1;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case VALUE_TYPE.integer :
|
|
|
|
case VALUE_TYPE.float :
|
|
|
|
switch(display_type) {
|
|
|
|
case VALUE_DISPLAY._default : #region
|
2023-01-01 02:06:02 +01:00
|
|
|
if(is_array(_val)) break;
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
var _angle = argument_count > 8? argument[8] : 0;
|
|
|
|
var _scale = argument_count > 9? argument[9] : 1;
|
|
|
|
var spr = argument_count > 10? argument[10] : THEME.anchor_selector;
|
2022-01-17 02:19:01 +01:00
|
|
|
var index = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
var __ax = lengthdir_x(_val * _scale, _angle);
|
|
|
|
var __ay = lengthdir_y(_val * _scale, _angle);
|
|
|
|
|
|
|
|
var _ax = _x + __ax * _s;
|
|
|
|
var _ay = _y + __ay * _s;
|
|
|
|
|
|
|
|
if(drag_type) {
|
2022-01-17 02:19:01 +01:00
|
|
|
index = 1;
|
2022-01-13 05:24:03 +01:00
|
|
|
var dist = point_distance(_mx, _my, _x, _y) / _s / _scale;
|
2022-12-22 03:09:55 +01:00
|
|
|
if(key_mod_press(CTRL))
|
2022-01-13 05:24:03 +01:00
|
|
|
dist = round(dist);
|
|
|
|
|
|
|
|
if(setValue( dist ))
|
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 0;
|
|
|
|
UNDO_HOLDING = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(point_in_circle(_mx, _my, _ax, _ay, 8)) {
|
|
|
|
hover = 1;
|
2022-01-17 02:19:01 +01:00
|
|
|
index = 1;
|
2022-12-12 09:08:03 +01:00
|
|
|
if(mouse_press(mb_left, active)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 1;
|
|
|
|
drag_mx = _mx;
|
|
|
|
drag_my = _my;
|
|
|
|
drag_sx = _ax;
|
|
|
|
drag_sy = _ay;
|
|
|
|
}
|
|
|
|
}
|
2022-01-17 02:19:01 +01:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_sprite_ui_uniform(spr, index, _ax, _ay);
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
#endregion
|
|
|
|
case VALUE_DISPLAY.rotation : #region
|
2023-01-01 02:06:02 +01:00
|
|
|
if(is_array(_val)) break;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
var _rad = argument_count > 8? argument[8] : 64;
|
2022-01-13 05:24:03 +01:00
|
|
|
var _ax = _x + lengthdir_x(_rad, _val);
|
|
|
|
var _ay = _y + lengthdir_y(_rad, _val);
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui(THEME.anchor_rotate, 0, _ax, _ay, 1, 1, _val - 90, c_white, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(drag_type) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS._main_accent);
|
2022-01-13 05:24:03 +01:00
|
|
|
draw_set_alpha(0.5);
|
|
|
|
draw_circle(_x, _y, _rad, true);
|
|
|
|
draw_set_alpha(1);
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui(THEME.anchor_rotate, 1, _ax, _ay, 1, 1, _val - 90, c_white, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
var angle = point_direction(_x, _y, _mx, _my);
|
2022-12-22 03:09:55 +01:00
|
|
|
if(key_mod_press(CTRL))
|
2022-01-13 05:24:03 +01:00
|
|
|
angle = round(angle / 15) * 15;
|
|
|
|
|
|
|
|
if(setValue( angle ))
|
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 0;
|
|
|
|
UNDO_HOLDING = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(point_in_circle(_mx, _my, _ax, _ay, 8)) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS._main_accent);
|
2022-01-13 05:24:03 +01:00
|
|
|
draw_set_alpha(0.5);
|
|
|
|
draw_circle(_x, _y, _rad, true);
|
|
|
|
draw_set_alpha(1);
|
|
|
|
hover = 1;
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui(THEME.anchor_rotate, 1, _ax, _ay, 1, 1, _val - 90, c_white, 1);
|
2022-12-12 09:08:03 +01:00
|
|
|
if(mouse_press(mb_left, active)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 1;
|
|
|
|
drag_mx = _mx;
|
|
|
|
drag_my = _my;
|
|
|
|
drag_sx = _ax;
|
|
|
|
drag_sy = _ay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endregion
|
|
|
|
case VALUE_DISPLAY.vector : #region
|
2023-01-01 02:06:02 +01:00
|
|
|
if(is_array(_val[0])) break;
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
var __ax = _val[0];
|
|
|
|
var __ay = _val[1];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
var _ax = __ax * _s + _x;
|
|
|
|
var _ay = __ay * _s + _y;
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax, _ay);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(drag_type) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 1, _ax, _ay);
|
2022-12-19 13:35:30 +01:00
|
|
|
var _nx = value_snap((drag_sx + (_mx - drag_mx) - _x) / _s, _snx);
|
|
|
|
var _ny = value_snap((drag_sy + (_my - drag_my) - _y) / _s, _sny);
|
2022-12-22 03:09:55 +01:00
|
|
|
if(key_mod_press(CTRL)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[0] = round(_nx);
|
|
|
|
_val[1] = round(_ny);
|
|
|
|
} else {
|
|
|
|
_val[0] = _nx;
|
|
|
|
_val[1] = _ny;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(setValue( _val ))
|
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 0;
|
|
|
|
UNDO_HOLDING = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(point_in_circle(_mx, _my, _ax, _ay, 8)) {
|
|
|
|
hover = 1;
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 1, _ax, _ay);
|
2022-12-12 09:08:03 +01:00
|
|
|
if(mouse_press(mb_left, active)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 1;
|
|
|
|
drag_mx = _mx;
|
|
|
|
drag_my = _my;
|
|
|
|
drag_sx = _ax;
|
|
|
|
drag_sy = _ay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endregion
|
|
|
|
case VALUE_DISPLAY.area : #region
|
2023-01-01 02:06:02 +01:00
|
|
|
if(is_array(_val[0])) break;
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
var __ax = array_safe_get(_val, 0);
|
|
|
|
var __ay = array_safe_get(_val, 1);
|
|
|
|
var __aw = array_safe_get(_val, 2);
|
|
|
|
var __ah = array_safe_get(_val, 3);
|
|
|
|
var __at = array_safe_get(_val, 4);
|
|
|
|
|
|
|
|
var _ax = __ax * _s + _x;
|
|
|
|
var _ay = __ay * _s + _y;
|
|
|
|
var _aw = __aw * _s;
|
|
|
|
var _ah = __ah * _s;
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS._main_accent);
|
2022-01-13 05:24:03 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor, 0, _ax, _ay);
|
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax + _aw, _ay + _ah);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(point_in_circle(_mx, _my, _ax + _aw, _ay + _ah, 8))
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 1, _ax + _aw, _ay + _ah);
|
2022-01-13 05:24:03 +01:00
|
|
|
else if(point_in_rectangle(_mx, _my, _ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah))
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor, 0, _ax, _ay, 1.25, c_white);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(drag_type == 1) {
|
2022-12-19 13:35:30 +01:00
|
|
|
var _xx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
|
|
|
|
var _yy = value_snap(drag_sy + (_my - drag_my) / _s, _sny);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
if(key_mod_press(CTRL)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[0] = round(_xx);
|
|
|
|
_val[1] = round(_yy);
|
|
|
|
} else {
|
|
|
|
_val[0] = _xx;
|
|
|
|
_val[1] = _yy;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(setValue(_val))
|
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 0;
|
|
|
|
UNDO_HOLDING = false;
|
|
|
|
}
|
|
|
|
} else if(drag_type == 2) {
|
2022-12-19 13:35:30 +01:00
|
|
|
var _dx = value_snap((_mx - drag_mx) / _s, _snx);
|
|
|
|
var _dy = value_snap((_my - drag_my) / _s, _sny);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
if(key_mod_press(CTRL)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
_val[2] = round(_dx);
|
|
|
|
_val[3] = round(_dy);
|
|
|
|
} else {
|
|
|
|
_val[2] = _dx;
|
|
|
|
_val[3] = _dy;
|
|
|
|
}
|
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
if(keyboard_check(vk_shift)) {
|
|
|
|
_val[2] = max(_dx, _dy);
|
|
|
|
_val[3] = max(_dx, _dy);
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(setValue(_val))
|
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 0;
|
|
|
|
UNDO_HOLDING = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-12 09:08:03 +01:00
|
|
|
if(active) {
|
2022-01-13 05:24:03 +01:00
|
|
|
if(point_in_circle(_mx, _my, _ax + _aw, _ay + _ah, 8)) {
|
|
|
|
hover = 2;
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_press(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 2;
|
|
|
|
drag_mx = _ax;
|
|
|
|
drag_my = _ay;
|
|
|
|
}
|
|
|
|
} else if(point_in_rectangle(_mx, _my, _ax - _aw, _ay - _ah, _ax + _aw, _ay + _ah)) {
|
|
|
|
hover = 1;
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_press(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 1;
|
|
|
|
drag_sx = __ax;
|
|
|
|
drag_sy = __ay;
|
|
|
|
drag_mx = _mx;
|
|
|
|
drag_my = _my;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endregion
|
|
|
|
case VALUE_DISPLAY.puppet_control : #region
|
2023-01-01 02:06:02 +01:00
|
|
|
if(is_array(_val[0])) break;
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
var __ax = _val[PUPPET_CONTROL.cx];
|
|
|
|
var __ay = _val[PUPPET_CONTROL.cy];
|
|
|
|
var __ax1 = _val[PUPPET_CONTROL.fx];
|
|
|
|
var __ay1 = _val[PUPPET_CONTROL.fy];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
var _ax = __ax * _s + _x;
|
|
|
|
var _ay = __ay * _s + _y;
|
|
|
|
|
|
|
|
var _ax1 = (__ax + __ax1) * _s + _x;
|
|
|
|
var _ay1 = (__ay + __ay1) * _s + _y;
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS._main_accent);
|
2022-09-23 13:28:42 +02:00
|
|
|
switch(_val[PUPPET_CONTROL.mode]) {
|
|
|
|
case PUPPET_FORCE_MODE.move :
|
|
|
|
draw_line_width2(_ax, _ay, _ax1, _ay1, 6, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax, _ay);
|
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 2, _ax1, _ay1);
|
2022-09-23 13:28:42 +02:00
|
|
|
draw_circle(_ax, _ay, _val[PUPPET_CONTROL.width] * _s, true);
|
|
|
|
break;
|
|
|
|
case PUPPET_FORCE_MODE.pinch :
|
|
|
|
case PUPPET_FORCE_MODE.inflate :
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax, _ay);
|
2022-09-23 13:28:42 +02:00
|
|
|
draw_circle(_ax, _ay, _val[PUPPET_CONTROL.width] * _s, true);
|
|
|
|
break;
|
|
|
|
case PUPPET_FORCE_MODE.wind :
|
|
|
|
var dir = _val[PUPPET_CONTROL.fy];
|
|
|
|
var rad = _val[PUPPET_CONTROL.width] * _s;
|
|
|
|
|
|
|
|
var _l0x = _ax + lengthdir_x(rad, dir + 90);
|
|
|
|
var _l0y = _ay + lengthdir_y(rad, dir + 90);
|
|
|
|
var _l1x = _ax + lengthdir_x(rad, dir - 90);
|
|
|
|
var _l1y = _ay + lengthdir_y(rad, dir - 90);
|
|
|
|
|
|
|
|
var _l0x0 = _l0x + lengthdir_x(1000, dir);
|
|
|
|
var _l0y0 = _l0y + lengthdir_y(1000, dir);
|
|
|
|
var _l0x1 = _l0x + lengthdir_x(1000, dir + 180);
|
|
|
|
var _l0y1 = _l0y + lengthdir_y(1000, dir + 180);
|
|
|
|
|
|
|
|
var _l1x0 = _l1x + lengthdir_x(1000, dir);
|
|
|
|
var _l1y0 = _l1y + lengthdir_y(1000, dir);
|
|
|
|
var _l1x1 = _l1x + lengthdir_x(1000, dir + 180);
|
|
|
|
var _l1y1 = _l1y + lengthdir_y(1000, dir + 180);
|
|
|
|
|
|
|
|
draw_line(_l0x0, _l0y0, _l0x1, _l0y1);
|
|
|
|
draw_line(_l1x0, _l1y0, _l1x1, _l1y1);
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax, _ay);
|
2022-09-23 13:28:42 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(drag_type == 1) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 1, _ax, _ay);
|
2022-12-19 13:35:30 +01:00
|
|
|
var _nx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
|
|
|
|
var _ny = value_snap(drag_sy + (_my - drag_my) / _s, _sny);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
if(key_mod_press(CTRL)) {
|
2022-09-23 13:28:42 +02:00
|
|
|
_val[PUPPET_CONTROL.cx] = round(_nx);
|
|
|
|
_val[PUPPET_CONTROL.cy] = round(_ny);
|
2022-01-13 05:24:03 +01:00
|
|
|
} else {
|
2022-09-23 13:28:42 +02:00
|
|
|
_val[PUPPET_CONTROL.cx] = _nx;
|
|
|
|
_val[PUPPET_CONTROL.cy] = _ny;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(setValue( _val ))
|
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 0;
|
|
|
|
UNDO_HOLDING = false;
|
|
|
|
}
|
|
|
|
} else if(drag_type == 2) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax1, _ay1);
|
2022-12-19 13:35:30 +01:00
|
|
|
var _nx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
|
|
|
|
var _ny = value_snap(drag_sy + (_my - drag_my) / _s, _sny);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
if(key_mod_press(CTRL)) {
|
2022-09-23 13:28:42 +02:00
|
|
|
_val[PUPPET_CONTROL.fx] = round(_nx);
|
|
|
|
_val[PUPPET_CONTROL.fy] = round(_ny);
|
2022-01-13 05:24:03 +01:00
|
|
|
} else {
|
2022-09-23 13:28:42 +02:00
|
|
|
_val[PUPPET_CONTROL.fx] = _nx;
|
|
|
|
_val[PUPPET_CONTROL.fy] = _ny;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(setValue( _val ))
|
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 0;
|
|
|
|
UNDO_HOLDING = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(point_in_circle(_mx, _my, _ax, _ay, 8)) {
|
|
|
|
hover = 1;
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 1, _ax, _ay);
|
2022-12-12 09:08:03 +01:00
|
|
|
if(mouse_press(mb_left, active)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 1;
|
|
|
|
drag_mx = _mx;
|
|
|
|
drag_my = _my;
|
|
|
|
drag_sx = __ax;
|
|
|
|
drag_sy = __ay;
|
|
|
|
}
|
2022-09-23 13:28:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(_val[PUPPET_CONTROL.mode] == PUPPET_FORCE_MODE.move && point_in_circle(_mx, _my, _ax1, _ay1, 8)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
hover = 2;
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax1, _ay1);
|
2022-12-12 09:08:03 +01:00
|
|
|
if(mouse_press(mb_left, active)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
drag_type = 2;
|
|
|
|
drag_mx = _mx;
|
|
|
|
drag_my = _my;
|
|
|
|
drag_sx = __ax1;
|
|
|
|
drag_sy = __ay1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return hover;
|
|
|
|
}
|
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
static drawJunction = function(_s, _mx, _my) {
|
2022-01-26 06:57:34 +01:00
|
|
|
if(!isVisible()) return false;
|
|
|
|
|
|
|
|
var ss = max(0.25, _s / 2);
|
|
|
|
var is_hover = false;
|
|
|
|
|
|
|
|
if(point_in_circle(_mx, _my, x, y, 10 * _s)) {
|
|
|
|
is_hover = true;
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ext(isArray()? THEME.node_junctions_array_hover : THEME.node_junctions_single_hover, type, x, y, ss, ss, 0, c_white, 1);
|
2022-01-26 06:57:34 +01:00
|
|
|
} else {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ext(isArray()? THEME.node_junctions_array : THEME.node_junctions_single, type, x, y, ss, ss, 0, c_white, 1);
|
2022-01-26 06:57:34 +01:00
|
|
|
}
|
2022-09-27 06:37:28 +02:00
|
|
|
|
|
|
|
return is_hover;
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawNameBG = function(_s) {
|
|
|
|
if(!isVisible()) return false;
|
|
|
|
|
|
|
|
draw_set_text(f_p1, fa_left, fa_center);
|
2022-12-10 05:06:01 +01:00
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
var tw = string_width(name) + 16;
|
|
|
|
var th = string_height(name) + 16;
|
|
|
|
|
|
|
|
if(connect_type == JUNCTION_CONNECT.input) {
|
|
|
|
var tx = x - 12 * _s;
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.node_junction_name_bg, 0, tx - tw, y - th / 2, tw + 16, th, c_white, 0.5);
|
2022-09-27 06:37:28 +02:00
|
|
|
} else {
|
|
|
|
var tx = x + 12 * _s;
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.node_junction_name_bg, 0, tx - 16, y - th / 2, tw + 16, th, c_white, 0.5);
|
2022-01-26 06:57:34 +01:00
|
|
|
}
|
2022-09-27 06:37:28 +02:00
|
|
|
}
|
|
|
|
static drawName = function(_s, _mx, _my) {
|
|
|
|
if(!isVisible()) return false;
|
2022-01-26 06:57:34 +01:00
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
var _hover = point_in_circle(_mx, _my, x, y, 10 * _s);
|
2022-11-18 03:20:31 +01:00
|
|
|
var _draw_cc = _hover? COLORS._main_text : COLORS._main_text_sub;
|
2022-09-27 06:37:28 +02:00
|
|
|
draw_set_text(f_p1, fa_left, fa_center, _draw_cc);
|
|
|
|
|
|
|
|
if(connect_type == JUNCTION_CONNECT.input) {
|
|
|
|
var tx = x - 12 * _s;
|
|
|
|
draw_set_halign(fa_right);
|
|
|
|
draw_text(tx, y, name);
|
|
|
|
} else {
|
|
|
|
var tx = x + 12 * _s;
|
|
|
|
draw_set_halign(fa_left);
|
|
|
|
draw_text(tx, y, name);
|
|
|
|
}
|
2022-01-26 06:57:34 +01:00
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static isVisible = function() {
|
|
|
|
if(!node.active) return false;
|
2023-01-04 02:30:04 +01:00
|
|
|
return value_from || visible;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
static extractNode = function() {
|
|
|
|
if(extract_node == "") return noone;
|
|
|
|
|
|
|
|
var tr = nodeBuild(extract_node, node.x, node.y);
|
|
|
|
tr.x -= tr.w + 32;
|
|
|
|
|
|
|
|
setFrom(tr.outputs[| 0]);
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static serialize = function(scale = false) {
|
|
|
|
var _map = ds_map_create();
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
ds_map_add_list(_map, "raw value", animator.serialize(scale));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
_map[? "on end"] = on_end;
|
|
|
|
_map[? "visible"] = visible;
|
2022-12-27 04:00:50 +01:00
|
|
|
_map[? "unit"] = unit.mode;
|
2022-09-23 13:28:42 +02:00
|
|
|
_map[? "anim"] = animator.is_anim;
|
2022-01-13 05:24:03 +01:00
|
|
|
_map[? "from node"] = value_from? value_from.node.node_id : -1;
|
|
|
|
_map[? "from index"] = value_from? value_from.index : -1;
|
|
|
|
|
|
|
|
ds_map_add_list(_map, "data", ds_list_clone(extra_data));
|
|
|
|
|
|
|
|
return _map;
|
|
|
|
}
|
|
|
|
|
|
|
|
con_node = -1;
|
|
|
|
con_index = -1;
|
2022-12-21 02:30:23 +01:00
|
|
|
|
|
|
|
static applyDeserialize = function(_map, scale = false) {
|
2022-12-22 03:09:55 +01:00
|
|
|
if(_map == undefined) return;
|
2023-01-09 03:14:20 +01:00
|
|
|
if(_map == noone) return;
|
2023-01-01 02:06:02 +01:00
|
|
|
|
|
|
|
printIf(TESTING, " |- Applying deserialize to junction " + name + " of node " + node.name);
|
2022-01-13 05:24:03 +01:00
|
|
|
on_end = ds_map_try_get(_map, "on end", on_end);
|
|
|
|
visible = ds_map_try_get(_map, "visible", visible);
|
2022-12-27 04:00:50 +01:00
|
|
|
unit.mode = ds_map_try_get(_map, "unit", VALUE_UNIT.constant);
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
animator.deserialize(_map[? "raw value"], scale);
|
2022-12-27 13:30:02 +01:00
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
animator.is_anim = _map[? "anim"];
|
2022-01-13 05:24:03 +01:00
|
|
|
con_node = _map[? "from node"];
|
|
|
|
con_index = _map[? "from index"];
|
|
|
|
|
|
|
|
if(ds_map_exists(_map, "data"))
|
|
|
|
ds_list_copy(extra_data, _map[? "data"]);
|
2022-12-27 13:30:02 +01:00
|
|
|
|
2022-08-30 07:36:37 +02:00
|
|
|
onValidate();
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
static connect = function(log = false) {
|
|
|
|
if(con_node == -1 || con_index == -1)
|
|
|
|
return true;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
var _node = con_node;
|
2022-12-21 02:30:23 +01:00
|
|
|
if(APPENDING) {
|
2022-09-21 06:09:40 +02:00
|
|
|
_node = GetAppendID(con_node);
|
2022-12-21 02:30:23 +01:00
|
|
|
if(_node == -1)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!ds_map_exists(NODE_MAP, _node)) {
|
|
|
|
var txt = "Node connect error : Node ID " + string(_node) + " not found.";
|
|
|
|
log_warning("LOAD", "[Connect] " + txt);
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-19 03:05:13 +01:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
var _nd = NODE_MAP[? _node];
|
|
|
|
var _ol = ds_list_size(_nd.outputs);
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
if(log)
|
|
|
|
log_warning("LOAD", "[Connect] Reconnecting " + string(node.name) + " to " + _nd.name);
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
if(con_index < _ol) {
|
|
|
|
if(setFrom(_nd.outputs[| con_index], false))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
log_warning("LOAD", "[Connect] Connection conflict " + string(node.name) + " to " + string(_nd.name) + " : Connection failed.");
|
|
|
|
return false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
log_warning("LOAD", "[Connect] Connection conflict " + string(node.name) + " to " + string(_nd.name) + " : Node not exist.");
|
2022-01-19 03:05:13 +01:00
|
|
|
return false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-01-19 06:11:17 +01:00
|
|
|
|
|
|
|
static cleanUp = function() {
|
|
|
|
ds_list_destroy(value_to);
|
|
|
|
ds_list_destroy(extra_data);
|
2022-09-23 13:28:42 +02:00
|
|
|
animator.cleanUp();
|
|
|
|
delete animator;
|
2022-01-19 06:11:17 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|