From b5a58d73312d245a7411610bc83b916158752db8 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Tue, 29 Jun 2021 16:44:23 -0400 Subject: [PATCH] Add an option to adjust the ground's position --- macrovision.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/macrovision.js b/macrovision.js index 09628a3f..d9f9c19e 100644 --- a/macrovision.js +++ b/macrovision.js @@ -619,7 +619,15 @@ function updateSizes(dirtyOnly = false) { updateRatios(); if (config.lockYAxis) { - config.y = 0; + if (config.groundPos === "high") { + config.y = -config.height.toNumber("meters") / 2; + } else if (config.groundPos === "medium") { + config.y = -config.height.toNumber("meters") / 4; + } else if (config.groundPos === "low") { + config.y = -config.height.toNumber("meters") / 6; + } else { + config.y = 0; + } } drawScales(dirtyOnly); @@ -2244,6 +2252,25 @@ const settingsData = { } } }, + "ground-pos": { + name: "Ground Position", + desc: "How high the ground is if the y-axis is locked", + type: "select", + default: "bottom", + options: [ + "high", + "medium", + "low", + "bottom" + ], + get value() { + return config.groundPos; + }, + set value(param) { + config.groundPos = param; + updateSizes(); + } + }, "auto-scale": { name: "Auto-Size World", desc: "Constantly zoom to fit the largest entity", @@ -3724,7 +3751,25 @@ function prepareEntities() { button.addEventListener("click", e => { const newEntity = entityList[select.value].constructor() - displayEntity(newEntity, newEntity.defaultView, config.x, config.y + (config.lockYAxis ? 0 : config.height.toNumber("meters")/2), true, true); + let yOffset = 0; + + if (config.lockYAxis) { + if (config.groundPos === "high") { + yOffset = config.height.toNumber("meters")/2; + } + else if (config.groundPos === "medium") { + yOffset = config.height.toNumber("meters")/4; + } + else if (config.groundPos === "low") { + yOffset = config.height.toNumber("meters")/6; + } + else if (config.groundPos === "bottom") { + yOffset = 0; + } + } else { + yOffset = (config.lockYAxis ? 0 : config.height.toNumber("meters")/2); + } + displayEntity(newEntity, newEntity.defaultView, config.x, config.y + yOffset, true, true); }); const categoryOption = document.createElement("option");