diff --git a/main.js b/main.js
index 5ae5af74..737f972d 100644
--- a/main.js
+++ b/main.js
@@ -2070,6 +2070,7 @@ function showStatistics() {
mapId = Date.now(); // unique map id is it's creation date number
mapHistory.push({seed, width: graphWidth, height: graphHeight, template: heightmap, created: mapId});
INFO && console.log(stats);
+ track("generate", `Template: ${template} ${templateRandom}. Points: ${pointsInput.dataset.cells}`);
}
const regenerateMap = debounce(async function (options) {
diff --git a/modules/export.js b/modules/export.js
index d2b63110..45081230 100644
--- a/modules/export.js
+++ b/modules/export.js
@@ -4,6 +4,7 @@
// download map as SVG
async function saveSVG() {
TIME && console.time("saveSVG");
+ track("export", "svg");
const url = await getMapURL("svg");
const link = document.createElement("a");
link.download = getFileName() + ".svg";
@@ -17,6 +18,7 @@ async function saveSVG() {
// download map as PNG
async function savePNG() {
TIME && console.time("savePNG");
+ track("export", "png");
const url = await getMapURL("png");
const link = document.createElement("a");
@@ -47,6 +49,7 @@ async function savePNG() {
// download map as JPEG
async function saveJPEG() {
TIME && console.time("saveJPEG");
+ track("export", "jpg");
const url = await getMapURL("png");
const canvas = document.createElement("canvas");
@@ -264,7 +267,11 @@ async function getMapURL(type, options = {}) {
if (!cloneEl.getElementById("labels")) cloneEl.getElementById("textPaths")?.remove(); // removed unused textPaths
// add armies style
- if (cloneEl.getElementById("armies")) cloneEl.insertAdjacentHTML("afterbegin", "");
+ if (cloneEl.getElementById("armies"))
+ cloneEl.insertAdjacentHTML(
+ "afterbegin",
+ ""
+ );
// add xlink: for href to support svg1.1
if (type === "svg") {
@@ -372,6 +379,7 @@ function inlineStyle(clone) {
}
function saveGeoJSON_Cells() {
+ track("export", "getJSON cells");
const json = {type: "FeatureCollection", features: []};
const cells = pack.cells;
const getPopulation = i => {
@@ -402,6 +410,7 @@ function saveGeoJSON_Cells() {
}
function saveGeoJSON_Routes() {
+ track("export", "getJSON routes");
const json = {type: "FeatureCollection", features: []};
routes.selectAll("g > path").each(function () {
@@ -418,6 +427,7 @@ function saveGeoJSON_Routes() {
}
function saveGeoJSON_Rivers() {
+ track("export", "getJSON rivers");
const json = {type: "FeatureCollection", features: []};
rivers.selectAll("path").each(function () {
@@ -440,6 +450,8 @@ function saveGeoJSON_Rivers() {
}
function saveGeoJSON_Markers() {
+ // TODO: rework for new markers
+ track("export", "getJSON markers");
const json = {type: "FeatureCollection", features: []};
markers.selectAll("use").each(function () {
diff --git a/modules/load.js b/modules/load.js
index e5b60ae7..5ab04034 100644
--- a/modules/load.js
+++ b/modules/load.js
@@ -67,7 +67,8 @@ function loadMapPrompt(blob) {
});
function loadLastSavedMap() {
- WARN && console.warn('Load last saved map');
+ WARN && console.warn("Load last saved map");
+ track("load", `from browser storage`);
try {
uploadMap(blob);
} catch (error) {
@@ -78,6 +79,7 @@ function loadMapPrompt(blob) {
}
function loadMapFromURL(maplink, random) {
+ track("load", `from url`);
const URL = decodeURIComponent(maplink);
fetch(URL, {method: "GET", mode: "cors"})
@@ -93,6 +95,7 @@ function loadMapFromURL(maplink, random) {
}
function showUploadErrorMessage(error, URL, random) {
+ track("error", `map load from url`);
ERROR && console.error(error);
alertMessage.innerHTML = `Cannot load map from the ${link(URL, "link provided")}.
${random ? `A new random map is generated. ` : ""}
@@ -433,14 +436,29 @@ function parseLoadedData(data) {
// 1.0 adds a legend box
legend = svg.append("g").attr("id", "legend");
- legend.attr("font-family", "Almendra SC").attr("font-size", 13).attr("data-size", 13).attr("data-x", 99).attr("data-y", 93).attr("stroke-width", 2.5).attr("stroke", "#812929").attr("stroke-dasharray", "0 4 10 4").attr("stroke-linecap", "round");
+ legend
+ .attr("font-family", "Almendra SC")
+ .attr("font-size", 13)
+ .attr("data-size", 13)
+ .attr("data-x", 99)
+ .attr("data-y", 93)
+ .attr("stroke-width", 2.5)
+ .attr("stroke", "#812929")
+ .attr("stroke-dasharray", "0 4 10 4")
+ .attr("stroke-linecap", "round");
// 1.0 separated drawBorders fron drawStates()
- stateBorders = borders.append('g').attr('id', 'stateBorders');
- provinceBorders = borders.append('g').attr('id', 'provinceBorders');
- borders.attr('opacity', null).attr('stroke', null).attr('stroke-width', null).attr('stroke-dasharray', null).attr('stroke-linecap', null).attr('filter', null);
- stateBorders.attr('opacity', 0.8).attr('stroke', '#56566d').attr('stroke-width', 1).attr('stroke-dasharray', '2').attr('stroke-linecap', 'butt');
- provinceBorders.attr('opacity', 0.8).attr('stroke', '#56566d').attr('stroke-width', 0.5).attr('stroke-dasharray', '1').attr('stroke-linecap', 'butt');
+ stateBorders = borders.append("g").attr("id", "stateBorders");
+ provinceBorders = borders.append("g").attr("id", "provinceBorders");
+ borders
+ .attr("opacity", null)
+ .attr("stroke", null)
+ .attr("stroke-width", null)
+ .attr("stroke-dasharray", null)
+ .attr("stroke-linecap", null)
+ .attr("filter", null);
+ stateBorders.attr("opacity", 0.8).attr("stroke", "#56566d").attr("stroke-width", 1).attr("stroke-dasharray", "2").attr("stroke-linecap", "butt");
+ provinceBorders.attr("opacity", 0.8).attr("stroke", "#56566d").attr("stroke-width", 0.5).attr("stroke-dasharray", "1").attr("stroke-linecap", "butt");
// 1.0 adds state relations, provinces, forms and full names
provs = viewbox.insert('g', '#borders').attr('id', 'provs').attr('opacity', 0.6);
@@ -986,9 +1004,9 @@ function parseLoadedData(data) {
$(this).dialog('close');
mapToLoad.click();
},
- 'New map': function () {
- $(this).dialog('close');
- regenerateMap();
+ "New map": function () {
+ $(this).dialog("close");
+ regenerateMap("loading error");
},
Cancel: function () {
$(this).dialog('close');
diff --git a/modules/ui/heightmap-editor.js b/modules/ui/heightmap-editor.js
index 980d788e..783f8145 100644
--- a/modules/ui/heightmap-editor.js
+++ b/modules/ui/heightmap-editor.js
@@ -1,33 +1,4 @@
-<<<<<<< HEAD
"use strict";
-=======
-'use strict';
-
-function editHeightmap() {
- void (function selectEditMode() {
- alertMessage.innerHTML = `Heightmap is a core element on which all other data (rivers, burgs, states etc) is based.
- So the best edit approach is to
erase the secondary data and let the system automatically regenerate it on edit completion.
-
Erase mode also allows you Convert an Image into a heightmap or use Template Editor.
-
You can keep the data, but you won't be able to change the coastline.
-
Try risk mode to change the coastline and keep the data. The data will be restored as much as possible, but it can cause unpredictable errors.
-
Please save the map before editing the heightmap!
-
Check out ${link("https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Heightmap-customization", "wiki")} for guidance.
`;
-
- $('#alert').dialog({
- resizable: false,
- title: 'Edit Heightmap',
- width: '28em',
- buttons: {
- Erase: () => enterHeightmapEditMode('erase'),
- Keep: () => enterHeightmapEditMode('keep'),
- Risk: () => enterHeightmapEditMode('risk'),
- Cancel: function () {
- $(this).dialog('close');
- }
- }
- });
- })();
->>>>>>> f557701e (dropbox - import changes from alpha)
function editHeightmap(options) {
const {mode, tool} = options || {};
@@ -1089,7 +1060,8 @@ function editHeightmap(options) {
}
function openImageConverter() {
- if ($('#imageConverter').is(':visible')) return;
+ if ($("#imageConverter").is(":visible")) return;
+ track("edit", "convert image");
imageToLoad.click();
closeDialogs('#imageConverter');
diff --git a/modules/ui/options.js b/modules/ui/options.js
index 83ae9d15..bfd89ff0 100644
--- a/modules/ui/options.js
+++ b/modules/ui/options.js
@@ -665,7 +665,7 @@ function restoreDefaultOptions() {
// Sticked menu Options listeners
document.getElementById("sticked").addEventListener("click", function (event) {
const id = event.target.id;
- if (id === "newMapButton") regeneratePrompt();
+ if (id === "newMapButton") regeneratePrompt("sticky button");
else if (id === "saveButton") showSavePane();
else if (id === "exportButton") showExportPane();
else if (id === "loadButton") showLoadPane();
@@ -931,8 +931,9 @@ function enterStandardView() {
}
async function enter3dView(type) {
- const canvas = document.createElement('canvas');
- canvas.id = 'canvas3d';
+ track("click", `3d mode: ${type}`);
+ const canvas = document.createElement("canvas");
+ canvas.id = "canvas3d";
canvas.dataset.type = type;
if (type === 'heightmap3DView') {