forked from SilverStudioGames/WTS
66 lines
2.7 KiB
Plaintext
66 lines
2.7 KiB
Plaintext
|
init python:
|
||
|
class DollMakeup(DollCloth):
|
||
|
def __init__(self, name, categories, type, id, color, zorder=None, unlocked=False, level=0, blacklist=[], parent=None, modpath=None, tracking=None):
|
||
|
self.tracking = tracking
|
||
|
|
||
|
super().__init__(name, categories, type, id, color, zorder, unlocked, level, blacklist, parent, modpath)
|
||
|
|
||
|
def __repr__(self):
|
||
|
return f"DollMakeup(name={self.name}, categories={self.categories}, type={self.type}, id={self.id}, color={self.color}, zorder={self.zorder}, unlocked={self.unlocked}, level={self.level}, blacklist={self.blacklist}, parent={self.parent}, modpath={self.modpath or None}, tracking={self.tracking})"
|
||
|
|
||
|
def generate_hash(self):
|
||
|
salt = str( sorted( [self.name, self.type, self.id, str(self.color), str(self.char.face._hash)] ) )
|
||
|
return hash(salt)
|
||
|
|
||
|
def get_layers(self):
|
||
|
tracking = self.char.face._face.get(self.tracking, None)
|
||
|
|
||
|
if tracking is None:
|
||
|
print(f"Invalid tracker for object: {self}")
|
||
|
return []
|
||
|
|
||
|
path = os.path.join(self.modpath, "characters", self.name, self.pose, "clothes", self.type, self.id, tracking)
|
||
|
|
||
|
extensions = self.extensions
|
||
|
types = self.layer_types
|
||
|
modifiers = self.layer_modifiers
|
||
|
|
||
|
layers = {}
|
||
|
for f in renpy.list_files():
|
||
|
fp, fn = os.path.split(f)
|
||
|
fn, ext = os.path.splitext(fn)
|
||
|
|
||
|
if not fp == path or not ext in extensions:
|
||
|
continue
|
||
|
|
||
|
ltype, *tails = fn.rsplit("_")
|
||
|
|
||
|
if not ltype.isdigit() and not ltype in types:
|
||
|
print(f"Invalid layer type for file: {f}")
|
||
|
continue
|
||
|
|
||
|
zorder = z if (z := types.get(ltype)) is not None else self.zorder
|
||
|
|
||
|
if isinstance(zorder, str):
|
||
|
zorder = self.zorder + int(zorder)
|
||
|
|
||
|
if tails:
|
||
|
lmodifier, *tails = tails
|
||
|
|
||
|
if not lmodifier in modifiers:
|
||
|
print("Invalid modifier for file: {}".format(f))
|
||
|
continue
|
||
|
|
||
|
zorder_mod = modifiers.get(lmodifier)
|
||
|
zorder = (zorder + int(zorder_mod)) if lmodifier != "zorder" else int(tails[-1])
|
||
|
layers.setdefault("_".join([ltype, lmodifier]), [f, zorder])
|
||
|
else:
|
||
|
layers.setdefault(ltype, [f, zorder])
|
||
|
|
||
|
return layers
|
||
|
|
||
|
def rebuild_image(self):
|
||
|
self.layers = self.get_layers()
|
||
|
self._hash = self.generate_hash()
|
||
|
self._image_cached = False
|