Ren'Py Help with Return button in Gallery

Nov 14, 2020
20
4
Hello everyone,

I have a small issue, I have in gallery a screen in which you can select a specific character and then you can see the unlocked scenes with this character - and here is my issue - when I click return in the scene gallery of any specific character, I get thrown back to the main menu, when I would like to go back just one step - to the gallery character selection. Can somebody help me with that? Here is my whole code for the gallery:


Code:
init python:
    galleryItems = []

    class GalleryItem:
        def __init__(self, char, label, lockedImage, unlockedImage, unlockedText, scope=None):
            self.char = char
            self.label = label
            self.lockedImage = lockedImage
            self.unlockedImage = unlockedImage
            self.unlockedText = unlockedText

            if scope is None: self.scope = {}
            else: self.scope = scope

            galleryItems.append(self)

    def updateScope(newScope):
        rv = scopeDict.copy()
        rv.update(newScope)
        return rv

    ## GALLERY ITEMS HERE
    # GalleryItem("CHARACTER", "LABEL", "LOCKED_IMAGE", "UNLOCKED_IMAGE", "UNLOCKED_TEXT", SCOPE)
    GalleryItem("Ashira", "ashirasex1", "PatreonAshiraBlack.jpg", "Day1AshiraApartment.jpg", "Ashira's Apartment Day 1")
    GalleryItem("Alero", "myLabel", "PatreonAleroBlack.jpg", "Day1AshiraAleroPool.jpg", "Ashira and Alero Swimming Pool Day 1")

default scopeDict = {}

define galleryMenu = [
    # ["CHARACTER", "IDLE_IMAGE", "HOVER_IMAGE"]
    ["Ashira", "PatreonAshiraQualityFull1.jpg", "patreonashiraqualityfullhovered.jpg"],
    ["Alero", "PatreonAleroQualityFull1.jpg", "patreonaleroqualityfullhovered.jpg"],
    ["Naomi", "PatreonNaomiQualityFull1.jpg", "patreonnaomiqualityfullhovered.jpg"],
    ["Nix", "PatreonNixQualityFull1.jpg", "patreonnixqualityfullhovered.jpg"],
    ["Odessa", "PatreonOdessaQualityFull1.jpg", "patreonodessaqualityfullhovered.jpg"],
    ["Vanessa", "PatreonVanessaQualityFull1.jpg", "patreonvanessaqualityfullhovered.jpg"]
]

screen scene_gallery():
    tag menu

    use game_menu(_("Scene Gallery"), scroll="viewport"):

            grid 2 3:
                spacing 10

                for char in galleryMenu:
                    imagebutton:
                        idle char[1]
                        hover char[2]
                        focus_mask True
                        action Show("scene_selection", character=char[0])

screen scene_selection(character):
    tag menu

    use game_menu(_("Scene Gallery"), scroll="viewport"):

        hbox:
            box_wrap True
            spacing 10

            for galleryItem in galleryItems:
                if galleryItem.char == character:
                    vbox:
                        imagebutton:
                            idle galleryItem.unlockedImage
                            insensitive galleryItem.lockedImage
                            action Replay(galleryItem.label, scope=updateScope(galleryItem.scope), locked=False)
                        if renpy.seen_label(galleryItem.label):
                            text galleryItem.unlockedText
                        else:
                            text "???"
    textbutton "Return" action Show("scene_gallery")
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
No, it doesn't work, I still jump straight back to main menu

You're invoking the gallery from the main menu's navigation screen, yes?
That's how it's designed to work.

Python:
# --- screens.rpy ---


#blah, blah.
screen navigation():

    vbox:

        #more blah, blah..

        if main_menu:
            textbutton _("Gallery") action ShowMenu("scene_gallery")

        #even more blah, blah..

Edit: Also your indenting of textbutton "Return" action ShowMenu("scene_gallery") is wrong in your original post. It needs an extra 4 spaces. So it lines up with the hbox: statement. Could be that.

As your code is now, it would put a [Return] button in the top left corner of the screen. If you didn't notice that and have been pressing the [Return] button in the lower left corner... that would take you back to the main menu.
 
Last edited:
  • Like
Reactions: HalloweenOracle
Nov 14, 2020
20
4
You're invoking the gallery from the main menu's navigation screen, yes?
That's how it's designed to work.

Python:
# --- screens.rpy ---


#blah, blah.
screen navigation():

    vbox:

        #more blah, blah..

        if main_menu:
            textbutton _("Gallery") action ShowMenu("scene_gallery")

        #even more blah, blah..

Edit: Also your indenting of textbutton "Return" action ShowMenu("scene_gallery") is wrong in your original post. It needs an extra 4 spaces. So it lines up with the hbox: statement. Could be that.

As your code is now, it would put a [Return] button in the top left corner of the screen. If you didn't notice that and have been pressing the [Return] button in the lower left corner... that would take you back to the main menu.
Thank you good sir, the proper indenting helped!

I have another question, if you can spare me a while longer - I have this
Code:
show bg ch1ashiraridingcock3 with dissolve

    ah "Let's make sure that you are happy"

    ah "I think I know quite a few tricks"

    show ch1ashiracowgirl movie

    pause

    hide ch1ashiracowgirl movie

    show bg ch1ashiraridingcock4 with dissolve
Why is it that when I click while the movie is playing to go on to the next render, it jumps back to previous render (ch1ashiraridingcock3) for a second and then it shows the next one (ch1ashiraridingcock4)?
 
Last edited:

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Why is it that when I click while the movie is playing to go on to the next render, it jumps back to previous render (ch1ashiraridingcock3) for a second and then it shows the next one (ch1ashiraridingcock4)?

Because you're using show instead of scene.

scene clears the current game UI and shows the named displayable (usually an image).

show merely places the named displayable on top of the existing scene.
So when you do hide, the image behind the image you are hiding is shown.

Better to do this (in my option):

Python:
    scene bg ch1ashiraridingcock3 with dissolve

    ah "Let's make sure that you are happy"
    ah "I think I know quite a few tricks"

    scene ch1ashiracowgirl movie
    pause

    scene bg ch1ashiraridingcock4 with dissolve

Though now, you might see a brief moment where the transparent background is visible (not sure, it can happen). Try it, I could be wrong about that one, as it mainly happens when doing stuff like show Movie(play="mymovie.webm" as bgmov. Usually adding a with dissolve fixes it in specific circumstances.

You could try a mix:

Python:
    scene bg ch1ashiraridingcock3 with dissolve

    ah "Let's make sure that you are happy"
    ah "I think I know quite a few tricks"

    show ch1ashiracowgirl movie with dissolve
    pause

    scene bg ch1ashiraridingcock4 with dissolve

My first example would be my preferred option. Though... your game... your choice.

scene exists so you don't need to keep using hide.

Edit: Also... It's generally a better idea to use pause <n> instead of pause for playing an animation or movie. Where <n> is the runtime of the movie in seconds. It will stop people who play with "auto advance forward" switched on from skipping the movie almost entirely.
 
Last edited:
  • Like
Reactions: HalloweenOracle

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,364
15,281
Why is it that when I click while the movie is playing to go on to the next render, it jumps back to previous render (ch1ashiraridingcock3) for a second and then it shows the next one (ch1ashiraridingcock4)?
It's easy to spot the reason, less to explain it.

shown image are displayed by Ren'py until they are hidden. In your code, you're hiding the movie, what make Ren'py display what was hidden by it, "bg ch1ashiraridingcock3", before it's finally told to show a new image, "bg ch1ashiraridingcock4".
A solution to your problem would be to invert those two lines:
Code:
    hide ch1ashiracowgirl movie
    show bg ch1ashiraridingcock4 with dissolve
But if you are complaining about the image being shown, I get that they aren't just sprite, but take the whole screen. What lead to the issue not being the moment you hide the movie, but the whole use of show when you should have used scene.

Edit: 79flavors beat me for two seconds ;)
 
Nov 14, 2020
20
4
You're invoking the gallery from the main menu's navigation screen, yes?
That's how it's designed to work.

Python:
# --- screens.rpy ---


#blah, blah.
screen navigation():

    vbox:

        #more blah, blah..

        if main_menu:
            textbutton _("Gallery") action ShowMenu("scene_gallery")

        #even more blah, blah..

Edit: Also your indenting of textbutton "Return" action ShowMenu("scene_gallery") is wrong in your original post. It needs an extra 4 spaces. So it lines up with the hbox: statement. Could be that.

As your code is now, it would put a [Return] button in the top left corner of the screen. If you didn't notice that and have been pressing the [Return] button in the lower left corner... that would take you back to the main menu.
Because you're using show instead of scene.

scene clears the current game UI and shows the named displayable (usually an image).

show merely places the named displayable on top of the existing scene.
So when you do hide, the image behind the image you are hiding is shown.

Better to do this (in my option):

Python:
    scene bg ch1ashiraridingcock3 with dissolve

    ah "Let's make sure that you are happy"
    ah "I think I know quite a few tricks"

    scene ch1ashiracowgirl movie
    pause

    scene bg ch1ashiraridingcock4 with dissolve

Though now, you might see a brief moment where the transparent background is visible (not sure, it can happen). Try it, I could be wrong about that one, as it mainly happens when doing stuff like show Movie(play="mymovie.webm" as bgmov. Usually adding a with dissolve fixes it in specific circumstances.

You could try a mix:

Python:
    scene bg ch1ashiraridingcock3 with dissolve

    ah "Let's make sure that you are happy"
    ah "I think I know quite a few tricks"

    show ch1ashiracowgirl movie with dissolve
    pause

    scene bg ch1ashiraridingcock4 with dissolve

My first example would be my preferred option. Though... your game... your choice.

scene exists so you don't need to keep using hide.

Edit: Also... It's generally a better idea to use pause <n> instead of pause for playing an animation or movie. Where <n> is the runtime of the movie in seconds. It will stop people who play with "auto advance forward" switched on from skipping the movie almost entirely.

Yes unfortunately the transparent screen appears...is there any other way to try and remove it?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,364
15,281
Yes unfortunately the transparent screen appears...is there any other way to try and remove it?
Wouldn't the start_image and image arguments of help with this ?

The first one show an image while the movie is starting ; it's better to use the first frame of the movie.
The second show an image when the movie is transitioning to the next image/movie. Here it would lead to some problems since you don't control when the player will decide to skip the movie (if he decide to), but it can still be a less worse solution.
 
  • Like
Reactions: HalloweenOracle
Nov 14, 2020
20
4
Wouldn't the start_image and image arguments of help with this ?

The first one show an image while the movie is starting ; it's better to use the first frame of the movie.
The second show an image when the movie is transitioning to the next image/movie. Here it would lead to some problems since you don't control when the player will decide to skip the movie (if he decide to), but it can still be a less worse solution.

It did work now, when I did the Force Recompile on Ren'py! So thank you very much for help!