mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
fix(#781): add vertices data to full json export
This commit is contained in:
parent
d54a6a44b1
commit
1142be65c6
4 changed files with 87 additions and 73 deletions
17
index.html
17
index.html
|
|
@ -5825,18 +5825,12 @@
|
||||||
|
|
||||||
<div style="margin: 1em 0 0.3em; font-weight: bold">Export To JSON</div>
|
<div style="margin: 1em 0 0.3em; font-weight: bold">Export To JSON</div>
|
||||||
<div>
|
<div>
|
||||||
<button onclick="exportToJson('Full')" data-tip="Download full data as in JSON format">full</button>
|
<button onclick="exportToJson('Full')" data-tip="Download full data in JSON">full</button>
|
||||||
<button onclick="exportToJson('Minimal')" data-tip="Download minimal data as in JSON format">minimal</button>
|
<button onclick="exportToJson('Minimal')" data-tip="Download minimal data in JSON">minimal</button>
|
||||||
<button
|
<button onclick="exportToJson('PackCells')" data-tip="Download map metadata and pack cells data in JSON">
|
||||||
onclick="exportToJson('PackCells')"
|
|
||||||
data-tip="Download map metadata and pack cells data as in JSON format"
|
|
||||||
>
|
|
||||||
pack cells
|
pack cells
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button onclick="exportToJson('GridCells')" data-tip="Download map metadata and grid cells data in JSON">
|
||||||
onclick="exportToJson('GridCells')"
|
|
||||||
data-tip="Download map metadata and grid cells data as in JSON format"
|
|
||||||
>
|
|
||||||
grid cells
|
grid cells
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -7929,7 +7923,7 @@
|
||||||
<script src="modules/ui/stylePresets.js"></script>
|
<script src="modules/ui/stylePresets.js"></script>
|
||||||
|
|
||||||
<script src="modules/ui/general.js?v=02062022"></script>
|
<script src="modules/ui/general.js?v=02062022"></script>
|
||||||
<script src="modules/ui/options.js?v=04062022"></script>
|
<script src="modules/ui/options.js?v=040620222"></script>
|
||||||
<script src="main.js?v=020620222"></script>
|
<script src="main.js?v=020620222"></script>
|
||||||
|
|
||||||
<script defer src="modules/relief-icons.js"></script>
|
<script defer src="modules/relief-icons.js"></script>
|
||||||
|
|
@ -7977,7 +7971,6 @@
|
||||||
<script defer src="modules/io/load.js?v=01062022"></script>
|
<script defer src="modules/io/load.js?v=01062022"></script>
|
||||||
<script defer src="modules/io/cloud.js?v=04062022"></script>
|
<script defer src="modules/io/cloud.js?v=04062022"></script>
|
||||||
<script defer src="modules/io/export.js?v=04062022"></script>
|
<script defer src="modules/io/export.js?v=04062022"></script>
|
||||||
<script defer src="modules/io/export-json.js"></script>
|
|
||||||
<script defer src="modules/io/formats.js"></script>
|
<script defer src="modules/io/formats.js"></script>
|
||||||
|
|
||||||
<!-- Web Components -->
|
<!-- Web Components -->
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
function exportToJson(type) {
|
export function exportToJson(type) {
|
||||||
if (customization) return tip("Map cannot be saved when edit mode is active, please exit the mode and retry", false, "error");
|
if (customization)
|
||||||
|
return tip("Data cannot be exported when edit mode is active, please exit the mode and retry", false, "error");
|
||||||
closeDialogs("#alert");
|
closeDialogs("#alert");
|
||||||
|
|
||||||
const typeMap = {
|
const typeMap = {
|
||||||
Full: getFullDataJson,
|
Full: getFullDataJson,
|
||||||
Minimal: getMinimalDataJson,
|
Minimal: getMinimalDataJson,
|
||||||
PackCells: getPackCellsDataJson,
|
PackCells: getPackCellsDataJson,
|
||||||
GridCells: getGridCellsDataJson,
|
GridCells: getGridCellsDataJson
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapData = typeMap[type]();
|
const mapData = typeMap[type]();
|
||||||
|
|
@ -20,6 +21,62 @@ function exportToJson(type) {
|
||||||
window.URL.revokeObjectURL(URL);
|
window.URL.revokeObjectURL(URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFullDataJson() {
|
||||||
|
TIME && console.time("getFullDataJson");
|
||||||
|
|
||||||
|
const info = getMapInfo();
|
||||||
|
const settings = getSettings();
|
||||||
|
const cells = getPackCellsData();
|
||||||
|
const vertices = getPackVerticesData();
|
||||||
|
const exportData = {info, settings, coords: mapCoordinates, cells, vertices, biomes: biomesData, notes, nameBases};
|
||||||
|
|
||||||
|
TIME && console.timeEnd("getFullDataJson");
|
||||||
|
return JSON.stringify(exportData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMinimalDataJson() {
|
||||||
|
TIME && console.time("getMinimalDataJson");
|
||||||
|
|
||||||
|
const info = getMapInfo();
|
||||||
|
const settings = getSettings();
|
||||||
|
const packData = {
|
||||||
|
features: pack.features,
|
||||||
|
cultures: pack.cultures,
|
||||||
|
burgs: pack.burgs,
|
||||||
|
states: pack.states,
|
||||||
|
provinces: pack.provinces,
|
||||||
|
religions: pack.religions,
|
||||||
|
rivers: pack.rivers,
|
||||||
|
markers: pack.markers
|
||||||
|
};
|
||||||
|
const exportData = {info, settings, coords: mapCoordinates, pack: packData, biomes: biomesData, notes, nameBases};
|
||||||
|
|
||||||
|
TIME && console.timeEnd("getMinimalDataJson");
|
||||||
|
return JSON.stringify(exportData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPackCellsDataJson() {
|
||||||
|
TIME && console.time("getCellsDataJson");
|
||||||
|
|
||||||
|
const info = getMapInfo();
|
||||||
|
const cells = getPackCellsData();
|
||||||
|
const exportData = {info, cells};
|
||||||
|
|
||||||
|
TIME && console.timeEnd("getCellsDataJson");
|
||||||
|
return JSON.stringify(exportData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGridCellsDataJson() {
|
||||||
|
TIME && console.time("getGridCellsDataJson");
|
||||||
|
|
||||||
|
const info = getMapInfo();
|
||||||
|
const gridCells = getGridCellsData();
|
||||||
|
const exportData = {info, gridCells};
|
||||||
|
|
||||||
|
TIME && console.log("getGridCellsDataJson");
|
||||||
|
return JSON.stringify(exportData);
|
||||||
|
}
|
||||||
|
|
||||||
function getMapInfo() {
|
function getMapInfo() {
|
||||||
const info = {
|
const info = {
|
||||||
version,
|
version,
|
||||||
|
|
@ -92,6 +149,7 @@ function getPackCellsData() {
|
||||||
religion: Array.from(pack.cells.religion),
|
religion: Array.from(pack.cells.religion),
|
||||||
province: Array.from(pack.cells.province)
|
province: Array.from(pack.cells.province)
|
||||||
};
|
};
|
||||||
|
|
||||||
const cellObjArr = [];
|
const cellObjArr = [];
|
||||||
{
|
{
|
||||||
cellConverted.i.forEach(value => {
|
cellConverted.i.forEach(value => {
|
||||||
|
|
@ -140,70 +198,28 @@ function getPackCellsData() {
|
||||||
return cellsData;
|
return cellsData;
|
||||||
}
|
}
|
||||||
|
|
||||||
//data only containing graphical appearance
|
|
||||||
function getGridCellsData() {
|
function getGridCellsData() {
|
||||||
const gridData = {
|
const gridData = {
|
||||||
|
cellsDesired: grid.cellsDesired,
|
||||||
spacing: grid.spacing,
|
spacing: grid.spacing,
|
||||||
cellsY: grid.cellsY,
|
cellsY: grid.cellsY,
|
||||||
cellsX: grid.cellsX,
|
cellsX: grid.cellsX,
|
||||||
points: grid.points,
|
points: grid.points,
|
||||||
boundary: grid.boundary
|
boundary: grid.boundary
|
||||||
}
|
|
||||||
return gridData
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFullDataJson() {
|
|
||||||
TIME && console.time("getFullDataJson");
|
|
||||||
|
|
||||||
const info = getMapInfo();
|
|
||||||
const settings = getSettings();
|
|
||||||
const cells = getPackCellsData();
|
|
||||||
const exportData = {info, settings, coords: mapCoordinates, cells, biomes: biomesData, notes, nameBases};
|
|
||||||
|
|
||||||
TIME && console.timeEnd("getFullDataJson");
|
|
||||||
return JSON.stringify(exportData);
|
|
||||||
}
|
|
||||||
|
|
||||||
// data excluding cells
|
|
||||||
function getMinimalDataJson() {
|
|
||||||
TIME && console.time("getMinimalDataJson");
|
|
||||||
|
|
||||||
const info = getMapInfo();
|
|
||||||
const settings = getSettings();
|
|
||||||
const packData = {
|
|
||||||
features: pack.features,
|
|
||||||
cultures: pack.cultures,
|
|
||||||
burgs: pack.burgs,
|
|
||||||
states: pack.states,
|
|
||||||
provinces: pack.provinces,
|
|
||||||
religions: pack.religions,
|
|
||||||
rivers: pack.rivers,
|
|
||||||
markers: pack.markers
|
|
||||||
};
|
};
|
||||||
const exportData = {info, settings, coords: mapCoordinates, pack: packData, biomes: biomesData, notes, nameBases};
|
return gridData;
|
||||||
|
|
||||||
TIME && console.timeEnd("getMinimalDataJson");
|
|
||||||
return JSON.stringify(exportData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPackCellsDataJson() {
|
function getPackVerticesData() {
|
||||||
TIME && console.time("getCellsDataJson");
|
const {vertices} = pack;
|
||||||
|
const verticesNumber = vertices.p.length;
|
||||||
const info = getMapInfo();
|
const verticesArray = new Array(verticesNumber);
|
||||||
const cells = getPackCellsData();
|
for (let i = 0; i < verticesNumber; i++) {
|
||||||
const exportData = {info, cells};
|
verticesArray[i] = {
|
||||||
|
p: vertices.p[i],
|
||||||
TIME && console.timeEnd("getCellsDataJson");
|
v: vertices.v[i],
|
||||||
return JSON.stringify(exportData);
|
c: vertices.c[i]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
return verticesArray;
|
||||||
function getGridCellsDataJson() {
|
|
||||||
TIME && console.time("getGridCellsDataJson");
|
|
||||||
|
|
||||||
const info = getMapInfo();
|
|
||||||
const gridCells = getGridCellsData()
|
|
||||||
const exportData = {info,gridCells};
|
|
||||||
|
|
||||||
TIME && console.log("getGridCellsDataJson");
|
|
||||||
return JSON.stringify(exportData);
|
|
||||||
}
|
}
|
||||||
|
|
@ -717,6 +717,11 @@ function showExportPane() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function exportToJson(type) {
|
||||||
|
const {exportToJson} = await import("../dynamic/export-json.js");
|
||||||
|
exportToJson(type);
|
||||||
|
}
|
||||||
|
|
||||||
async function showLoadPane() {
|
async function showLoadPane() {
|
||||||
$("#loadMapData").dialog({
|
$("#loadMapData").dialog({
|
||||||
title: "Load map",
|
title: "Load map",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
// version and caching control
|
// version and caching control
|
||||||
|
|
||||||
const version = "1.85.01"; // generator version, update each time
|
const version = "1.85.02"; // generator version, update each time
|
||||||
|
|
||||||
{
|
{
|
||||||
document.title += " v" + version;
|
document.title += " v" + version;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue