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,22 +873,9 @@ function getSelectedBiomeIDAndElement() {
return [null, null];
}
function checkDrawValid(context) {
if (!context) {
if (!voronoiCanvas.hidden) {
voronoiCanvas.hidden = true;
coordinateDisplay.hidden = true;
altitudeDisplay.hidden = true;
rangeDisplay.hidden = true;
configDiv.hidden = true;
errorMessage.innerText = "ERROR: Could not get the canvas context which means this tool won't work for you. Maybe your browser does not support the HTML canvas element properly.";
console.error("Could not get the canvas context!");
}
return false;
}
let showDiagramMessage = function(context, text) {
// Show a message in the center of the given draw
// context.
function showDiagramMessage(context, text) {
context.textAlign = "center";
context.fillStyle = "black";
context.textBaseline = "middle";
@ -903,6 +890,26 @@ function checkDrawValid(context) {
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) {
if (!context) {
// We don't even have a valid draw context!
// Write an error message in the error message element
if (!voronoiCanvas.hidden) {
voronoiCanvas.hidden = true;
coordinateDisplay.hidden = true;
altitudeDisplay.hidden = true;
rangeDisplay.hidden = true;
configDiv.hidden = true;
errorMessage.innerText = "ERROR: Could not get the canvas context which means this tool won't work for you. Maybe your browser does not support the HTML canvas element properly.";
console.error("Could not get the canvas context!");
}
return false;
}
// 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)) {
showDiagramMessage(context, "Value range is too small.");