2023-02-07 19:22:05 +00:00
|
|
|
init 1 python:
|
|
|
|
class DollBodypart(DollCloth):
|
|
|
|
layer_types = {
|
|
|
|
"mask": "-1",
|
|
|
|
}
|
|
|
|
|
|
|
|
layer_modifiers = {
|
|
|
|
"zorder": None,
|
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(self, name, categories, type, id, zorder=None, unlocked=False, level=0, blacklist=[], parent=None, modpath=None):
|
2023-09-08 19:40:46 +00:00
|
|
|
super().__init__(name, categories, type, id, None, zorder, unlocked, level, blacklist, modpath, parent)
|
2023-02-07 19:22:05 +00:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f"DollBodypart(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})"
|
|
|
|
|
|
|
|
def generate_hash(self):
|
|
|
|
salt = str( [self.name, self.type, self.char.pose, self.id, str(self.char.body._hash)] )
|
2024-09-05 09:00:09 +00:00
|
|
|
return hashstring(salt)
|
2023-02-07 19:22:05 +00:00
|
|
|
|
|
|
|
@functools.cache
|
2023-02-19 02:56:26 +00:00
|
|
|
def get_layers(self, hash, subpath=""):
|
2023-02-22 17:50:13 +00:00
|
|
|
path = posixpath.join(self.modpath, "characters", self.name, "poses", self.char.pose, subpath, "bodyparts", self.type, self.id)
|
2023-02-07 19:22:05 +00:00
|
|
|
|
|
|
|
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 in types:
|
2024-03-26 19:31:41 +00:00
|
|
|
# print(f"Invalid layer type for file: {f}")
|
2023-02-07 19:22:05 +00:00
|
|
|
# continue
|
|
|
|
|
|
|
|
zorder = types.get(ltype) or self.zorder
|
|
|
|
|
|
|
|
if isinstance(zorder, str):
|
|
|
|
# Note: Layer uses relative zorder if it's passed as a string
|
|
|
|
zorder = self.zorder + int(zorder)
|
|
|
|
|
|
|
|
if tails:
|
|
|
|
lmodifier, *tails = tails
|
|
|
|
|
|
|
|
if not lmodifier in modifiers:
|
2024-03-26 19:31:41 +00:00
|
|
|
print(f"Invalid modifier for file: {f}")
|
2023-02-07 19:22:05 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
zorder_mod = modifiers.get(lmodifier)
|
|
|
|
zorder = (zorder + int(zorder_mod)) if lmodifier != "zorder" else int(tails[-1])
|
2023-07-26 17:54:30 +00:00
|
|
|
layers.setdefault("_".join([ltype, lmodifier, str(zorder)]), [f, zorder])
|
2023-02-07 19:22:05 +00:00
|
|
|
else:
|
|
|
|
layers.setdefault(ltype, [f, zorder])
|
|
|
|
|
|
|
|
return layers
|
|
|
|
|
|
|
|
def apply_color(self, img, n):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def set_color(self, n):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def reset_color(self, n=None):
|
|
|
|
raise NotImplementedError
|