From 6603c682627e46d53a743f53518f1a1386989724 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Mon, 8 Aug 2022 23:11:18 +0100 Subject: [PATCH] Xray Displayable * Added support for image references * Added support for LayeredImage, and LayeredImageProxy * Added the ability to use show statements as a proxy for Xray displayables * Added previously omitted mask child to the visit method * Restored automatic image definitions (As a part of CG implementation effort) --- game/scripts/cg/xray.rpy | 40 ++++++++++++++++++++++++++++++++++------ game/scripts/options.rpy | 8 ++++---- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/game/scripts/cg/xray.rpy b/game/scripts/cg/xray.rpy index 8ed4424c..670f09da 100644 --- a/game/scripts/cg/xray.rpy +++ b/game/scripts/cg/xray.rpy @@ -36,13 +36,18 @@ init python: "mask", ] - def __init__(self, child, overlay, mask=Null(), radius=0.25, **kwargs): - super(Xray, self).__init__() + def __init__(self, child, overlay, mask=Null(), radius=0.25, tag_prefix="xray", **properties): + super(Xray, self).__init__(**properties) - self.child = renpy.displayable(child) - self.overlay = renpy.displayable(overlay) - self.mask = renpy.displayable(mask) + self._child = child + self._overlay = overlay + self._mask = mask + + self.child = ImageReference(child) if isinstance(child, basestring) else child + self.overlay = ImageReference(overlay) if isinstance(overlay, basestring) else overlay + self.mask = ImageReference(mask) if isinstance(mask, basestring) else mask self.radius = radius + self.tag_prefix = tag_prefix self.target = (0, 0) def render(self, width, height, st, at): @@ -69,6 +74,29 @@ init python: return rv + def per_interact(self): + tag_prefix = self.tag_prefix + redraw = False + + for layer in self.nosave: + child = getattr(self, layer) + + if isinstance(child, ImageReference): + name = getattr(self, "_{}".format(layer)) + attributes = renpy.get_attributes(name) or renpy.get_attributes("{}_{}".format(tag_prefix, layer)) + + if not attributes: + continue + + attributes = " ".join(attributes) + + child = ImageReference("{} {}".format(name, attributes)) + setattr(self, layer, child) + redraw = True + + if redraw: + renpy.redraw(self, 0) + def event(self, ev, x, y, st): if not pygame.mouse.get_focused(): @@ -84,4 +112,4 @@ init python: renpy.redraw(self, 0) def visit(self): - return [ self.child, self.overlay ] + return [ self.child, self.overlay, self.mask ] diff --git a/game/scripts/options.rpy b/game/scripts/options.rpy index 93f33760..017f28e3 100644 --- a/game/scripts/options.rpy +++ b/game/scripts/options.rpy @@ -80,10 +80,10 @@ define config.debug_image_cache = False # define config.predict_screens = False # Disable automatic image scanning -define config.automatic_images = None -define config.images_directory = None -init -1: - define config.late_images_scan = True +# define config.automatic_images = None +# define config.images_directory = None +# init -1: +# define config.late_images_scan = True # Saving and loading define config.save_directory = "Witch Trainer Silver"