From 46d04e7d509734a4c746ad8f50a37f278998e556 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Mon, 22 Feb 2021 18:31:54 -0600 Subject: [PATCH] Add label rendering vars --- scripts/client/label.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/client/label.js b/scripts/client/label.js index 410760f5..64db5624 100644 --- a/scripts/client/label.js +++ b/scripts/client/label.js @@ -25,6 +25,11 @@ let unlockedColour = toColour(50, 205, 50, 255); let lockedColour = toColour(205, 92, 92, 255); let jobHelpColour = toColour(234, 198, 126, 255); +let renderLabelDistance = 7.5; + +let propertyLabelLockedOffset = 16; +let propertyLabelNameOffset = 18; + // ------------------------------------------------------------------------- bindEventHandler("onResourceReady", thisResource, function(event, resource) { @@ -54,13 +59,17 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price) tempPosition.z = tempPosition.z + propertyLabelHeight; let screenPosition = getScreenFromWorldPosition(tempPosition); + if(screenPosition.x < 0 || screenPosition.x > gta.width) { + return false; + } + let text = ""; if(price > 0) { text = `For sale: $${price}`; let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(0, 150, 0, 255), false, true, false, true); - screenPosition.y -= 18; + screenPosition.y -= propertyLabelLockedOffset; } text = (locked) ? "LOCKED" : "UNLOCKED"; @@ -71,7 +80,7 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price) let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, (locked) ? lockedColour : unlockedColour, false, true, false, true); - screenPosition.y -= 22; + screenPosition.y -= propertyLabelNameOffset; text = name || " "; size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true); @@ -97,6 +106,10 @@ function renderPropertyExitLabel(position) { tempPosition.z = tempPosition.z + propertyLabelHeight; let screenPosition = getScreenFromWorldPosition(tempPosition); + if(screenPosition.x < 0 || screenPosition.x > gta.width) { + return false; + } + let text = "EXIT"; size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true); propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true); @@ -121,6 +134,10 @@ function renderJobLabel(name, position, jobType) { tempPosition.z = tempPosition.z + propertyLabelHeight; let screenPosition = getScreenFromWorldPosition(tempPosition); + if(screenPosition.x < 0 || screenPosition.x > gta.width) { + return false; + } + let text = ""; if(jobType == localPlayerJobType) { if(localPlayerWorking) { @@ -153,7 +170,7 @@ function processLabelRendering() { let pickups = getElementsByType(ELEMENT_PICKUP); for(let i in pickups) { if(pickups[i].getData("ag.label.type") != null) { - if(getDistance(localPlayer.position, pickups[i].position) <= 7.5) { + if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) { let price = 0; if(pickups[i].getData("ag.label.price") != null) { price = pickups[i].getData("ag.label.price");