mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 02:21:24 +01:00
v1.4.03
This commit is contained in:
parent
9573f99376
commit
a2b93f1396
16 changed files with 130 additions and 130 deletions
|
|
@ -2,45 +2,35 @@
|
|||
|
||||
function showEPForRoute(node) {
|
||||
const points = [];
|
||||
var prevB=0, i=0, j=0, b=0, ma=0, mi=100, h=0;
|
||||
debug.select("#controlPoints").selectAll("circle").each(function() {
|
||||
i = findCell(this.getAttribute("cx"), this.getAttribute("cy"));
|
||||
const i = findCell(this.getAttribute("cx"), this.getAttribute("cy"));
|
||||
points.push(i);
|
||||
});
|
||||
|
||||
const routeLen = node.getTotalLength() * distanceScaleInput.value;
|
||||
|
||||
showElevationProfile(points, routeLen, false);
|
||||
}
|
||||
|
||||
function showEPForRiver(node) {
|
||||
const points = [];
|
||||
var prevB=0, i=0, j=0, b=0, ma=0, mi=100, h=0;
|
||||
debug.select("#controlPoints").selectAll("circle").each(function() {
|
||||
i = findCell(this.getAttribute("cx"), this.getAttribute("cy"));
|
||||
const i = findCell(this.getAttribute("cx"), this.getAttribute("cy"));
|
||||
points.push(i);
|
||||
});
|
||||
|
||||
const riverLen = (node.getTotalLength() / 2) * distanceScaleInput.value;
|
||||
|
||||
showElevationProfile(points, riverLen, true);
|
||||
}
|
||||
|
||||
function resizeElevationProfile() {
|
||||
}
|
||||
|
||||
function closeElevationProfile() {
|
||||
modules.elevation = false;
|
||||
}
|
||||
|
||||
function showElevationProfile(data, routeLen, isRiver) {
|
||||
// data is an array of cell indexes, routeLen is the distance, isRiver should be true for rivers, false otherwise
|
||||
// data is an array of cell indexes, routeLen is the distance, isRiver should be true for rivers, false otherwise
|
||||
document.getElementById("elevationGraph").innerHTML = "";
|
||||
|
||||
$("#elevationProfile").dialog({
|
||||
title: "Elevation profile", resizable: false,
|
||||
width: window.width,
|
||||
close: closeElevationProfile,
|
||||
title: "Elevation profile", resizable: false, width: window.width,
|
||||
position: {my: "left top", at: "left+20 bottom-240", of: window, collision: "fit"}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -223,16 +223,20 @@ function getRiverInfo(id) {
|
|||
return r ? `${r.name} ${r.type} (${id})` : "n/a";
|
||||
}
|
||||
|
||||
function getCellPopulation(i) {
|
||||
const rural = pack.cells.pop[i] * populationRate.value;
|
||||
const urban = pack.cells.burg[i] ? pack.burgs[pack.cells.burg[i]].population * populationRate.value * urbanization.value : 0;
|
||||
return [rural, urban];
|
||||
}
|
||||
|
||||
// get user-friendly (real-world) population value from map data
|
||||
function getFriendlyPopulation(i) {
|
||||
const rural = pack.cells.pop[i] * populationRate.value;
|
||||
const urban = pack.cells.burg[i] ? pack.burgs[pack.cells.burg[i]].population * populationRate.value * urbanization.value : 0;
|
||||
const [rural, urban] = getCellPopulation(i);
|
||||
return `${si(rural+urban)} (${si(rural)} rural, urban ${si(urban)})`;
|
||||
}
|
||||
|
||||
function getPopulationTip(i) {
|
||||
const rural = pack.cells.pop[i] * populationRate.value;
|
||||
const urban = pack.cells.burg[i] ? pack.burgs[pack.cells.burg[i]].population * populationRate.value * urbanization.value : 0;
|
||||
const [rural, urban] = getCellPopulation(i);
|
||||
return `Cell population: ${si(rural+urban)}; Rural: ${si(rural)}; Urban: ${si(urban)}`;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ function drawTemp() {
|
|||
temperature.append("path").attr("d", `M0,0 h${svgWidth} v${svgHeight} h${-svgWidth} Z`).attr("fill", scheme(1 - (min - tMin) / delta)).attr("stroke", "none");
|
||||
|
||||
for (const t of isolines) {
|
||||
const path = chains.filter(c => c[0] === t).map(c => round(lineGen(c[1]))).join();
|
||||
const path = chains.filter(c => c[0] === t).map(c => round(lineGen(c[1]))).join("");
|
||||
if (!path) continue;
|
||||
const fill = scheme(1 - (t - tMin) / delta), stroke = d3.color(fill).darker(.2);
|
||||
temperature.append("path").attr("d", path).attr("fill", fill).attr("stroke", stroke);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ function editNamesbase() {
|
|||
document.getElementById("namesbaseMin").addEventListener("input", updateBaseMin);
|
||||
document.getElementById("namesbaseMax").addEventListener("input", updateBaseMax);
|
||||
document.getElementById("namesbaseDouble").addEventListener("input", updateBaseDublication);
|
||||
document.getElementById("namesbaseMulti").addEventListener("input", updateBaseMiltiwordRate);
|
||||
document.getElementById("namesbaseAdd").addEventListener("click", namesbaseAdd);
|
||||
document.getElementById("namesbaseAnalize").addEventListener("click", analizeNamesbase);
|
||||
document.getElementById("namesbaseDefault").addEventListener("click", namesbaseRestoreDefault);
|
||||
|
|
@ -46,7 +45,6 @@ function editNamesbase() {
|
|||
document.getElementById("namesbaseMin").value = nameBases[base].min;
|
||||
document.getElementById("namesbaseMax").value = nameBases[base].max;
|
||||
document.getElementById("namesbaseDouble").value = nameBases[base].d;
|
||||
document.getElementById("namesbaseMulti").value = nameBases[base].m;
|
||||
updateExamples();
|
||||
}
|
||||
|
||||
|
|
@ -67,10 +65,9 @@ function editNamesbase() {
|
|||
|
||||
function updateNamesData() {
|
||||
const base = +document.getElementById("namesbaseSelect").value;
|
||||
const b = document.getElementById("namesbaseTextarea").value.replace(/ /g, "");
|
||||
const b = document.getElementById("namesbaseTextarea").value;
|
||||
if (b.split(",").length < 3) {
|
||||
tip("The names data provided is not correct", false, "error");
|
||||
document.getElementById("namesbaseTextarea").value = nameBases[base].b;
|
||||
tip("The names data provided is too short of incorrect", false, "error");
|
||||
return;
|
||||
}
|
||||
nameBases[base].b = b;
|
||||
|
|
@ -101,12 +98,6 @@ function editNamesbase() {
|
|||
nameBases[base].d = this.value;
|
||||
}
|
||||
|
||||
function updateBaseMiltiwordRate() {
|
||||
if (isNaN(+this.value) || +this.value < 0 || +this.value > 1) {tip("Please provide a number within [0-1] range", false, "error"); return;}
|
||||
const base = +document.getElementById("namesbaseSelect").value;
|
||||
nameBases[base].m = +this.value;
|
||||
}
|
||||
|
||||
function analizeNamesbase() {
|
||||
const string = document.getElementById("namesbaseTextarea").value;
|
||||
if (!string) {tip("Names data field should not be empty", false, "error"); return;}
|
||||
|
|
@ -174,7 +165,6 @@ function editNamesbase() {
|
|||
document.getElementById("namesbaseMin").value = 5;
|
||||
document.getElementById("namesbaseMax").value = 12;
|
||||
document.getElementById("namesbaseDouble").value = "";
|
||||
document.getElementById("namesbaseMulti").value = 0;
|
||||
document.getElementById("namesbaseExamples").innerHTML = "Please provide names data";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,18 +69,11 @@ document.getElementById("options").querySelector("div.tab").addEventListener("cl
|
|||
if (id === "aboutTab") aboutContent.style.display = "block";
|
||||
});
|
||||
|
||||
document.getElementById("options").querySelectorAll("i.collapsible").forEach(el => el.addEventListener("click", collapse));
|
||||
function collapse(e) {
|
||||
const trigger = e.target;
|
||||
const section = trigger.parentElement.nextElementSibling;
|
||||
|
||||
if (section.style.display === "none") {
|
||||
section.style.display = "block";
|
||||
trigger.classList.replace("icon-down-open", "icon-up-open");
|
||||
} else {
|
||||
section.style.display = "none";
|
||||
trigger.classList.replace("icon-up-open", "icon-down-open");
|
||||
}
|
||||
// show popup with a list of Patreon supportes (updated manually, to be replaced with API call)
|
||||
function showSupporters() {
|
||||
const supporters = "Aaron Meyer, Ahmad Amerih, AstralJacks, aymeric, Billy Dean Goehring, Branndon Edwards, Chase Mayers, Curt Flood, cyninge, Dino Princip, E.M. White, es, Fondue, Fritjof Olsson, Gatsu, Johan Fröberg, Jonathan Moore, Joseph Miranda, Kate, KC138, Luke Nelson, Markus Finster, Massimo Vella, Mikey, Nathan Mitchell, Paavi1, Pat, Ryan Westcott, Sasquatch, Shawn Spencer, Sizz_TV, Timothée CALLET, UTG community, Vlad Tomash, Wil Sisney, William Merriott, Xariun, Gun Metal Games, Scott Marner, Spencer Sherman, Valerii Matskevych, Alloyed Clavicle, Stewart Walsh, Ruthlyn Mollett (Javan), Benjamin Mair-Pratt, Diagonath, Alexander Thomas, Ashley Wilson-Savoury, William Henry, Preston Brooks, JOSHUA QUALTIERI, Hilton Williams, Katharina Haase, Hisham Bedri, Ian arless, Karnat, Bird, Kevin, Jessica Thomas, Steve Hyatt, Logicspren, Alfred García, Jonathan Killstring, John Ackley, Invad3r233, Norbert Žigmund, Jennifer, PoliticsBuff, _gfx_, Maggie, Connor McMartin, Jared McDaris, BlastWind, Franc Casanova Ferrer, Dead & Devil, Michael Carmody, Valerie Elise, naikibens220, Jordon Phillips, William Pucs, The Dungeon Masters, Brady R Rathbun, J, Shadow, Matthew Tiffany, Huw Williams, Joseph Hamilton, FlippantFeline, Tamashi Toh, kms, Stephen Herron, MidnightMoon, Whakomatic x, Barished, Aaron bateson, Brice Moss, Diklyquill, PatronUser, Michael Greiner, Steven Bennett, Jacob Harrington, Miguel C., Reya C., Giant Monster Games, Noirbard, Brian Drennen, Ben Craigie, Alex Smolin, Endwords";
|
||||
alertMessage.innerHTML = "<ul style='column-count: 3; column-gap: 2em'>" + supporters.split(", ").sort().map(n => `<li>${n}</li>`).join("") + "</ul>";
|
||||
$("#alert").dialog({resizable: false, title: "Patreon Supporters", width: "30vw", position: {my: "center", at: "center", of: "svg"}});
|
||||
}
|
||||
|
||||
// Option listeners
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ function editStates() {
|
|||
path.transition().duration(dur).attrTween("stroke-dasharray", function() {return t => i(t)});
|
||||
}
|
||||
|
||||
function stateHighlightOff(event) {
|
||||
function stateHighlightOff() {
|
||||
debug.selectAll(".highlight").each(function() {
|
||||
d3.select(this).transition().duration(1000).attr("opacity", 0).remove();
|
||||
});
|
||||
|
|
@ -201,6 +201,12 @@ function editStates() {
|
|||
statesBody.select("#state-gap"+state).attr("stroke", fill);
|
||||
const halo = d3.color(fill) ? d3.color(fill).darker().hex() : "#666666";
|
||||
statesHalo.select("#state-border"+state).attr("stroke", halo);
|
||||
|
||||
// recolor regiments
|
||||
const solidColor = fill[0] === "#" ? fill : "#999";
|
||||
const darkerColor = d3.color(solidColor).darker().hex();
|
||||
armies.select("#army"+state).attr("fill", solidColor);
|
||||
armies.select("#army"+state).selectAll("g > rect:nth-of-type(2)").attr("fill", darkerColor);
|
||||
}
|
||||
|
||||
openPicker(currentFill, callback);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue