diff --git a/macrovision.js b/macrovision.js index 58fa489d..579f689e 100644 --- a/macrovision.js +++ b/macrovision.js @@ -571,13 +571,12 @@ function updateEntityElement(entity, element) { let ratioInfo function updateRatios() { + let text = "" if (config.showRatios) { if (selectedEntity !== null && prevSelectedEntity !== null && selectedEntity !== prevSelectedEntity) { let first = selectedEntity.currentView.height; let second = prevSelectedEntity.currentView.height; - let text = "" - if (first.toNumber("meters") < second.toNumber("meters")) { text += selectedEntity.name + " is " + math.format(math.divide(second, first), { precision: 5 }) + " times smaller than " + prevSelectedEntity.name; } else { @@ -592,23 +591,35 @@ function updateRatios() { apparentHeight = apparentHeight.to("meters"); } - text += prevSelectedEntity.name + " looks " + math.format(apparentHeight, { precision: 3}) + " tall to " + selectedEntity.name; + text += prevSelectedEntity.name + " looks " + math.format(apparentHeight, { precision: 3}) + " tall to " + selectedEntity.name + "\n"; if (selectedEntity.currentView.capacity && prevSelectedEntity.currentView.weight) { const containCount = math.divide(selectedEntity.currentView.capacity, math.divide(prevSelectedEntity.currentView.weight, math.unit("80kg/people"))); if (containCount > 0.1) { - text += "\n" - text += selectedEntity.name + " can fit " + math.format(containCount, { precision: 1 }) + " of " + prevSelectedEntity.name + " inside them" + text += selectedEntity.name + " can fit " + math.format(containCount, { precision: 1 }) + " of " + prevSelectedEntity.name + " inside them" + "\n" } } - ratioInfo.innerText = text; - } else { - //ratioInfo.innerText = ""; } } + + if (config.showHorizon) { + if (selectedEntity !== null) { + const R = math.unit(1.27560e+7, "meters") + const h = selectedEntity.currentView.height + + const first = math.multiply(2, math.multiply(R, h)) + const second = math.multiply(h, h) + + const sightline = math.sqrt(math.add(first, second)).to(config.height.units[0].unit.name) + + text += selectedEntity.name + " could see for " + math.format(sightline, { precision: 3 }) + } + } + + ratioInfo.innerText = text; } @@ -2752,11 +2763,20 @@ const settingsData = { }, set value(param) { config.showRatios = param; - if (param) { - document.body.querySelector(".ratio-info").style.display = "block"; - } else { - document.body.querySelector(".ratio-info").style.display = "none"; - } + updateRatios(); + } + }, + "show-horizon": { + name: "Show Horizon", + desc: "Show how far the horizon would be for the selected character", + type: "toggle", + default: false, + get value() { + return config.showHorizon; + }, + set value(param) { + config.showHorizon = param; + updateRatios(); } }, "attach-rulers": {