WTS/game/scripts/doll/makeup.rpy
LoafyLemon c1b04f6ccd IO Overhaul, Refactoring, and more
* Refactored DollFace
* Refactored DollBody
* Refactored DollCum
* Refactored DollCloth
* Refactored Doll
* Refactored clothing item zorders
* Refactored implementation of body, face, cum, clothing layers
* Refactored function calls
* Removed DollLipstick
* Added DollMakeup class, allowing adding dynamic clothes tracking face states
* Added DollClothDynamic, allowing dynamic clothes tracking other cloth states with bangs support
* Added cache to frequently called functions, drastically reducing the overhead
* Added hash system, reducing clone redundancy
* Added layer modifiers support for all types (face, body, cum, clothes etc.)
* Added support for an arbitrary number of equipped multislot clothing items (makeup, tattoos, piercings, etc.)
* Simplified initialization for clothing items and dolls
* Simplified class function calls
* Reduced the number of image creation calls
* Added hue support for additional skin layers
* Added displayable support to image cropping function
* Replaced store cache with built-in functools cache for _list_files function
* Refactored all character files
* and more...
2023-01-14 23:04:54 +00:00

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