Pixel-Composer/objects/o_dialog_textbox_function_guide/Draw_64.gml

50 lines
1.3 KiB
Plaintext
Raw Normal View History

2023-07-12 16:28:32 +02:00
/// @description
if(!active) exit;
if(textbox == noone) exit;
#region
draw_set_text(f_code, fa_left, fa_top, COLORS._main_text);
dialog_w = string_width(prompt) + ui(16);
dialog_h = string_height(prompt) + ui(16);
dialog_x = clamp(dialog_x, 0, WIN_W - dialog_w - 1);
var dy = clamp(dialog_y - dialog_h, 0, WIN_H - dialog_h - 1);
#endregion
#region draw
draw_sprite_stretched(THEME.textbox, 3, dialog_x, dy, dialog_w, dialog_h);
var cx = dialog_x + ui(8);
var cy = dy + ui(8);
var ind = 1;
var amo = string_length(prompt);
var cch = "";
var fname = true;
var var_ind = 0;
repeat(amo) {
cch = string_char_at(prompt, ind);
ind++;
if(cch == "(") fname = false;
if(cch == ",") var_ind++;
if(cch == "(" || cch == ")" || cch == "[" || cch == "]" || cch == "{" || cch == "}")
draw_set_color(COLORS.lua_highlight_bracklet);
else if(cch == ",")
draw_set_color(COLORS._main_text);
else if(fname)
draw_set_color(COLORS.lua_highlight_function);
else
draw_set_color(var_ind == index? COLORS._main_text : COLORS._main_text_sub);
draw_text(cx, cy, cch);
cx += string_width(cch);
}
draw_sprite_stretched(THEME.textbox, 1, dialog_x, dy, dialog_w, dialog_h);
#endregion
if(keyboard_check_pressed(vk_escape))
active = false;