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 GitHub
9 changed files with 54 additions and 32 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
// 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))
// 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.
#define CTRL_KEY (1<<8)
#define SHIFT_KEY (1<<9)
+13 -7
View File
@@ -98,12 +98,18 @@
if(!direction)
return ""
var/list/dirs = list()
if(direction & NORTH) dirs += "NORTH"
if(direction & SOUTH) dirs += "SOUTH"
if(direction & EAST) dirs += "EAST"
if(direction & WEST) dirs += "WEST"
if(direction & UP) dirs += "UP"
if(direction & DOWN) dirs += "DOWN"
if(direction & NORTH)
dirs += "NORTH"
if(direction & SOUTH)
dirs += "SOUTH"
if(direction & EAST)
dirs += "EAST"
if(direction & WEST)
dirs += "WEST"
if(direction & UP)
dirs += "UP"
if(direction & DOWN)
dirs += "DOWN"
return dirs.Join(" ")
// Converts an angle (degrees) into an ss13 direction
@@ -315,4 +321,4 @@
error("File not found ([filename])")
catch(var/exception/E)
if(error_on_invalid_return)
error("Exception when loading file as string: [E]")
error("Exception when loading file as string: [E]")
+1 -1
View File
@@ -637,4 +637,4 @@
return selfimage
/atom/movable/proc/get_cell()
return
return
+1
View File
@@ -87,6 +87,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,
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
@@ -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)
var/movekey = MOVE_KEY_MAPPINGS[movekeyName]
// Validate input. Must be one (and only one) of the key codes)
if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1)))
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)
var/movekey = MOVE_KEY_MAPPINGS[movekeyName]
// Validate input. Must be one (and only one) of the key codes)
if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1)))
log_debug("Client [ckey] sent an illegal movement key up: [movekeyName] ([movekey])")
return
// Clear bit indicating we were holding the key
move_keys_held &= ~movekey
mod_keys_held &= ~movekey
+31 -16
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
/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
/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
/datum/proc/keyLoop(client/user) // Called once every server tick
/// Called once every server tick
/datum/proc/keyLoop(client/user)
set waitfor = FALSE
return
/// Set mob's focus
/// TODO - Do we even need this concept?
/// Set mob's focus. TODO: Decide if required.
/mob/proc/set_focus(datum/new_focus)
if(focus == new_focus)
return
@@ -20,15 +24,26 @@
if(!keys)
return ""
var/list/out = list()
if(keys & NORTH_KEY) out += "NORTH"
if(keys & SOUTH_KEY) out += "SOUTH"
if(keys & EAST_KEY) out += "EAST"
if(keys & WEST_KEY) out += "WEST"
if(keys & W_KEY) out += "W"
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"
if(keys & NORTH_KEY)
out += "NORTH"
if(keys & SOUTH_KEY)
out += "SOUTH"
if(keys & EAST_KEY)
out += "EAST"
if(keys & WEST_KEY)
out += "WEST"
if(keys & W_KEY)
out += "W"
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(" ")
+1 -1
View File
@@ -233,4 +233,4 @@
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
+1 -1
View File
@@ -159,8 +159,8 @@
// We're still cooling down from the last move
if(!my_mob.checkMoveCooldown())
DEBUG_INPUT("--------")
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_sub = 0 // I'm not really sure why next_move_dir_sub even exists.
+2 -2
View File
@@ -268,7 +268,7 @@ macro "macro"
elem
name = "TAB"
command = ".winset \"mainwindow.macro=hotkeymode hotkey_toggle.is-checked=true mapwindow.map.focus=true\""
elem
elem
name = "Shift"
command = "KeyDown Shift"
elem
@@ -492,7 +492,7 @@ macro "hotkeymode"
elem
name = "TAB"
command = ".winset \"mainwindow.macro=macro hotkey_toggle.is-checked=false input.focus=true\""
elem
elem
name = "Shift"
command = "KeyDown Shift"
elem