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
This commit is contained in:
LoafyLemon 2023-06-18 23:18:50 +01:00
parent 8fdd50dcd1
commit f94b96104c
3 changed files with 17 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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__()}")