Skip to content

Commit

Permalink
overrideByName causes legend to omit shields #1165
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua authored and Joshua committed Dec 16, 2024
1 parent 40ffdd4 commit 72f4b88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions src/js/legend_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ export default class LegendControl {
let unrecognizedNetworks = new Set();
for (let image of images) {
if (!(image.network in imagesByNetwork)) {
imagesByNetwork[image.network] = { overridesByRef: {} };
imagesByNetwork[image.network] = {
overridesByRef: {},
overridesByName: {},
};
}
let networkImages = imagesByNetwork[image.network];

Expand All @@ -476,13 +479,15 @@ export default class LegendControl {
if (!networkImages.overridesByRef[image.ref]) {
networkImages.overridesByRef[image.ref] = image.imageName;
}
} else if (image.name && shieldDef?.overrideByName?.[image.name]) {
// Store a different image for each override in the shield definition.
if (!networkImages.overridesByName[image.name]) {
networkImages.overridesByName[image.name] =
shieldDef.overrideByName[image.name].spriteBlank;
}
} else if (!networkImages.ref && image.ref) {
// Store the numbered variant of a shield if required by the shield
// definition.
networkImages.ref = image.imageName;
} else if (!networkImages.noRef && !image.ref) {
// Store the unnumbered variant of a shield if required by the shield
// definition.
networkImages.noRef = image.imageName;
}

Expand All @@ -501,6 +506,7 @@ export default class LegendControl {
images.noRef,
images.ref,
...Object.values(images.overridesByRef),
...Object.values(images.overridesByName), // Add overrides by name
].filter((i) => i);
};

Expand Down

0 comments on commit 72f4b88

Please sign in to comment.