From a617dda3ad7dbc50aee384a1d0e0bd3a2f98035b Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 28 Jun 2022 22:11:32 +0300 Subject: [PATCH] fix: cultures upload --- .gitignore | 3 +- index.html | 2 +- modules/dynamic/editors/cultures-editor.js | 39 ++++++++++++++++------ modules/ui/editors.js | 2 +- versioning.js | 2 +- 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index a110f3e5..daf5cd1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.bat .vscode .idea -.DS_Store \ No newline at end of file +/node_modules diff --git a/index.html b/index.html index b8f1d208..5b94ff0d 100644 --- a/index.html +++ b/index.html @@ -7825,7 +7825,7 @@ - + diff --git a/modules/dynamic/editors/cultures-editor.js b/modules/dynamic/editors/cultures-editor.js index b5e329ce..fc663aee 100644 --- a/modules/dynamic/editors/cultures-editor.js +++ b/modules/dynamic/editors/cultures-editor.js @@ -883,18 +883,37 @@ async function uploadCulturesData() { } current.removed = false; - current.name = c.culture; - current.code = abbreviate( - current.name, - cultures.map(c => c.code) - ); + current.name = c.name; - current.color = c.color; - current.expansionism = +c.expansionism; - current.origins = JSON.parse(c.origins); + if (current.i) { + current.code = abbreviate( + current.name, + cultures.map(c => c.code) + ); - if (cultureTypes.includes(c.type)) current.type = c.type; - else current.type = "Generic"; + current.color = c.color; + current.expansionism = +c.expansionism; + + if (cultureTypes.includes(c.type)) current.type = c.type; + else current.type = "Generic"; + } + + function restoreOrigins(originsString) { + const originNames = originsString + .replaceAll('"', "") + .split(",") + .map(s => s.trim()) + .filter(s => s); + + const originIds = originNames.map(name => { + const id = cultures.findIndex(c => c.name === name); + return id === -1 ? null : id; + }); + + current.origins = originIds.filter(id => id !== null); + if (!current.origins.length) current.origins = [0]; + } + c.origins = current.i ? restoreOrigins(c.origins) : [null]; const shieldShape = c["emblems shape"].toLowerCase(); if (shapes.includes(shieldShape)) current.shield = shieldShape; diff --git a/modules/ui/editors.js b/modules/ui/editors.js index d0403b0a..df7291f1 100644 --- a/modules/ui/editors.js +++ b/modules/ui/editors.js @@ -1182,7 +1182,7 @@ async function editStates() { async function editCultures() { if (customization) return; - const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.87.01"); + const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.87.06"); Editor.open(); } diff --git a/versioning.js b/versioning.js index 81e279db..90ed8a41 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.87.05"; // generator version, update each time +const version = "1.87.06"; // generator version, update each time { document.title += " v" + version;