Use new keybind utils
This commit is contained in:
@@ -16,10 +16,15 @@ let maxChatBoxHistory = 500;
|
||||
let scrollAmount = 1;
|
||||
let maxChatBoxLines = 6;
|
||||
|
||||
let scrollUpKey = false;
|
||||
let scrollDownKey = false;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initChatBoxScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Initializing chatbox script ...");
|
||||
scrollUpKey = getKeyIdFromParams("pageup");
|
||||
scrollDownKey = getKeyIdFromParams("pagedown");
|
||||
bindChatBoxKeys();
|
||||
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Chatbox script initialized!");
|
||||
}
|
||||
@@ -27,15 +32,15 @@ function initChatBoxScript() {
|
||||
// ===========================================================================
|
||||
|
||||
function bindChatBoxKeys() {
|
||||
bindKey(SDLK_PAGEUP, KEYSTATE_DOWN, chatBoxScrollUp);
|
||||
bindKey(SDLK_PAGEDOWN, KEYSTATE_DOWN, chatBoxScrollDown);
|
||||
bindKey(toInteger(scrollUpKey), KEYSTATE_DOWN, chatBoxScrollUp);
|
||||
bindKey(toInteger(scrollDownKey), KEYSTATE_DOWN, chatBoxScrollDown);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function unBindChatBoxKeys() {
|
||||
unbindKey(SDLK_PAGEUP);
|
||||
unbindKey(SDLK_PAGEDOWN);
|
||||
unbindKey(toInteger(scrollUpKey));
|
||||
unbindKey(toInteger(scrollDownKey));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// TYPE: Client (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let keyBinds = [];
|
||||
let lastKeyBindUse = 0;
|
||||
let keyBindDelayTime = 500;
|
||||
let keyBindShortHoldDuration = 500;
|
||||
@@ -23,6 +24,7 @@ function initKeyBindScript() {
|
||||
|
||||
function bindAccountKey(key, keyState) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Binded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
|
||||
keyBinds.push(toInteger(key));
|
||||
bindKey(toInteger(key), keyState, function(event) {
|
||||
if(hasKeyBindDelayElapsed()) {
|
||||
if(canLocalPlayerUseKeyBinds()) {
|
||||
@@ -43,6 +45,7 @@ function bindAccountKey(key, keyState) {
|
||||
function unBindAccountKey(key) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Unbinded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
|
||||
unbindKey(key);
|
||||
keyBinds.splice(keyBinds.indexOf(key), 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -62,4 +65,13 @@ function canLocalPlayerUseKeyBinds() {
|
||||
return true; //(!usingSkinSelector && isSpawned && !itemActionDelayEnabled);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function clearKeyBinds() {
|
||||
for(let i in keyBinds) {
|
||||
unbindKey(keyBinds[i]);
|
||||
}
|
||||
keyBinds = [];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -62,6 +62,7 @@ function addAllNetworkHandlers() {
|
||||
|
||||
addNetworkHandler("vrr.delKeyBind", unBindAccountKey);
|
||||
addNetworkHandler("vrr.addKeyBind", bindAccountKey);
|
||||
addNetworkHandler("vrr.clearKeyBinds", clearKeyBinds);
|
||||
|
||||
addNetworkHandler("vrr.nametag", updatePlayerNameTag);
|
||||
addNetworkHandler("vrr.ping", updatePlayerPing);
|
||||
|
||||
Reference in New Issue
Block a user