From c3b117b8748899b5beeab7069fa6af948eaac322 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Mon, 30 Jan 2023 20:18:54 +0000 Subject: [PATCH] Bug fix * Fixed character studio --- game/scripts/wardrobe/studio.rpy | 48 +++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/game/scripts/wardrobe/studio.rpy b/game/scripts/wardrobe/studio.rpy index 7ed314cf..282811b1 100644 --- a/game/scripts/wardrobe/studio.rpy +++ b/game/scripts/wardrobe/studio.rpy @@ -5,25 +5,39 @@ default studio.choices = None default studio.drags = None init python in studio: + import os + import functools + Transform = renpy.store.Transform Flatten = renpy.store.Flatten Drag = renpy.store.Drag CHARACTERS = renpy.store.CHARACTERS + get_character_object = renpy.store.get_character_object + @functools.cache def get_faces(): - filters = ("_mask", "_skin") - d = {} + d = _dict() - for i in CHARACTERS: - d[i] = {} - for j in ("eyebrows", "eyes", "mouth", "pupils", "cheeks", "tears"): - path = "characters/{}/face/{}/".format(i, j) - d[i][j] = [x.split(path)[1].split(".webp")[0] for x in renpy.list_files() if x.startswith(path) and x.endswith(".webp") and not any(f in x for f in filters)] + for charname in CHARACTERS: + charobj = get_character_object(charname) + extensions = charobj.extensions - if j in ("cheeks", "tears"): - d[i][j].insert(0, None) - elif renpy.config.developer: - d[i][j].insert(0, None) + for part in charobj.face._face.keys(): + + path = os.path.join("characters", charname, charobj.pose, "face", part) + + 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 not fp.startswith(path) or not ext in extensions: + continue + + expressions = d.setdefault(charname, _dict()).setdefault(part, _list((None,))) + + if not expression in expressions: + expressions.append(expression) return d def get_choices(): @@ -31,12 +45,12 @@ init python in studio: for i in CHARACTERS: d[i] = {} - d[i]["eyebrows"] = faces[i]["eyebrows"].index("base") - d[i]["eyes"] = faces[i]["eyes"].index("base") - d[i]["mouth"] = faces[i]["mouth"].index("base") - d[i]["pupils"] = faces[i]["pupils"].index("mid") - d[i]["cheeks"] = faces[i]["cheeks"].index(None) - d[i]["tears"] = faces[i]["tears"].index(None) + d[i]["eyebrows"] = faces[i].get("eyebrows", [None]).index("base") + d[i]["eyes"] = faces[i].get("eyes", [None]).index("base") + d[i]["mouth"] = faces[i].get("mouth", [None]).index("base") + d[i]["pupils"] = faces[i].get("pupils", [None]).index("mid") + d[i]["cheeks"] = faces[i].get("cheeks", [None]).index(None) + d[i]["tears"] = faces[i].get("tears", [None]).index(None) d[i]["zoom"] = 0.5 d[i]["flip"] = 1 d[i]["alpha"] = 1.0