mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 10:01:23 +01:00
refactor: migrate heightmap editor
This commit is contained in:
parent
a97e7f44f6
commit
a15f60150f
26 changed files with 103 additions and 80 deletions
|
|
@ -1,12 +1,12 @@
|
|||
import * as d3 from "d3";
|
||||
|
||||
import {restoreDefaultEvents} from "scripts/events";
|
||||
import {findCell} from "utils/graphUtils";
|
||||
import {byId} from "utils/shorthands";
|
||||
import {tip} from "scripts/tooltips";
|
||||
import {rn, minmax, normalize} from "utils/numberUtils";
|
||||
import {parseTransform} from "utils/stringUtils";
|
||||
import {findCell} from "utils/graphUtils";
|
||||
import {minmax, normalize, rn} from "utils/numberUtils";
|
||||
import {each} from "utils/probabilityUtils";
|
||||
import {byId} from "utils/shorthands";
|
||||
import {parseTransform} from "utils/stringUtils";
|
||||
|
||||
// clear elSelected variable
|
||||
export function unselect() {
|
||||
|
|
@ -650,7 +650,7 @@ function fog(id, path) {
|
|||
}
|
||||
|
||||
// remove fogging
|
||||
function unfog(id) {
|
||||
export function unfog(id) {
|
||||
let el = defs.select("#fog #" + id);
|
||||
if (!id || !el.size()) el = defs.select("#fog").selectAll("path");
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ function handleKeyup(event) {
|
|||
else if (ctrl && code === "KeyC") saveToDropbox();
|
||||
else if (ctrl && code === "KeyZ" && undo?.offsetParent) undo.click();
|
||||
else if (ctrl && code === "KeyY" && redo?.offsetParent) redo.click();
|
||||
else if (shift && code === "KeyH") editHeightmap();
|
||||
else if (shift && code === "KeyH") openDialog("heightmapEditor");
|
||||
else if (shift && code === "KeyB") editBiomes();
|
||||
else if (shift && code === "KeyS") openDialog("statesEditor");
|
||||
else if (shift && code === "KeyP") editProvinces();
|
||||
|
|
@ -100,7 +100,7 @@ function handleKeyup(event) {
|
|||
else if (code === "ArrowUp") zoom.translateBy(svg, 0, 10);
|
||||
else if (code === "ArrowDown") zoom.translateBy(svg, 0, -10);
|
||||
else if (key === "+" || key === "-") pressNumpadSign(key);
|
||||
else if (key === "0") resetZoom(1000);
|
||||
else if (key === "0") Zoom.reset(1000);
|
||||
else if (key === "1") zoom.scaleTo(svg, 1);
|
||||
else if (key === "2") zoom.scaleTo(svg, 2);
|
||||
else if (key === "3") zoom.scaleTo(svg, 3);
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ function randomizeCultureSet() {
|
|||
}
|
||||
|
||||
function setRendering(value) {
|
||||
fmg.viewbox?.attr("shape-rendering", value);
|
||||
viewbox?.attr("shape-rendering", value);
|
||||
}
|
||||
|
||||
// generate current year and era name
|
||||
|
|
@ -901,7 +901,7 @@ function updateTilesOptions() {
|
|||
|
||||
// View mode
|
||||
viewMode.addEventListener("click", changeViewMode);
|
||||
function changeViewMode(event) {
|
||||
export function changeViewMode(event) {
|
||||
const button = event.target;
|
||||
if (button.tagName !== "BUTTON") return;
|
||||
const pressed = button.classList.contains("pressed");
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import * as d3 from "d3";
|
||||
|
||||
import {closeDialogs} from "dialogs/utils";
|
||||
import {openDialog} from "dialogs";
|
||||
import {closeDialogs} from "dialogs/utils";
|
||||
import {turnLayerButtonOff} from "layers";
|
||||
import {unfog} from "modules/ui/editors";
|
||||
import {restoreDefaultEvents} from "scripts/events";
|
||||
import {clearMainTip, showMainTip, tip} from "scripts/tooltips";
|
||||
import {unique} from "utils/arrayUtils";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import * as d3 from "d3";
|
||||
|
||||
import {INFO} from "config/logging";
|
||||
import {tip} from "scripts/tooltips";
|
||||
import {rn} from "utils/numberUtils";
|
||||
import {parseTransform} from "utils/stringUtils";
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ window.UISubmap = (function () {
|
|||
});
|
||||
|
||||
async function openResampleMenu() {
|
||||
resetZoom(0);
|
||||
Zoom.reset(0);
|
||||
|
||||
byId("submapAngleInput").value = 0;
|
||||
byId("submapAngleOutput").value = "0";
|
||||
|
|
@ -283,7 +283,7 @@ window.UISubmap = (function () {
|
|||
|
||||
async function startResample(options) {
|
||||
// Do model changes with Submap.resample then do view changes if needed
|
||||
resetZoom(0);
|
||||
Zoom.reset(0);
|
||||
let oldstate = {
|
||||
grid: structuredClone(grid),
|
||||
pack: structuredClone(pack),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ import * as d3 from "d3";
|
|||
|
||||
import {openDialog} from "dialogs";
|
||||
import {closeDialogs} from "dialogs/utils";
|
||||
import {turnLayerButtonOn} from "layers";
|
||||
import {renderLayer, toggleLayer, turnLayerButtonOn} from "layers";
|
||||
import {unfog} from "modules/ui/editors";
|
||||
import {aleaPRNG} from "scripts/aleaPRNG";
|
||||
import {restoreDefaultEvents} from "scripts/events";
|
||||
import {prompt} from "scripts/prompt";
|
||||
|
|
@ -20,7 +21,7 @@ toolsContent.addEventListener("click", function (event) {
|
|||
const button = event.target.id;
|
||||
|
||||
// click on open Editor buttons
|
||||
if (button === "editHeightmapButton") editHeightmap();
|
||||
if (button === "editHeightmapButton") openDialog("heightmapEditor");
|
||||
else if (button === "editBiomesButton") editBiomes();
|
||||
else if (button === "editStatesButton") openDialog("statesEditor");
|
||||
else if (button === "editProvincesButton") editProvinces();
|
||||
|
|
@ -133,8 +134,8 @@ function regenerateRivers() {
|
|||
Rivers.generate();
|
||||
Lakes.defineGroup();
|
||||
Rivers.specify();
|
||||
if (!layerIsOn("toggleRivers")) toggleRivers();
|
||||
else drawRivers();
|
||||
if (!layerIsOn("toggleRivers")) toggleLayer("toggleRivers");
|
||||
else renderLayer("rivers");
|
||||
}
|
||||
|
||||
function recalculatePopulation() {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import * as d3 from "d3";
|
|||
import {tip} from "scripts/tooltips";
|
||||
import {rn} from "utils/numberUtils";
|
||||
import {round, parseTransform} from "utils/stringUtils";
|
||||
import {renderLayer} from "layers";
|
||||
|
||||
let isLoaded = false;
|
||||
|
||||
|
|
@ -68,11 +69,11 @@ export function editWorld() {
|
|||
pack.cells.h = new Float32Array(heights);
|
||||
Biomes.define();
|
||||
|
||||
if (layerIsOn("toggleTemp")) drawTemp();
|
||||
if (layerIsOn("togglePrec")) drawPrec();
|
||||
if (layerIsOn("toggleBiomes")) drawBiomes();
|
||||
if (layerIsOn("toggleTemp")) renderLayer("temperature");
|
||||
if (layerIsOn("togglePrec")) renderLayer("precipitation");
|
||||
if (layerIsOn("toggleBiomes")) renderLayer("biomes");
|
||||
if (layerIsOn("toggleCoordinates")) drawCoordinates();
|
||||
if (layerIsOn("toggleRivers")) drawRivers();
|
||||
if (layerIsOn("toggleRivers")) renderLayer("rivers");
|
||||
if (document.getElementById("canvas3d")) setTimeout(ThreeD.update(), 500);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import * as d3 from "d3";
|
||||
|
||||
import {closeDialogs} from "dialogs/utils";
|
||||
import {unfog} from "modules/ui/editors";
|
||||
import {restoreDefaultEvents} from "scripts/events";
|
||||
import {clearMainTip, showMainTip, tip} from "scripts/tooltips";
|
||||
import {unique} from "utils/arrayUtils";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue