Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 50e3477

Browse filesBrowse files
authored
Rips out the old keybind system and ports a better version from /tg/ (yogstation13#17216)
* Initial version Ripped out old version and added new version * Update some of the keybinds * More changes * Added hotkey sanity checks * Misc. fixes and features * Small fix * Refactor keys_held * Adds emote keybinds * Small spelling fixes * I always forget this one * Add 1 second cooldown on emotes * Fix DME * Don't spam * Make linter happy * New MC init
1 parent b8e070f commit 50e3477
Copy full SHA for 50e3477

66 files changed

+1,367-1,474Lines changed: 1367 additions & 1474 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎code/__DEFINES/admin.dm‎

Copy file name to clipboardExpand all lines: code/__DEFINES/admin.dm
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@
9999
/// Number of identical messages required before the spam-prevention will automute you
100100
#define SPAM_TRIGGER_AUTOMUTE 10
101101

102+
///Maximum keys that can be bound to one button
103+
#define MAX_COMMANDS_PER_KEY 5
104+
///Maximum keys per keybind
105+
#define MAX_KEYS_PER_KEYBIND 3
106+
///Length of held key buffer
107+
#define HELD_KEY_BUFFER_LENGTH 15
108+
102109
#define STICKYBAN_DB_CACHE_TIME 10 SECONDS
103110
#define STICKYBAN_ROGUE_CHECK_TIME 5
104111

Collapse file

‎code/__DEFINES/{yogs_defines}/keybindings.dm‎

Copy file name to clipboardExpand all lines: code/__DEFINES/{yogs_defines}/keybindings.dm
-202Lines changed: 0 additions & 202 deletions
This file was deleted.
Collapse file

‎code/__HELPERS/cmp.dm‎

Copy file name to clipboardExpand all lines: code/__HELPERS/cmp.dm
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ GLOBAL_VAR_INIT(cmp_field, "name")
2929
/proc/cmp_records_dsc(datum/data/record/a, datum/data/record/b)
3030
return sorttext(a.fields[GLOB.cmp_field], b.fields[GLOB.cmp_field])
3131

32+
// Datum cmp with vars is always slower than a specialist cmp proc, use your judgement.
33+
/proc/cmp_datum_numeric_asc(datum/a, datum/b, variable)
34+
return cmp_numeric_asc(a.vars[variable], b.vars[variable])
35+
36+
/proc/cmp_datum_numeric_dsc(datum/a, datum/b, variable)
37+
return cmp_numeric_dsc(a.vars[variable], b.vars[variable])
38+
39+
/proc/cmp_datum_text_asc(datum/a, datum/b, variable)
40+
return sorttext(b.vars[variable], a.vars[variable])
41+
42+
/proc/cmp_datum_text_dsc(datum/a, datum/b, variable)
43+
return sorttext(a.vars[variable], b.vars[variable])
44+
3245
/proc/cmp_ckey_asc(client/a, client/b)
3346
return sorttext(b.ckey, a.ckey)
3447

Collapse file

‎code/__HELPERS/global_lists.dm‎

Copy file name to clipboardExpand all lines: code/__HELPERS/global_lists.dm
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@
5959
var/datum/sprite_accessory/hair_gradient/H = new path()
6060
GLOB.hair_gradients_list[H.name] = H
6161

62-
62+
// Keybindings
63+
init_keybindings()
64+
6365
GLOB.emote_list = init_emote_list()
6466
//Skillcapes
6567
for(var/path in subtypesof(/datum/skillcape))
Collapse file

‎code/__HELPERS/sanitize_values.dm‎

Copy file name to clipboardExpand all lines: code/__HELPERS/sanitize_values.dm
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
return text
1212
return default
1313

14+
/proc/sanitize_islist(value, default)
15+
if(islist(value) && length(value))
16+
return value
17+
if(default)
18+
return default
19+
1420
/proc/sanitize_inlist(value, list/List, default)
1521
if(value in List)
1622
return value
Collapse file

‎code/_globalvars/lists/client.dm‎

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
GLOBAL_LIST_EMPTY(classic_keybinding_list_by_key)
2+
GLOBAL_LIST_EMPTY(hotkey_keybinding_list_by_key)
3+
GLOBAL_LIST_EMPTY(keybindings_by_name)
4+
5+
// This is a mapping from JS keys to Byond - ref: https://keycode.info/
6+
GLOBAL_LIST_INIT(_kbMap, list(
7+
"UP" = "North",
8+
"RIGHT" = "East",
9+
"DOWN" = "South",
10+
"LEFT" = "West",
11+
"INSERT" = "Insert",
12+
"HOME" = "Northwest",
13+
"PAGEUP" = "Northeast",
14+
"DEL" = "Delete",
15+
"END" = "Southwest",
16+
"PAGEDOWN" = "Southeast",
17+
"SPACEBAR" = "Space",
18+
"ALT" = "Alt",
19+
"SHIFT" = "Shift",
20+
"CONTROL" = "Ctrl"
21+
))
Collapse file
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// Creates and sorts all the keybinding datums
2+
/proc/init_keybindings()
3+
for(var/KB in subtypesof(/datum/keybinding))
4+
var/datum/keybinding/keybinding = KB
5+
if(!initial(keybinding.hotkey_keys))
6+
continue
7+
add_keybinding(new keybinding)
8+
init_emote_keybinds()
9+
10+
/// Adds an instanced keybinding to the global tracker
11+
/proc/add_keybinding(datum/keybinding/instance)
12+
GLOB.keybindings_by_name[instance.name] = instance
13+
14+
// Classic
15+
if(LAZYLEN(instance.classic_keys))
16+
for(var/bound_key in instance.classic_keys)
17+
LAZYADD(GLOB.classic_keybinding_list_by_key[bound_key], list(instance.name))
18+
19+
// Hotkey
20+
if(LAZYLEN(instance.hotkey_keys))
21+
for(var/bound_key in instance.hotkey_keys)
22+
LAZYADD(GLOB.hotkey_keybinding_list_by_key[bound_key], list(instance.name))
23+
24+
/proc/init_emote_keybinds()
25+
for(var/i in subtypesof(/datum/emote))
26+
var/datum/emote/faketype = i
27+
if(!initial(faketype.key))
28+
continue
29+
var/datum/keybinding/emote/emote_kb = new
30+
emote_kb.link_to_emote(faketype)
31+
add_keybinding(emote_kb)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.