forked from infinitystation/Baystation12
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port hotkey system from SS220 Paradise (#13)
* Port hotkey system from paradise * Заменил для некоторых вещей клик СКМ на Альт+СКМ, в целом ни на что не влияет, т.к. у них были аналоги в виде обычного Альт клика
- Loading branch information
Showing
36 changed files
with
728 additions
and
880 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
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
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
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
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
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
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
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
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
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
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
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
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,124 @@ | ||
SUBSYSTEM_DEF(input) | ||
name = "Input" | ||
wait = 1 //SS_TICKER means this runs every tick | ||
init_order = SS_INIT_INPUT | ||
flags = SS_TICKER | ||
priority = SS_PRIORITY_INPUT | ||
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY | ||
|
||
var/list/macro_sets | ||
var/list/movement_keys | ||
var/list/alt_movement_keys | ||
|
||
/datum/controller/subsystem/input/Initialize() | ||
setup_default_macro_sets() | ||
|
||
setup_default_movement_keys() | ||
|
||
initialized = TRUE | ||
|
||
refresh_client_macro_sets() | ||
|
||
return ..() | ||
|
||
// This is for when macro sets are eventualy datumized | ||
/datum/controller/subsystem/input/proc/setup_default_macro_sets() | ||
var/list/static/default_macro_sets | ||
|
||
if(default_macro_sets) | ||
macro_sets = default_macro_sets | ||
return | ||
|
||
default_macro_sets = list( | ||
"default" = list( | ||
"Tab" = "\".winset \\\"input.focus=true?map.focus=true input.background-color=[COLOR_INPUT_DISABLED]:input.focus=true input.background-color=[COLOR_INPUT_ENABLED]\\\"\"", | ||
"Back" = "\".winset \\\"input.focus=true input.text=\\\"\\\"\\\"\"", // This makes it so backspace can remove default inputs | ||
"Any" = "\"KeyDown \[\[*\]\]\"", | ||
"Any+UP" = "\"KeyUp \[\[*\]\]\"", | ||
), | ||
"old_default" = list( | ||
"Tab" = "\".winset \\\"mainwindow.macro=old_hotkeys map.focus=true input.background-color=[COLOR_INPUT_DISABLED]\\\"\"", | ||
), | ||
"old_hotkeys" = list( | ||
"Tab" = "\".winset \\\"mainwindow.macro=old_default input.focus=true input.background-color=[COLOR_INPUT_ENABLED]\\\"\"", | ||
"Back" = "\".winset \\\"input.focus=true input.text=\\\"\\\"\\\"\"", // This makes it so backspace can remove default inputs | ||
"Any" = "\"KeyDown \[\[*\]\]\"", | ||
"Any+UP" = "\"KeyUp \[\[*\]\]\"", | ||
), | ||
) | ||
|
||
// Because i'm lazy and don't want to type all these out twice | ||
var/list/old_default = default_macro_sets["old_default"] | ||
|
||
var/list/static/oldmode_keys = list( | ||
"North", "East", "South", "West", | ||
"Northeast", "Southeast", "Northwest", "Southwest", | ||
"Insert", "Delete", "Ctrl", "Alt", "Shift", | ||
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", | ||
) | ||
|
||
for(var/i in 1 to oldmode_keys.len) | ||
var/key = oldmode_keys[i] | ||
old_default[key] = "\"KeyDown [key]\"" | ||
old_default["[key]+UP"] = "\"KeyUp [key]\"" | ||
|
||
var/list/static/oldmode_ctrl_override_keys = list( | ||
"W" = "W", "A" = "A", "S" = "S", "D" = "D", // movement | ||
"1" = "1", "2" = "2", "3" = "3", "4" = "4", // intent | ||
"B" = "B", // resist, rest | ||
"E" = "E", // quick equip | ||
"F" = "F", // intent left | ||
"G" = "G", // intent right | ||
"H" = "H", // stop pulling | ||
"Q" = "Q", // drop | ||
"R" = "R", // throw | ||
"X" = "X", // switch hands | ||
"Y" = "Y", // activate item | ||
"Z" = "Z", // activate item | ||
"T" = "T", // say, whisper | ||
"M" = "M", // me | ||
"O" = "O", // ooc | ||
"L" = "L", // looc | ||
"C" = "C", // stop pulling | ||
) | ||
|
||
for(var/i in 1 to oldmode_ctrl_override_keys.len) | ||
var/key = oldmode_ctrl_override_keys[i] | ||
var/override = oldmode_ctrl_override_keys[key] | ||
old_default["Ctrl+[key]"] = "\"KeyDown [override]\"" | ||
old_default["Ctrl+[key]+UP"] = "\"KeyUp [override]\"" | ||
|
||
macro_sets = default_macro_sets | ||
|
||
// For initially setting up or resetting to default the movement keys | ||
/datum/controller/subsystem/input/proc/setup_default_movement_keys() | ||
var/static/list/default_movement_keys = list( | ||
"W" = NORTH, "A" = WEST, "S" = SOUTH, "D" = EAST, // WASD | ||
"North" = NORTH, "West" = WEST, "South" = SOUTH, "East" = EAST, // Arrow keys & Numpad | ||
) | ||
var/static/list/azerty_movement_keys = list( | ||
"Z" = NORTH, "Q" = WEST, "S" = SOUTH, "D" = EAST, // WASD | ||
"North" = NORTH, "West" = WEST, "South" = SOUTH, "East" = EAST, // Arrow keys & Numpad | ||
) | ||
movement_keys = default_movement_keys.Copy() | ||
alt_movement_keys = azerty_movement_keys.Copy() | ||
|
||
// Badmins just wanna have fun ♪ | ||
/datum/controller/subsystem/input/proc/refresh_client_macro_sets() | ||
var/list/clients = GLOB.clients | ||
for(var/i in 1 to clients.len) | ||
var/client/user = clients[i] | ||
user.set_macros() | ||
|
||
/datum/controller/subsystem/input/fire() | ||
var/list/clients = GLOB.clients // Let's sing the list cache song | ||
if(listclearnulls(clients)) // clear nulls before we run keyloop | ||
log_world("Found a null in clients list!") | ||
for(var/i in 1 to clients.len) | ||
var/client/C = clients[i] | ||
C.keyLoop() | ||
|
||
/datum/controller/subsystem/input/Recover() | ||
macro_sets = SSinput.macro_sets | ||
movement_keys = SSinput.movement_keys | ||
alt_movement_keys = SSinput.alt_movement_keys |
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
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
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,32 @@ | ||
/datum/admins/key_down(_key, client/user) | ||
switch(_key) | ||
if("F5") | ||
// if(user.keys_held["Shift"]) | ||
// user.get_mentor_say() | ||
// else | ||
user.get_admin_say() | ||
return | ||
if("F6") | ||
user.admin_ghost() | ||
return | ||
if("F7") | ||
player_panel() | ||
return | ||
if("F8") | ||
user.cmd_admin_pm_panel() | ||
return | ||
if("F9") | ||
user.invisimin() | ||
return | ||
if("F10") | ||
user.get_dead_say() | ||
return | ||
..() | ||
|
||
/client/proc/get_admin_say() | ||
var/msg = input(src, null, "asay \"text\"") as text|null | ||
cmd_admin_say(msg) | ||
|
||
/client/proc/get_dead_say() | ||
var/msg = input(src, null, "dsay \"text\"") as text | ||
dsay(msg) |
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,6 @@ | ||
/mob/living/silicon/ai/key_down(_key, client/user) | ||
switch(_key) | ||
if("4") | ||
a_intent_change(INTENT_HOTKEY_LEFT) | ||
return | ||
return ..() |
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,19 @@ | ||
// You might be wondering why this isn't client level. If focus is null, we don't want you to move. | ||
// Only way to do that is to tie the behavior into the focus's keyLoop(). | ||
|
||
/atom/movable/keyLoop(client/user) | ||
if(!user.keys_held["Ctrl"]) | ||
var/movement_dir = null | ||
var/list/movement = SSinput.movement_keys | ||
for(var/_key in user.keys_held) | ||
movement_dir = movement_dir | movement[_key] | ||
if(user.next_move_dir_add) | ||
movement_dir |= user.next_move_dir_add | ||
if(user.next_move_dir_sub) | ||
movement_dir &= ~user.next_move_dir_sub | ||
// Sanity checks in case you hold left and right and up to make sure you only go up | ||
if((movement_dir & NORTH) && (movement_dir & SOUTH)) | ||
movement_dir &= ~(NORTH|SOUTH) | ||
if((movement_dir & EAST) && (movement_dir & WEST)) | ||
movement_dir &= ~(EAST|WEST) | ||
user.Move(get_step(src, movement_dir), movement_dir) |
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,21 @@ | ||
|
||
/mob/living/carbon/key_down(_key, client/user) | ||
user.keys_held[_key] = world.time | ||
if(!user.keys_held["Shift"]) | ||
switch(_key) | ||
if("R", "Southwest") // Southwest is End | ||
toggle_throw_mode() | ||
return | ||
if("1") | ||
a_intent_change(I_HELP) | ||
return | ||
if("2") | ||
a_intent_change(I_DISARM) | ||
return | ||
if("3") | ||
a_intent_change(I_GRAB) | ||
return | ||
if("4") | ||
a_intent_change(I_HURT) | ||
return | ||
return ..() |
Oops, something went wrong.