Expand matrixes support for body layers

This commit is contained in:
LoafyLemon 2023-07-27 00:56:37 +01:00
parent 34c356b29b
commit 22ce846d81
5 changed files with 13 additions and 10 deletions

View File

@ -12,17 +12,17 @@ init python:
def __init__(self, obj):
self.char = obj
self.hue = HueMatrix(0)
self.matrix = IdentityMatrix()
self.zorder = 0
self._hash = None
def set_hue(self, hue):
self.hue = HueMatrix(hue)
def set_matrix(self, matrix):
self.matrix = matrix
self.is_stale()
def generate_hash(self):
bodyparts_hash = str([x[0]._hash for x in self.char.states.values() if istype(x[0], DollBodypart) and x[2]])
salt = str( [self.char.name, self.char.pose, str(self.hue.__hash__()), bodyparts_hash])
salt = str( [self.char.name, self.char.pose, str(self.matrix.__hash__()), bodyparts_hash])
return hash(salt)
@functools.cache
@ -38,7 +38,7 @@ init python:
@functools.cache
def build_image(self, hash, matrix=None):
if matrix is None:
matrix = self.hue
matrix = self.matrix
processors = {
"default": lambda file: Transform(Image(file), matrixcolor=matrix),
@ -59,7 +59,7 @@ init python:
if not renpy.is_skipping() and self.is_stale():
hash = self._hash
sprites = self.build_image(hash, self.hue)
sprites = self.build_image(hash, self.matrix)
sprites.sort(key=itemgetter(2))
sprites = [x[1] for x in sprites]

View File

@ -138,7 +138,7 @@ init python:
# 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
matrix = self.char.body.matrix
processors = {
"skin": lambda file, _: Transform(file, maxsize=maxsize, matrixcolor=matrix),

View File

@ -115,7 +115,7 @@ init python:
@functools.cache
def build_image(self, hash, subpath="", matrix=None):
if matrix is None:
matrix = self.char.body.hue
matrix = self.char.body.matrix
processors = {
"skin": lambda file: Transform(file, matrixcolor=matrix),

View File

@ -78,7 +78,7 @@ init python:
eyemask = next((layers.pop(k, None) for k in layers if "eyemask" in k), [None])[0]
if matrix is None:
matrix = self.char.body.hue
matrix = self.char.body.matrix
processors = {
"skin": lambda file: Transform(file, matrixcolor=matrix),

View File

@ -480,7 +480,10 @@ init python:
def set_body_hue(self, arg):
"""Takes integer between 0 - 359, rotates the character body colour by given amount."""
self.body.set_hue(arg)
self.set_body_matrix(HueMatrix(arg))
def set_body_matrix(self, arg):
self.body.set_matrix(arg)
for i in self.states.values():
if i[0]: