Skip to content

Commit

Permalink
Merge branch 'main' into peru
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeLonewolf authored Jan 1, 2025
2 parents eac568e + 563b8b1 commit 49a8780
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 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.

10 changes: 5 additions & 5 deletions shieldlib/src/shield_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export function triangleDownShield(
rectWidth: number
): Partial<ShieldDefinition> {
textColor = textColor ?? strokeColor;
radius = radius ?? 2;
radius = radius ?? 3;

return {
shapeBlank: {
Expand All @@ -232,10 +232,10 @@ export function triangleDownShield(
},
textLayout: textConstraint("triangleDown"),
padding: {
left: 1,
right: 1,
top: 2,
bottom: 1,
left: 0,
right: 0,
top: 3,
bottom: 0,
},
textColor,
};
Expand Down
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
6 changes: 0 additions & 6 deletions src/js/shield_defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ export function loadShields() {
shields["default"] = {
textColor: Color.shields.black,
textHaloColor: Color.backgroundFill,
padding: {
left: 3,
right: 3,
top: 3,
bottom: 3,
},
};

// NORTH AMERICA
Expand Down

0 comments on commit 49a8780

Please sign in to comment.