tzhf/chatguessr

[Enhancement?] add support for webp flags

Closed this issue · 1 comments

webp is a quite popular format on the web, and it would be convenient to be able to use them for flags. from what i can tell, the only change this would require is adding an extra line in this segment, as electron should support webp by default (as should the css background-url property):

async function findFlagFile(id) {
const customFlagPaths = [
path.join(customFlagsDir, `${id}.png`),
path.join(customFlagsDir, `${id}.svg`),
];

where it gets rendered i think (for reference):

renderGuess(guess) {
const guessRow = {
Position: "",
Player: `${
guess.flag ? `<span class="flag-icon" style="background-image: url(flag:${guess.flag})"></span>` : ""
}<span class='username' style='color:${guess.color}'>${guess.username}</span>`,
Streak: { current: guess.streak, last: null },
Distance: { value: guess.distance, display: this.toMeter(guess.distance) },
Score: { value: guess.score, display: guess.score },
};

this is not high priority, just thought i'd bring it up in case it's that simple to do. i also don't know if there are any other considerations to be made. it's not that hard to convert either way (for me, that is - plus my original reason for this was discord emojis, which are also available as png apparently D: ).

tzhf commented

Webp and other formats are now supported for custom flags: 4beb223
I haven't tested webp with the css backround image yet, but i guess it should work, still not a very common format tho