Pixel-Composer/objects/addon_key_displayer/Draw_75.gml

144 lines
4.2 KiB
Plaintext
Raw Permalink 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;
2024-03-02 10:08:44 +01:00
#region mouse graph
2023-02-28 09:43:01 +01:00
if(show_graph) {
2024-03-02 10:08:44 +01:00
win_y -= 128;
2023-02-28 09:43:01 +01:00
draw_set_color(c_black);
draw_set_alpha(0.5);
draw_rectangle(0, win_y, WIN_W, WIN_H, false);
draw_set_alpha(1);
2024-03-02 10:08:44 +01:00
draw_set_color(c_green);
2023-02-28 09:43:01 +01:00
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);
2023-02-28 09:43:01 +01:00
ox = nx;
oy = ny;
}
2024-03-02 10:08:44 +01:00
draw_set_color(c_red);
var mlx = WIN_W - array_length(mouse_right);
var ox, oy, nx, ny;
for( var i = 0, n = array_length(mouse_right); i < n; i++ ) {
nx = mlx + i;
ny = WIN_H - 64 - 4 - mouse_right[i] * 24;
if(i) draw_line(ox, oy, nx, ny);
2024-03-02 10:08:44 +01:00
ox = nx;
oy = ny;
}
// draw_set_color(PEN_USE? c_yellow : c_white);
// draw_set_alpha(0.75);
// BLEND_ADD
// for( var i = 1, n = array_length(mouse_pos); i < n; i++ )
// draw_line(mouse_pos[i - 1][0], mouse_pos[i - 1][1], mouse_pos[i][0], mouse_pos[i][1]);
// BLEND_NORMAL
// draw_set_alpha(1);
2024-03-02 10:08:44 +01:00
var mp = 0;
if(DOUBLE_CLICK) mp = 2;
else if(mouse_lpress(mb_left)) mp = 1.3;
else if(mouse_lrelease(mb_left)) mp = 1.3;
else if(mouse_lclick(mb_left)) mp = 1;
2023-02-28 09:43:01 +01:00
2024-03-02 10:08:44 +01:00
array_push(mouse_left, mp);
if(array_length(mouse_left) > WIN_W)
array_delete(mouse_left, 0, 1);
2023-02-28 09:43:01 +01:00
2024-03-02 10:08:44 +01:00
var mp = 0;
if(mouse_rpress(mb_right)) mp = 1.3;
else if(mouse_rrelease(mb_right)) mp = 1.3;
else if(mouse_rclick(mb_right)) mp = 1;
array_push(mouse_right, mp);
if(array_length(mouse_right) > WIN_W)
array_delete(mouse_right, 0, 1);
array_push(mouse_pos, [ mouse_mx, mouse_my ])
if(array_length(mouse_pos) > 1000)
array_delete(mouse_pos, 0, 1);
}
2023-02-28 09:43:01 +01:00
#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.s_box_r2, 0, dcx, dcy, dcw, dch, COLORS._main_icon_dark, 0.5);
draw_sprite_stretched_ext(THEME.s_box_r2, 0, dcx, dcy, _dcw, dch, COLORS._main_icon_light, 1.0);
2023-02-28 09:43:01 +01:00
}
var cc = PEN_USE? COLORS._main_accent : c_white;
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);
if(mouse_click(mb_right)) draw_sprite_ext(s_key_display_mouse, 2, mxs, mys, 1, 1, 0, COLORS._main_icon_light, 1);
if(mouse_click(mb_middle)) draw_sprite_ext(s_key_display_mouse, 3, mxs, mys, 1, 1, 0, COLORS._main_icon_light, 1);
2023-02-28 09:43:01 +01:00
if(mouse_wheel_up()) draw_sprite_ext(s_key_display_mouse, 3, mxs, mys, 1, 1, 0, COLORS._main_accent, 1);
if(mouse_wheel_down()) draw_sprite_ext(s_key_display_mouse, 3, mxs, mys, 1, 1, 0, COLORS._main_accent, 1);
draw_sprite_ext_add(s_key_display_mouse, 0, mxs, mys, 1, 1, 0, cc, 0.5);
2023-02-28 09:43:01 +01:00
#endregion
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);
}
2023-01-09 03:14:20 +01:00
#endregion