lagging return button (unpredicted image?)

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
Qlara
Regular
Posts: 80
Joined: Fri Nov 28, 2014 10:22 am
Completed: Carmilla
Skype: kantonija
itch: visualgothic
Location: Berlin
Contact:

lagging return button (unpredicted image?)

#1 Post by Qlara »

I have a screen that shows a chapter overview. Upon hover on the chapter title (left), an image and synopsis appear to the right.
screenshot0001.png
Quite often the return button will not respond. The other buttons keep working. Image load log shows "unpredicted image".
I've optimized the images to the right as well as I could, but the problem persists.
In addition, hovering has started to produce two hover sounds. :?

Code: Select all

screen chaptitles:
    tag menu 
    style_prefix "chaptitles"
    add "gui/chaps.png" 
    vbox:
        xpos .17
        ypos  .12
        spacing gui.navigation_spacing    
        frame:            
            vbox: 
                textbutton _("  + Editor's Preface") action Start("chap00") hovered ShowTransient("chapentry00") unhovered Hide("chapentry00")
                text "{size=14} {/size}"

                textbutton _("  1: A Guest"):
                    if persistent.unlock_chap01:
                        action Start("chap01") hovered ShowTransient("chapentry01") unhovered Hide("chapentry01") 
                    else:
                        action ShowTransient("chapentry01") hovered ShowTransient("chapentry01") unhovered Hide("chapentry01")
                
                textbutton _("  2: Drifting"):
                    if persistent.unlock_chap04:
                        action Start("chap04") hovered ShowTransient("chapentry02") unhovered Hide("chapentry02") 
                    else:
                        action ShowTransient("chapentry02") hovered ShowTransient("chapentry02") unhovered Hide("chapentry02")

                textbutton _("  3: Descending"):
                    if persistent.unlock_chap06:
                        action Start("chap06") hovered ShowTransient("chapentry03") unhovered Hide("chapentry03") 
                    else:
                        action ShowTransient("chapentry03") hovered ShowTransient("chapentry03") unhovered Hide("chapentry03")
                
                textbutton _("  4: The Story"):
                    if persistent.unlock_chap10:
                        action Start("chap10") hovered ShowTransient("chapentry04") unhovered Hide("chapentry04") 
                    else:
                        action ShowTransient("chapentry04") hovered ShowTransient("chapentry04") unhovered Hide("chapentry04")
                
                textbutton _("  5: Discovery"):
                    if persistent.unlock_chap13:
                        action Start("chap13") hovered ShowTransient("chapentry05") unhovered Hide("chapentry05")  
                    else:
                        action ShowTransient("chapentry05") hovered ShowTransient("chapentry05") unhovered Hide("chapentry05")
                
    textbutton _("Return"):
        style "chaptitles_return_button"
        action Return()

style chaptitles_frame is empty
style chaptitles_vbox is vbox
style chaptitles_return_button is return_button
style chaptitles_return_button_text is return_button_text
style chaptitles_text is gui_text
style chaptitles_title is main_menu_text
style chaptitles_textbutton is navi_button

style chaptitles_return_button:
    xpos 280    
    ypos 570

style chaptitles_frame:
    xsize 320
    yfill True
    xpos 10

style chaptitles_vbox:
    ypos 80
    xmaximum 300

style chaptitles_text:
    properties gui.text_properties("main_menu", accent=True)

style chaptitles_title:
    properties gui.text_properties("title")

style chaptitles_textbutton_text:
    idle_color '#778799'
    hover_color '#90BCDD'

Code: Select all

screen chapentry:
    tag menu 
    use chaptitles
    style_prefix "chapentry"
   
    frame: 
        vbox:
            label " "
            text " "
                   
style chapentry_frame is empty
style chapentry_vbox is vbox
style chapentry_text is gui_text
style chapentry_label is entry_label

style chapentry_text:
    xalign .5
    size 21
    font "fonts/Alegreya-Regular.ttf"
    color "#9BB8FF"
    ypos 400

style chapentry_frame:
    xsize 420
    xpos 685
    yfill True
    ymargin 100

style chapentry_label:
    xsize 420
    xalign .5

style chapentry_vbox:
    xsize 400
    xalign .5

style chapentry_label_text:
    xalign .5
    size 55
    font "fonts/FoglihtenNo04-070.otf"
    color "#9BB8FF"

Code: Select all

screen chapentry01: 
    use chaptitles
    style_prefix "chapentry"
    add "gui/overlay/ch1over.jpg" pos (650, 72)
    frame: 
        label "A Guest" 
        vbox:
            text "Chapter 1:"              
            text "In which Laura introduces her home and a mysterious guest arrives at the castle."

User avatar
Qlara
Regular
Posts: 80
Joined: Fri Nov 28, 2014 10:22 am
Completed: Carmilla
Skype: kantonija
itch: visualgothic
Location: Berlin
Contact:

Re: lagging return button (unpredicted image?)

#2 Post by Qlara »

I understand this is an ugly question, but I really need help, even just a pointer. I've given up on almost all of my issues here (none of which seem to have solutions), but I'd really like to solve this one as, otherwise, I have to remove the whole menu from the game.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: lagging return button (unpredicted image?)

#3 Post by gas »

Instead of a transient screen use tooltip, and everything will be fine.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: lagging return button (unpredicted image?)

#4 Post by kivik »

Oh man! I didn't know what ShowTransient is for, but having looked through the documentation and your code I finally understand it, and I think I know what the problem is in your code.

Your screen code has a recursion going on - each time you hover over a button, it shows a new screen - and your new screen has the title on the left and the entries on the right, and so you hover over the new screen's buttons and another new screen is created. You're not actually replacing the current screen, you're just layering more and more over it.

That would explain why the return doesn't work > you've just gone one screen below, with more underneath. Chances are, if you keep clicking return, you'll eventually get rid of all the screens.

I think you need to rewrite the way you want to achieve what you want, in fact I was helping someone else with their [url=viewtopic.php?f=8&t=50008]pokemon screen[/b] earlier that probably does exactly what you want: in their case they want to click on a button and show more stuff on the same screen, or different stuff - I believe that's the end goal of what you're trying to do.

Don't use ShowTransient, use SetScreenVariable with your hovered instead and a showif to use the correct entry.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: lagging return button (unpredicted image?)

#5 Post by gas »

kivik wrote: Tue May 08, 2018 1:48 pm Oh man! I didn't know what ShowTransient is for, but having looked through the documentation and your code I finally understand it,
In fact is hard to find any case of use for transients.
Anyway, why not a tooltip if those screens just display stuff? The buttons on the left are active alone, the right panel is a preview.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Qlara
Regular
Posts: 80
Joined: Fri Nov 28, 2014 10:22 am
Completed: Carmilla
Skype: kantonija
itch: visualgothic
Location: Berlin
Contact:

Re: lagging return button (unpredicted image?)

#6 Post by Qlara »

Could you give me an idiot-proof link to using tooltip? I couldn't find any.
Kivik, your explanation makes a lot of sense and probably explains the weird double hover sound I get. Return usually happens on its own if I wait long enough, though. I'll take a look at your Pokemon code.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: lagging return button (unpredicted image?)

#7 Post by kivik »

Here's the renpy tooltip section: https://www.renpy.org/doc/html/screen_a ... l#tooltips

It's meant for basic tooltips, but you can easily use it to show completely different things. For example you'd actually put "chapentry01" in the tooltip line, and then use GetTooltip() to determine which button you'd hovered over. It's kinda the same idea as the pokemon thing I linked, in fact better since it's less code!

User avatar
Qlara
Regular
Posts: 80
Joined: Fri Nov 28, 2014 10:22 am
Completed: Carmilla
Skype: kantonija
itch: visualgothic
Location: Berlin
Contact:

Re: lagging return button (unpredicted image?)

#8 Post by Qlara »

Unfortunately, I'm not part of Ren'Py's documentation target group, since I almost never get it.
Here are the changes I made:

Code: Select all

default tt = Tooltip(screen(chapentry))

Code: Select all

                textbutton _("1: A Guest"):
                    if persistent.unlock_chap01:
                        action Start("chap01") hovered tt.Action(screen(chapentry01)) 
                    else:
                        hovered tt.Action(screen(chapentry01))
Everything looks and hovers as it did before, but the return button still lags like hell :cry: and hover sound is still duplicated unless I move the mouse slowly from the bottom upwards :?.
I still see 'unpredicted image' in the image load log and I saw something in a recent changelog about image prediction and main_menu but, for the life of me, cannot find it now. Perhaps my troubles originate there?
Also, how much can I really expect? Entering the screen in question, hovering over one or two titles, more or less slowly, and then hitting return, causes no problems (except double hover sounds). But moving my mouse mindlessly up and down the buttons will cause a return freeze (on any device, OS, compiled or not). Am I just asking too much?

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: lagging return button (unpredicted image?)

#9 Post by philat »

Why not just use the pokemon code? It works. It's simple. Are there probably better ways to do it -- possibly, but you probably don't want to spend more time figuring it out.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: lagging return button (unpredicted image?)

#10 Post by kivik »

Qlara wrote: Wed May 09, 2018 3:48 am Unfortunately, I'm not part of Ren'Py's documentation target group, since I almost never get it.
Here are the changes I made:

Code: Select all

default tt = Tooltip(screen(chapentry))

Code: Select all

                textbutton _("1: A Guest"):
                    if persistent.unlock_chap01:
                        action Start("chap01") hovered tt.Action(screen(chapentry01)) 
                    else:
                        hovered tt.Action(screen(chapentry01))
Everything looks and hovers as it did before, but the return button still lags like hell :cry: and hover sound is still duplicated unless I move the mouse slowly from the bottom upwards :?.
I still see 'unpredicted image' in the image load log and I saw something in a recent changelog about image prediction and main_menu but, for the life of me, cannot find it now. Perhaps my troubles originate there?
Also, how much can I really expect? Entering the screen in question, hovering over one or two titles, more or less slowly, and then hitting return, causes no problems (except double hover sounds). But moving my mouse mindlessly up and down the buttons will cause a return freeze (on any device, OS, compiled or not). Am I just asking too much?
No no no no no no no... You're still creating recursion with that. Basically this is what's happening (simplified):

[screen1] > trigger tooltip, which brings up screen2

[screen2] > trigger tooltip, brings up screen3
[screen1]

[screen3] > trigger tooltip, brings up screen3
[screen2]
[screen1]

[screen4] > trigger tooltip, brings up screen3
[screen3]
[screen2]
[screen1]

And so on. You want:

[screen [screen entry1]] > trigger tooltip, load entry 2 screen

[screen [screen entry2]] > trigger tooltip, load entry 3 screen

[screen [screen entry3]] > trigger tooltip, load entry 4 screen

[screen [screen entry4]]


So you want to read the pokemon code, which uses a screen variable to keep track of what to load, and that thing is loaded, otherwise it's still there just hidden. Tooltip can basically act like a screen variable, it makes the code shorter because instead of using the SetScreenVariable() function you can just type tooltip "variable string".

But if you're not familiar with coding, try just duplicating the pokemon code in the other thread and see how it goes :)

User avatar
Qlara
Regular
Posts: 80
Joined: Fri Nov 28, 2014 10:22 am
Completed: Carmilla
Skype: kantonija
itch: visualgothic
Location: Berlin
Contact:

Re: lagging return button (unpredicted image?)

#11 Post by Qlara »

I'm glad to hear I messed it up, as that means it still can be fixed.
My problem with the Pokemon code was that I saw no equivalent to my action Start("chap01").
If I just wanted the screen that pops up when hovering, I could use the Pokemon code as is. But where do I put the action Start() command then?

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: lagging return button (unpredicted image?)

#12 Post by philat »

https://www.renpy.org/doc/html/screen_actions.html#actions wrote:An action may also be a list of actions, in which case the actions in the list are run in order.
I also see no reason you couldn't shift the SetScreenVariable() to hover/unhovered as you had before.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: lagging return button (unpredicted image?)

#13 Post by kivik »

Here's a stripped down version of the code, you'll have to put the style and images back (as I couldn't test it with them on):

Code: Select all

screen chapscreen:
    default entry = ""
    tag menu
    hbox:
    # add "gui/chaps.png"
        vbox:
            xsize 400
            spacing gui.navigation_spacing
            frame:
                vbox:
                    textbutton "  1: A Guest":
                        if persistent.unlock_chap01:
                            action Start("chap01")
                            hovered SetScreenVariable('entry', "chapentry01")
                            unhovered SetScreenVariable('entry', "")
                        else:
                            action SetScreenVariable('entry', "chapentry01")
                            hovered SetScreenVariable('entry', "chapentry01")
                            unhovered SetScreenVariable('entry', "")

                    textbutton "  2: Drifting":
                        if persistent.unlock_chap04:
                            action Start("chap04")
                            hovered SetScreenVariable('entry', "chapentry02")
                            unhovered SetScreenVariable('entry', "")
                        else:
                            action ShowTransient("chapentry02")
                            hovered SetScreenVariable('entry', "chapentry02")
                            unhovered SetScreenVariable('entry', "")

                    textbutton "  3: Descending":
                        if persistent.unlock_chap06:
                            action Start("chap06")
                            hovered SetScreenVariable('entry', "chapentry03")
                            unhovered SetScreenVariable('entry', "")
                        else:
                            action ShowTransient("chapentry03")
                            hovered SetScreenVariable('entry', "chapentry03")
                            unhovered SetScreenVariable('entry', "")

                    textbutton "  4: The Story":
                        if persistent.unlock_chap10:
                            action Start("chap10")
                            hovered SetScreenVariable('entry', "chapentry04")
                            unhovered SetScreenVariable('entry', "")
                        else:
                            action ShowTransient("chapentry04")
                            hovered SetScreenVariable('entry', "chapentry04")
                            unhovered SetScreenVariable('entry', "")

                    textbutton "  5: Discovery":
                        if persistent.unlock_chap13:
                            action Start("chap13")
                            hovered SetScreenVariable('entry', "chapentry05")
                            unhovered SetScreenVariable('entry', "")
                        else:
                            action ShowTransient("chapentry05")
                            hovered SetScreenVariable('entry', "chapentry05")
                            unhovered SetScreenVariable('entry', "")
        frame:
            xsize 400
            if entry == "chapentry01":
                use chapentry01
            elif entry == "chapentry02":
                use chapentry02
            elif entry == "chapentry03":
                use chapentry03
            elif entry == "chapentry04":
                use chapentry04
            elif entry == "chapentry05":
                use chapentry05

    textbutton _("Return"):
        style "chaptitles_return_button"
        action Return()

screen chapentry01:
    text "chapentry01"
screen chapentry02:
    text "chapentry02"
screen chapentry03:
    text "chapentry03"
screen chapentry04:
    text "chapentry04"
screen chapentry05:
    text "chapentry05"

label start:
    call screen chapscreen

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: lagging return button (unpredicted image?)

#14 Post by gas »

Qlara wrote: Wed May 09, 2018 7:22 am I'm glad to hear I messed it up, as that means it still can be fixed.
My problem with the Pokemon code was that I saw no equivalent to my action Start("chap01").
If I just wanted the screen that pops up when hovering, I could use the Pokemon code as is. But where do I put the action Start() command then?
Even easier.
In those buttons on the left.
Button - action - tooltip.
That's everything you need.
Nothing else. Read the docs, you're actually putti g more IF than needed.

Code: Select all

textbutton "whatever" action Start() tooltip "whatever"
This is the link on new tooltips
https://www.renpy.org/doc/html/screen_a ... l#tooltips
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: lagging return button (unpredicted image?)

#15 Post by kivik »

Well they want the entire right side to change with different image and text. I can see from their test code that tooltip actually launched a new screen, which caused the recursion - I suppose if they change the screen to only containing the right half it'll work!

I tried using use with a variable but it doesn't like it, hence all the if statements.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot]