mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-25 13:07:46 +01:00
You can now walk while you have a TGUI menu focused. (#18537)
* TGUI hotkey passthrough listener * always pass keydown * dictionary * AA nit Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> * AA nit part 2 Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> * AA nit part 3 Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> * Update tgui/packages/tgui/hotkeys.js Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com> Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com>
This commit is contained in:
co-authored by
AffectedArc07
S34N
parent
df1eefe9e2
commit
67edcdc0e8
@@ -154,6 +154,19 @@
|
||||
to_chat(usr, "<span class='boldannounce'>Your ToS consent has been withdrawn. You have been kicked from the server</span>")
|
||||
qdel(src)
|
||||
|
||||
if(href_list["__keydown"])
|
||||
var/keycode = href_list["__keydown"]
|
||||
if(keycode)
|
||||
KeyDown(keycode)
|
||||
return
|
||||
|
||||
if(href_list["__keyup"])
|
||||
var/keycode = href_list["__keyup"]
|
||||
if(keycode)
|
||||
KeyUp(keycode)
|
||||
return
|
||||
|
||||
|
||||
switch(href_list["action"])
|
||||
if("openLink")
|
||||
src << link(href_list["link"])
|
||||
|
||||
@@ -100,6 +100,40 @@ const getKeyData = (e) => {
|
||||
};
|
||||
};
|
||||
|
||||
const keyCodeToByond = keyCode => {
|
||||
const dict = {
|
||||
16 : 'Shift',
|
||||
17 : 'Ctrl',
|
||||
18 : 'Alt',
|
||||
33 : 'Northeast',
|
||||
34 : 'Southeast',
|
||||
35 : 'Southwest',
|
||||
36 : 'Northwest',
|
||||
37 : 'West',
|
||||
38 : 'North',
|
||||
39 : 'East',
|
||||
40 : 'South',
|
||||
45 : 'Insert',
|
||||
46 : 'Delete'
|
||||
}
|
||||
|
||||
if (dict[keyCode]) {
|
||||
return dict[keyCode];
|
||||
}
|
||||
if (keyCode >= 48 && keyCode <= 57 || keyCode >= 65 && keyCode <= 90) {
|
||||
return String.fromCharCode(keyCode);
|
||||
}
|
||||
if (keyCode >= 96 && keyCode <= 105) {
|
||||
return 'Numpad' + (keyCode - 96);
|
||||
}
|
||||
if (keyCode >= 112 && keyCode <= 123) {
|
||||
return 'F' + (keyCode - 111);
|
||||
}
|
||||
if (keyCode === 188) {return ',';}
|
||||
if (keyCode === 189) {return '-';}
|
||||
if (keyCode === 190) {return '.';}
|
||||
};
|
||||
|
||||
/**
|
||||
* Keyboard passthrough logic. This allows you to keep doing things
|
||||
* in game while the browser window is focused.
|
||||
@@ -114,21 +148,25 @@ const handlePassthrough = (e, eventType) => {
|
||||
}
|
||||
const keyData = getKeyData(e);
|
||||
const { keyCode, ctrlKey, shiftKey } = keyData;
|
||||
const byondKey = keyCodeToByond(keyCode);
|
||||
// NOTE: We pass through only Alt of all modifier keys, because Alt
|
||||
// modifier (for toggling run/walk) is implemented very shittily
|
||||
// modifier is implemented very shittily
|
||||
// in our codebase. We pass no other modifier keys, because they can
|
||||
// be used internally as tgui hotkeys.
|
||||
if (ctrlKey || shiftKey || NO_PASSTHROUGH_KEYS.includes(keyCode)) {
|
||||
if (NO_PASSTHROUGH_KEYS.includes(keyCode)) {
|
||||
return;
|
||||
}
|
||||
if (eventType === 'keyup' && keyState[keyCode]) { // this needs to happen regardless of ctrl or shift, else you can get stuck walking one way
|
||||
logger.debug('passthrough', eventType, keyData);
|
||||
return callByond('', { __keyup: byondKey });
|
||||
}
|
||||
if (ctrlKey || shiftKey) {
|
||||
return;
|
||||
}
|
||||
// Send this keypress to BYOND
|
||||
if (eventType === 'keydown' && !keyState[keyCode]) {
|
||||
logger.debug('passthrough', eventType, keyData);
|
||||
return callByond('', { __keydown: keyCode });
|
||||
}
|
||||
if (eventType === 'keyup' && keyState[keyCode]) {
|
||||
logger.debug('passthrough', eventType, keyData);
|
||||
return callByond('', { __keyup: keyCode });
|
||||
return callByond('', { __keydown: byondKey });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user