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
|
|
|
|
enum KEYBOARD_STATUS {
|
|
|
|
idle,
|
|
|
|
down,
|
|
|
|
pressing,
|
|
|
|
up
|
|
|
|
}
|
|
|
|
|
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;
|
2022-12-22 03:09:55 +01:00
|
|
|
CTRL = KEYBOARD_STATUS.idle;
|
|
|
|
ALT = KEYBOARD_STATUS.idle;
|
|
|
|
SHIFT = KEYBOARD_STATUS.idle;
|
|
|
|
|
|
|
|
function key_release() {
|
2023-07-30 13:56:22 +02:00
|
|
|
gml_pragma("forceinline");
|
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
CTRL = KEYBOARD_STATUS.up;
|
|
|
|
ALT = KEYBOARD_STATUS.up;
|
|
|
|
SHIFT = KEYBOARD_STATUS.up;
|
|
|
|
|
|
|
|
keyboard_key_release(vk_control);
|
|
|
|
keyboard_key_release(vk_shift);
|
|
|
|
keyboard_key_release(vk_alt);
|
|
|
|
}
|
|
|
|
|
|
|
|
function key_mod_press(key) {
|
2023-07-30 13:56:22 +02:00
|
|
|
gml_pragma("forceinline");
|
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
return key == KEYBOARD_STATUS.pressing;
|
|
|
|
}
|
2023-04-21 19:08:10 +02:00
|
|
|
|
|
|
|
function key_mod_press_index(keyindex) {
|
2023-07-30 13:56:22 +02:00
|
|
|
gml_pragma("forceinline");
|
|
|
|
|
2023-04-21 19:08:10 +02:00
|
|
|
switch(keyindex) {
|
|
|
|
case MOD_KEY.alt : return ALT == KEYBOARD_STATUS.pressing;
|
|
|
|
case MOD_KEY.shift : return SHIFT == KEYBOARD_STATUS.pressing;
|
|
|
|
case MOD_KEY.ctrl : return CTRL == KEYBOARD_STATUS.pressing;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-07-30 13:56:22 +02:00
|
|
|
gml_pragma("forceinline");
|
|
|
|
|
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-07-30 13:56:22 +02:00
|
|
|
gml_pragma("forceinline");
|
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
if(array_length(WIDGET_ACTIVE) == 0) 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))
|
2023-01-25 06:49:00 +01:00
|
|
|
wid = array_safe_get(WIDGET_ACTIVE, 0);
|
|
|
|
else
|
|
|
|
wid = array_safe_get(WIDGET_ACTIVE, ind + 1);
|
|
|
|
|
|
|
|
if(wid) wid.activate();
|
2023-01-17 08:11:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function widget_previous() {
|
|
|
|
if(array_length(WIDGET_ACTIVE) == 0) 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)
|
2023-01-25 06:49:00 +01:00
|
|
|
wid = array_safe_get(WIDGET_ACTIVE, array_length(WIDGET_ACTIVE) - 1);
|
2023-01-17 08:11:55 +01:00
|
|
|
else
|
2023-01-25 06:49:00 +01:00
|
|
|
wid = array_safe_get(WIDGET_ACTIVE, ind - 1);
|
|
|
|
|
|
|
|
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;
|
|
|
|
if(array_length(WIDGET_ACTIVE) == 0) return;
|
|
|
|
|
|
|
|
var ind = array_find(WIDGET_ACTIVE, WIDGET_CURRENT);
|
|
|
|
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
|