Add keypress for some GUI buttons + fix prompt text
This commit is contained in:
@@ -29,12 +29,6 @@ let textInputAlpha = 180;
|
|||||||
|
|
||||||
let guiReady = false;
|
let guiReady = false;
|
||||||
|
|
||||||
let guiSubmitKey = false;
|
|
||||||
let guiLeftKey = false;
|
|
||||||
let guiRightKey = false;
|
|
||||||
let guiUpKey = false;
|
|
||||||
let guiDownKey = false;
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
let characterData = [];
|
let characterData = [];
|
||||||
@@ -170,23 +164,23 @@ addNetworkEventHandler("vrr.switchCharacterSelect", function(firstName, lastName
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
addNetworkEventHandler("vrr.showError", function(errorMessage, errorTitle) {
|
addNetworkEventHandler("vrr.showError", function(errorMessage, errorTitle, buttonText) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Received request from server to show error window`);
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Received request from server to show error window`);
|
||||||
showError(errorMessage, errorTitle);
|
showError(errorMessage, errorTitle, buttonText);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
addNetworkEventHandler("vrr.showPrompt", function(promptMessage, promptTitle) {
|
addNetworkEventHandler("vrr.showPrompt", function(promptMessage, promptTitle, yesButtonText, noButtonText) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Received request from server to show prompt window`);
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Received request from server to show prompt window`);
|
||||||
showYesNoPromptGUI(promptMessage, promptTitle);
|
showYesNoPromptGUI(promptMessage, promptTitle, yesButtonText, noButtonText);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
addNetworkEventHandler("vrr.showInfo", function(infoMessage) {
|
addNetworkEventHandler("vrr.showInfo", function(infoMessage, buttonText) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Received request from server to show info dialog`);
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Received request from server to show info dialog`);
|
||||||
showInfo(infoMessage);
|
showInfo(infoMessage, buttonText);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -277,29 +271,42 @@ function hideAllGUI() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function processGUIKeyPress(keyCode) {
|
function processGUIKeyPress(keyCode) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Processing key press: ${keyCode}`);
|
||||||
|
|
||||||
if(!isAnyGUIActive()) {
|
if(!isAnyGUIActive()) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.GUI] GUI is not active. Cancelling keypress processing.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(keyCode == SDLK_RETURN || keyCode == SDLK_RETURN2) {
|
if(keyCode == SDLK_RETURN || keyCode == SDLK_RETURN2) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is submit (${guiSubmitKey})`);
|
||||||
if(guiSubmitKey != false) {
|
if(guiSubmitKey != false) {
|
||||||
guiSubmitKey();
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling submit key function`);
|
||||||
|
guiSubmitKey.call();
|
||||||
}
|
}
|
||||||
} else if(keyCode == getKeyIdFromParams("left") || keyCode == getKeyIdFromParams("a")) {
|
} else if(keyCode == getKeyIdFromParams("left") || keyCode == getKeyIdFromParams("a")) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is left (${guiLeftKey})`);
|
||||||
if(guiLeftKey != false) {
|
if(guiLeftKey != false) {
|
||||||
guiLeftKey();
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling left key function`);
|
||||||
|
guiLeftKey.call();
|
||||||
}
|
}
|
||||||
} else if(keyCode == getKeyIdFromParams("right") || keyCode == getKeyIdFromParams("d")) {
|
} else if(keyCode == getKeyIdFromParams("right") || keyCode == getKeyIdFromParams("d")) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is right (${guiRightKey})`);
|
||||||
if(guiRightKey != false) {
|
if(guiRightKey != false) {
|
||||||
guiRightKey();
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling right key function`);
|
||||||
|
guiRightKey.call();
|
||||||
}
|
}
|
||||||
} else if(keyCode == getKeyIdFromParams("down") || keyCode == getKeyIdFromParams("s")) {
|
} else if(keyCode == getKeyIdFromParams("down") || keyCode == getKeyIdFromParams("s")) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is down (${guiDownKey})`);
|
||||||
if(guiDownKey != false) {
|
if(guiDownKey != false) {
|
||||||
guiDownKey();
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling down key function`);
|
||||||
|
guiDownKey.call();
|
||||||
}
|
}
|
||||||
} else if(keyCode == getKeyIdFromParams("up") || keyCode == getKeyIdFromParams("w")) {
|
} else if(keyCode == getKeyIdFromParams("up") || keyCode == getKeyIdFromParams("w")) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is up (${guiUpKey})`);
|
||||||
if(guiUpKey != false) {
|
if(guiUpKey != false) {
|
||||||
guiUpKey();
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling up key function`);
|
||||||
|
guiUpKey.call();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,6 +163,10 @@ function showCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, ski
|
|||||||
characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`;
|
characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`;
|
||||||
characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
|
characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
|
||||||
characterSelect.window.shown = true;
|
characterSelect.window.shown = true;
|
||||||
|
|
||||||
|
guiSubmitKey = selectThisCharacter;
|
||||||
|
guiLeftKey = selectPreviousCharacter;
|
||||||
|
guiRightKey = selectNextCharacter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -211,6 +215,7 @@ function switchCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, s
|
|||||||
characterSelect.skinImage = (getGame() == VRR_GAME_GTA_III) ? characterSelect.window.image(310, 32, 100, 90, `files/images/skins/gta3/${getSkinImage(skinId)}.png`) : characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
|
characterSelect.skinImage = (getGame() == VRR_GAME_GTA_III) ? characterSelect.window.image(310, 32, 100, 90, `files/images/skins/gta3/${getSkinImage(skinId)}.png`) : characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
|
||||||
|
|
||||||
characterSelect.window.shown = true;
|
characterSelect.window.shown = true;
|
||||||
|
|
||||||
guiSubmitKey = selectThisCharacter;
|
guiSubmitKey = selectThisCharacter;
|
||||||
guiLeftKey = selectPreviousCharacter;
|
guiLeftKey = selectPreviousCharacter;
|
||||||
guiRightKey = selectNextCharacter;
|
guiRightKey = selectNextCharacter;
|
||||||
|
|||||||
@@ -63,12 +63,14 @@ function initErrorDialogGUI() {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function showErrorGUI(errorMessage, errorTitle) {
|
function showErrorGUI(errorMessage, errorTitle, buttonText) {
|
||||||
closeAllWindows();
|
closeAllWindows();
|
||||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`);
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`);
|
||||||
setChatWindowEnabled(false);
|
setChatWindowEnabled(false);
|
||||||
mexui.setInput(true);
|
mexui.setInput(true);
|
||||||
errorDialog.messageLabel.text = errorMessage;
|
errorDialog.messageLabel.text = errorMessage;
|
||||||
|
errorDialog.okayButton.text = buttonText;
|
||||||
|
errprDialog.window.title = errorTitle;
|
||||||
errorDialog.window.shown = true;
|
errorDialog.window.shown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,11 +70,13 @@ function closeInfoDialog() {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function showInfo(infoMessage, infoTitle) {
|
function showInfo(infoMessage, infoTitle, buttonText) {
|
||||||
closeAllWindows();
|
closeAllWindows();
|
||||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`);
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`);
|
||||||
mexui.setInput(true);
|
mexui.setInput(true);
|
||||||
infoDialog.messageLabel.text = infoMessage;
|
infoDialog.messageLabel.text = infoMessage;
|
||||||
|
infoDialog.okayButton.text = buttonText;
|
||||||
|
infoDialog.window.title = infoTitle;
|
||||||
infoDialog.window.shown = true;
|
infoDialog.window.shown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,11 +78,14 @@ function initYesNoDialogGUI() {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function showYesNoPromptGUI(promptMessage, promptTitle) {
|
function showYesNoPromptGUI(promptMessage, promptTitle, yesButtonText, noButtonText) {
|
||||||
closeAllWindows();
|
closeAllWindows();
|
||||||
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`);
|
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`);
|
||||||
mexui.setInput(true);
|
mexui.setInput(true);
|
||||||
yesNoDialog.messageLabel.text = promptMessage;
|
yesNoDialog.messageLabel.text = promptMessage;
|
||||||
|
yesNoDialog.yesButton.text = yesButtonText;
|
||||||
|
yesNoDialog.noButton.text = noButtonText;
|
||||||
|
yesNoDialog.window.title = promptTitle;
|
||||||
yesNoDialog.window.shown = true;
|
yesNoDialog.window.shown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user