Avoid using screens for chibis

Not exactly sure what to do with the screens for saves compat tbh, should be fine either way and maybe removing the definitions will work
This commit is contained in:
Gouvernathor 2024-04-03 01:33:13 +02:00
parent 00eda2aae5
commit c0bc1cd69f

View File

@ -1,5 +1,4 @@
# Screen used by chibi class (each chibi object derives its own uniquely tagged screen from this one)
# Screens left for saves compat
screen chibi(chibi_object):
zorder chibi_object.zorder
sensitive False
@ -35,6 +34,21 @@ label chibi_emote(emote, name):
default chibi_moves = {}
init -1 python:
def chibi_displayable(chibi_object):
return At(Fixed(*chibi_object.displayables(), fit_first=True), chibi_object.transform)
def chibi_emote_displayable(emote, chibi_object):
if chibi_object.flip:
xzoom = -1
else:
xzoom = 1
if chibi_object.tag in ("genie", "snape"):
offset = (int(75*ChibiRoom.get().scale), int(-200*ChibiRoom.get().scale))
else:
offset = (int(50*ChibiRoom.get().scale), int(-170*ChibiRoom.get().scale))
# TODO: test in which order the transforms should be put
return At(f"emo_{emote}", emote_effect, Transform(anchor=(.5, 1.), pos=chibi_object.pos, zoom=ChibiRoom.get().scale, xzoom=xzoom, offset=offset))
def update_chibi(name):
"""Update the chibi object for a given character."""
# TODO: Remove once chibi is ready.
@ -136,37 +150,25 @@ init -1 python:
self.special = None
self.transform = None
# Define a screen for the chibi
self.screen_tag = f"{tag}_chibi"
renpy.define_screen(self.screen_tag, Chibi._screen, tag=self.screen_tag, zorder="chibi_object.zorder")
self.screen_tag = screen_tag = f"{tag}_chibi"
config.tag_layer[screen_tag] = "master"
# Define a screen for the chibi emote
self.emote_tag = f"{tag}_chibi_emote"
renpy.define_screen(self.emote_tag, Chibi._emote_screen, tag=self.emote_tag, zorder="chibi_object.zorder")
@staticmethod
def _screen(chibi_object, **kwargs):
# Emulate a Ren'py `use` statement to derive a chibi screen from the generic one
renpy.use_screen("chibi", chibi_object, _name=kwargs["_name"], _scope=kwargs["_scope"])
@staticmethod
def _emote_screen(emote, chibi_object, **kwargs):
# Emulate a Ren'py `use` statement to derive a chibi_emote screen from the generic one
renpy.use_screen("chibi_emote", emote, chibi_object, _name=kwargs["_name"], _scope=kwargs["_scope"])
self.emote_tag = emote_tag = f"{tag}_chibi_emote"
config.tag_layer[emote_tag] = "master"
def show(self):
renpy.show_screen(self.screen_tag, chibi_object=self)
renpy.show(self.screen_tag, zorder=self.zorder, what=chibi_displayable(self))
def hide(self):
renpy.hide_screen(self.screen_tag)
renpy.hide_screen(self.emote_tag)
renpy.hide(self.screen_tag)
renpy.hide(self.emote_tag)
def emote(self, emote=None):
if renpy.get_screen(self.emote_tag):
renpy.hide_screen(self.emote_tag)
if renpy.showing(self.emote_tag):
renpy.hide(self.emote_tag)
renpy.pause(0.2) # Pause for duration of emote_effect
if emote:
renpy.show_screen(self.emote_tag, emote=emote, chibi_object=self)
renpy.show(self.emote_tag, zorder=self.zorder, what=chibi_emote_displayable(emote, self))
def update(self):
self.clear()