Pixel-Composer/objects/o_dialog_lua_reference/Create_0.gml

109 lines
3.2 KiB
Plaintext
Raw Normal View History

2023-02-14 02:48:33 +01:00
/// @description init
event_inherited();
#region data
dialog_resizable = true;
dialog_w = ui(960);
dialog_h = ui(640);
destroy_on_click_out = true;
onResize = function() {
2023-02-28 09:43:01 +01:00
sp_note.resize(dialog_w - ui(padding + padding), dialog_h - ui(title_height + padding));
2023-02-14 02:48:33 +01:00
}
is_open = array_create(array_length(global.lua_functions), false);
2023-02-28 09:43:01 +01:00
sp_note = new scrollPane(dialog_w - ui(padding + padding), dialog_h - ui(title_height + padding), function(_y, _m) {
2023-02-14 02:48:33 +01:00
draw_clear_alpha(c_white, 0);
var f = global.lua_functions;
var amo = array_length(f);
var pad = ui(4);
var yy = _y + pad;
var _h = 0;
var ind = 0;
for( var i = 0; i < amo; i++ ) {
var _f = f[i];
if(is_string(_f)) {
draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text_accent);
yy += ui(8);
2023-05-28 20:00:51 +02:00
var hh = line_get_height() + pad + ui(8);
2023-02-14 02:48:33 +01:00
2023-06-10 13:59:45 +02:00
draw_text_add(ui(24), yy, _f);
2023-02-14 02:48:33 +01:00
ind = 0;
yy += hh;
_h += hh;
continue;
}
draw_set_text(f_code, fa_left, fa_top, COLORS._main_text);
var _func = array_length(_f) > 2? _f[2] : _f[0];
2024-03-31 05:36:11 +02:00
var _desp = array_safe_get_fast(_f, 3, "");
var _args = array_safe_get_fast(_f, 4, []);
2023-05-28 20:00:51 +02:00
var hh = line_get_height();
2023-02-14 02:48:33 +01:00
if(is_open[i]) {
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
hh += pad + string_height(_desp) + ui(8);
if(array_length(_args))
2023-05-28 20:00:51 +02:00
hh += (line_get_height() + ui(4)) * (array_length(_args) + 1) + ui(20);
2023-02-14 02:48:33 +01:00
}
hh += pad * 2;
BLEND_OVERRIDE;
if(sp_note.hover && point_in_rectangle(_m[0], _m[1], 0, yy, sp_note.surface_w, yy + hh)) {
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, yy,
sp_note.surface_w, hh, COLORS.dialog_lua_ref_bg_hover, 1);
if(mouse_press(mb_left, sFOCUS))
is_open[i] = !array_get(is_open, i);
} else
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, yy,
sp_note.surface_w, hh, COLORS.dialog_lua_ref_bg, 1);
BLEND_NORMAL;
2023-05-28 20:00:51 +02:00
draw_sprite_ui(THEME.arrow, is_open[i]? 3 : 0, ui(16), yy + pad + line_get_height() / 2,,,, COLORS._main_icon);
2023-02-14 02:48:33 +01:00
draw_set_text(f_code, fa_left, fa_top, COLORS._main_text);
2023-09-07 20:59:14 +02:00
draw_code_lua(ui(28), yy + pad, _func);
2023-02-14 02:48:33 +01:00
if(is_open[i]) {
2023-05-28 20:00:51 +02:00
var ty = yy + pad + line_get_height() + ui(4);
2023-02-14 02:48:33 +01:00
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_sub);
draw_text(ui(32), ty, _desp);
if(array_length(_args)) {
var ax0 = ui(64 + 16);
var ax1 = ui(200);
var ax2 = ui(320);
2023-05-28 20:00:51 +02:00
ty += line_get_height() + ui(12);
2023-02-14 02:48:33 +01:00
2023-05-28 20:00:51 +02:00
var ah = (line_get_height() + ui(4)) * (array_length(_args) + 1) + ui(8);
2023-02-14 02:48:33 +01:00
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, ui(64), ty, sp_note.surface_w - ui(96), ah,
COLORS.dialog_lua_ref_bg_args, 1);
ty += ui(4);
draw_text(ax0, ty, "Argument");
draw_text(ax1, ty, "Type");
draw_text(ax2, ty, "Description");
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
2023-05-28 20:00:51 +02:00
ty += line_get_height() + ui(4);
2023-02-14 02:48:33 +01:00
for( var j = 0; j < array_length(_args); j++ ) {
draw_text(ax0, ty, _args[j][0]);
draw_text(ax1, ty, _args[j][1]);
draw_text(ax2, ty, _args[j][2]);
2023-05-28 20:00:51 +02:00
ty += line_get_height() + ui(4);
2023-02-14 02:48:33 +01:00
}
}
}
ind++;
yy += hh + pad;
_h += hh + pad;
}
return _h + ui(128);
})
#endregion