Some Twitch emotes have the "wrong" scale factor on the 3x image, and some Twitch emotes have the "wrong" base size. This became more apparent after #5192
This PR overrides the base size & scale factor of some emotes I've found to be problematic.
To figure out which emotes were problematic, I applied this patch & loaded the emotes I thought were broken in all scales by opening emote menu or sending them in chat, then scrolling my zoom through all the various zoom levels (can be done smarter xd)
Then I ran /debug-env to copy all emote data to clipboard, pasted it to emotes.json and ran this python script to generate to .cpp files I could paste into the 3x scale override & base size overrides
#!/usr/bin/env python3
import json
input_file = "emotes.json"
with open(input_file, "r") as fh:
raw_emote_data = fh.read()
fixed_base_size = []
fixed_3_scales = []
emote_data = json.loads(raw_emote_data)
for raw_emote in emote_data:
emote = {
"id": raw_emote["id"],
"name": raw_emote["name"],
"size1": (
int(raw_emote["size1"].replace("{", "").replace("}", "").split(",")[0]),
int(raw_emote["size1"].replace("{", "").replace("}", "").split(",")[1]),
),
"size2": (
int(raw_emote["size2"].replace("{", "").replace("}", "").split(",")[0]),
int(raw_emote["size2"].replace("{", "").replace("}", "").split(",")[1]),
),
"size3": (
int(raw_emote["size3"].replace("{", "").replace("}", "").split(",")[0]),
int(raw_emote["size3"].replace("{", "").replace("}", "").split(",")[1]),
),
}
if emote["size1"][0] != 28 or emote["size1"][1] != 28:
# Bad base size
print(f"Emote {emote['name']} has a bad size {emote}")
fixed_base_size.append(
{"name": emote["name"], "id": emote["id"], "base_size": emote["size1"]}
)
scale2 = emote["size1"][0] / emote["size2"][0]
scale3 = emote["size1"][0] / emote["size3"][0]
if scale2 != 0.5:
# Bad scale
print(f"Emote {emote['name']} has a bad 2.0 scale {emote}")
if scale3 != 0.25:
# Bad scale
print(f"Emote {emote['name']} has a bad 3.0 scale {emote}")
fixed_3_scales.append(
{"name": emote["name"], "id": emote["id"], "3.0_scale": scale3}
)
with open("fixed-base-sizes.json", "w") as fh:
fh.write(json.dumps(fixed_base_size))
with open("fixed-3-scales.json", "w") as fh:
fh.write(json.dumps(fixed_3_scales))
with open("fixed-base-sizes.cpp", "w") as fh:
for fix in fixed_base_size:
# {"49106", {27, 28}},
clean_name = fix["name"].replace("\\", "\\\\")
fh.write(
f"{{\"{fix['id']}\", {{{fix['base_size'][0]}, {fix['base_size'][1]}}}}}, /* {clean_name} */\n"
)
with open("fixed-3-scales.cpp", "w") as fh:
for fix in fixed_3_scales:
# {"49106", 0.33333333},
clean_name = fix["name"].replace("\\", "\\\\")
fh.write(f"{{\"{fix['id']}\", {fix['3.0_scale']}}}, /* {clean_name} */\n")
Some Twitch emotes have the "wrong" scale factor on the 3x image, and some Twitch emotes have the "wrong" base size. This became more apparent after #5192 This PR overrides the base size & scale factor of some emotes I've found to be problematic. To figure out which emotes were problematic, I applied this patch & loaded the emotes I thought were broken in all scales by opening emote menu or sending them in chat, then scrolling my zoom through all the various zoom levels (can be done smarter xd)
Then I ran
/debug-env
to copy all emote data to clipboard, pasted it to emotes.json and ran this python script to generate to .cpp files I could paste into the 3x scale override & base size overrides