diff --git a/index.html b/index.html
index fe622361..c71a7708 100644
--- a/index.html
+++ b/index.html
@@ -8063,7 +8063,7 @@
-
+
diff --git a/modules/dynamic/editors/cultures-editor.js b/modules/dynamic/editors/cultures-editor.js
index fac79955..b7218372 100644
--- a/modules/dynamic/editors/cultures-editor.js
+++ b/modules/dynamic/editors/cultures-editor.js
@@ -857,8 +857,19 @@ function closeCulturesEditor() {
}
async function uploadCulturesData() {
- const csv = await Formats.csvParser(this.files[0]);
+ const file = this.files[0];
this.value = "";
+ const csv = await file.text();
+ const data = d3.csvParse(csv, d => ({
+ i: +d.Id,
+ name: d.Name,
+ color: d.Color,
+ expansionism: +d.Expansionism,
+ type: d.Type,
+ population: +d.Population,
+ emblemsShape: d["Emblems Shape"],
+ origins: d.Origins
+ }));
const {cultures, cells} = pack;
const shapes = Object.keys(COA.shields.types)
@@ -870,20 +881,26 @@ async function uploadCulturesData() {
if (item.i) item.removed = true;
});
- for (const c of csv.iterator((a, b) => +a[0] > +b[0])) {
+ for (const culture of data) {
let current;
- if (+c.id < cultures.length) {
- current = cultures[c.id];
+ if (culture.i < cultures.length) {
+ current = cultures[culture.i];
const ratio = current.urban / (current.rural + current.urban);
- applyPopulationChange(current.rural, current.urban, c.population * (1 - ratio), c.population * ratio, +c.id);
+ applyPopulationChange(
+ current.rural,
+ current.urban,
+ culture.population * (1 - ratio),
+ culture.population * ratio,
+ culture.i
+ );
} else {
current = {i: cultures.length, center: ra(populated), area: 0, cells: 0, origin: 0, rural: 0, urban: 0};
cultures.push(current);
}
current.removed = false;
- current.name = c.name;
+ current.name = culture.name;
if (current.i) {
current.code = abbreviate(
@@ -891,10 +908,10 @@ async function uploadCulturesData() {
cultures.map(c => c.code)
);
- current.color = c.color;
- current.expansionism = +c.expansionism;
+ current.color = culture.color;
+ current.expansionism = +culture.expansionism;
- if (cultureTypes.includes(c.type)) current.type = c.type;
+ if (cultureTypes.includes(culture.type)) current.type = culture.type;
else current.type = "Generic";
}
@@ -913,13 +930,11 @@ async function uploadCulturesData() {
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;
- else current.shield = "heater";
+ culture.origins = current.i ? restoreOrigins(culture.origins || "") : [null];
+ current.shield = shapes.includes(culture.emblemsShape) ? culture.emblemsShape : "heater";
- const nameBaseIndex = nameBases.findIndex(n => n.name == c.namesbase);
+ const nameBaseIndex = nameBases.findIndex(n => n.name == culture.namesbase);
current.base = nameBaseIndex === -1 ? 0 : nameBaseIndex;
}
diff --git a/modules/io/formats.js b/modules/io/formats.js
deleted file mode 100644
index 439e124e..00000000
--- a/modules/io/formats.js
+++ /dev/null
@@ -1,24 +0,0 @@
-"use strict";
-
-window.Formats = (function () {
- async function csvParser(file, separator = ",") {
- const txt = await file.text();
- const rows = txt.split("\n");
- const headers = rows
- .shift()
- .split(separator)
- .map(x => x.toLowerCase());
- const data = rows.filter(a => a.trim() !== "").map(r => r.split(separator));
-
- return {
- headers,
- data,
- iterator: function* (sortf) {
- const dataset = sortf ? this.data.sort(sortf) : this.data;
- for (const d of dataset) yield Object.fromEntries(d.map((a, i) => [this.headers[i], a]));
- }
- };
- }
-
- return {csvParser};
-})();
diff --git a/modules/ui/editors.js b/modules/ui/editors.js
index 368229ac..a7c0c9cb 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.96.00");
+ const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.96.01");
Editor.open();
}
diff --git a/versioning.js b/versioning.js
index b2c673e1..e2cd1b6e 100644
--- a/versioning.js
+++ b/versioning.js
@@ -1,7 +1,7 @@
"use strict";
// version and caching control
-const version = "1.96.00"; // generator version, update each time
+const version = "1.96.01"; // generator version, update each time
{
document.title += " v" + version;