Bug fix + Sanity check

* Fixed Cho's Sweater 2
* Added sanity check for mismatched number of textures and colours for clothing items, with a user-friendly warning rather than a hard crash
This commit is contained in:
LoafyLemon 2023-02-13 22:59:46 +00:00
parent 7ed5b01227
commit 968b8aab01
3 changed files with 11 additions and 6 deletions

Binary file not shown.

View File

@ -714,6 +714,8 @@ label tonks_intro_E3:
$ achievements.unlock("unlockton", True) $ achievements.unlock("unlockton", True)
call popup("{size=-4}You can now summon Tonks into your office.{/size}", "Character unlocked!", "interface/icons/head/tonks.webp") call popup("{size=-4}You can now summon Tonks into your office.{/size}", "Character unlocked!", "interface/icons/head/tonks.webp")
gen "(Now that the matter is resolved, I guess I can get back to teaching Hermione...)"
$ tonks_busy = True $ tonks_busy = True
$ tonks_intro.E3_complete = True $ tonks_intro.E3_complete = True

View File

@ -166,7 +166,8 @@ init python:
try: try:
bounds = self.get_layers(hash).get("outline", [sprites[0][1]])[0] bounds = self.get_layers(hash).get("outline", [sprites[0][1]])[0]
except IndexError: except IndexError:
return Text(f"Error\n{{color=#00ffff}}{{size=-6}}ID:{self.id}{{/size}}{{/color}}", color="#ff0000") print(f"Missing textures:\n{self.__repr__()}")
return Text(f"TexErr\n{{color=#00ffff}}{{size=-6}}ID:{self.id}{{/size}}{{/color}}", color="#ff0000")
sprites.extend(self.char.body.build_image(self.char.body._hash, matrix=matrix)) sprites.extend(self.char.body.build_image(self.char.body._hash, matrix=matrix))
sprites.sort(key=itemgetter(2)) sprites.sort(key=itemgetter(2))
@ -197,8 +198,13 @@ init python:
def apply_color(self, img, n): def apply_color(self, img, n):
"""Takes image and int layer number. Used internally.""" """Takes image and int layer number. Used internally."""
try:
c = TintMatrix(self.color[n]) c = TintMatrix(self.color[n])
return Transform(img, matrixcolor=c) return Transform(img, matrixcolor=c)
except IndexError:
print(f"Mismatched number of textures and colors:\n{self.__repr__()}")
d = At(Frame(Text("IndxErr", color="#ff0000"), tile=True), blink_repeat)
return Transform(AlphaMask(d, img))
def set_color(self, n): def set_color(self, n):
"""Takes int layer number for manual color picking or a list to replace the cloth color in its entirety.""" """Takes int layer number for manual color picking or a list to replace the cloth color in its entirety."""