Scoreboard error checking

This commit is contained in:
Vortrex
2023-02-21 20:28:27 -06:00
parent 697ccd860f
commit e3a0b27c4e

View File

@@ -38,13 +38,34 @@ function initScoreBoardListFont() {
// =========================================================================== // ===========================================================================
function processScoreBoardRendering() { function processScoreBoardRendering() {
if (isAnyGUIActive()) { if (!renderScoreBoard) {
logToConsole(LOG_VERBOSE | LOG_ERROR, `[V.RP.ScoreBoard] Could not render scoreboard. Scoreboard rendering is disabled!`);
return false;
}
if (scoreBoardListFont == null) {
logToConsole(LOG_VERBOSE | LOG_ERROR, `[V.RP.ScoreBoard] Could not render scoreboard. List font is null!`);
return false;
}
if (scoreBoardTitleFont == null) {
logToConsole(LOG_VERBOSE | LOG_ERROR, `[V.RP.ScoreBoard] Could not render scoreboard. Title font is null!`);
return false;
}
if (isAnyGUIActive()) {
logToConsole(LOG_VERBOSE | LOG_ERROR, `[V.RP.ScoreBoard] Could not render scoreboard. A GUI window is active!`);
return false;
}
if (scoreBoardKey == null) {
return false;
}
if (!isKeyDown(scoreBoardKey)) {
return false; return false;
} }
if (renderScoreBoard) {
if (isKeyDown(scoreBoardKey)) {
if (scoreBoardListFont != null && scoreBoardTitleFont != null) {
let scoreboardStart = (game.height / 2) - (Math.floor(getClients().length / 2) * 20); let scoreboardStart = (game.height / 2) - (Math.floor(getClients().length / 2) * 20);
let titleSize = scoreBoardTitleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false); let titleSize = scoreBoardTitleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false);
scoreBoardTitleFont.render("PLAYERS", [game.width / 2, scoreboardStart - 50], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true); scoreBoardTitleFont.render("PLAYERS", [game.width / 2, scoreboardStart - 50], 0, 0.5, 0.0, scoreBoardTitleFont.size, COLOUR_WHITE, false, false, false, true);
@@ -99,9 +120,6 @@ function processScoreBoardRendering() {
} }
} }
} }
}
}
}
// =========================================================================== // ===========================================================================