Fix showDiagramMessage function not exposed enough

This commit is contained in:
Wuzzy 2023-10-28 08:09:58 +02:00
parent 8f3bdd6188
commit 6f55d3a67b

View File

@ -873,8 +873,30 @@ function getSelectedBiomeIDAndElement() {
return [null, null]; return [null, null];
} }
// Show a message in the center of the given draw
// context.
function showDiagramMessage(context, text) {
context.textAlign = "center";
context.fillStyle = "black";
context.textBaseline = "middle";
if (voronoiCanvas.width < 300) {
context.font = "100% sans-serif";
} else if (voronoiCanvas.width < 450) {
context.font = "150% sans-serif";
} else {
context.font = "200% sans-serif";
}
context.fillText(text, voronoiCanvas.width/2, voronoiCanvas.height/2);
updateAltitudeText();
}
// Check if a diagram can be drawn on the draw context and
// if not, draws a message and return false.
// If everything is fine, return true.
function checkDrawValid(context) { function checkDrawValid(context) {
if (!context) { if (!context) {
// We don't even have a valid draw context!
// Write an error message in the error message element
if (!voronoiCanvas.hidden) { if (!voronoiCanvas.hidden) {
voronoiCanvas.hidden = true; voronoiCanvas.hidden = true;
coordinateDisplay.hidden = true; coordinateDisplay.hidden = true;
@ -888,21 +910,6 @@ function checkDrawValid(context) {
return false; return false;
} }
let showDiagramMessage = function(context, text) {
context.textAlign = "center";
context.fillStyle = "black";
context.textBaseline = "middle";
if (voronoiCanvas.width < 300) {
context.font = "100% sans-serif";
} else if (voronoiCanvas.width < 450) {
context.font = "150% sans-serif";
} else {
context.font = "200% sans-serif";
}
context.fillText(text, voronoiCanvas.width/2, voronoiCanvas.height/2);
updateAltitudeText();
}
// Fail and render a special message if the value range is tiny // Fail and render a special message if the value range is tiny
if ((limit_heat_max - limit_heat_min < 0.01) || (limit_humidity_max - limit_humidity_min < 0.01)) { if ((limit_heat_max - limit_heat_min < 0.01) || (limit_humidity_max - limit_humidity_min < 0.01)) {
showDiagramMessage(context, "Value range is too small."); showDiagramMessage(context, "Value range is too small.");