* Replaced os.path.join with posixpath.join in some instances to enforce UNIX paths
62 lines
2.6 KiB
Plaintext
62 lines
2.6 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( [self.name, self.type, self.char.pose, self.id, str(self.color), str(self.char.face._hash), str(self.char.body._hash)] )
|
|
return hash(salt)
|
|
|
|
@functools.cache
|
|
def get_layers(self, hash):
|
|
tracking = self.char.face._face.get(self.tracking, None)
|
|
|
|
if tracking is None:
|
|
print(f"Invalid tracker for object: {self}")
|
|
return []
|
|
|
|
path = posixpath.join(self.modpath, "characters", self.name, self.char.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
|