forked from Skyrat-SS13/Skyrat-tg
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak: moved cyrillic fix to modules (#18)
* moved to module * oops * removed extra * fixed looc and whisper * abc Cyrillic key fixes (#3) * fix: communication hotkeys * Feat: add ability to setup keybinds on russian keylayout --------- feat: Cyrillic names (#20) Co-authored-by: Vallat <[email protected]>
- Loading branch information
Showing
6 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
modular_ss220/modules/cyrillic_key_fixes/code/client_procs.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/client/update_special_keybinds(datum/preferences/direct_prefs) | ||
var/datum/preferences/D = prefs || direct_prefs | ||
if(!D?.key_bindings) | ||
return | ||
movement_keys = list() | ||
for(var/kb_name in D.key_bindings) | ||
for(var/key in D.key_bindings[kb_name]) | ||
switch(kb_name) | ||
if("North") | ||
movement_keys[key] = NORTH | ||
if("East") | ||
movement_keys[key] = EAST | ||
if("West") | ||
movement_keys[key] = WEST | ||
if("South") | ||
movement_keys[key] = SOUTH | ||
if(ADMIN_CHANNEL) | ||
if(holder) | ||
var/asay = tgui_say_create_open_command(ADMIN_CHANNEL) | ||
winset(src, "default-[REF(key)]", "parent=default;name=[key];command=[asay]") | ||
else | ||
winset(src, "default-[REF(key)]", "parent=default;name=[key];command=") |
35 changes: 35 additions & 0 deletions
35
modular_ss220/modules/cyrillic_key_fixes/code/communication.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/datum/keybinding/client/communication/say/down(client/user) | ||
. = ..() | ||
if(.) | ||
return | ||
winset(user, null, "command=[user.tgui_say_create_open_command(SAY_CHANNEL)]") | ||
return TRUE | ||
|
||
|
||
/datum/keybinding/client/communication/ooc/down(client/user) | ||
. = ..() | ||
if(.) | ||
return | ||
winset(user, null, "command=[user.tgui_say_create_open_command(OOC_CHANNEL)]") | ||
return TRUE | ||
|
||
/datum/keybinding/client/communication/me/down(client/user) | ||
. = ..() | ||
if(.) | ||
return | ||
winset(user, null, "command=[user.tgui_say_create_open_command(ME_CHANNEL)]") | ||
return TRUE | ||
|
||
/datum/keybinding/client/communication/looc/down(client/user) | ||
. = ..() | ||
if(.) | ||
return | ||
winset(user, null, "command=looc") | ||
return TRUE | ||
|
||
/datum/keybinding/client/communication/whisper/down(client/user) | ||
. = ..() | ||
if(.) | ||
return | ||
winset(user, null, "command=whisper") | ||
return TRUE |
36 changes: 36 additions & 0 deletions
36
modular_ss220/modules/cyrillic_key_fixes/code/keybindings.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#define MAX_HOTKEY_SLOTS 3 | ||
|
||
|
||
/datum/preference_middleware/keybindings/set_keybindings(list/params) | ||
var/keybind_name = params["keybind_name"] | ||
|
||
if (isnull(GLOB.keybindings_by_name[keybind_name])) | ||
return FALSE | ||
|
||
var/list/raw_hotkeys = params["hotkeys"] | ||
if (!istype(raw_hotkeys)) | ||
return FALSE | ||
|
||
if (raw_hotkeys.len > MAX_HOTKEY_SLOTS) | ||
return FALSE | ||
|
||
// There's no optimal, easy way to check if something is an array | ||
// and not an object in BYOND, so just sanitize it to make sure. | ||
var/list/hotkeys = list() | ||
for (var/hotkey in raw_hotkeys) | ||
if (!istext(hotkey)) | ||
return FALSE | ||
|
||
// Fairly arbitrary number, it's just so you don't save enormous fake keybinds. | ||
if (length(hotkey) > 100) | ||
return FALSE | ||
|
||
hotkeys += convert_ru_key_to_en_key(hotkey) | ||
|
||
preferences.key_bindings[keybind_name] = hotkeys | ||
preferences.key_bindings_by_key = preferences.get_key_bindings_by_key(preferences.key_bindings) | ||
|
||
return TRUE | ||
|
||
|
||
#undef MAX_HOTKEY_SLOTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
GLOBAL_LIST_INIT(ru_key_to_en_key, list( | ||
"й" = "q", "ц" = "w", "у" = "e", "к" = "r", "е" = "t", "н" = "y", "г" = "u", "ш" = "i", "щ" = "o", "з" = "p", "х" = "\[", "ъ" = "]", | ||
"ф" = "a", "ы" = "s", "в" = "d", "а" = "f", "п" = "g", "р" = "h", "о" = "j", "л" = "k", "д" = "l", "ж" = ";", "э" = "'", | ||
"я" = "z", "ч" = "x", "с" = "c", "м" = "v", "и" = "b", "т" = "n", "ь" = "m", "б" = ",", "ю" = "." | ||
)) | ||
|
||
/proc/convert_ru_key_to_en_key(var/_key) | ||
var/new_key = lowertext(_key) | ||
new_key = GLOB.ru_key_to_en_key[new_key] | ||
if(!new_key) | ||
return _key | ||
return uppertext(new_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters