mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
Option for exporting grid cell (#731)
* Added Save Option for Api-like json export. Will be updated and set to a scheme * Save Option for Api-like added * Moved UI of json export to export dialog. Moved json export to another file named export-json.js * Added Seperated json export selections - all JSON : exports all json data. - minimal JSON : exports json data without cells data. - cells JSON : exports json data only with pack.cells data. * More Stable Cell Export... * Grid cells export option.
This commit is contained in:
parent
2608a27a34
commit
6fea480fad
2 changed files with 31 additions and 7 deletions
|
|
@ -3611,7 +3611,8 @@
|
||||||
<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 as in JSON format">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 as in JSON format">minimal</button>
|
||||||
<button onclick="exportToJson('Cells')" data-tip="Download map metadata and cells data as in JSON format">cells</button>
|
<button onclick="exportToJson('PackCells')" data-tip="Download map metadata and pack cells data as in JSON format">pack cells</button>
|
||||||
|
<button onclick="exportToJson('GridCells')" data-tip="Download map metadata and grid cells data as in JSON format">grid cells</button>
|
||||||
</div>
|
</div>
|
||||||
<p>Export in JSON format can be used as an API replacement.</p>
|
<p>Export in JSON format can be used as an API replacement.</p>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ function exportToJson(type) {
|
||||||
const typeMap = {
|
const typeMap = {
|
||||||
Full: getFullDataJson,
|
Full: getFullDataJson,
|
||||||
Minimal: getMinimalDataJson,
|
Minimal: getMinimalDataJson,
|
||||||
Cells: getCellsDataJson
|
PackCells: getPackCellsDataJson,
|
||||||
|
GridCells: getGridCellsDataJson,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapData = typeMap[type]();
|
const mapData = typeMap[type]();
|
||||||
|
|
@ -64,7 +65,7 @@ function getSettings() {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCellsData() {
|
function getPackCellsData() {
|
||||||
const cellConverted = {
|
const cellConverted = {
|
||||||
i: Array.from(pack.cells.i),
|
i: Array.from(pack.cells.i),
|
||||||
v: pack.cells.v,
|
v: pack.cells.v,
|
||||||
|
|
@ -91,7 +92,6 @@ function getCellsData() {
|
||||||
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,12 +140,24 @@ function getCellsData() {
|
||||||
return cellsData;
|
return cellsData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//data only containing graphical appearance
|
||||||
|
function getGridCellsData(){
|
||||||
|
const gridData = {
|
||||||
|
spacing: grid.spacing,
|
||||||
|
cellsY: grid.cellsY,
|
||||||
|
cellsX: grid.cellsX,
|
||||||
|
points: grid.points,
|
||||||
|
boundary: grid.boundary
|
||||||
|
}
|
||||||
|
return gridData
|
||||||
|
}
|
||||||
|
|
||||||
function getFullDataJson() {
|
function getFullDataJson() {
|
||||||
TIME && console.time("getFullDataJson");
|
TIME && console.time("getFullDataJson");
|
||||||
|
|
||||||
const info = getMapInfo();
|
const info = getMapInfo();
|
||||||
const settings = getSettings();
|
const settings = getSettings();
|
||||||
const cells = getCellsData();
|
const cells = getPackCellsData();
|
||||||
const exportData = {info, settings, coords: mapCoordinates, cells, biomes: biomesData, notes, nameBases};
|
const exportData = {info, settings, coords: mapCoordinates, cells, biomes: biomesData, notes, nameBases};
|
||||||
|
|
||||||
TIME && console.timeEnd("getFullDataJson");
|
TIME && console.timeEnd("getFullDataJson");
|
||||||
|
|
@ -174,13 +186,24 @@ function getMinimalDataJson() {
|
||||||
return JSON.stringify(exportData);
|
return JSON.stringify(exportData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCellsDataJson() {
|
function getPackCellsDataJson() {
|
||||||
TIME && console.time("getCellsDataJson");
|
TIME && console.time("getCellsDataJson");
|
||||||
|
|
||||||
const info = getMapInfo();
|
const info = getMapInfo();
|
||||||
const cells = getCellsData();
|
const cells = getPackCellsData();
|
||||||
const exportData = {info, cells};
|
const exportData = {info, cells};
|
||||||
|
|
||||||
TIME && console.timeEnd("getCellsDataJson");
|
TIME && console.timeEnd("getCellsDataJson");
|
||||||
return JSON.stringify(exportData);
|
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);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue