Render buy help text on biz's with items

This commit is contained in:
Vortrex
2021-04-23 18:14:19 -05:00
parent 2d69010562
commit 08a1970152

View File

@@ -67,7 +67,7 @@ function initLabelJobHelpFont() {
// =========================================================================== // ===========================================================================
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price) { function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, shouldShowBuyInfo) {
if(localPlayer == null) { if(localPlayer == null) {
return false; return false;
} }
@@ -92,7 +92,7 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price)
if(price > 0) { if(price > 0) {
text = `For sale: $${price}`; text = `For sale: $${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(0, 150, 0, 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 -= propertyLabelLockedOffset; screenPosition.y -= propertyLabelLockedOffset;
} }
@@ -100,6 +100,13 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price)
text = (locked) ? "LOCKED" : "UNLOCKED"; text = (locked) ? "LOCKED" : "UNLOCKED";
if(isBusiness) { if(isBusiness) {
text = (locked) ? "CLOSED" : "OPEN"; text = (locked) ? "CLOSED" : "OPEN";
if(!locked && shouldShowBuyInfo) {
if(getDistance(localPlayer.position, position) <= renderLabelDistance-2) {
let size = propertyLabelLockedFont.measure(`Use /buy to purchase items`, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(`Use /buy to purchase items`, [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;
}
}
} }
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);
@@ -198,13 +205,18 @@ function processLabelRendering() {
if(pickups[i].getData("ag.label.type") != null) { if(pickups[i].getData("ag.label.type") != null) {
if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) { if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
let price = 0; let price = 0;
let shouldShowBuyHelp = false;
if(pickups[i].getData("ag.label.price") != null) { if(pickups[i].getData("ag.label.price") != null) {
price = pickups[i].getData("ag.label.price"); price = pickups[i].getData("ag.label.price");
} }
if(pickups[i].getData("ag.label.buyhelp") != null) {
shouldShowBuyHelp = pickups[i].getData("ag.label.buyhelp");
}
switch(pickups[i].getData("ag.label.type")) { switch(pickups[i].getData("ag.label.type")) {
case AG_LABEL_BUSINESS: case AG_LABEL_BUSINESS:
renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), true, price); renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), true, price, shouldShowBuyHelp);
break; break;
case AG_LABEL_HOUSE: case AG_LABEL_HOUSE: