fix: auto-update old burg styles

This commit is contained in:
Azgaar 2025-04-29 21:05:54 +02:00
parent 96228fe704
commit bc8ad03c0f
2 changed files with 28 additions and 7 deletions

View file

@ -313,7 +313,7 @@ window.Burgs = (() => {
];
function defineGroup(burg, populations) {
if (burg.lock) {
if (burg.lock && burg.group) {
// locked burgs: don't change group if it still exists
const group = options.burgs.groups.find(g => g.name === burg.group);
if (group) return;

View file

@ -974,13 +974,32 @@ export function resolveVersionConflicts(mapVersion) {
}
if (isOlderThan("1.109.0")) {
// v1.107.0 changeв burg groups and added customizable icons
icons.selectAll("circle, use").remove();
// v1.109.0 added customizable burg groups and icons
burgIcons.selectAll("circle, use").each(function () {
const group = this.parentNode.id;
const id = this.id.replace(/^burg/, "");
const burg = pack.burgs[id];
if (burg) burg.group = group;
});
const groups = Array.from(document.querySelectorAll("#burgIcons > g")).map(g => g.id);
options.burgs = {
groups: groups.map(name => ({name, active: true, preview: null}))
};
options.burgs = {groups: []};
burgIcons.selectAll("g").each(function () {
const name = this.id;
options.burgs.groups.push({name, active: true, preview: "watabou-city"});
const size = Number(this.getAttribute("size") || 2) * 2;
this.removeAttribute("size");
this.setAttribute("font-size", size);
this.setAttribute("stroke-width", 10);
});
anchors.selectAll("g").each(function () {
const size = Number(this.getAttribute("size") || 1);
this.removeAttribute("size");
this.setAttribute("font-size", size);
});
pack.burgs.forEach(burg => {
if (!burg.i || burg.removed) return;
@ -991,6 +1010,8 @@ export function resolveVersionConflicts(mapVersion) {
}
});
layerIsOn("toggleBurgIcons") && drawBurgIcons();
delete options.showBurgPreview;
delete options.showMFCGMap;
delete options.villageMaxPopulation;