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