Skip to content

Commit

Permalink
feat: show event stop markers if no quests/invasions
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Jan 10, 2024
1 parent ef6be7f commit 32df5e9
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 5 deletions.
6 changes: 6 additions & 0 deletions server/src/configs/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,12 @@
"md": 1,
"lg": 2,
"xl": 3
},
"event": {
"sm": 20,
"md": 40,
"lg": 60,
"xl": 80
}
}
},
Expand Down
68 changes: 64 additions & 4 deletions src/components/markers/usePokestopMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ export default function usePokestopMarker({
}, basicEqualFn)
const filters = useStore((s) => s.filters.pokestops.filter)

const [invasionMod, pokestopMod, rewardMod] = Icons.getModifiers(
const [invasionMod, pokestopMod, rewardMod, eventMod] = Icons.getModifiers(
'invasion',
'pokestop',
'reward',
'event',
)

let popupYOffset = 1.3
Expand All @@ -71,6 +72,8 @@ export default function usePokestopMarker({
const invasionSizes = []
const questIcons = []
const questSizes = []
const showcaseIcons = []
const showcaseSizes = []

if (hasInvasion) {
invasions.forEach((invasion) => {
Expand Down Expand Up @@ -185,7 +188,34 @@ export default function usePokestopMarker({
popupY += rewardMod.popupY
})
}

if (hasEvent && !hasInvasion && !hasQuest) {
events.forEach((event) => {
if (event.display_type === 8) {
showcaseIcons.unshift({
url: Icons.getPokemon(352),
})
showcaseSizes.unshift(Icons.getSize('event', filters.b7?.size))
} else if (event.display_type === 9) {
showcaseIcons.unshift({
url: Icons.getPokemon(
event.showcase_pokemon_id,
event.showcase_pokemon_form_id,
),
})
showcaseSizes.unshift(
Icons.getSize(
'event',
filters[
`f${event.showcase_pokemon_id}-${event.showcase_pokemon_form_id}`
]?.size,
),
)
}
popupYOffset += rewardMod.offsetY - 1
popupX += rewardMod.popupX
popupY += rewardMod.popupY
})
}
const totalQuestSize = questSizes.reduce((a, b) => a + b, 0)
const totalInvasionSize = invasionSizes.reduce((a, b) => a + b, 0)

Expand Down Expand Up @@ -284,7 +314,6 @@ export default function usePokestopMarker({
.map(
(invasion, i) => /* html */ `
<img
key="${invasion.icon}"
src="${invasion.icon}"
alt="${invasion.icon}"
style="
Expand All @@ -301,6 +330,37 @@ export default function usePokestopMarker({
`,
)
.join('')}
</div>`,
${showcaseIcons
.map(
(icon, i) => `
<img
src="${icon.url}"
alt="${icon.url}"
style="
width: ${showcaseSizes[i]}px;
height: ${showcaseSizes[i]}px;
bottom: ${
baseSize * 0.6 * eventMod.offsetY + showcaseSizes[i] * i
}px;
left: ${eventMod.offsetX * 50}%;
transform: translateX(-50%);
"
/>
<img
src="${Icons.getMisc('showcase')}"
style="
width: ${showcaseSizes[i] * 0.66}px;
height: ${showcaseSizes[i] * 0.66}px;
bottom: ${
baseSize * 0.3 * eventMod.offsetY + showcaseSizes[i] * i
}px;
left: ${eventMod.offsetX * 50}%;
transform: translateX(-50%);
"
/>
`,
)
.join('')}
</div>`,
})
}
2 changes: 1 addition & 1 deletion src/services/Icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class UAssets {
* @param {'sm' | 'md' | 'lg' | 'xl'} [size]
*/
getSize(category, size = 'md') {
const baseSize = this.sizes[category][size]
const baseSize = this.sizes[category]?.[size] || 20
return this.modifiers[category]
? baseSize * this.modifiers[category].sizeMultiplier
: baseSize
Expand Down

0 comments on commit 32df5e9

Please sign in to comment.