* Fixed character studio
This commit is contained in:
LoafyLemon 2023-01-30 20:18:54 +00:00
parent e8a617ac7b
commit c3b117b874

View File

@ -5,25 +5,39 @@ default studio.choices = None
default studio.drags = None default studio.drags = None
init python in studio: init python in studio:
import os
import functools
Transform = renpy.store.Transform Transform = renpy.store.Transform
Flatten = renpy.store.Flatten Flatten = renpy.store.Flatten
Drag = renpy.store.Drag Drag = renpy.store.Drag
CHARACTERS = renpy.store.CHARACTERS CHARACTERS = renpy.store.CHARACTERS
get_character_object = renpy.store.get_character_object
@functools.cache
def get_faces(): def get_faces():
filters = ("_mask", "_skin") d = _dict()
d = {}
for i in CHARACTERS: for charname in CHARACTERS:
d[i] = {} charobj = get_character_object(charname)
for j in ("eyebrows", "eyes", "mouth", "pupils", "cheeks", "tears"): extensions = charobj.extensions
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)]
if j in ("cheeks", "tears"): for part in charobj.face._face.keys():
d[i][j].insert(0, None)
elif renpy.config.developer: path = os.path.join("characters", charname, charobj.pose, "face", part)
d[i][j].insert(0, None)
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 return d
def get_choices(): def get_choices():
@ -31,12 +45,12 @@ init python in studio:
for i in CHARACTERS: for i in CHARACTERS:
d[i] = {} d[i] = {}
d[i]["eyebrows"] = faces[i]["eyebrows"].index("base") d[i]["eyebrows"] = faces[i].get("eyebrows", [None]).index("base")
d[i]["eyes"] = faces[i]["eyes"].index("base") d[i]["eyes"] = faces[i].get("eyes", [None]).index("base")
d[i]["mouth"] = faces[i]["mouth"].index("base") d[i]["mouth"] = faces[i].get("mouth", [None]).index("base")
d[i]["pupils"] = faces[i]["pupils"].index("mid") d[i]["pupils"] = faces[i].get("pupils", [None]).index("mid")
d[i]["cheeks"] = faces[i]["cheeks"].index(None) d[i]["cheeks"] = faces[i].get("cheeks", [None]).index(None)
d[i]["tears"] = faces[i]["tears"].index(None) d[i]["tears"] = faces[i].get("tears", [None]).index(None)
d[i]["zoom"] = 0.5 d[i]["zoom"] = 0.5
d[i]["flip"] = 1 d[i]["flip"] = 1
d[i]["alpha"] = 1.0 d[i]["alpha"] = 1.0