Merge pull request #13881 from VOREStation/upstream-merge-8199

[MIRROR] Ports Diagonal Movement [READY FOR MERGE]
This commit is contained in:
Casey
2022-10-09 23:07:54 -04:00
committed by CHOMPStation2
parent 0972599a01
commit 24a6d07198
9 changed files with 54 additions and 32 deletions

View File

@@ -10,7 +10,7 @@
// Combine the held WASD and arrow keys together (OR) into byond N/S/E/W dir // Combine the held WASD and arrow keys together (OR) into byond N/S/E/W dir
#define MOVEMENT_KEYS_TO_DIR(MK) ((((MK)>>4)|(MK))&(ALL_CARDINALS)) #define MOVEMENT_KEYS_TO_DIR(MK) ((((MK)>>4)|(MK))&(ALL_CARDINALS))
// Bitflags for pressed modifier keys. // Bitflags for pressed modifier keys.
// Values chosen specifically to not conflict with dir bitfield, in case we want to smoosh them together. // Values chosen specifically to not conflict with dir bitfield, in case we want to smoosh them together.
#define CTRL_KEY (1<<8) #define CTRL_KEY (1<<8)
#define SHIFT_KEY (1<<9) #define SHIFT_KEY (1<<9)

View File

@@ -98,12 +98,18 @@
if(!direction) if(!direction)
return "" return ""
var/list/dirs = list() var/list/dirs = list()
if(direction & NORTH) dirs += "NORTH" if(direction & NORTH)
if(direction & SOUTH) dirs += "SOUTH" dirs += "NORTH"
if(direction & EAST) dirs += "EAST" if(direction & SOUTH)
if(direction & WEST) dirs += "WEST" dirs += "SOUTH"
if(direction & UP) dirs += "UP" if(direction & EAST)
if(direction & DOWN) dirs += "DOWN" dirs += "EAST"
if(direction & WEST)
dirs += "WEST"
if(direction & UP)
dirs += "UP"
if(direction & DOWN)
dirs += "DOWN"
return dirs.Join(" ") return dirs.Join(" ")
// Converts an angle (degrees) into an ss13 direction // Converts an angle (degrees) into an ss13 direction
@@ -315,4 +321,4 @@
error("File not found ([filename])") error("File not found ([filename])")
catch(var/exception/E) catch(var/exception/E)
if(error_on_invalid_return) if(error_on_invalid_return)
error("Exception when loading file as string: [E]") error("Exception when loading file as string: [E]")

View File

@@ -639,4 +639,4 @@
return selfimage return selfimage
/atom/movable/proc/get_cell() /atom/movable/proc/get_cell()
return return

View File

@@ -91,6 +91,7 @@ var/list/reverse_dir = list( // reverse_dir[dir] = reverse of dir
41, 43, 36, 38, 37, 39, 44, 46, 45, 47, 16, 18, 17, 19, 24, 26, 25, 27, 20, 22, 21, 41, 43, 36, 38, 37, 39, 44, 46, 45, 47, 16, 18, 17, 19, 24, 26, 25, 27, 20, 22, 21,
23, 28, 30, 29, 31, 48, 50, 49, 51, 56, 58, 57, 59, 52, 54, 53, 55, 60, 62, 61, 63 23, 28, 30, 29, 31, 48, 50, 49, 51, 56, 58, 57, 59, 52, 54, 53, 55, 60, 62, 61, 63
) )
var/global/const/SQRT_TWO = 1.41421356237
var/datum/configuration/config = null var/datum/configuration/config = null

View File

@@ -22,7 +22,7 @@ var/global/list/MOVE_KEY_MAPPINGS = list(
// Map text sent by skin.dmf to our numeric codes. (This can be optimized away once we update skin.dmf) // Map text sent by skin.dmf to our numeric codes. (This can be optimized away once we update skin.dmf)
var/movekey = MOVE_KEY_MAPPINGS[movekeyName] var/movekey = MOVE_KEY_MAPPINGS[movekeyName]
// Validate input. Must be one (and only one) of the key codes) // Validate input. Must be one (and only one) of the key codes)
if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1))) if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1)))
log_debug("Client [ckey] sent an illegal movement key down: [movekeyName] ([movekey])") log_debug("Client [ckey] sent an illegal movement key down: [movekeyName] ([movekey])")
@@ -54,12 +54,12 @@ var/global/list/MOVE_KEY_MAPPINGS = list(
// Map text sent by skin.dmf to our numeric codes. (This can be optimized away once we update skin.dmf) // Map text sent by skin.dmf to our numeric codes. (This can be optimized away once we update skin.dmf)
var/movekey = MOVE_KEY_MAPPINGS[movekeyName] var/movekey = MOVE_KEY_MAPPINGS[movekeyName]
// Validate input. Must be one (and only one) of the key codes) // Validate input. Must be one (and only one) of the key codes)
if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1))) if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1)))
log_debug("Client [ckey] sent an illegal movement key up: [movekeyName] ([movekey])") log_debug("Client [ckey] sent an illegal movement key up: [movekeyName] ([movekey])")
return return
// Clear bit indicating we were holding the key // Clear bit indicating we were holding the key
move_keys_held &= ~movekey move_keys_held &= ~movekey
mod_keys_held &= ~movekey mod_keys_held &= ~movekey

View File

@@ -1,15 +1,19 @@
// Set a client's focus to an object and override these procs on that object to let it handle keypresses // Set a client's focus to an object and override these procs on that object to let it handle keypresses
/datum/proc/key_down(key, client/user) // Called when a key is pressed down initially /// Called when a key is pressed down initially
/datum/proc/key_down(key, client/user)
return return
/datum/proc/key_up(key, client/user) // Called when a key is released
/// Called when a key is released
/datum/proc/key_up(key, client/user)
return return
/datum/proc/keyLoop(client/user) // Called once every server tick
/// Called once every server tick
/datum/proc/keyLoop(client/user)
set waitfor = FALSE set waitfor = FALSE
return return
/// Set mob's focus /// Set mob's focus. TODO: Decide if required.
/// TODO - Do we even need this concept?
/mob/proc/set_focus(datum/new_focus) /mob/proc/set_focus(datum/new_focus)
if(focus == new_focus) if(focus == new_focus)
return return
@@ -20,15 +24,26 @@
if(!keys) if(!keys)
return "" return ""
var/list/out = list() var/list/out = list()
if(keys & NORTH_KEY) out += "NORTH" if(keys & NORTH_KEY)
if(keys & SOUTH_KEY) out += "SOUTH" out += "NORTH"
if(keys & EAST_KEY) out += "EAST" if(keys & SOUTH_KEY)
if(keys & WEST_KEY) out += "WEST" out += "SOUTH"
if(keys & W_KEY) out += "W" if(keys & EAST_KEY)
if(keys & A_KEY) out += "A" out += "EAST"
if(keys & S_KEY) out += "S" if(keys & WEST_KEY)
if(keys & D_KEY) out += "D" out += "WEST"
if(keys & CTRL_KEY) out += "CTRL" if(keys & W_KEY)
if(keys & SHIFT_KEY) out += "SHIFT" out += "W"
if(keys & ALT_KEY) out += "ALT" if(keys & A_KEY)
out += "A"
if(keys & S_KEY)
out += "S"
if(keys & D_KEY)
out += "D"
if(keys & CTRL_KEY)
out += "CTRL"
if(keys & SHIFT_KEY)
out += "SHIFT"
if(keys & ALT_KEY)
out += "ALT"
return out.Join(" ") return out.Join(" ")

View File

@@ -233,4 +233,4 @@
var/list/progressbars = null //VOREStation Edit var/list/progressbars = null //VOREStation Edit
var/datum/focus //What receives our keyboard inputs. src by default // VOREStation Add - Key Handling var/datum/focus //What receives our keyboard inputs. src by default

View File

@@ -159,8 +159,8 @@
// We're still cooling down from the last move // We're still cooling down from the last move
if(!my_mob.checkMoveCooldown()) if(!my_mob.checkMoveCooldown())
DEBUG_INPUT("--------")
return return
DEBUG_INPUT("--------")
next_move_dir_add = 0 // This one I *think* exists so you can tap move and it will move even if delay isn't quite up. next_move_dir_add = 0 // This one I *think* exists so you can tap move and it will move even if delay isn't quite up.
next_move_dir_sub = 0 // I'm not really sure why next_move_dir_sub even exists. next_move_dir_sub = 0 // I'm not really sure why next_move_dir_sub even exists.

View File

@@ -268,7 +268,7 @@ macro "macro"
elem elem
name = "TAB" name = "TAB"
command = ".winset \"mainwindow.macro=hotkeymode hotkey_toggle.is-checked=true mapwindow.map.focus=true\"" command = ".winset \"mainwindow.macro=hotkeymode hotkey_toggle.is-checked=true mapwindow.map.focus=true\""
elem elem
name = "Shift" name = "Shift"
command = "KeyDown Shift" command = "KeyDown Shift"
elem elem
@@ -492,7 +492,7 @@ macro "hotkeymode"
elem elem
name = "TAB" name = "TAB"
command = ".winset \"mainwindow.macro=macro hotkey_toggle.is-checked=false input.focus=true\"" command = ".winset \"mainwindow.macro=macro hotkey_toggle.is-checked=false input.focus=true\""
elem elem
name = "Shift" name = "Shift"
command = "KeyDown Shift" command = "KeyDown Shift"
elem elem