/
Bybaleshqa
/
Fsfall
Обзор
Документация
Войти
/
Bybaleshqa
/
Fsfall
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
Releases
scripting/headers/lib.misc.h
51 строка
1 KB
Mr.Stalin
Обновление файлов для релиза.
22 сен 2024, 02:05
22 сен 2024, 02:05
c980793
Код
Авторство
О чём код?
#ifndef LIB_MISC_H #define LIB_MISC_H /* Some generic procedures */ /* * Parses keyboard shortcut definition (key code + optional modifier key) from a string into an integer for later use in other hotkey procedures. */ procedure parse_hotkey(variable string) begin variable lst := string_split(string, "+"); if (len_array(lst) == 0) then return 0; variable n := atoi(lst[0]); if (len_array(lst) > 1) then n += atoi(lst[1]) * 0x10000; return n; end /** * Checks if a given shortcut is currently pressed (see parse_hotkey). * n - hotkey data parsed with *parse_hotkey* */ procedure hotkey_pressed(variable n) begin if (n < 0x10000) then return key_pressed(n); else return key_pressed(n bwand 0xFFFF) and key_pressed((n bwand 0xFFFF0000) / 0x10000); end /** * Checks if a shortcut is currently pressed, given that *key* is already pressed. * n - hotkey data parsed with *parse_hotkey* * key - DX scancode */ procedure hotkey_pressed_now(variable n, variable key) begin if (n < 0x10000) then return key == n; else begin variable k1 := (n bwand 0xFFFF), k2 := ((n bwand 0xFFFF0000) / 0x10000); if (k1 == key) then begin if (key_pressed(k2)) then return true; end else if (k2 == key) then begin if (key_pressed(k1)) then return true; end return false; end end #endif