Fixed client side UI failure caused by apostrophes in text.

Updated the Chem Dispenser UI with an Energy bar.

UIs attached to the Chem Dispenser will now update on recharge(), recharge now recharges 1 every 15 ticks instead of 2 every 30 (to make it feel more fluid).
This commit is contained in:
Mark Aherne (Faerdan)
2013-09-01 00:55:46 +01:00
parent 9cb0b79d78
commit cffdca9596
7 changed files with 65 additions and 24 deletions

View File

@@ -75,7 +75,7 @@ NanoBaseHelpers = function ()
return '';
},
// Display a bar. Used to show health, capacity, etc.
displayBar: function(value, rangeMin, rangeMax, styleClass) {
displayBar: function(value, rangeMin, rangeMax, styleClass, showText) {
if (rangeMin < rangeMax)
{
@@ -100,14 +100,19 @@ NanoBaseHelpers = function ()
}
}
if (typeof styleClass == 'undefined')
if (typeof styleClass == 'undefined' || !styleClass)
{
styleClass = '';
}
if (typeof showText == 'undefined' || !showText)
{
showText = '';
}
var percentage = Math.round((value - rangeMin) / (rangeMax - rangeMin) * 100);
return '<div class="progressBar"><div class="progressFill ' + styleClass + '" style="width: ' + percentage + '%;"></div></div>';
return '<div class="displayBar ' + styleClass + '"><div class="displayBarFill ' + styleClass + '" style="width: ' + percentage + '%;"></div><div class="displayBarText ' + styleClass + '">' + showText + '</div></div>';
}
});
}