Ren'Py Main menu dissolve + buttons Issue

Playstorepers

Member
May 24, 2020
160
79
Hey everyone,

I have created my own custom main menu, which consists of three "layers" so to say:
1 background image slideshow, which gets chosen randomly from a list of pictures
1 bar on the bottom half of the screen, which persists
all the buttons atop of that bar.

Now I have a small problem, which is almost unnoticable, but just like most small flaws in the world, I can't unsee it...

When the background picture dissolves into the next and I click at the exact timing on a button, nothing happens.
I'm guessing it has to do with the Dissolve function which according to another thread is loading a complete new screen each time, but maybe I'm wrong...

So does anyone have any ideas, how to fix this?

TLDR: Slideshow dissolve eats up all clicks on the main menu during dissolve. What can I do about it?


Code taken from other forums :

Python:
init python:
     #Fill up the images that get rotated in the main menu
    #random pic for mainmenu
    import random
    mm_imgs = [INSERT PICS HERE]
    mm_img = mm_imgs[0]

    def next_mm_img(kind="random"):
        global mm_img
        global mm_imgs
        if kind == "random":
            mm_img = random.choice(mm_imgs)
        elif kind == "progressive":
            index = mm_imgs.index(mm_img)
            index = (index+1) % len(mm_imgs)
            mm_img = mm_imgs[index]



screen main_menu():

    tag menu

    style_prefix "main_menu"

    add mm_img
    timer 8.0 action Function(next_mm_img, "random"), With(dissolve) repeat True
   
    add "gui/bottomhalf.png" #Set Main menu bar (Just a black bar)

    #Imagebutton code (Fill in all buttons here)
    imagebutton auto "gui/buttons/newgamebutton_%s.png":
        xalign 0.2
        yalign 0.95
        focus_mask True
        action Start()
 

riktor

Active Member
Nov 26, 2018
906
1,161
perhaps move the buttons to a second screen definition to use as an overlay with zorder. or even separate the background portion and show it as an underlay. either way then the background changes should occur on a lower layer without effecting focus.
 
Last edited:

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,490
7,035
Weekly bump.

If anyone has any suggestions for a workaround, I'm happy to hear them.
A simpler approach might be to have your background image and its transitions be defined with ATL.

Code:
image mm_img:
    "first_image" with dissolve
    pause 8.0
    "second_image" with dissolve
    pause 8.0
    ...
    repeat
(Essentially doing the "progressive" thing explicitly in ATL)

You can do the "random" thing in ATL using "choice":

Code:
image mm_img:
    choice:
        "first_image" with dissolve
    choice:
        "second_image" with dissolve
    (more choices)
    pause 8.0
    repeat
With your approach, Ren'py has to recognize, as a result of the timer firing, that the contents of "mm_img" has changed, and, based on that, it has to go back and restart the display of the screen. So, it's going to throw away everything it knows about the screen and re-parse it from scratch, since it doesn't know that "if" blocks haven't changed, or what other effects a change in a global variable might have on the screen, etc. That can cause a bit of a hitch in its giddy-up, which may be what you're seeing.

With the ATL approach, from the screen's point of view, the image never changes. It just happens to be animated. No need for a timer, the screen code itself isn't re-parsed, etc.
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,490
7,035
Oh, forgot to add - part of the root cause of your issue is likely to be the With(dissolve) in the timer line. When the timer fires, it's going to call the function, then it's going to execute the "With(dissolve)". The latter takes time, and Ren'py may not "move on" and redisplay the screen until that has completed. In other words, that may be inserting a half-second "dead time" into the behavior of the screen every time the timer fires. Essentially, a "sleep" command in the middle of things.
 
  • Like
Reactions: Playstorepers