mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-23 04:21:24 +01:00
Merge branch 'Azgaar:master' into master
This commit is contained in:
commit
b952376547
5 changed files with 55 additions and 39 deletions
|
|
@ -50,6 +50,7 @@ iframe {
|
||||||
mask-mode: alpha;
|
mask-mode: alpha;
|
||||||
mask-clip: no-clip;
|
mask-clip: no-clip;
|
||||||
fill-rule: evenodd;
|
fill-rule: evenodd;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#canvas {
|
#canvas {
|
||||||
|
|
|
||||||
76
main.js
76
main.js
|
|
@ -172,29 +172,32 @@ landmass.append("rect").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr
|
||||||
oceanPattern.append("rect").attr("fill", "url(#oceanic)").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr("height", graphHeight);
|
oceanPattern.append("rect").attr("fill", "url(#oceanic)").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr("height", graphHeight);
|
||||||
oceanLayers.append("rect").attr("id", "oceanBase").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr("height", graphHeight);
|
oceanLayers.append("rect").attr("id", "oceanBase").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr("height", graphHeight);
|
||||||
|
|
||||||
if (!location.hostname) {
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
const wiki = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Run-FMG-locally";
|
if (!location.hostname) {
|
||||||
alertMessage.innerHTML = `Fantasy Map Generator cannot run serverless.
|
const wiki = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Run-FMG-locally";
|
||||||
Follow the <a href="${wiki}" target="_blank">instructions</a> on how you can easily run a local web-server`;
|
alertMessage.innerHTML = `Fantasy Map Generator cannot run serverless.
|
||||||
|
Follow the <a href="${wiki}" target="_blank">instructions</a> on how you can easily run a local web-server`;
|
||||||
|
|
||||||
$("#alert").dialog({
|
$("#alert").dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
title: "Loading error",
|
title: "Loading error",
|
||||||
width: "28em",
|
width: "28em",
|
||||||
position: {my: "center center-4em", at: "center", of: "svg"},
|
position: {my: "center center-4em", at: "center", of: "svg"},
|
||||||
buttons: {
|
buttons: {
|
||||||
OK: function () {
|
OK: function () {
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
d3.select("#loading-text").transition().duration(1000).style("opacity", 0);
|
d3.select("#loading-text").transition().duration(1000).style("opacity", 0);
|
||||||
d3.select("#init-rose").transition().duration(4000).style("opacity", 0);
|
d3.select("#init-rose").transition().duration(4000).style("opacity", 0);
|
||||||
} else {
|
} else {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
checkLoadParameters();
|
await checkLoadParameters();
|
||||||
}
|
}
|
||||||
|
restoreDefaultEvents(); // apply default viewbox events
|
||||||
|
});
|
||||||
|
|
||||||
function hideLoading() {
|
function hideLoading() {
|
||||||
const queryString = window.location.search;
|
const queryString = window.location.search;
|
||||||
|
|
@ -218,7 +221,7 @@ function showLoading() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// decide which map should be loaded or generated on page load
|
// decide which map should be loaded or generated on page load
|
||||||
function checkLoadParameters() {
|
async function checkLoadParameters() {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
const params = url.searchParams;
|
const params = url.searchParams;
|
||||||
|
|
||||||
|
|
@ -239,32 +242,39 @@ function checkLoadParameters() {
|
||||||
// if there is a seed (user of MFCG provided), generate map for it
|
// if there is a seed (user of MFCG provided), generate map for it
|
||||||
if (params.get("seed")) {
|
if (params.get("seed")) {
|
||||||
WARN && console.warn("Generate map for seed");
|
WARN && console.warn("Generate map for seed");
|
||||||
generateMapOnLoad();
|
await generateMapOnLoad();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open latest map if option is active and map is stored
|
// open latest map if option is active and map is stored
|
||||||
if (onloadMap.value === "saved") {
|
const loadLastMap = () => new Promise((resolve, reject) => {
|
||||||
ldb.get("lastMap", blob => {
|
ldb.get("lastMap", blob => {
|
||||||
if (blob) {
|
if (blob) {
|
||||||
WARN && console.warn("Load last saved map");
|
WARN && console.warn("Load last saved map");
|
||||||
try {
|
try {
|
||||||
uploadMap(blob);
|
uploadMap(blob);
|
||||||
|
resolve();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ERROR && console.error(error);
|
reject(error);
|
||||||
WARN && console.warn("Cannot load stored map, random map to be generated");
|
|
||||||
generateMapOnLoad();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ERROR && console.error("No map stored, random map to be generated");
|
reject("No map stored");
|
||||||
generateMapOnLoad();
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
return;
|
})
|
||||||
}
|
|
||||||
|
|
||||||
WARN && console.warn("Generate random map");
|
if (onloadMap.value === "saved") {
|
||||||
generateMapOnLoad();
|
try {
|
||||||
|
await loadLastMap();
|
||||||
|
} catch(error) {
|
||||||
|
ERROR && console.error(error);
|
||||||
|
WARN && console.warn("Cannot load stored map, random map to be generated");
|
||||||
|
await generateMapOnLoad();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WARN && console.warn("Generate random map");
|
||||||
|
await generateMapOnLoad();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateMapOnLoad() {
|
async function generateMapOnLoad() {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
modules.editors = true;
|
modules.editors = true;
|
||||||
restoreDefaultEvents(); // apply default viewbox events on load
|
|
||||||
|
|
||||||
// restore default viewbox events
|
// restore default viewbox events
|
||||||
function restoreDefaultEvents() {
|
function restoreDefaultEvents() {
|
||||||
|
|
|
||||||
|
|
@ -1502,6 +1502,12 @@ function drawRivers() {
|
||||||
|
|
||||||
const riverPaths = pack.rivers.map(({cells, points, i, widthFactor, sourceWidth}) => {
|
const riverPaths = pack.rivers.map(({cells, points, i, widthFactor, sourceWidth}) => {
|
||||||
if (!cells || cells.length < 2) return;
|
if (!cells || cells.length < 2) return;
|
||||||
|
|
||||||
|
if (points && points.length !== cells.length) {
|
||||||
|
console.error(`River ${i} has ${cells.length} cells, but only ${points.length} points defined. Resetting points data`);
|
||||||
|
points = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const meanderedPoints = addMeandering(cells, points);
|
const meanderedPoints = addMeandering(cells, points);
|
||||||
const path = getRiverPath(meanderedPoints, widthFactor, sourceWidth);
|
const path = getRiverPath(meanderedPoints, widthFactor, sourceWidth);
|
||||||
return `<path id="river${i}" d="${path}"/>`;
|
return `<path id="river${i}" d="${path}"/>`;
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ function showSupporters() {
|
||||||
Jonathan Williams,ojacid .,Brian Wilson,A Patreon of the Ahts,Shubham Jakhotiya,www15o,Jan Bundesmann,Angelique Badger,Joshua Xiong,Moist mongol,
|
Jonathan Williams,ojacid .,Brian Wilson,A Patreon of the Ahts,Shubham Jakhotiya,www15o,Jan Bundesmann,Angelique Badger,Joshua Xiong,Moist mongol,
|
||||||
Frank Fewkes,jason baldrick,Game Master Pro,Andrew Kircher,Preston Mitchell,Chris Kohut,Emarandzeb,Trentin Bergeron,Damon Gallaty,Pleaseworkforonce,
|
Frank Fewkes,jason baldrick,Game Master Pro,Andrew Kircher,Preston Mitchell,Chris Kohut,Emarandzeb,Trentin Bergeron,Damon Gallaty,Pleaseworkforonce,
|
||||||
Jordan,William Markus,Sidr Dim,Alexander Whittaker,The Next Level,Patrick Valverde,Markus Peham,Daniel Cooper,the Beagles of Neorbus,Marley Moule,
|
Jordan,William Markus,Sidr Dim,Alexander Whittaker,The Next Level,Patrick Valverde,Markus Peham,Daniel Cooper,the Beagles of Neorbus,Marley Moule,
|
||||||
Maximilian Schielke,Johnathan Xavier Hutchinson,Ele,Rita`;
|
Maximilian Schielke,Johnathan Xavier Hutchinson,Ele,Rita,Randy Ross,John Wick,RedSpaz,cameron cannon,Ian Grau-Fay,Kyle Barrett,Charlotte Wiland`;
|
||||||
|
|
||||||
const array = supporters
|
const array = supporters
|
||||||
.replace(/(?:\r\n|\r|\n)/g, "")
|
.replace(/(?:\r\n|\r|\n)/g, "")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue