Pixel-Composer/scripts/node_base_convert/node_base_convert.gml

37 lines
1.2 KiB
Text
Raw Normal View History

2023-03-29 15:02:03 +02:00
function Node_Base_Convert(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Convert Base";
color = COLORS.node_blend_number;
2024-05-02 11:05:02 +02:00
setDimension(96, 48);
2023-03-29 15:02:03 +02:00
2024-08-18 09:13:41 +02:00
newInput(0, nodeValue_Text("Value", self, ""))
2023-03-29 15:02:03 +02:00
.setVisible(true, true);
2024-08-18 06:16:20 +02:00
newInput(1, nodeValue_Int("Base from", self, 10));
2023-03-29 15:02:03 +02:00
2024-08-18 06:16:20 +02:00
newInput(2, nodeValue_Int("Base to", self, 10));
2023-03-29 15:02:03 +02:00
2024-08-08 06:57:51 +02:00
outputs[0] = nodeValue_Output("Result", self, VALUE_TYPE.text, "");
2023-03-29 15:02:03 +02:00
2023-08-17 16:56:54 +02:00
static processData = function(_output, _data, _output_index, _array_index = 0) {
2023-03-29 15:02:03 +02:00
var val = _data[0];
var bFrom = max(2, _data[1]);
var bTo = max(2, _data[2]);
return convertBase(val, bFrom, bTo);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
2024-03-31 05:36:11 +02:00
var baseFrom = array_safe_get_fast(current_data, 1);
var baseTo = array_safe_get_fast(current_data, 2);
2023-03-29 15:02:03 +02:00
var bbox = drawGetBbox(xx, yy, _s);
2023-06-13 14:42:06 +02:00
var b1 = BBOX().fromPoints(bbox.x0, bbox.y0, bbox.xc - _s * 8, bbox.y1);
var b2 = BBOX().fromPoints(bbox.xc + _s * 8, bbox.y0, bbox.x1, bbox.y1);
2023-03-29 15:02:03 +02:00
draw_sprite_ext(THEME.arrow, 0, bbox.xc, bbox.yc + 1 * _s, .5 * _s, .5 * _s, 0, COLORS._main_icon, 1);
draw_text_bbox(b1, baseFrom);
draw_text_bbox(b2, baseTo);
}
}