Add optional custom HUD (money only for now, more later)
This commit is contained in:
1
meta.xml
1
meta.xml
@@ -127,6 +127,7 @@
|
|||||||
<script src="scripts/client/gui.js" type="client" language="javascript" />
|
<script src="scripts/client/gui.js" type="client" language="javascript" />
|
||||||
<script src="scripts/client/gps.js" type="client" language="javascript" />
|
<script src="scripts/client/gps.js" type="client" language="javascript" />
|
||||||
<script src="scripts/client/house.js" type="client" language="javascript" />
|
<script src="scripts/client/house.js" type="client" language="javascript" />
|
||||||
|
<script src="scripts/client/hud.js" type="client" language="javascript" />
|
||||||
<script src="scripts/client/item.js" type="client" language="javascript" />
|
<script src="scripts/client/item.js" type="client" language="javascript" />
|
||||||
<script src="scripts/client/job.js" type="client" language="javascript" />
|
<script src="scripts/client/job.js" type="client" language="javascript" />
|
||||||
<script src="scripts/client/keybind.js" type="client" language="javascript" />
|
<script src="scripts/client/keybind.js" type="client" language="javascript" />
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ function onDrawnHUD(event) {
|
|||||||
processSkinSelectRendering();
|
processSkinSelectRendering();
|
||||||
processNameTagRendering();
|
processNameTagRendering();
|
||||||
processInteriorLightsRendering();
|
processInteriorLightsRendering();
|
||||||
|
processCustomHUDRendering();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
58
scripts/client/hud.js
Normal file
58
scripts/client/hud.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
// ===========================================================================
|
||||||
|
// Vortrex's Roleplay Resource
|
||||||
|
// https://github.com/VortrexFTW/v-roleplay
|
||||||
|
// ===========================================================================
|
||||||
|
// FILE: hud.js
|
||||||
|
// DESC: Provides custom HUD functions and usage
|
||||||
|
// TYPE: Client (JavaScript)
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
let customHUDMoneyFont = null;
|
||||||
|
let customHUDMoneyColour = toColour(200, 200, 200, 200);
|
||||||
|
let customHUDMoneySize = 22.0;
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function initCustomHUDScript() {
|
||||||
|
logToConsole(LOG_DEBUG, "[V.RP.HUD]: Initializing HUD script ...");
|
||||||
|
customHUDMoneyFont = initCustomHUDMoneyFont();
|
||||||
|
logToConsole(LOG_DEBUG, "[V.RP.HUD]: HUD script initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function processCustomHUDRendering() {
|
||||||
|
logToConsole(LOG_VERBOSE, "[V.RP.HUD]: Processing custom HUD rendering ...");
|
||||||
|
|
||||||
|
if (renderHUD == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getGame() == V_GAME_MAFIA_ONE) {
|
||||||
|
if (customHUDMoneyFont != null) {
|
||||||
|
let text = getCurrencyString(localPlayerMoney);
|
||||||
|
logToConsole(LOG_VERBOSE, `[V.RP.HUD]: Rendering custom HUD money (${text})...`);
|
||||||
|
customHUDMoneyFont.render(text, [game.width - 150, 20], 130, 1.0, 0.0, customHUDMoneyFont.size, customHUDMoneyColour, true, true, false, true);
|
||||||
|
} else {
|
||||||
|
logToConsole(LOG_VERBOSE | LOG_ERROR, `[V.RP.HUD]: Rendering custom HUD money FAILED. Font object is null!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function initCustomHUDMoneyFont() {
|
||||||
|
logToConsole(LOG_DEBUG, "[V.RP.HUD]: Loading custom HUD money font ...");
|
||||||
|
let tempFont = null;
|
||||||
|
let fontStream = openFile("files/fonts/aurora-bold-condensed.ttf");
|
||||||
|
if (fontStream != null) {
|
||||||
|
tempFont = lucasFont.createFont(fontStream, customHUDMoneySize);
|
||||||
|
logToConsole(LOG_DEBUG, "[V.RP.HUD]: Custom HUD money font loaded successfully!");
|
||||||
|
} else {
|
||||||
|
logToConsole(LOG_DEBUG | LOG_ERROR, "[V.RP.HUD]: Loading custom HUD money font FAILED. Font file stream is null!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
@@ -21,6 +21,7 @@ function initClientScripts() {
|
|||||||
initEventScript();
|
initEventScript();
|
||||||
initSkinSelectScript();
|
initSkinSelectScript();
|
||||||
initCursorScript();
|
initCursorScript();
|
||||||
|
initCustomHUDScript();
|
||||||
|
|
||||||
addAllNetworkHandlers();
|
addAllNetworkHandlers();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user