mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-04-02 13:37:24 +02:00
feat: Implement RuntimeDefsModule for managing shared runtime definitions and update related components
This commit is contained in:
parent
f928f9d101
commit
73d6d664fc
14 changed files with 126 additions and 43 deletions
|
|
@ -197,8 +197,8 @@ export function resolveVersionConflicts(mapVersion) {
|
|||
}
|
||||
|
||||
// v1.1 features stores more data
|
||||
defs.select("#land").selectAll("path").remove();
|
||||
defs.select("#water").selectAll("path").remove();
|
||||
RuntimeDefs.getLandMask().selectAll("path").remove();
|
||||
RuntimeDefs.getWaterMask().selectAll("path").remove();
|
||||
coastline.selectAll("path").remove();
|
||||
lakes.selectAll("path").remove();
|
||||
|
||||
|
|
@ -936,10 +936,9 @@ export function resolveVersionConflicts(mapVersion) {
|
|||
|
||||
if (isOlderThan("1.106.0")) {
|
||||
// v1.104.0 introduced bugs with coastlines. Redraw features
|
||||
defs.select("#featurePaths").remove();
|
||||
defs.append("g").attr("id", "featurePaths");
|
||||
defs.select("#land").selectAll("path, use").remove();
|
||||
defs.select("#water").selectAll("path, use").remove();
|
||||
RuntimeDefs.getFeaturePaths().html("");
|
||||
RuntimeDefs.getLandMask().selectAll("path, use").remove();
|
||||
RuntimeDefs.getWaterMask().selectAll("path, use").remove();
|
||||
viewbox.select("#coastline").selectAll("path, use").remove();
|
||||
|
||||
// v1.104.0 introduced bugs with state borders
|
||||
|
|
|
|||
|
|
@ -367,6 +367,8 @@ async function parseLoadedData(data, mapVersion) {
|
|||
}
|
||||
}
|
||||
|
||||
RuntimeDefs.purgeMapDefStubs();
|
||||
|
||||
{
|
||||
grid = JSON.parse(data[6]);
|
||||
const {cells, vertices} = calculateVoronoi(grid.points, grid.boundary);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ function editCoastline() {
|
|||
const feature = features[featureId];
|
||||
|
||||
// change coastline path
|
||||
defs.select("#featurePaths > path#feature_" + featureId).attr("d", getFeaturePath(feature));
|
||||
d3.select("#featurePaths > path#feature_" + featureId).attr("d", getFeaturePath(feature));
|
||||
|
||||
// update area
|
||||
const points = feature.vertices.map(vertex => vertices.p[vertex]);
|
||||
|
|
|
|||
|
|
@ -75,8 +75,9 @@ function editHeightmap(options) {
|
|||
viewbox.selectAll("#landmass, #lakes").style("display", "none");
|
||||
changeOnlyLand.checked = true;
|
||||
} else if (mode === "risk") {
|
||||
defs.selectAll("#land, #water").selectAll("path").remove();
|
||||
defs.select("#featurePaths").selectAll("path").remove();
|
||||
RuntimeDefs.getLandMask().selectAll("path").remove();
|
||||
RuntimeDefs.getWaterMask().selectAll("path").remove();
|
||||
RuntimeDefs.getFeaturePaths().selectAll("path").remove();
|
||||
viewbox.selectAll("#coastline use, #lakes path, #oceanLayers path").remove();
|
||||
changeOnlyLand.checked = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ function editLake() {
|
|||
const feature = getLake();
|
||||
|
||||
// update lake path
|
||||
defs.select("#featurePaths > path#feature_" + feature.i).attr("d", getFeaturePath(feature));
|
||||
d3.select("#featurePaths > path#feature_" + feature.i).attr("d", getFeaturePath(feature));
|
||||
|
||||
// update area
|
||||
const points = feature.vertices.map(vertex => pack.vertices.p[vertex]);
|
||||
|
|
|
|||
|
|
@ -649,8 +649,7 @@ function addLabelOnClick() {
|
|||
.attr("x", 0)
|
||||
.text(name);
|
||||
|
||||
defs
|
||||
.select("#textPaths")
|
||||
RuntimeDefs.getTextPaths()
|
||||
.append("path")
|
||||
.attr("id", "textPath_" + id)
|
||||
.attr("d", `M${point[0] - width},${point[1]} h${width * 2}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue