2023-09-08 19:47:48 +02:00
|
|
|
#region key list
|
|
|
|
global.KEYS_VK = [
|
|
|
|
vk_left, vk_right, vk_up, vk_down, vk_space, vk_backspace, vk_tab, vk_home, vk_end, vk_delete, vk_insert,
|
|
|
|
vk_pageup, vk_pagedown, vk_pause, vk_printscreen,
|
|
|
|
vk_f1, vk_f2, vk_f3, vk_f4, vk_f5, vk_f6, vk_f7, vk_f8, vk_f9, vk_f10, vk_f11, vk_f12,
|
|
|
|
];
|
|
|
|
#endregion
|
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
#region keyboard
|
2024-07-05 05:18:46 +02:00
|
|
|
enum KEY_STAT {
|
2022-12-22 03:09:55 +01:00
|
|
|
idle,
|
|
|
|
down,
|
|
|
|
pressing,
|
2024-07-05 05:18:46 +02:00
|
|
|
up,
|
|
|
|
|
|
|
|
double
|
2022-12-22 03:09:55 +01:00
|
|
|
}
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
globalvar KEYBOARD_STRING, KEYBOARD_PRESSED;
|
2022-12-22 03:09:55 +01:00
|
|
|
globalvar CTRL, ALT, SHIFT;
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
WIDGET_ACTIVE = [];
|
2023-01-01 02:06:02 +01:00
|
|
|
KEYBOARD_PRESSED = vk_nokey;
|
2024-07-05 05:18:46 +02:00
|
|
|
CTRL = KEY_STAT.idle;
|
|
|
|
ALT = KEY_STAT.idle;
|
|
|
|
SHIFT = KEY_STAT.idle;
|
2022-12-22 03:09:55 +01:00
|
|
|
|
|
|
|
function key_release() {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-07-30 13:56:22 +02:00
|
|
|
|
2024-07-05 05:18:46 +02:00
|
|
|
CTRL = KEY_STAT.up;
|
|
|
|
ALT = KEY_STAT.up;
|
|
|
|
SHIFT = KEY_STAT.up;
|
2022-12-22 03:09:55 +01:00
|
|
|
|
|
|
|
keyboard_key_release(vk_control);
|
|
|
|
keyboard_key_release(vk_shift);
|
|
|
|
keyboard_key_release(vk_alt);
|
|
|
|
}
|
|
|
|
|
2024-04-11 15:43:03 +02:00
|
|
|
function key_mod_press_any() {
|
|
|
|
INLINE
|
2024-07-05 05:18:46 +02:00
|
|
|
return CTRL == KEY_STAT.pressing || ALT == KEY_STAT.pressing || SHIFT == KEY_STAT.pressing;
|
2024-04-11 15:43:03 +02:00
|
|
|
}
|
|
|
|
|
2024-07-05 05:18:46 +02:00
|
|
|
function key_mod_down(key) { INLINE return key == KEY_STAT.down; }
|
|
|
|
function key_mod_double(key) { INLINE return key == KEY_STAT.double; }
|
|
|
|
function key_mod_press(key) { INLINE return key == KEY_STAT.pressing; }
|
2024-05-27 03:41:41 +02:00
|
|
|
function key_mod_presses(keys) {
|
|
|
|
INLINE
|
|
|
|
switch(argument_count) {
|
2024-07-05 05:18:46 +02:00
|
|
|
case 1 : return argument[0] == KEY_STAT.pressing;
|
|
|
|
case 2 : return argument[0] == KEY_STAT.pressing && argument[1] == KEY_STAT.pressing;
|
|
|
|
case 3 : return argument[0] == KEY_STAT.pressing && argument[1] == KEY_STAT.pressing && argument[2] == KEY_STAT.pressing;
|
2024-05-27 03:41:41 +02:00
|
|
|
}
|
|
|
|
return false;
|
2022-12-22 03:09:55 +01:00
|
|
|
}
|
2023-04-21 19:08:10 +02:00
|
|
|
|
|
|
|
function key_mod_press_index(keyindex) {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-07-30 13:56:22 +02:00
|
|
|
|
2023-04-21 19:08:10 +02:00
|
|
|
switch(keyindex) {
|
2024-07-05 05:18:46 +02:00
|
|
|
case MOD_KEY.alt : return ALT == KEY_STAT.pressing;
|
|
|
|
case MOD_KEY.shift : return SHIFT == KEY_STAT.pressing;
|
|
|
|
case MOD_KEY.ctrl : return CTRL == KEY_STAT.pressing;
|
2023-04-21 19:08:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2023-01-17 08:11:55 +01:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region widget
|
|
|
|
globalvar WIDGET_CURRENT, WIDGET_ACTIVE, WIDGET_CURRENT_SCROLL;
|
|
|
|
WIDGET_CURRENT = noone;
|
|
|
|
WIDGET_CURRENT_SCROLL = noone;
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
function widget_start() {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-07-30 13:56:22 +02:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(array_length(WIDGET_ACTIVE) == 0) return;
|
|
|
|
WIDGET_ACTIVE[0].activate();
|
|
|
|
}
|
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
function widget_next() {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-07-30 13:56:22 +02:00
|
|
|
|
2024-01-16 14:08:57 +01:00
|
|
|
if(array_length(WIDGET_ACTIVE) == 0) {
|
|
|
|
if(WIDGET_CURRENT != noone) {
|
|
|
|
WIDGET_CURRENT.deactivate();
|
|
|
|
WIDGET_CURRENT = noone;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(WIDGET_CURRENT == noone) {
|
|
|
|
widget_start()
|
|
|
|
return;
|
|
|
|
}
|
2023-01-17 08:11:55 +01:00
|
|
|
|
|
|
|
var ind = array_find(WIDGET_ACTIVE, WIDGET_CURRENT);
|
|
|
|
WIDGET_CURRENT.deactivate();
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
var wid = noone;
|
2023-01-17 08:11:55 +01:00
|
|
|
if(ind + 1 == array_length(WIDGET_ACTIVE))
|
2024-03-31 05:36:11 +02:00
|
|
|
wid = array_safe_get_fast(WIDGET_ACTIVE, 0);
|
2023-01-25 06:49:00 +01:00
|
|
|
else
|
2024-03-31 05:36:11 +02:00
|
|
|
wid = array_safe_get_fast(WIDGET_ACTIVE, ind + 1);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
if(wid) wid.activate();
|
2023-01-17 08:11:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function widget_previous() {
|
2024-01-16 14:08:57 +01:00
|
|
|
if(array_length(WIDGET_ACTIVE) == 0) {
|
|
|
|
if(WIDGET_CURRENT != noone) {
|
|
|
|
WIDGET_CURRENT.deactivate();
|
|
|
|
WIDGET_CURRENT = noone;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(WIDGET_CURRENT == noone) {
|
|
|
|
widget_start()
|
|
|
|
return;
|
|
|
|
}
|
2023-01-17 08:11:55 +01:00
|
|
|
|
|
|
|
var ind = array_find(WIDGET_ACTIVE, WIDGET_CURRENT);
|
|
|
|
WIDGET_CURRENT.deactivate();
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
var wid = noone;
|
2023-01-17 08:11:55 +01:00
|
|
|
if(ind == 0)
|
2024-03-31 05:36:11 +02:00
|
|
|
wid = array_safe_get_fast(WIDGET_ACTIVE, array_length(WIDGET_ACTIVE) - 1);
|
2023-01-17 08:11:55 +01:00
|
|
|
else
|
2024-03-31 05:36:11 +02:00
|
|
|
wid = array_safe_get_fast(WIDGET_ACTIVE, ind - 1);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
if(wid) wid.activate();
|
|
|
|
}
|
|
|
|
|
|
|
|
function widget_set(_widget) {
|
|
|
|
if(array_length(WIDGET_ACTIVE) == 0) return;
|
|
|
|
|
|
|
|
if(WIDGET_CURRENT) {
|
|
|
|
var ind = array_find(WIDGET_ACTIVE, WIDGET_CURRENT);
|
|
|
|
WIDGET_CURRENT.deactivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
_widget.activate();
|
|
|
|
}
|
|
|
|
|
|
|
|
function widget_clear() {
|
|
|
|
if(WIDGET_CURRENT == noone) return;
|
|
|
|
|
|
|
|
WIDGET_CURRENT.deactivate();
|
|
|
|
WIDGET_CURRENT = noone;
|
2023-01-17 08:11:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function widget_trigger() {
|
|
|
|
if(WIDGET_CURRENT == noone) return;
|
|
|
|
WIDGET_CURRENT.trigger();
|
|
|
|
}
|
|
|
|
#endregion
|