From 04a07328fe95d1898d8a55db0ef656f56ee7b28f Mon Sep 17 00:00:00 2001 From: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Date: Tue, 26 Mar 2024 23:10:18 +0100 Subject: [PATCH] Cleanup (cherry picked from commit 17ebf501709a4b9ae82052610e06a58f34134192) --- game/scripts/wardrobe/studio.rpy | 55 ++++++++++++++------------------ 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/game/scripts/wardrobe/studio.rpy b/game/scripts/wardrobe/studio.rpy index 13fe690f..03629a54 100644 --- a/game/scripts/wardrobe/studio.rpy +++ b/game/scripts/wardrobe/studio.rpy @@ -9,58 +9,55 @@ init python in studio: import functools import posixpath - Transform = renpy.store.Transform - Flatten = renpy.store.Flatten - Drag = renpy.store.Drag - get_character_object = renpy.store.get_character_object + from store import Transform, Flatten, Drag, get_character_object @functools.cache def get_faces(): - d = _dict() + faces = _dict() for charname in renpy.store.states.dolls: charobj = get_character_object(charname) extensions = charobj.extensions + face = faces.setdefault(charname, _dict()) for part in charobj.face._face.keys(): path = posixpath.join("characters", charname, "poses", charobj.pose, "face", part) + if part in ("cheeks", "tears"): + expressions = face.setdefault(part, _list((False,))) + else: + expressions = face.setdefault(part, _list()) + for f in renpy.list_files(): fp, fn = os.path.split(f) fn, ext = os.path.splitext(fn) expression = os.path.split(fp)[1] - - if part in ("cheeks", "tears"): - expressions = d.setdefault(charname, _dict()).setdefault(part, _list((False,))) - else: - expressions = d.setdefault(charname, _dict()).setdefault(part, _list()) - if not fp.startswith(path) or not ext in extensions: continue if not expression in expressions: expressions.append(expression) - return d + return faces def get_choices(): - d = {} + choices = {} for i in renpy.store.states.dolls: - d[i] = di = {} + choices[i] = ci = {} fi = faces[i] - di["eyebrows"] = fi.get("eyebrows", [None]).index("base") - di["eyes"] = fi.get("eyes", [None]).index("base") - di["mouth"] = fi.get("mouth", [None]).index("base") - di["pupils"] = fi.get("pupils", [None]).index("mid") - di["cheeks"] = fi.get("cheeks", [False]).index(False) - di["tears"] = fi.get("tears", [False]).index(False) - di["zoom"] = 0.5 - di["flip"] = 1 - di["alpha"] = 1.0 + ci["eyebrows"] = fi.get("eyebrows", [None]).index("base") + ci["eyes"] = fi.get("eyes", [None]).index("base") + ci["mouth"] = fi.get("mouth", [None]).index("base") + ci["pupils"] = fi.get("pupils", [None]).index("mid") + ci["cheeks"] = fi.get("cheeks", [False]).index(False) + ci["tears"] = fi.get("tears", [False]).index(False) + ci["zoom"] = 0.5 + ci["flip"] = 1 + ci["alpha"] = 1.0 - d["background"] = { + choices["background"] = { "image": 0, "alpha": 1.0, "hue": 0, @@ -70,7 +67,7 @@ init python in studio: "list": ["wall_day", "castle", "forest", "quidditch_pitch", "highlight", "versus", "corridor", "custom"] } - d["overlay"] = { + choices["overlay"] = { "image": 0, "alpha": 1.0, "hue": 0, @@ -79,15 +76,11 @@ init python in studio: "blur": 0.0, "list": [None, "curtains", "card", "g_bottom", "g_left", "g_circular"] } - return d + return choices def get_drags(): active_girl = renpy.store.states.active_girl - d = {} - - for i in renpy.store.states.dolls: - d[i] = [drag_init(getattr(renpy.store, i)), (i == active_girl)] - return d + return {i: [drag_init(getattr(renpy.store, i)), (i == active_girl)] for i in renpy.store.states.dolls} def get_face(char): cho = choices[char]