Pixel-Composer/scripts/argumentRenderer/argumentRenderer.gml

59 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-09-15 20:12:02 +02:00
function argumentRenderer(_typeArray = []) {
argument_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus, _panel = noone) {
2023-01-17 08:11:55 +01:00
argument_renderer.x = _x;
argument_renderer.y = _y;
argument_renderer.w = _w;
var spc = _panel.viewMode == INSP_VIEW_MODE.spacious;
var tx = _x;
var ty = _y + ui(8);
var hh = ui(8);
2024-10-01 05:46:28 +02:00
var _fn = spc? f_p1 : f_p2;
var _th = spc? line_get_height(f_p0, 12) : line_get_height(f_p2, 12);
2023-01-04 02:30:04 +01:00
2024-08-08 06:57:51 +02:00
for( var i = input_fix_len; i < array_length(inputs); i += data_length ) {
var _jType = inputs[i + 1];
2023-01-04 02:30:04 +01:00
var _h = 0;
2023-06-21 20:36:53 +02:00
_jType.editWidget.setFocusHover(_focus, _hover);
_jType.editWidget.font = _fn;
_jType.editWidget.draw(tx, ty, ui(128), _th, _jType.display_data.data[_jType.showValue()], _m, argument_renderer.rx, argument_renderer.ry);
2023-01-04 02:30:04 +01:00
2024-08-08 06:57:51 +02:00
var _jName = inputs[i + 0];
2023-06-21 20:36:53 +02:00
_jName.editWidget.setFocusHover(_focus, _hover);
_jName.editWidget.font = _fn;
2023-01-04 02:30:04 +01:00
_jName.editWidget.draw(tx + ui(128 + 8), ty, _w - ui(128 + 8), _th, _jName.showValue(), _m, _jName.display_type);
2023-09-17 13:23:24 +02:00
_h += _th + ui(8);
2023-01-04 02:30:04 +01:00
2024-08-08 06:57:51 +02:00
var _jValue = inputs[i + 2];
if(argument_renderer.showValue && _jValue.editWidget != noone) {
draw_set_text(_fn, fa_left, fa_top, COLORS._main_text_sub);
2024-03-02 10:08:44 +01:00
draw_text_add(tx + ui(8), ty + _th + ui(8 + 6), __txt("Value"));
2024-10-01 05:46:28 +02:00
var params = new widgetParam(tx + ui(64), ty + _th + ui(10), _w - ui(64), _th, _jValue.showValue(), {}, _m, argument_renderer.rx, argument_renderer.ry);
params.font = _fn;
2023-09-15 20:12:02 +02:00
2023-06-21 20:36:53 +02:00
_jValue.editWidget.setFocusHover(_focus, _hover);
2023-09-17 13:23:24 +02:00
_h += _jValue.editWidget.drawParam(params) + ui(10);
2023-01-04 02:30:04 +01:00
}
hh += _h;
ty += _h;
}
2023-01-17 08:11:55 +01:00
argument_renderer.h = hh;
2023-01-04 02:30:04 +01:00
return hh;
});
2023-01-17 08:11:55 +01:00
argument_renderer.register = function(parent = noone) {
2024-08-08 06:57:51 +02:00
for( var i = input_fix_len; i < array_length(inputs); i += data_length ) {
inputs[i + 1].editWidget.register(parent);
inputs[i + 0].editWidget.register(parent);
if(inputs[i + 2].editWidget != noone)
inputs[i + 2].editWidget.register(parent);
2023-01-17 08:11:55 +01:00
}
}
argument_renderer.showValue = true;
2023-01-04 02:30:04 +01:00
}