Pixel-Composer/objects/addon_key_displayer/Draw_75.gml

114 lines
3.2 KiB
Text
Raw Normal View History

2023-01-09 03:14:20 +01:00
/// @description
#region draw
var key = "";
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(extra_keys); i < n; i++ ) {
2023-01-17 08:11:55 +01:00
if(keyboard_check(extra_keys[i][0]))
key += key == ""? extra_keys[i][1] : (" + " + extra_keys[i][1]);
}
2023-01-09 03:14:20 +01:00
if(keyboard_check(vk_anykey)) {
2023-12-24 12:06:44 +01:00
var pres = last_key;
2023-01-09 03:14:20 +01:00
if(pres >= 32 && pres <= 126) {
pres = string_upper(ansi_char(pres));
2023-02-15 10:43:24 +01:00
if(pres == " ") pres = "space";
2023-01-09 03:14:20 +01:00
key += key == ""? pres : " + " + pres;
}
}
var pressing = key != "";
if(key != "") {
disp_text = key;
alpha = 2;
} else
alpha = lerp_linear(alpha, 0, 0.01);
2023-02-28 09:43:01 +01:00
var win_y = WIN_H;
#region graph
if(show_graph) {
win_y -= 64;
draw_set_color(c_black);
draw_set_alpha(0.5);
draw_rectangle(0, win_y, WIN_W, WIN_H, false);
draw_set_alpha(1);
draw_set_color(c_white);
var mlx = WIN_W - array_length(mouse_left);
var ox, oy, nx, ny;
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(mouse_left); i < n; i++ ) {
2023-02-28 09:43:01 +01:00
nx = mlx + i;
ny = WIN_H - 4 - mouse_left[i] * 24;
if(i)
draw_line(ox, oy, nx, ny);
ox = nx;
oy = ny;
}
}
var mp = 0;
if(DOUBLE_CLICK) mp = 2;
else if(mouse_press(mb_left)) mp = 1.2;
else if(mouse_release(mb_left)) mp = 1.2;
else if(mouse_click(mb_left)) mp = 1;
array_push(mouse_left, mp);
if(array_length(mouse_left) > WIN_W)
array_delete(mouse_left, 0, 1);
#endregion
#region mouse
var mxs = WIN_W - ui(16);
var mys = win_y - ui(16);
if(show_doubleclick) {
var dcw = 72;
var dch = 8;
var dcx = mxs - 72;
var dcy = mys - 96 - 8 - dch;
2023-10-31 05:30:42 +01:00
var _dcw = dcw * clamp(o_main.dc_check / PREFERENCES.double_click_delay, 0., 1.);
2023-02-28 09:43:01 +01:00
draw_sprite_stretched_ext(THEME.menu_button_mask, 0, dcx, dcy, dcw, dch, COLORS._main_icon_dark, 0.5);
draw_sprite_stretched_ext(THEME.menu_button_mask, 0, dcx, dcy, _dcw, dch, COLORS._main_icon_light, 1.0);
}
2023-07-30 13:56:22 +02:00
draw_sprite_ext(s_key_display_mouse, 0, mxs, mys, 1, 1, 0, c_white, 0.5);
2023-02-28 09:43:01 +01:00
if(DOUBLE_CLICK)
draw_sprite_ext(s_key_display_mouse, 1, mxs, mys, 1, 1, 0, COLORS._main_value_positive, 1);
else if(mouse_click(mb_left))
draw_sprite_ext(s_key_display_mouse, 1, mxs, mys, 1, 1, 0, COLORS._main_icon_light, 1);
2023-07-30 13:56:22 +02:00
if(mouse_click(mb_right))
2023-02-28 09:43:01 +01:00
draw_sprite_ext(s_key_display_mouse, 2, mxs, mys, 1, 1, 0, COLORS._main_icon_light, 1);
2023-07-30 13:56:22 +02:00
if(mouse_click(mb_middle))
2023-02-28 09:43:01 +01:00
draw_sprite_ext(s_key_display_mouse, 3, mxs, mys, 1, 1, 0, COLORS._main_icon_light, 1);
if(mouse_wheel_up())
2023-07-30 13:56:22 +02:00
draw_sprite_ext(s_key_display_mouse, 3, mxs, mys, 1, 1, 0, COLORS._main_accent, 1);
2023-02-28 09:43:01 +01:00
if(mouse_wheel_down())
2023-07-30 13:56:22 +02:00
draw_sprite_ext(s_key_display_mouse, 3, mxs, mys, 1, 1, 0, COLORS._main_accent, 1);
2023-02-28 09:43:01 +01:00
#endregion
2023-01-09 03:14:20 +01:00
if(alpha > 0) {
2023-07-30 13:56:22 +02:00
draw_set_text(_f_h5, fa_right, fa_bottom, COLORS._main_icon_dark);
var pd = ui(4);
var ww = string_width(disp_text) + pd * 3;
var hh = string_height(disp_text) + pd * 2;
2023-01-09 03:14:20 +01:00
2023-12-24 12:06:44 +01:00
var x1 = WIN_W - ui(32 + sprite_get_width(s_key_display_mouse));
2023-02-28 09:43:01 +01:00
var y1 = win_y - ui(8);
2023-01-09 03:14:20 +01:00
var x0 = x1 - ww;
var y0 = y1 - hh;
2023-12-24 12:06:44 +01:00
draw_sprite_stretched_ext(THEME.key_display, 0, x0, y0, ww, hh, pressing? COLORS._main_accent : COLORS._main_icon, alpha);
2023-01-09 03:14:20 +01:00
draw_set_alpha(alpha);
2023-07-30 13:56:22 +02:00
draw_text(x1 - pd * 1.5, y1 - pd, disp_text);
2023-01-09 03:14:20 +01:00
draw_set_alpha(1);
}
#endregion