mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
fix: routes (v1.104.3)
This commit is contained in:
parent
3d1f268003
commit
5904e9e7c6
9 changed files with 98 additions and 65 deletions
|
|
@ -393,12 +393,12 @@ function createVillageGeneratorLink(burg) {
|
|||
else if (cells.r[cell]) tags.push("river");
|
||||
else if (pop < 200 && each(4)(cell)) tags.push("pond");
|
||||
|
||||
const connections = pack.cells.routes[cell] || {};
|
||||
const roads = Object.values(connections).filter(routeId => {
|
||||
const route = pack.routes[routeId];
|
||||
const roadsNumber = Object.values(pack.cells.routes[cell] || {}).filter(routeId => {
|
||||
const route = pack.routes.find(route => route.i === routeId);
|
||||
if (!route) return false;
|
||||
return route.group === "roads" || route.group === "trails";
|
||||
}).length;
|
||||
tags.push(roads > 1 ? "highway" : roads === 1 ? "dead end" : "isolated");
|
||||
tags.push(roadsNumber > 1 ? "highway" : roadsNumber === 1 ? "dead end" : "isolated");
|
||||
|
||||
const biome = cells.biome[cell];
|
||||
const arableBiomes = cells.r[cell] ? [1, 2, 3, 4, 5, 6, 7, 8] : [5, 6, 7, 8];
|
||||
|
|
|
|||
|
|
@ -153,9 +153,11 @@ function showMapTooltip(point, e, i, g) {
|
|||
|
||||
if (group === "routes") {
|
||||
const routeId = +e.target.id.slice(5);
|
||||
const name = pack.routes[routeId]?.name;
|
||||
if (name) return tip(`${name}. Click to edit the Route`);
|
||||
return tip("Click to edit the Route");
|
||||
const route = pack.routes.find(route => route.i === routeId);
|
||||
if (route) {
|
||||
if (route.name) return tip(`${route.name}. Click to edit the Route`);
|
||||
return tip("Click to edit the Route");
|
||||
}
|
||||
}
|
||||
|
||||
if (group === "terrain") return tip("Click to edit the Relief Icon");
|
||||
|
|
|
|||
|
|
@ -250,8 +250,7 @@ const voiceInterval = setInterval(function () {
|
|||
select.options.add(new Option(voice.name, i, false));
|
||||
});
|
||||
if (stored("speakerVoice")) select.value = stored("speakerVoice");
|
||||
// se voice to store
|
||||
else select.value = voices.findIndex(voice => voice.lang === "en-US"); // or to first found English-US
|
||||
else select.value = voices.findIndex(voice => voice.lang === "en-US");
|
||||
}, 1000);
|
||||
|
||||
function testSpeaker() {
|
||||
|
|
|
|||
|
|
@ -174,9 +174,10 @@ function editRoute(id) {
|
|||
|
||||
function handleControlPointClick() {
|
||||
const controlPoint = d3.select(this);
|
||||
|
||||
const point = controlPoint.datum();
|
||||
const route = getRoute();
|
||||
if (route.points.length < 3) return; // can't remove or split point if only 2 points in route
|
||||
|
||||
const index = route.points.indexOf(point);
|
||||
|
||||
const isSplitMode = byId("routeSplit").classList.contains("pressed");
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ function overviewRoutes() {
|
|||
let lines = "";
|
||||
|
||||
for (const route of pack.routes) {
|
||||
if (!route.points || route.points.length < 2) continue;
|
||||
route.name = route.name || Routes.generateName(route);
|
||||
route.length = route.length || Routes.getLength(route.i);
|
||||
const length = rn(route.length * distanceScale) + " " + distanceUnitInput.value;
|
||||
|
|
@ -92,8 +93,8 @@ function overviewRoutes() {
|
|||
}
|
||||
|
||||
function zoomToRoute() {
|
||||
const r = +this.parentNode.dataset.id;
|
||||
const route = routes.select("#route" + r).node();
|
||||
const routeId = +this.parentNode.dataset.id;
|
||||
const route = routes.select("#route" + routeId).node();
|
||||
highlightElement(route, 3);
|
||||
}
|
||||
|
||||
|
|
@ -111,15 +112,16 @@ function overviewRoutes() {
|
|||
}
|
||||
|
||||
function openRouteEditor() {
|
||||
const id = "route" + this.parentNode.dataset.id;
|
||||
editRoute(id);
|
||||
const routeId = "route" + this.parentNode.dataset.id;
|
||||
editRoute(routeId);
|
||||
}
|
||||
|
||||
function toggleLockStatus() {
|
||||
const routeId = +this.parentNode.dataset.id;
|
||||
const route = pack.routes[routeId];
|
||||
route.lock = !route.lock;
|
||||
const route = pack.routes.find(route => route.i === routeId);
|
||||
if (!route) return;
|
||||
|
||||
route.lock = !route.lock;
|
||||
if (this.classList.contains("icon-lock")) {
|
||||
this.classList.remove("icon-lock");
|
||||
this.classList.add("icon-lock-open");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue