Page 1 of 1

Possible to get a list of images currently shown on screen?

Posted: Thu Jan 21, 2021 9:40 am
by Woetoo
So I have an idea for a cellphone interface where the game shows a cellphone in the foreground and blurs the background image.
I realize I could create a screen, where I pass it the name of the current game background and do something with im.Blur().

But I had it in my head to make it more generic than that and have the screen "figure out" the current image background based on some mythical, yet unknown to me, list of active images.

The closest I can find at first glance is some combination of renpy.list_images() and renpy.showing(). But since one is a list of images and the other deals with displayable tags - I'm both not hopeful and somewhat concerned that looping through a list of ALL images looking for the showing ones might be too slow.

Can anyone point me in the direction of an alternate solution?
Ideally an image function that has a list of currently shown images.

I'm figuring with a list of current images, I could work out the image dimensions and hopefully only find a single image which is a full screen image (i.e. the current background).

I know the "pass the image name to the screen" is a simpler solution. But it'll bug me if I don't at least try to work through this more generic solution.
In all likelihood, there will be other problems that will make it impractical... but I had to ask.

Cheers in advance for any help offered.

Re: Possible to get a list of images currently shown on screen?

Posted: Thu Jan 21, 2021 9:58 am
by Angelo Seraphim
Hi @Woetoo
I think this only might be what you are looking for - https://www.renpy.org/doc/html/displayi ... ist_images
It states;
Returns a list of images that have been added to Ren'Py, as a list of strings with spaces between the name components.
I believe on that same page there are functions where you can get the dimensions of an image and so on.

Not sure if there's anything else, but I hope this helps.

Re: Possible to get a list of images currently shown on screen?

Posted: Thu Jan 21, 2021 10:15 am
by PyTom
What you probably want to do, in 7.4.1, is to use a blur transform. The setup:

Code: Select all

define config.gl2 = True

transform blur:
    blur 8
Then something like:

Code: Select all

show layer master at blur
call screen cellphone
show layer master

Re: Possible to get a list of images currently shown on screen?

Posted: Thu Jan 21, 2021 12:25 pm
by _ticlock_
You can also add the transform directly to the screen cellphone like this:

Code: Select all

define config.gl2 = True

screen cellphone:
    on "show" action Function(renpy.show_layer_at, linear_blur(0,8), layer='master')
    on "hide" action Function(renpy.show_layer_at, linear_blur(8,0), layer='master')
    ...

transform linear_blur(start,end):
    blur start
    linear 0.5 blur end
In this case, screen cellphone have linear blur transform when the screen is shown(called) and linear blur transform back to the normal background when the screen is hidden(returned from call statement).
If you want instantaneous transition you can remove linear 0.5

Re: Possible to get a list of images currently shown on screen?

Posted: Thu Jan 21, 2021 1:02 pm
by Woetoo
Cheers all.
I'm not seeing how each will work yet, but I can have a play. Ta.

But since it'll bug me if I don't ask... is it possible to get the list of currently displayed images?