This commit is contained in:
Vortrex
2022-06-14 17:32:15 -05:00
parent e965e15ad2
commit d6f767e321

View File

@@ -66,25 +66,25 @@ function initLabelJobHelpFont() {
// =========================================================================== // ===========================================================================
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType) { function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType) {
if(localPlayer == null) { if (localPlayer == null) {
return false; return false;
} }
if(propertyLabelNameFont == null) { if (propertyLabelNameFont == null) {
return false; return false;
} }
if(propertyLabelLockedFont == null) { if (propertyLabelLockedFont == null) {
return false; return false;
} }
if(getGame() == VRR_GAME_GTA_IV) { if (getGame() == VRR_GAME_GTA_IV) {
if(!natives.doesViewportExist(natives.getGameViewportId())) { if (!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false; return false;
} }
if(!natives.isViewportActive(natives.getGameViewportId())) { if (!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false; return false;
} }
@@ -93,45 +93,45 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
let tempPosition = position; let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight; tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0); let screenPosition = new Vec3(0.0, 0.0, 0.0);
if(getGame() == VRR_GAME_GTA_IV) { if (getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId()); screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else { } else {
screenPosition = getScreenFromWorldPosition(tempPosition); screenPosition = getScreenFromWorldPosition(tempPosition);
} }
if(screenPosition.x < 0 || screenPosition.x > game.width) { if (screenPosition.x < 0 || screenPosition.x > game.width) {
return false; return false;
} }
let text = ""; let text = "";
if(price > "0") { if (price > "0") {
text = getLocaleString("PropertyForSaleLabel", price); text = getLocaleString("PropertyForSaleLabel", price);
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); 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(200, 200, 200, 255), false, true, false, true); propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset; screenPosition.y -= propertyLabelPriceOffset;
} }
text = ""; text = "";
if(rentPrice != "0") { if (rentPrice != "0") {
text = getLocaleString("PropertyForRentLabel", rentPrice); text = getLocaleString("PropertyForRentLabel", rentPrice);
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); 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(200, 200, 200, 255), false, true, false, true); propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset; screenPosition.y -= propertyLabelPriceOffset;
} }
if(isBusiness) { if (isBusiness) {
text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open")); text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open"));
} else { } else {
text = (locked) ? toUpperCase(getLocaleString("Locked")) : toUpperCase(getLocaleString("Unlocked")); text = (locked) ? toUpperCase(getLocaleString("Locked")) : toUpperCase(getLocaleString("Unlocked"));
} }
if(!locked && labelInfoType != VRR_PROPLABEL_INFO_NONE) { if (!locked && labelInfoType != VRR_PROPLABEL_INFO_NONE) {
let infoText = ""; let infoText = "";
switch(labelInfoType) { switch (labelInfoType) {
case VRR_PROPLABEL_INFO_ENTER: { case VRR_PROPLABEL_INFO_ENTER: {
if(enterPropertyKey) { if (enterPropertyKey) {
infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey))); infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey)));
} else { } else {
infoText = getLocaleString("PropertyEnterCommandLabel", "/enter"); infoText = getLocaleString("PropertyEnterCommandLabel", "/enter");
@@ -165,7 +165,7 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
} }
default: { default: {
if(enterPropertyKey) { if (enterPropertyKey) {
infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey))); infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey)));
} else { } else {
infoText = getLocaleString("PropertyEnterCommandLabel", "/enter"); infoText = getLocaleString("PropertyEnterCommandLabel", "/enter");
@@ -173,45 +173,45 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
break; break;
} }
} }
if(getDistance(localPlayer.position, position) <= renderLabelDistance-2) { if (getDistance(localPlayer.position, position) <= renderLabelDistance - 2) {
let size = propertyLabelLockedFont.measure(infoText, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); let size = propertyLabelLockedFont.measure(infoText, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(infoText, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true); propertyLabelLockedFont.render(infoText, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true);
screenPosition.y -= propertyLabelLockedOffset; screenPosition.y -= propertyLabelLockedOffset;
} }
} }
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); 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); 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 -= propertyLabelNameOffset; screenPosition.y -= propertyLabelNameOffset;
text = name || " "; text = name || " ";
size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true); 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, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true); propertyLabelNameFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function renderPropertyExitLabel(position) { function renderPropertyExitLabel(position) {
if(localPlayer == null) { if (localPlayer == null) {
return false; return false;
} }
if(propertyLabelNameFont == null) { if (propertyLabelNameFont == null) {
return false; return false;
} }
if(propertyLabelLockedFont == null) { if (propertyLabelLockedFont == null) {
return false; return false;
} }
if(getGame() == VRR_GAME_GTA_IV) { if (getGame() == VRR_GAME_GTA_IV) {
if(!natives.doesViewportExist(natives.getGameViewportId())) { if (!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false; return false;
} }
if(!natives.isViewportActive(natives.getGameViewportId())) { if (!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false; return false;
} }
@@ -220,43 +220,43 @@ function renderPropertyExitLabel(position) {
let tempPosition = position; let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight; tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0); let screenPosition = new Vec3(0.0, 0.0, 0.0);
if(getGame() == VRR_GAME_GTA_IV) { if (getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId()); screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else { } else {
screenPosition = getScreenFromWorldPosition(tempPosition); screenPosition = getScreenFromWorldPosition(tempPosition);
} }
if(screenPosition.x < 0 || screenPosition.x > game.width) { if (screenPosition.x < 0 || screenPosition.x > game.width) {
return false; return false;
} }
let text = "EXIT"; let text = "EXIT";
let size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true); let 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); 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);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function renderJobLabel(name, position, jobType) { function renderJobLabel(name, position, jobType) {
if(localPlayer == null) { if (localPlayer == null) {
return false; return false;
} }
if(jobNameLabelFont == null) { if (jobNameLabelFont == null) {
return false; return false;
} }
if(jobHelpLabelFont == null) { if (jobHelpLabelFont == null) {
return false; return false;
} }
if(getGame() == VRR_GAME_GTA_IV) { if (getGame() == VRR_GAME_GTA_IV) {
if(!natives.doesViewportExist(natives.getGameViewportId())) { if (!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false; return false;
} }
if(!natives.isViewportActive(natives.getGameViewportId())) { if (!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!"); logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false; return false;
} }
@@ -265,25 +265,25 @@ function renderJobLabel(name, position, jobType) {
let tempPosition = position; let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight; tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0); let screenPosition = new Vec3(0.0, 0.0, 0.0);
if(getGame() == VRR_GAME_GTA_IV) { if (getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId()); screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else { } else {
screenPosition = getScreenFromWorldPosition(tempPosition); screenPosition = getScreenFromWorldPosition(tempPosition);
} }
if(screenPosition.x < 0 || screenPosition.x > game.width) { if (screenPosition.x < 0 || screenPosition.x > game.width) {
return false; return false;
} }
let text = ""; let text = "";
if(jobType == localPlayerJobType) { if (jobType == localPlayerJobType) {
if(localPlayerWorking) { if (localPlayerWorking) {
text = getLocaleString("JobEquipAndUniformLabel", "/equip", "/uniform", "/stopwork"); text = getLocaleString("JobEquipAndUniformLabel", "/equip", "/uniform", "/stopwork");
} else { } else {
text = getLocaleString("StartWorkLabel", "/startwork"); text = getLocaleString("StartWorkLabel", "/startwork");
} }
} else { } else {
if(localPlayerJobType == 0) { if (localPlayerJobType == 0) {
text = getLocaleString("TakeJobLabel", "/takejob"); text = getLocaleString("TakeJobLabel", "/takejob");
} else { } else {
text = getLocaleString("NotYourJobLabel", "/quitjob"); text = getLocaleString("NotYourJobLabel", "/quitjob");
@@ -291,37 +291,37 @@ function renderJobLabel(name, position, jobType) {
} }
let size = jobHelpLabelFont.measure(text, game.width, 0.0, 0.0, jobHelpLabelFont.size, true, true); let size = jobHelpLabelFont.measure(text, game.width, 0.0, 0.0, jobHelpLabelFont.size, true, true);
jobHelpLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true); jobHelpLabelFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true);
screenPosition.y -= 18; screenPosition.y -= 18;
text = getLocaleString("JobLabel", name); text = getLocaleString("JobLabel", name);
size = jobNameLabelFont.measure(text, game.width, 0.0, 0.0, jobNameLabelFont.size, true, true); size = jobNameLabelFont.measure(text, game.width, 0.0, 0.0, jobNameLabelFont.size, true, true);
jobNameLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true); jobNameLabelFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function processLabelRendering() { function processLabelRendering() {
if(renderLabels) { if (renderLabels) {
if(!areServerElementsSupported()) { if (!areServerElementsSupported()) {
if(localPlayer != null) { if (localPlayer != null) {
getServerData().businesses.forEach((business) => { getServerData().businesses.forEach((business) => {
if(getDistance(localPlayer.position, business.entrancePosition) <= 75.0) { if (getDistance(localPlayer.position, business.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255); natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255);
//renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, makeLargeNumberReadable(business.price), makeLargeNumberReadable(business.rentPrice), business.labelInfoType); //renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, makeLargeNumberReadable(business.price), makeLargeNumberReadable(business.rentPrice), business.labelInfoType);
} }
}); });
getServerData().houses.forEach((house) => { getServerData().houses.forEach((house) => {
if(getDistance(localPlayer.position, house.entrancePosition) <= 75.0) { if (getDistance(localPlayer.position, house.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255); natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255);
//renderPropertyEntranceLabel("House", house.entrancePosition, house.locked, true, makeLargeNumberReadable(house.price), makeLargeNumberReadable(house.rentPrice), 0); //renderPropertyEntranceLabel("House", house.entrancePosition, house.locked, true, makeLargeNumberReadable(house.price), makeLargeNumberReadable(house.rentPrice), 0);
} }
}); });
getServerData().jobs.forEach((job) => { getServerData().jobs.forEach((job) => {
if(getDistance(localPlayer.position, job.position) <= 75.0) { if (getDistance(localPlayer.position, job.position) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255); natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255);
//renderJobLabel(job.name, job.position, job.jobType); //renderJobLabel(job.name, job.position, job.jobType);
} }
@@ -329,29 +329,29 @@ function processLabelRendering() {
} }
} }
if(areWorldLabelsSupported()) { if (areWorldLabelsSupported()) {
if(localPlayer != null) { if (localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP); let pickups = getElementsByType(ELEMENT_PICKUP);
for(let i in pickups) { for (let i in pickups) {
if(pickups[i].getData("vrr.label.type") != null) { if (pickups[i].getData("vrr.label.type") != null) {
if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) { if (getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
if(!pickups[i].isOnScreen) { if (!pickups[i].isOnScreen) {
let price = "0"; let price = "0";
let rentPrice = "0"; let rentPrice = "0";
let labelInfoType = VRR_PROPLABEL_INFO_NONE; let labelInfoType = VRR_PROPLABEL_INFO_NONE;
if(pickups[i].getData("vrr.label.price") != null) { if (pickups[i].getData("vrr.label.price") != null) {
price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price")); price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price"));
} }
if(pickups[i].getData("vrr.label.rentprice") != null) { if (pickups[i].getData("vrr.label.rentprice") != null) {
rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice")); rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice"));
} }
if(pickups[i].getData("vrr.label.help") != null) { if (pickups[i].getData("vrr.label.help") != null) {
labelInfoType = pickups[i].getData("vrr.label.help"); labelInfoType = pickups[i].getData("vrr.label.help");
} }
switch(pickups[i].getData("vrr.label.type")) { switch (pickups[i].getData("vrr.label.type")) {
case VRR_LABEL_BUSINESS: { case VRR_LABEL_BUSINESS: {
renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType); renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType);
break; break;