mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41: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>
|
||||
<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('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>
|
||||
<p>Export in JSON format can be used as an API replacement.</p>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ function exportToJson(type) {
|
|||
const typeMap = {
|
||||
Full: getFullDataJson,
|
||||
Minimal: getMinimalDataJson,
|
||||
Cells: getCellsDataJson
|
||||
PackCells: getPackCellsDataJson,
|
||||
GridCells: getGridCellsDataJson,
|
||||
};
|
||||
|
||||
const mapData = typeMap[type]();
|
||||
|
|
@ -64,7 +65,7 @@ function getSettings() {
|
|||
return settings;
|
||||
}
|
||||
|
||||
function getCellsData() {
|
||||
function getPackCellsData() {
|
||||
const cellConverted = {
|
||||
i: Array.from(pack.cells.i),
|
||||
v: pack.cells.v,
|
||||
|
|
@ -91,7 +92,6 @@ function getCellsData() {
|
|||
religion: Array.from(pack.cells.religion),
|
||||
province: Array.from(pack.cells.province)
|
||||
};
|
||||
|
||||
const cellObjArr = [];
|
||||
{
|
||||
cellConverted.i.forEach(value => {
|
||||
|
|
@ -140,12 +140,24 @@ function getCellsData() {
|
|||
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() {
|
||||
TIME && console.time("getFullDataJson");
|
||||
|
||||
const info = getMapInfo();
|
||||
const settings = getSettings();
|
||||
const cells = getCellsData();
|
||||
const cells = getPackCellsData();
|
||||
const exportData = {info, settings, coords: mapCoordinates, cells, biomes: biomesData, notes, nameBases};
|
||||
|
||||
TIME && console.timeEnd("getFullDataJson");
|
||||
|
|
@ -174,13 +186,24 @@ function getMinimalDataJson() {
|
|||
return JSON.stringify(exportData);
|
||||
}
|
||||
|
||||
function getCellsDataJson() {
|
||||
function getPackCellsDataJson() {
|
||||
TIME && console.time("getCellsDataJson");
|
||||
|
||||
const info = getMapInfo();
|
||||
const cells = getCellsData();
|
||||
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue