Skip to content

Commit

Permalink
Merge pull request #1180 from joshuamanivinod/main
Browse files Browse the repository at this point in the history
overrideByName causes legend to omit shields #1165
  • Loading branch information
ZeLonewolf authored Jan 1, 2025
2 parents 92c99d8 + 048e974 commit 563b8b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 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.

14 changes: 12 additions & 2 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,6 +479,12 @@ 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.
Expand All @@ -498,9 +507,10 @@ export default class LegendControl {
let images = imagesByNetwork[network];
if (!images) return [];
return [
images.noRef,
Object.values(images.overridesByName).length > 0 ? "" : images.noRef,
images.ref,
...Object.values(images.overridesByRef),
...Object.values(images.overridesByName),
].filter((i) => i);
};

Expand Down

0 comments on commit 563b8b1

Please sign in to comment.