Skip to content

Commit 4edc027

Browse files
authored
Merge pull request #76 from WatWowMap/iv-circles
IV Badges
2 parents f4eb7c5 + 0b9eb2f commit 4edc027

7 files changed

Lines changed: 51 additions & 13 deletions

File tree

public/base-locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@
232232
"items": "Items",
233233
"energy": "Energy",
234234
"arEligible": "AR Eligible",
235+
"ivCircles": "IV Indicators",
236+
"minIvCircle": "Minimum Circle IV",
235237
"interactionRanges": "Interaction Ranges",
236238
"cannotConnect": "\nUnable to connect to the server at this time.\nTrying again immediately will only cause more issues.\nPlease try again in a few minutes.\n\n- Map Admin Team",
237239
"madQuestText": "Native Quests"

server/src/configs/default.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
"clustering": true,
117117
"prioritizePvpInfo": false,
118118
"legacyFilter": false,
119+
"ivCircles": false,
120+
"minIvCircle": 90,
119121
"interactionRanges": false,
120122
"glow": [
121123
{"name": "Hundo", "perm": "iv", "num": 100, "value": "#ff1744", "op": "=" },

server/src/services/ui/clientOptions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ module.exports = function clientOptions(perms) {
2222
clustering: { type: 'bool', perm: ['pokemon'] },
2323
prioritizePvpInfo: { type: 'bool', perm: ['pvp'] },
2424
legacyFilter: { type: 'bool', perm: ['iv', 'stats', 'pvp'] },
25+
ivCircles: { type: 'bool', perm: ['iv'] },
26+
minIvCircle: { type: 'number', perm: ['iv'], label: '%' },
2527
interactionRanges: { type: 'bool', perm: ['pokemon'] },
2628
glow: { type: 'bool', sub: {}, perm: ['pokemon'] },
2729
},

src/assets/scss/main.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,23 @@ img {
215215
content: "×";
216216
}
217217

218+
.iv-badge {
219+
position: absolute;
220+
right: -5px;
221+
bottom: -5px;
222+
text-align: center;
223+
align-items: center;
224+
justify-content: center;
225+
background-color: rgb(110, 110, 110);
226+
border: 2px solid white;
227+
border-radius: 12px;
228+
color: white;
229+
font: bold 15px/13px Helvetica, Verdana, Tahoma;
230+
height: 16px;
231+
min-width: 14px;
232+
padding: 4px 3px 0 3px;
233+
}
234+
218235
.quest-popup-img {
219236
text-align: center;
220237
max-width: 40px;

src/components/layout/dialogs/UserOptions.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default function UserOptions({ category, toggleDialog }) {
9393
size="small"
9494
type={fullOption.type}
9595
disabled={fullOption.disabled}
96+
endAdornment={fullOption.label || ''}
9697
inputProps={{
9798
min: 0,
9899
max: 100,
@@ -107,6 +108,7 @@ export default function UserOptions({ category, toggleDialog }) {
107108
checked={localState[subOption || option]}
108109
name={subOption || option}
109110
onChange={handleChange}
111+
disabled={fullOption.disabled}
110112
/>
111113
</Grid>
112114
)

src/components/markers/pokemon.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const basicMarker = (iconUrl, pkmn, filters, iconSizes) => {
1313
})
1414
}
1515

16-
export const fancyMarker = (iconUrl, pkmn, filters, iconSizes, glow) => {
16+
export const fancyMarker = (iconUrl, pkmn, filters, iconSizes, glow, ivCircles) => {
1717
let badge
1818
switch (pkmn.bestPvp) {
1919
default: break
@@ -25,14 +25,25 @@ export const fancyMarker = (iconUrl, pkmn, filters, iconSizes, glow) => {
2525
const filterId = `${pkmn.pokemon_id}-${pkmn.form}`
2626
const size = filters.filter[filterId] ? iconSizes[filters.filter[filterId].size] : iconSizes.md
2727

28-
const pvpHtml = badge ? `
29-
<img src="/images/misc/${badge}.png"
30-
style="width:${size / 2}px;
31-
height:auto;
32-
position:absolute;
33-
right:0;
34-
bottom:0;"
35-
/>` : ''
28+
const getExtraHtml = () => {
29+
if (badge) {
30+
return `
31+
<img src="/images/misc/${badge}.png"
32+
style="width:${size / 2}px;
33+
height:auto;
34+
position:absolute;
35+
right:0;
36+
bottom:0;"
37+
/>`
38+
}
39+
if (ivCircles) {
40+
return `
41+
<div class="iv-badge">
42+
${Math.round(pkmn.iv)}
43+
</div>`
44+
}
45+
return ''
46+
}
3647

3748
return L.divIcon({
3849
iconSize: [size, size],
@@ -48,6 +59,6 @@ export const fancyMarker = (iconUrl, pkmn, filters, iconSizes, glow) => {
4859
height:${size}px;"
4960
/>
5061
</div>
51-
${pvpHtml}`,
62+
${getExtraHtml()}`,
5263
})
5364
}

src/components/tiles/Pokemon.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const PokemonTile = ({
5353
return glowValue
5454
}, [])
5555
const glowStatus = userSettings.glow ? getGlowStatus() : undefined
56-
56+
const ivCircle = userSettings.ivCircles && item.iv >= userSettings.minIvCircle
5757
useEffect(() => {
5858
const { id } = params
5959
if (id === item.id) {
@@ -73,8 +73,8 @@ const PokemonTile = ({
7373
}
7474
}}
7575
position={[item.lat, item.lon]}
76-
icon={(item.bestPvp < 4 || glowStatus)
77-
? fancyMarker(iconUrl, item, filters, iconSizes, glowStatus)
76+
icon={(item.bestPvp < 4 || glowStatus || ivCircle)
77+
? fancyMarker(iconUrl, item, filters, iconSizes, glowStatus, userSettings.ivCircles)
7878
: basicMarker(iconUrl, item, filters, iconSizes)}
7979
>
8080
<Popup position={[item.lat, item.lon]} onClose={() => delete params.id}>
@@ -112,6 +112,8 @@ const areEqual = (prev, next) => (
112112
&& !next.excludeList.includes(`${prev.item.pokemon_id}-${prev.item.form}`)
113113
&& prev.path === next.path
114114
&& prev.userSettings.legacyFilter === next.userSettings.legacyFilter
115+
&& prev.userSettings.ivCircles === next.userSettings.ivCircles
116+
&& prev.userSettings.minIvCircle === next.userSettings.minIvCircle
115117
&& prev.showCircles === next.showCircles
116118
)
117119

0 commit comments

Comments
 (0)