From 6fea480fad01e800b0b90866181c9f2f7ca6da59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Efruz=20Y=C4=B1ld=C4=B1r=C4=B1r?= <30903352+yldrefruz@users.noreply.github.com> Date: Fri, 28 Jan 2022 14:44:46 +0300 Subject: [PATCH] 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. --- index.html | 3 ++- modules/export-json.js | 35 +++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index b8bcb074..6c1ea9cf 100644 --- a/index.html +++ b/index.html @@ -3611,7 +3611,8 @@
Export in JSON format can be used as an API replacement.
diff --git a/modules/export-json.js b/modules/export-json.js index b4c62916..28d87a09 100644 --- a/modules/export-json.js +++ b/modules/export-json.js @@ -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); +} \ No newline at end of file