- ${state}
@@ -83,6 +82,7 @@ function editBurgs() {
+ ${state}
`;
}
@@ -252,7 +252,7 @@ function editBurgs() {
}
function downloadBurgsData() {
- let data = "Id,Burg,State,Culture,Population,Capital,Port,Longitude,Latitude,Elevation\n"; // headers
+ let data = "Id,Burg,State,Culture,Population,Longitude,Latitude,Elevation ("+heightUnit.value+"),Capital,Port\n"; // headers
const valid = pack.burgs.filter(b => b.i && !b.removed); // all valid burgs
valid.forEach(b => {
@@ -261,20 +261,22 @@ function editBurgs() {
data += pack.states[b.state].name + ",";
data += pack.cultures[b.culture].name + ",";
data += rn(b.population * populationRate.value * urbanization.value) + ",";
- data += b.capital ? "capital," : ",";
- data += b.port ? "port," : ",";
// add geography data
data += mapCoordinates.lonW + (b.x / graphWidth) * mapCoordinates.lonT + ",";
data += mapCoordinates.latN - (b.y / graphHeight) * mapCoordinates.latT + ","; // this is inverted in QGIS otherwise
- data += parseInt(getFriendlyHeight(pack.cells.h[b.cell])) + "\n";
+ data += parseInt(getHeight(pack.cells.h[b.cell])) + ",";
+
+ // add status data
+ data += b.capital ? "capital," : ",";
+ data += b.port ? "port\n" : "\n";
});
const dataBlob = new Blob([data], {type: "text/plain"});
const url = window.URL.createObjectURL(dataBlob);
const link = document.createElement("a");
document.body.appendChild(link);
- link.download = "burgs_data" + Date.now() + ".csv";
+ link.download = getFileName("Burgs") + ".csv";
link.href = url;
link.click();
window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 2000);
diff --git a/modules/ui/cultures-editor.js b/modules/ui/cultures-editor.js
index 5062e649..9ad8bbcc 100644
--- a/modules/ui/cultures-editor.js
+++ b/modules/ui/cultures-editor.js
@@ -89,13 +89,13 @@ function editCultures() {
lines += `
-
+
${c.cells}
-
-
-
+
+
+
${si(area) + unit}
@@ -302,6 +302,7 @@ function editCultures() {
debug.select("#cultureCenters").style("display", "none");
culturesEditor.querySelectorAll(".hide").forEach(el => el.classList.add("hidden"));
+ culturesHeader.querySelector("div[data-sortby='type']").style.left = "6.8em";
culturesFooter.style.display = "none";
culturesHeader.querySelector("div[data-sortby='base']").style.marginLeft = "21px";
body.querySelectorAll("div > input, select, span, svg").forEach(e => e.style.pointerEvents = "none");
@@ -398,6 +399,7 @@ function editCultures() {
document.getElementById("culturesManuallyButtons").style.display = "none";
culturesEditor.querySelectorAll(".hide").forEach(el => el.classList.remove("hidden"));
+ culturesHeader.querySelector("div[data-sortby='type']").style.left = "15.8em";
culturesFooter.style.display = "block";
culturesHeader.querySelector("div[data-sortby='base']").style.marginLeft = "2px";
body.querySelectorAll("div > input, select, span, svg").forEach(e => e.style.pointerEvents = "all");
@@ -477,7 +479,7 @@ function editCultures() {
const url = window.URL.createObjectURL(dataBlob);
const link = document.createElement("a");
document.body.appendChild(link);
- link.download = "cultures_data" + Date.now() + ".csv";
+ link.download = getFileName("Cultures") + ".csv";
link.href = url;
link.click();
window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 2000);
diff --git a/modules/ui/diplomacy-editor.js b/modules/ui/diplomacy-editor.js
index 2869dd49..a9ca141a 100644
--- a/modules/ui/diplomacy-editor.js
+++ b/modules/ui/diplomacy-editor.js
@@ -204,7 +204,7 @@ function editDiplomacy() {
const url = window.URL.createObjectURL(dataBlob);
const link = document.createElement("a");
document.body.appendChild(link);
- link.download = "state_relations_history" + Date.now() + ".txt";
+ link.download = getFileName("Relations history") + ".txt";
link.href = url;
link.click();
window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 2000);
@@ -252,7 +252,7 @@ function editDiplomacy() {
const url = window.URL.createObjectURL(dataBlob);
const link = document.createElement("a");
document.body.appendChild(link);
- link.download = "state_relations_data" + Date.now() + ".csv";
+ link.download = getFileName("Relations") + ".csv";
link.href = url;
link.click();
window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 2000);
diff --git a/modules/ui/general.js b/modules/ui/general.js
index 2f8d2334..95f1d8c7 100644
--- a/modules/ui/general.js
+++ b/modules/ui/general.js
@@ -145,15 +145,18 @@ function updateCellInfo(point, i, g) {
// get user-friendly (real-world) height value from map data
function getFriendlyHeight(p) {
+ const packH = pack.cells.h[findCell(p[0], p[1])];
+ const gridH = grid.cells.h[findGridCell(p[0], p[1])];
+ const h = packH < 20 ? gridH : packH;
+ return getHeight(h);
+}
+
+function getHeight(h) {
const unit = heightUnit.value;
let unitRatio = 3.281; // default calculations are in feet
if (unit === "m") unitRatio = 1; // if meter
else if (unit === "f") unitRatio = 0.5468; // if fathom
- const packH = pack.cells.h[findCell(p[0], p[1])];
- const gridH = grid.cells.h[findGridCell(p[0], p[1])];
- const h = packH < 20 ? gridH : packH;
-
let height = -990;
if (h >= 20) height = Math.pow(h - 18, +heightExponentInput.value);
else if (h < 20 && h > 0) height = (h - 20) / h * 50;
@@ -226,14 +229,21 @@ function applyOption(select, option) {
select.value = option;
}
+// prevent default browser behavior for FMG-used hotkeys
+document.addEventListener("keydown", event => {
+ if ([112, 113, 117, 120, 9].includes(event.keyCode)) event.preventDefault(); // F1, F2, F6, F9, Tab
+});
+
// Hotkeys, see github.com/Azgaar/Fantasy-Map-Generator/wiki/Hotkeys
-document.addEventListener("keydown", function(event) {
+document.addEventListener("keyup", event => {
const active = document.activeElement.tagName;
if (active === "INPUT" || active === "SELECT" || active === "TEXTAREA") return; // don't trigger if user inputs a text
if (active === "DIV" && document.activeElement.contentEditable === "true") return; // don't trigger if user inputs a text
+ event.stopPropagation();
+
const key = event.keyCode, ctrl = event.ctrlKey, shift = event.shiftKey, meta = event.metaKey;
if (key === 27) {closeDialogs(); hideOptions();} // Escape to close all dialogs
- else if (key === 9) {toggleOptions(event); event.preventDefault();} // Tab to toggle options
+ else if (key === 9) toggleOptions(event); // Tab to toggle options
else if (key === 113) regeneratePrompt(); // "F2" for new map
else if (key === 46) removeElementOnKey(); // "Delete" to remove the selected element
diff --git a/modules/ui/heightmap-editor.js b/modules/ui/heightmap-editor.js
index 9fba3bd7..67116613 100644
--- a/modules/ui/heightmap-editor.js
+++ b/modules/ui/heightmap-editor.js
@@ -11,9 +11,11 @@ function editHeightmap() {
If you need to change the coastline and keep the data, you may try the risk edit option.
The data will be restored as much as possible, but the coastline change can cause unexpected fluctuations and errors.