From f94b96104c61644ea8672d7bd1b1a11736dbd261 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Sun, 18 Jun 2023 23:18:50 +0100 Subject: [PATCH] Bug fixes * Fixed transitions for chibis * Fixed lack of floor division in col calculations for chibis * Fixed maxsize change incompatibility with chibis * Disabled chibi-related debug printing for the public build --- game/scripts/cds.rpy | 2 +- game/scripts/doll/chibi.rpy | 10 ++++++---- game/scripts/doll/clothes.rpy | 17 ++++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/game/scripts/cds.rpy b/game/scripts/cds.rpy index 4021c553..fe6458ec 100644 --- a/game/scripts/cds.rpy +++ b/game/scripts/cds.rpy @@ -10,7 +10,7 @@ python early: who, action = p func = eval(f"{who}_chibi.{action}") - print(f"Execution: {who} {action}") + # print(f"Execution: {who} {action}") def lint_chibi(p): who, action = p diff --git a/game/scripts/doll/chibi.rpy b/game/scripts/doll/chibi.rpy index 173b91f3..ca0ec0fe 100644 --- a/game/scripts/doll/chibi.rpy +++ b/game/scripts/doll/chibi.rpy @@ -37,7 +37,9 @@ init 5 python: def register(self, pose, frames, size): self.poses[pose] = (frames, size) - print(f"Registered \"{pose}\" pose for {self.name}") + + if config.developer: + print(f"Registered \"{pose}\" pose for {self.name}") @functools.cache def build_image(self, hash, pose): @@ -45,7 +47,7 @@ init 5 python: items = [v[0] for v in states.values() if v[0] and v[2]] subpath = posixpath.join("chibi", pose) - sprites = [(ltype, img, z) for i in items for ltype, img, z in i.build_image(i._hash, subpath)] + sprites = [(ltype, img, z) for i in items for ltype, img, z in i.build_image(i._hash, subpath, maxsize=None)] masks = [sprites.pop(sprites.index(i)) for i in sprites if i[0] == "mask"] sprites.sort(key=itemgetter(2)) @@ -100,11 +102,11 @@ init 5 python: if trans and st >= interval: sprite = trans(old_widget=sprite, new_widget=sprite) - cr = renpy.render(self.anim_sprite, width, height, st, at) + cr = renpy.render(sprite, width, height, st, at) sheet_width, sheet_height = cr.get_size() # Calculate the position of the current frame within the sprite sheet - sheet_cols = sheet_width / frame_width + sheet_cols = sheet_width // frame_width sheet_row = int(frame / sheet_cols) sheet_col = frame % sheet_cols frame_x = sheet_col * frame_width diff --git a/game/scripts/doll/clothes.rpy b/game/scripts/doll/clothes.rpy index 674d4722..dc45c23e 100644 --- a/game/scripts/doll/clothes.rpy +++ b/game/scripts/doll/clothes.rpy @@ -127,15 +127,18 @@ init python: return layers @functools.cache - def build_image(self, hash, subpath="", matrix=None): + def build_image(self, hash, subpath="", matrix=None, maxsize=(1010, 1200)): + # Note to self: This function is called from within the new chibi class during clothes iteration, + # as a bridge to enable colourable clothing for chibis, double-check the changes before submitting them. + if matrix is None: matrix = self.char.body.hue processors = { - "skin": lambda file, _: Transform(file, maxsize=(1010, 1200), matrixcolor=matrix), - "armfix": lambda file, _: Transform(file, maxsize=(1010, 1200), matrixcolor=matrix), - "colored": lambda file, n: self.apply_color(file, int(n)), - "default": lambda file, _: Transform(file, maxsize=(1010, 1200)), + "skin": lambda file, _: Transform(file, maxsize=maxsize, matrixcolor=matrix), + "armfix": lambda file, _: Transform(file, maxsize=maxsize, matrixcolor=matrix), + "colored": lambda file, n: self.apply_color(file, int(n), maxsize), + "default": lambda file, _: Transform(file, maxsize=maxsize), } layers = self.get_layers(hash, subpath) @@ -202,7 +205,7 @@ init python: def icon(self): return self.build_icon(self._hash) - def apply_color(self, img, n): + def apply_color(self, img, n, maxsize): """Takes image and int layer number. Used internally.""" try: c = self.color[n] @@ -228,7 +231,7 @@ init python: average = (0.3333, 0.3333, 0.3333) - return Transform(img, maxsize=(1010, 1200), matrixcolor=SepiaMatrix(c, desat=average)*OpacityMatrix(c.alpha)) + return Transform(img, maxsize=maxsize, matrixcolor=SepiaMatrix(c, desat=average)*OpacityMatrix(c.alpha)) except TypeError: print(f"Item doesn't support colors but was supplied with a list; Try removing numbered files in its directory:\n{self.__repr__()}")