2022-12-27 04:00:50 +01:00
|
|
|
function Node_Counter(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constructor {
|
2022-01-13 05:24:03 +01:00
|
|
|
name = "Counter";
|
|
|
|
update_on_frame = true;
|
|
|
|
previewable = false;
|
|
|
|
|
|
|
|
w = 96;
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
inputs[| 0] = nodeValue(0, "Start", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
|
|
|
|
inputs[| 1] = nodeValue(1, "Speed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
|
2023-01-25 06:49:00 +01:00
|
|
|
inputs[| 2] = nodeValue(2, "Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, @"Counting mode
|
|
|
|
- Frame count: Count value up/down per frame.
|
|
|
|
- Animation progress: Count from 0 (first frame) to 1 (last frame). ")
|
2022-12-12 09:08:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.enum_scroll, ["Frame count", "Animation progress"]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
outputs[| 0] = nodeValue(0, "Counter", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
|
|
|
|
|
2022-12-12 09:08:03 +01:00
|
|
|
input_display_list = [
|
|
|
|
2, 0, 1
|
|
|
|
];
|
|
|
|
|
|
|
|
static step = function() {
|
|
|
|
var mode = inputs[| 2].getValue();
|
2022-12-27 04:00:50 +01:00
|
|
|
inputs[| 0].setVisible(mode == 0);
|
2022-12-12 09:08:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
function process_data(_output, _data, index = 0) {
|
2022-01-13 05:24:03 +01:00
|
|
|
var time = ANIMATOR.current_frame;
|
2022-12-12 09:08:03 +01:00
|
|
|
var mode = inputs[| 2].getValue();
|
|
|
|
var val;
|
|
|
|
|
|
|
|
switch(mode) {
|
|
|
|
case 0 : val = _data[0] + time * _data[1]; break;
|
|
|
|
case 1 : val = time / (ANIMATOR.frames_total - 1) * _data[1]; break;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s) {
|
2023-01-04 02:30:04 +01:00
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
var str = outputs[| 0].getValue();
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
2023-01-04 02:30:04 +01:00
|
|
|
var ss = string_scale(str, bbox.w, bbox.h);
|
|
|
|
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|