mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
refactor: drawPrecipitation
This commit is contained in:
parent
b3dc8da683
commit
7d461aa8f1
7 changed files with 18 additions and 14 deletions
|
|
@ -646,11 +646,11 @@
|
|||
Ice
|
||||
</li>
|
||||
<li
|
||||
id="togglePrec"
|
||||
id="togglePrecipitation"
|
||||
data-tip="Precipitation map: click to toggle, drag to raise or lower the layer. Ctrl + click to edit layer style"
|
||||
data-shortcut="A"
|
||||
class="buttonoff"
|
||||
onclick="togglePrec(event)"
|
||||
onclick="togglePrecipitation(event)"
|
||||
>
|
||||
Precipit<u>a</u>tion
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ async function parseLoadedData(data, mapVersion) {
|
|||
if (hasChildren(temperature)) turnOn("toggleTemperature");
|
||||
if (hasChild(population, "line")) turnOn("togglePopulation");
|
||||
if (hasChildren(ice)) turnOn("toggleIce");
|
||||
if (hasChild(prec, "circle")) turnOn("togglePrec");
|
||||
if (hasChild(prec, "circle")) turnOn("togglePrecipitation");
|
||||
if (isVisible(emblems) && hasChild(emblems, "use")) turnOn("toggleEmblems");
|
||||
if (isVisible(labels)) turnOn("toggleLabels");
|
||||
if (isVisible(icons)) turnOn("toggleIcons");
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ function showMapTooltip(point, e, i, g) {
|
|||
if (group === "ice") return tip("Click to edit the Ice");
|
||||
|
||||
// covering elements
|
||||
if (layerIsOn("togglePrec") && land) tip("Annual Precipitation: " + getFriendlyPrecipitation(i));
|
||||
if (layerIsOn("togglePrecipitation") && land) tip("Annual Precipitation: " + getFriendlyPrecipitation(i));
|
||||
else if (layerIsOn("togglePopulation")) tip(getPopulationTip(i));
|
||||
else if (layerIsOn("toggleTemperature")) tip("Temperature: " + convertTemperature(grid.cells.temp[g]));
|
||||
else if (layerIsOn("toggleBiomes") && pack.cells.biome[i]) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ function handleKeyup(event) {
|
|||
else if (code === "KeyT") toggleTemperature();
|
||||
else if (code === "KeyN") togglePopulation();
|
||||
else if (code === "KeyJ") toggleIce();
|
||||
else if (code === "KeyA") togglePrec();
|
||||
else if (code === "KeyA") togglePrecipitation();
|
||||
else if (code === "KeyY") toggleEmblems();
|
||||
else if (code === "KeyL") toggleLabels();
|
||||
else if (code === "KeyI") toggleIcons();
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ function restoreLayers() {
|
|||
if (layerIsOn("toggleCompass")) compass.style("display", "block");
|
||||
if (layerIsOn("toggleRoutes")) drawRoutes();
|
||||
if (layerIsOn("toggleTemperature")) drawTemperature();
|
||||
if (layerIsOn("togglePrec")) drawPrec();
|
||||
if (layerIsOn("togglePrecipitation")) drawPrecipitation();
|
||||
if (layerIsOn("togglePopulation")) drawPopulation();
|
||||
if (layerIsOn("toggleBiomes")) drawBiomes();
|
||||
if (layerIsOn("toggleRelief")) ReliefIcons.draw();
|
||||
|
|
@ -242,14 +242,14 @@ function drawBiomes() {
|
|||
TIME && console.timeEnd("drawBiomes");
|
||||
}
|
||||
|
||||
function togglePrec(event) {
|
||||
function togglePrecipitation(event) {
|
||||
if (!prec.selectAll("circle").size()) {
|
||||
turnButtonOn("togglePrec");
|
||||
drawPrec();
|
||||
turnButtonOn("togglePrecipitation");
|
||||
drawPrecipitation();
|
||||
if (event && isCtrlClick(event)) editStyle("prec");
|
||||
} else {
|
||||
if (event && isCtrlClick(event)) return editStyle("prec");
|
||||
turnButtonOff("togglePrec");
|
||||
turnButtonOff("togglePrecipitation");
|
||||
const hide = d3.transition().duration(1000).ease(d3.easeSinIn);
|
||||
prec.selectAll("text").attr("opacity", 1).transition(hide).attr("opacity", 0);
|
||||
prec.selectAll("circle").transition(hide).attr("r", 0).remove();
|
||||
|
|
@ -257,7 +257,9 @@ function togglePrec(event) {
|
|||
}
|
||||
}
|
||||
|
||||
function drawPrec() {
|
||||
function drawPrecipitation() {
|
||||
TIME && console.time("drawPrecipitation");
|
||||
|
||||
prec.selectAll("circle").remove();
|
||||
const {cells, points} = grid;
|
||||
|
||||
|
|
@ -279,6 +281,8 @@ function drawPrec() {
|
|||
.attr("r", 0)
|
||||
.transition(show)
|
||||
.attr("r", d => getRadius(cells.prec[d]));
|
||||
|
||||
TIME && console.timeEnd("drawPrecipitation");
|
||||
}
|
||||
|
||||
function togglePopulation(event) {
|
||||
|
|
@ -1259,7 +1263,7 @@ function getLayer(id) {
|
|||
if (id === "toggleBorders") return $("#borders");
|
||||
if (id === "toggleRoutes") return $("#routes");
|
||||
if (id === "toggleTemperature") return $("#temperature");
|
||||
if (id === "togglePrec") return $("#prec");
|
||||
if (id === "togglePrecipitation") return $("#prec");
|
||||
if (id === "togglePopulation") return $("#population");
|
||||
if (id === "toggleIce") return $("#ice");
|
||||
if (id === "toggleTexture") return $("#texture");
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ function editWorld() {
|
|||
Biomes.define();
|
||||
|
||||
if (layerIsOn("toggleTemperature")) drawTemperature();
|
||||
if (layerIsOn("togglePrec")) drawPrec();
|
||||
if (layerIsOn("togglePrecipitation")) drawPrecipitation();
|
||||
if (layerIsOn("toggleBiomes")) drawBiomes();
|
||||
if (layerIsOn("toggleCoordinates")) drawCoordinates();
|
||||
if (layerIsOn("toggleRivers")) drawRivers();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* Example: 1.102.0 -> Major version 1, Minor version 102, Patch version 0
|
||||
*/
|
||||
const VERSION = "1.103.00";
|
||||
const VERSION = "1.104.00";
|
||||
|
||||
{
|
||||
document.title += " v" + VERSION;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue