From 19c4d958c989610d7594aa2538cdc404ad66bb0e Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Wed, 19 Oct 2022 19:55:10 +0100 Subject: [PATCH] Fallback Support * Added fallback support for clothing ids lacking chibi images * Refactored various extension formats support --- .../cho/chibi/stand/bottom/fallback/0.webp | 3 +++ game/scripts/doll/chibi.rpy | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 game/characters/cho/chibi/stand/bottom/fallback/0.webp diff --git a/game/characters/cho/chibi/stand/bottom/fallback/0.webp b/game/characters/cho/chibi/stand/bottom/fallback/0.webp new file mode 100644 index 00000000..a803a057 --- /dev/null +++ b/game/characters/cho/chibi/stand/bottom/fallback/0.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a68b683210f8a060548a4abd49dbaed6497917d25f5feee949c9b8a0b632146f +size 10838 diff --git a/game/scripts/doll/chibi.rpy b/game/scripts/doll/chibi.rpy index 6b6aff80..f60458d5 100644 --- a/game/scripts/doll/chibi.rpy +++ b/game/scripts/doll/chibi.rpy @@ -11,6 +11,8 @@ init 5 python: "extra": 1, } + extensions = [ ".jpg", ".jpeg", ".png", ".webp" ] + def __init__(self, name, doll, pose="stand", layer="screens", zorder=12, zoom=0.28, *args, **properties): super(DollChibi, self).__init__(**properties) @@ -59,7 +61,7 @@ init 5 python: name, ext = os.path.splitext(os.path.basename(fn)) frame = name.split("_")[0] - if not ext.lower() in [ ".jpg", ".jpeg", ".png", ".webp" ]: + if not ext.lower() in self.extensions: continue d = renpy.displayable(fn) @@ -90,16 +92,25 @@ init 5 python: suffix = f"_{layer}" if name.endswith(suffix): - print(f"found {layer}") zorder += modifier cid = cid.removesuffix(suffix) break - # Check if clothing type and id matches with the chibi clothing type and id - if (not equipped.type == ctype or - not equipped.id == cid): + # Check if clothing type matches + if not equipped.type == ctype: continue + # Check if clothing id matches, if not, add fallback image instead + if not equipped.id == cid: + fpath = f"{path}/{ctype}/fallback/0" + + for i in self.extensions: + f = fpath + i + + if renpy.loadable(f): + d = renpy.displayable(f) + break + groups[frame].setdefault(zorder, []).append(d) # Iterate through frame groups and nested zorder groups