mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-26 13:37:58 +01:00
Lets go rebind things (#18166)
* SSinput Rewrite, Custom Keybindings
* hmm yes, safety
* azerty begone
* address AA and SteelSlayer
* Address the old man
* what
* CI dbconfig too
* Address TM issues
Unicode support
Better numpad support
Fix no perms message
Fix modifier screwing movement
* pre-TM tweak, nitfix
* pre TM change 2
* Display others
* MERGE ME
* unduplicates your rows
* reverts some changes, makes this work for now (not TM safe)
* fixes direction facing, removes hotkey help item
* weird keys
* TM commit revert later
* fixed asay/msay keybind
* adds ALL the emotes
* flip and spin
* makes old people happy
* and fixes admins not being able to msay
* lets borgs stow modules
* saves prefs when someone changes a keybind
* reverts skin changes and manually applies
HEAVEN HELP YOU IF YOU USE THE DM SKIN EDITOR IT BREAKS EVERYTHING
* tidies menu, unduplicates rest
* sql file pls come back
* Update SQL/updates/40-41.sql
* why did you not throw an error?!
* inits keybinds if your prefs somehow fail, i guess
* restores these spaces, i guess
* fixes local testing, i guess
* emote cooldown returns (oops)
* movement lock improvements
* Pageup does Swap Hands
* LOOC
* whisper for living mobs
* oops
* fix dsay
* fix IPC silicon emote hotkeys
* category name
* backspace only clears if input is focused
* Makes TAB and BACKSPACE rebindable
* charlie review
* define move
* yeet
* Lewcc review
* brings back legacy mode
* restores legacy mode
* tell legacy mode what is going on
* Update code/controllers/subsystem/input.dm
* Update code/controllers/subsystem/input.dm
Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
* safeties!
* legacy mode is a pref now
* undo TM changes
* null prefs safeties
* Revert "legacy mode is a pref now"
This reverts commit b45af65139.
* revert this too thanks
Co-authored-by: mochi <shenesis@gmail.com>
Co-authored-by: dearmochi <1496804+dearmochi@users.noreply.github.com>
Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
This commit is contained in:
co-authored by
AffectedArc07
mochi
dearmochi
parent
e1793d24c4
commit
3f95392c82
@@ -1070,6 +1070,125 @@
|
||||
INVOKE_ASYNC(user.client, /client.proc/edit_2fa)
|
||||
return // We return here to avoid focus being lost
|
||||
|
||||
if("keybindings")
|
||||
if(!keybindings_overrides)
|
||||
keybindings_overrides = list()
|
||||
|
||||
if(href_list["set"])
|
||||
var/datum/keybinding/KB = locateUID(href_list["set"])
|
||||
if(KB)
|
||||
if(href_list["key"])
|
||||
var/old_key = href_list["old"]
|
||||
var/new_key = copytext(url_decode(href_list["key"]), 1, 16)
|
||||
var/alt_mod = text2num(href_list["alt"]) ? "Alt" : ""
|
||||
var/ctrl_mod = text2num(href_list["ctrl"]) ? "Ctrl" : ""
|
||||
var/shift_mod = text2num(href_list["shift"]) ? "Shift" : ""
|
||||
var/numpad = (text2num(href_list["numpad"]) && text2num(new_key)) ? "Numpad" : ""
|
||||
var/clear = text2num(href_list["clear_key"])
|
||||
|
||||
if(new_key == "Unidentified") //There doesn't seem to be any any key!
|
||||
capture_keybinding(user, KB, href_list["old"])
|
||||
return
|
||||
|
||||
if(!(length_char(new_key) == 1 && text2ascii(new_key) >= 0x80)) // Don't uppercase unicode stuff
|
||||
new_key = uppertext(new_key)
|
||||
|
||||
// Map for JS keys
|
||||
var/static/list/key_map = list(
|
||||
"UP" = "North",
|
||||
"RIGHT" = "East",
|
||||
"DOWN" = "South",
|
||||
"LEFT" = "West",
|
||||
"INSERT" = "Insert",
|
||||
"HOME" = "Northwest",
|
||||
"PAGEUP" = "Northeast",
|
||||
"DEL" = "Delete",
|
||||
"END" = "Southwest",
|
||||
"PAGEDOWN" = "Southeast",
|
||||
"SPACEBAR" = "Space",
|
||||
"ALT" = "Alt",
|
||||
"SHIFT" = "Shift",
|
||||
"CONTROL" = "Ctrl",
|
||||
"DIVIDE" = "Divide",
|
||||
"MULTIPLY" = "Multiply",
|
||||
"ADD" = "Add",
|
||||
"SUBTRACT" = "Subtract",
|
||||
"DECIMAL" = "Decimal",
|
||||
"CLEAR" = "Center"
|
||||
)
|
||||
|
||||
new_key = key_map[new_key] || new_key
|
||||
|
||||
var/full_key
|
||||
switch(new_key)
|
||||
if("ALT")
|
||||
full_key = "Alt[ctrl_mod][shift_mod]"
|
||||
if("CONTROL")
|
||||
full_key = "[alt_mod]Ctrl[shift_mod]"
|
||||
if("SHIFT")
|
||||
full_key = "[alt_mod][ctrl_mod]Shift"
|
||||
else
|
||||
full_key = "[alt_mod][ctrl_mod][shift_mod][numpad][new_key]"
|
||||
|
||||
// Update overrides
|
||||
var/list/key_overrides = keybindings_overrides[KB.name] || KB.keys?.Copy() || list()
|
||||
var/index = key_overrides.Find(old_key)
|
||||
var/changed = FALSE
|
||||
if(clear) // Clear
|
||||
key_overrides -= old_key
|
||||
changed = TRUE
|
||||
else if(old_key != full_key)
|
||||
if(index) // Replace
|
||||
var/cur_index = key_overrides.Find(full_key)
|
||||
if(cur_index)
|
||||
key_overrides[cur_index] = old_key
|
||||
key_overrides[index] = full_key
|
||||
changed = TRUE
|
||||
else // Add
|
||||
key_overrides -= (old_key || full_key) // Defaults to the new key itself, as to reorder it
|
||||
key_overrides += full_key
|
||||
changed = TRUE
|
||||
else
|
||||
changed = isnull(keybindings_overrides[KB.name]) // Sets it in the JSON
|
||||
|
||||
if(changed)
|
||||
if(!length(key_overrides) && !length(KB.keys))
|
||||
keybindings_overrides -= KB.name
|
||||
else
|
||||
keybindings_overrides[KB.name] = key_overrides
|
||||
|
||||
user << browse(null, "window=capturekeypress")
|
||||
else
|
||||
capture_keybinding(user, KB, href_list["old"])
|
||||
return
|
||||
|
||||
else if(href_list["reset"])
|
||||
var/datum/keybinding/KB = locateUID(href_list["reset"])
|
||||
if(KB)
|
||||
keybindings_overrides -= KB.name
|
||||
|
||||
else if(href_list["clear"])
|
||||
var/datum/keybinding/KB = locateUID(href_list["clear"])
|
||||
if(KB)
|
||||
if(length(KB.keys))
|
||||
keybindings_overrides[KB.name] = list()
|
||||
else
|
||||
keybindings_overrides -= KB.name
|
||||
|
||||
else if(href_list["all"])
|
||||
var/yes = alert(user, "Really [href_list["all"]] all key bindings?", "Confirm", "Yes", "No") == "Yes"
|
||||
if(yes)
|
||||
switch(href_list["all"])
|
||||
if("reset")
|
||||
keybindings_overrides = list()
|
||||
if("clear")
|
||||
for(var/kb in GLOB.keybindings)
|
||||
var/datum/keybinding/KB = kb
|
||||
keybindings_overrides[KB.name] = list()
|
||||
|
||||
init_keybindings(keybindings_overrides)
|
||||
save_preferences(user) //Ideally we want to save people's keybinds when they enter them
|
||||
|
||||
|
||||
ShowChoices(user)
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user