Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Azgaar authored and sofronaspe committed Jan 11, 2025
1 parent 281abf4 commit 31c1303
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8385,7 +8385,7 @@

<script defer src="modules/relief-icons.js?v=1.99.05"></script>
<script defer src="modules/ui/style.js?v=1.104.0"></script>
<script defer src="modules/ui/editors.js?v=1.105.11"></script>
<script defer src="modules/ui/editors.js?v=1.105.23"></script>
<script defer src="modules/ui/tools.js?v=1.105.12"></script>
<script defer src="modules/ui/world-configurator.js?v=1.105.4"></script>
<script defer src="modules/ui/heightmap-editor.js?v=1.105.2"></script>
Expand Down
35 changes: 20 additions & 15 deletions modules/dynamic/editors/cultures-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,13 @@ function cultureChangeName() {
}

function cultureRegenerateName() {
const culture = +this.parentNode.dataset.id;
const name = Names.getCultureShort(culture);
const cultureId = +this.parentNode.dataset.id;
const base = pack.cultures[cultureId].base;
if (!nameBases[base]) return tip("Namesbase is not defined, please select a valid namesbase", false, "error", 5000);

const name = Names.getCultureShort(cultureId);
this.parentNode.querySelector("input.cultureName").value = name;
pack.cultures[culture].name = name;
pack.cultures[cultureId].name = name;
}

function cultureChangeExpansionism() {
Expand Down Expand Up @@ -494,12 +497,15 @@ function cultureRegenerateBurgs() {
if (customization === 4) return;

const cultureId = +this.parentNode.dataset.id;
const cBurgs = pack.burgs.filter(b => b.culture === cultureId && !b.lock);
cBurgs.forEach(b => {
const base = pack.cultures[cultureId].base;
if (!nameBases[base]) return tip("Namesbase is not defined, please select a valid namesbase", false, "error", 5000);

const cultureBurgs = pack.burgs.filter(b => b.culture === cultureId && !b.removed && !b.lock);
cultureBurgs.forEach(b => {
b.name = Names.getCulture(cultureId);
labels.select("[data-id='" + b.i + "']").text(b.name);
});
tip(`Names for ${cBurgs.length} burgs are regenerated`, false, "success");
tip(`Names for ${cultureBurgs.length} burgs are regenerated`, false, "success");
}

function removeCulture(cultureId) {
Expand Down Expand Up @@ -849,14 +855,15 @@ async function uploadCulturesData() {
this.value = "";
const csv = await file.text();
const data = d3.csvParse(csv, d => ({
i: +d.Id,
name: d.Name,
i: +d.Id,
color: d.Color,
expansionism: +d.Expansionism,
type: d.Type,
population: +d.Population,
emblemsShape: d["Emblems Shape"],
origins: d.Origins
origins: d.Origins,
namesbase: d.Namesbase
}));

const {cultures, cells} = pack;
Expand All @@ -883,7 +890,7 @@ async function uploadCulturesData() {
culture.i
);
} else {
current = {i: cultures.length, center: ra(populated), area: 0, cells: 0, origin: 0, rural: 0, urban: 0};
current = {i: cultures.length, center: ra(populated), area: 0, cells: 0, origins: [0], rural: 0, urban: 0};
cultures.push(current);
}

Expand All @@ -903,6 +910,10 @@ async function uploadCulturesData() {
else current.type = "Generic";
}

culture.origins = current.i ? restoreOrigins(culture.origins || "") : [null];
current.shield = shapes.includes(culture.emblemsShape) ? culture.emblemsShape : "heater";
current.base = nameBases.findIndex(n => n.name == culture.namesbase); // can be -1 if namesbase is not found

function restoreOrigins(originsString) {
const originNames = originsString
.replaceAll('"', "")
Expand All @@ -918,12 +929,6 @@ async function uploadCulturesData() {
current.origins = originIds.filter(id => id !== null);
if (!current.origins.length) current.origins = [0];
}

culture.origins = current.i ? restoreOrigins(culture.origins || "") : [null];
current.shield = shapes.includes(culture.emblemsShape) ? culture.emblemsShape : "heater";

const nameBaseIndex = nameBases.findIndex(n => n.name == culture.namesbase);
current.base = nameBaseIndex === -1 ? 0 : nameBaseIndex;
}

cultures.filter(c => c.removed).forEach(c => removeCulture(c.i));
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/editors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ async function editStates() {

async function editCultures() {
if (customization) return;
const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.105.11");
const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.105.23");
Editor.open();
}

Expand Down
2 changes: 1 addition & 1 deletion versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2
*/

const VERSION = "1.105.22";
const VERSION = "1.105.23";
if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function");

{
Expand Down

0 comments on commit 31c1303

Please sign in to comment.