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)
This commit is contained in:
LoafyLemon 2022-08-08 23:11:18 +01:00
parent 38214d719e
commit 6603c68262
2 changed files with 38 additions and 10 deletions

View File

@ -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 ]

View File

@ -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"