From 5903ad2dfd68dbda1ac06eee3f820ba6ca6b18bd Mon Sep 17 00:00:00 2001 From: Couls Date: Fri, 26 Apr 2019 03:33:29 -0400 Subject: [PATCH] Implement AZERTY and numpad targetting options --- code/__DEFINES/preferences.dm | 5 +- code/controllers/subsystem/input.dm | 7 +- .../client/preference/preferences_mysql.dm | 2 +- .../client/preference/preferences_toggles.dm | 24 +++ code/modules/keybindings/bindings_atom.dm | 4 +- code/modules/keybindings/bindings_client.dm | 2 + code/modules/keybindings/bindings_mob.dm | 158 ++++++++++++------ .../modules/mob/living/silicon/robot/login.dm | 3 - code/modules/mob/mob_movement.dm | 2 +- 9 files changed, 144 insertions(+), 63 deletions(-) diff --git a/code/__DEFINES/preferences.dm b/code/__DEFINES/preferences.dm index 13cfe5bdf20..ced351dc0c4 100644 --- a/code/__DEFINES/preferences.dm +++ b/code/__DEFINES/preferences.dm @@ -30,8 +30,9 @@ #define DISABLE_KARMA 262144 #define CHAT_NO_MENTORTICKETLOGS 524288 #define TYPING_ONCE 1048576 - -#define TOGGLES_DEFAULT (CHAT_OOC|CHAT_DEAD|CHAT_GHOSTEARS|CHAT_GHOSTSIGHT|CHAT_PRAYER|CHAT_RADIO|CHAT_LOOC|MEMBER_PUBLIC|DONATOR_PUBLIC) +#define NUMPAD_TARGET 2097512 +#define AZERTY 4194304 +#define TOGGLES_DEFAULT (CHAT_OOC|CHAT_DEAD|CHAT_GHOSTEARS|CHAT_GHOSTSIGHT|CHAT_PRAYER|CHAT_RADIO|CHAT_LOOC|MEMBER_PUBLIC|DONATOR_PUBLIC|NUMPAD_TARGET) // Admin attack logs filter system, see /proc/add_attack_logs and /proc/msg_admin_attack #define ATKLOG_ALL 0 diff --git a/code/controllers/subsystem/input.dm b/code/controllers/subsystem/input.dm index 8a17ad07d1c..f2e0fdb0497 100644 --- a/code/controllers/subsystem/input.dm +++ b/code/controllers/subsystem/input.dm @@ -8,6 +8,7 @@ SUBSYSTEM_DEF(input) var/list/macro_sets var/list/movement_keys + var/list/alt_movement_keys /datum/controller/subsystem/input/Initialize() setup_default_macro_sets() @@ -98,8 +99,12 @@ SUBSYSTEM_DEF(input) "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() diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index bfdc745cba3..e873b41db15 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -55,7 +55,7 @@ ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor)) UI_style = sanitize_inlist(UI_style, list("White", "Midnight"), initial(UI_style)) default_slot = sanitize_integer(default_slot, 1, max_save_slots, initial(default_slot)) - toggles = sanitize_integer(toggles, 0, 4194304, initial(toggles)) + toggles = sanitize_integer(toggles, 0, 8388608, initial(toggles)) sound = sanitize_integer(sound, 0, 65535, initial(sound)) UI_style_color = sanitize_hexcolor(UI_style_color, initial(UI_style_color)) UI_style_alpha = sanitize_integer(UI_style_alpha, 0, 255, initial(UI_style_alpha)) diff --git a/code/modules/client/preference/preferences_toggles.dm b/code/modules/client/preference/preferences_toggles.dm index 046dba64adb..7d7720b84d3 100644 --- a/code/modules/client/preference/preferences_toggles.dm +++ b/code/modules/client/preference/preferences_toggles.dm @@ -242,4 +242,28 @@ to_chat(usr, "You have enabled text popup limiting.") else to_chat(usr, "You have disabled text popup limiting.") + return + +/client/verb/numpad_target() + set name = "Toggle Numpad targetting" + set category = "Preferences" + set desc = "This button will allow you to enable or disable Numpad Targetting" + prefs.toggles ^= NUMPAD_TARGET + prefs.save_preferences(src) + if (prefs.toggles & NUMPAD_TARGET) + to_chat(usr, "You have enabled Numpad Targetting.") + else + to_chat(usr, "You have disabled Numpad Targetting.") + return + +/client/verb/azerty_toggle() + set name = "Toggle QWERTY/AZERTY" + set category = "Preferences" + set desc = "This button will switch you between QWERTY and AZERTY control sets" + prefs.toggles ^= AZERTY + prefs.save_preferences(src) + if (prefs.toggles & AZERTY) + to_chat(usr, "You are now in AZERTY mode.") + else + to_chat(usr, "You are now in QWERTY mode.") return \ No newline at end of file diff --git a/code/modules/keybindings/bindings_atom.dm b/code/modules/keybindings/bindings_atom.dm index 4aac76bd67e..50d36cfd220 100644 --- a/code/modules/keybindings/bindings_atom.dm +++ b/code/modules/keybindings/bindings_atom.dm @@ -4,8 +4,10 @@ /atom/movable/keyLoop(client/user) if(!user.keys_held["Ctrl"]) var/movement_dir = NONE + var/list/movement = SSinput.movement_keys + if (user.prefs.toggles & AZERTY) movement = SSinput.alt_movement_keys for(var/_key in user.keys_held) - movement_dir = movement_dir | SSinput.movement_keys[_key] + 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) diff --git a/code/modules/keybindings/bindings_client.dm b/code/modules/keybindings/bindings_client.dm index 005b6df1596..cea95f0e5b1 100644 --- a/code/modules/keybindings/bindings_client.dm +++ b/code/modules/keybindings/bindings_client.dm @@ -5,6 +5,7 @@ set hidden = TRUE keys_held[_key] = world.time var/movement = SSinput.movement_keys[_key] + if (prefs.toggles & AZERTY) movement = SSinput.alt_movement_keys[_key] if(!(next_move_dir_sub & movement) && !keys_held["Ctrl"]) next_move_dir_add |= movement @@ -35,6 +36,7 @@ set hidden = TRUE keys_held -= _key var/movement = SSinput.movement_keys[_key] + if (prefs.toggles & AZERTY) movement = SSinput.alt_movement_keys[_key] if(!(next_move_dir_add & movement)) next_move_dir_sub |= movement diff --git a/code/modules/keybindings/bindings_mob.dm b/code/modules/keybindings/bindings_mob.dm index e0c8828c391..c30e973c078 100644 --- a/code/modules/keybindings/bindings_mob.dm +++ b/code/modules/keybindings/bindings_mob.dm @@ -3,62 +3,112 @@ // Or we can have NPC's send actual keypresses and detect that by seeing no client /mob/key_down(_key, client/user) - switch(_key) - if("Delete", "H") - if(!pulling) - to_chat(src, "You are not pulling anything.") - else - stop_pulling() - return - if("Insert", "G") - a_intent_change(INTENT_HOTKEY_RIGHT) - return - if("F") - a_intent_change(INTENT_HOTKEY_LEFT) - return - if("X", "Northeast") // Northeast is Page-up - swap_hand() - return - if("Y", "Z", "Southeast") // Southeast is Page-down - mode() // attack_self(). No idea who came up with "mode()" - return - if("Q", "Northwest") // Northwest is Home - var/obj/item/I = get_active_hand() - if(!I) - to_chat(src, "You have nothing to drop in your hand!") - else - drop_item(I) - return - if("E") - quick_equip() - return - if("Alt") - toggle_move_intent() - return + if(user.prefs.toggles & AZERTY) + switch(_key) + if("Delete", "H") + if(!pulling) + to_chat(src, "You are not pulling anything.") + else + stop_pulling() + return + if("Insert", "G") + a_intent_change(INTENT_HOTKEY_RIGHT) + return + if("F") + a_intent_change(INTENT_HOTKEY_LEFT) + return + if("X", "Northeast") // Northeast is Page-up + swap_hand() + return + if("Y", "W", "Southeast") // Southeast is Page-down + mode() // attack_self(). No idea who came up with "mode()" + return + if("A", "Northwest") // Northwest is Home + var/obj/item/I = get_active_hand() + if(!I) + to_chat(src, "You have nothing to drop in your hand!") + else + drop_item(I) + return + if("E") + quick_equip() + return + if("Alt") + toggle_move_intent() + return + else + switch(_key) + if("Delete", "H") + if(!pulling) + to_chat(src, "You are not pulling anything.") + else + stop_pulling() + return + if("Insert", "G") + a_intent_change(INTENT_HOTKEY_RIGHT) + return + if("F") + a_intent_change(INTENT_HOTKEY_LEFT) + return + if("X", "Northeast") // Northeast is Page-up + swap_hand() + return + if("Y", "Z", "Southeast") // Southeast is Page-down + mode() // attack_self(). No idea who came up with "mode()" + return + if("Q", "Northwest") // Northwest is Home + var/obj/item/I = get_active_hand() + if(!I) + to_chat(src, "You have nothing to drop in your hand!") + else + drop_item(I) + return + if("E") + quick_equip() + return + if("Alt") + toggle_move_intent() + return //Bodypart selections - if("Numpad8") - user.body_toggle_head() - return - if("Numpad4") - user.body_r_arm() - return - if("Numpad5") - user.body_chest() - return - if("Numpad6") - user.body_l_arm() - return - if("Numpad1") - user.body_r_leg() - return - if("Numpad2") - user.body_groin() - return - if("Numpad3") - user.body_l_leg() - return + if(client.prefs.toggles & NUMPAD_TARGET) + switch(_key) + if("Numpad8") + user.body_toggle_head() + return + if("Numpad4") + user.body_r_arm() + return + if("Numpad5") + user.body_chest() + return + if("Numpad6") + user.body_l_arm() + return + if("Numpad1") + user.body_r_leg() + return + if("Numpad2") + user.body_groin() + return + if("Numpad3") + user.body_l_leg() + return - if(client.keys_held["Ctrl"]) + if(client.keys_held["Ctrl"] && client.prefs.toggles & AZERTY) + switch(SSinput.alt_movement_keys[_key]) + if(NORTH) + northface() + return + if(SOUTH) + southface() + return + if(WEST) + westface() + return + if(EAST) + eastface() + return + else if(client.keys_held["Ctrl"]) switch(SSinput.movement_keys[_key]) if(NORTH) northface() diff --git a/code/modules/mob/living/silicon/robot/login.dm b/code/modules/mob/living/silicon/robot/login.dm index d0262df743c..cf55cdd5f91 100644 --- a/code/modules/mob/living/silicon/robot/login.dm +++ b/code/modules/mob/living/silicon/robot/login.dm @@ -2,6 +2,3 @@ ..() regenerate_icons() show_laws(0) - - var/datum/hotkey_mode/cyborg/C = new(src) - C.set_winset_values() diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index cc6887abb42..6bf74f26409 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -304,7 +304,7 @@ for(var/obj/item/grab/G in mob.grabbed_by) G.adjust_position() if((direct & (direct - 1)) && mob.loc == n) //moved diagonally successfully - delay *= 2 + delay = mob.movement_delay() * 2 move_delay += delay moving = 0 if(mob && .)