Tooltips for Nav and Another Menu appear in both tooltip boxes

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.
Post Reply
Message
Author
User avatar
Avior
Regular
Posts: 61
Joined: Sat Apr 30, 2016 8:57 pm
Completed: Voeux, That Bitter Taste, MISSION: Otome!, B.A.T., Assume Survival, Glass Rooms, The Candles Breathe
Projects: String Us Together
Organization: Avior Games, Dream Team Studios
itch: avior
Contact:

Tooltips for Nav and Another Menu appear in both tooltip boxes

#1 Post by Avior »

Sorry if my title doesn't make sense, I struggled a little bit to summarize it concisely. :v

So my project has an inventory menu, which uses the navigation menu. Both the navigation menu and the inventory menu use tooltips, which are working just fine individually, however displaying both menus at the same time is causing issues.

Basically, the tooltips for each menu have a box where they're supposed to appear, but when the two menus are displayed together, the tooltips for both menus show up in both boxes. I can gather that this happens because this code:

Code: Select all

    $ tooltip = GetTooltip()

    if tooltip:
        text "[tooltip]" xpos 736 ypos 548 size 17
is defined under the same name for both menus, with different coordinates, so both menus read both instances of it. I've tried creating two different tooltip sets, for example:

Code: Select all

    $ tooltip = GetTooltip()

    if tooltip:
        text "[tooltip]"

    $ tooltip2 = GetTooltip()

    if tooltip2:
        text "[tooltip]"
This sort of works; it shows the applicable tooltip in the correct box and "none" in the other, though it also causes some errors where moving from one button to another causes the tooltips for those buttons to appear in both boxes and swap back and forth.

Basically, what I'm seeing is that I don't really understand the tooltip function well enough to figure it out at this point, haha.


Here's some screenshots to demonstrate the problem: (please ignore how horrible it looks; my game uses pixel art but I had to downsize the images for the forum)
Image
This is one of the nav menu tooltips displayed by itself.

Image
And one of the inventory menu tooltips with both menus open.

And here's the relevant code: ("phone_menu" is the nav menu.)

Code: Select all

screen inventory_menu:
    tag menu
    use phone_menu

    $ tooltip = GetTooltip()

    if tooltip:
        text "[tooltip]" xpos 736 ypos 548 size 17

    imagebutton:
        hover "gui/inv_osphone.png"
        idle "gui/inv_osphone.png"
        action NullAction()
        xpos 733
        ypos 283
        tooltip "{b}Ospina's Phone{/b}\nA smartphone you can wear on your wrist. The screen \nis cracked and the battery is dead, so it’s pretty useless \nright now."

Code: Select all

screen phone_menu:
    tag menu

    $ tooltip = GetTooltip()

    if tooltip:
        text "[tooltip]" xpos 468 ypos 578 size 17

    imagebutton:
        auto "gui/phone_return_%s.png"
        action SetVariable('qm_use', True), Return()
        xpos 538
        ypos 319
        tooltip "Return to surviving."
Any help in sorting this out would be greatly appreciated!
Image Image

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

Re: Tooltips for Nav and Another Menu appear in both tooltip boxes

#2 Post by gas »

You got everything right, the issue is how bad Tooltips are. And multiple Tooltips are even worst (so I usually suggest people to avoid them).
Having two Tooltips objects differently named was the 'solution', but as you can see it's prone to bugs the same.

What you are experiencing is an engine glitch that you can't solve.
You should rethink the interface.

One idea is to use for the phone buttons an 'hovered' action that show another screen, with text inside, actually faking the Tooltip system.

Code: Select all

screen phone_menu:
    tag menu

    imagebutton:
        auto "gui/phone_return_%s.png"
        action [SetVariable('qm_use', True), Return()] 
        hovered Show("ex_tooltip", ttext = "Return to surviving.") 
        unhovered Hide("ex_tooltip")
        xpos 538
        ypos 319

screen ex_tooltip(ttext):
    text "[ttext]"  xpos 468 ypos 578 size 17
This create a fake tooltip. Just repeat the logic for all phone buttons, passing a different text. That way you have just one real tooltip (the invenntory one) that shouldn't be prone to bugs by pairing with others.

Mind that's not the optimal solution, but it should work the way you want.
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
Imperf3kt
Lemma-Class Veteran
Posts: 3808
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Tooltips for Nav and Another Menu appear in both tooltip boxes

#3 Post by Imperf3kt »

I'd just use the one if tool tip and below that, add a further conditional which is set based on the button hovered. If the variable isn't true, the tool tip won't show, if it is, it will.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Avior
Regular
Posts: 61
Joined: Sat Apr 30, 2016 8:57 pm
Completed: Voeux, That Bitter Taste, MISSION: Otome!, B.A.T., Assume Survival, Glass Rooms, The Candles Breathe
Projects: String Us Together
Organization: Avior Games, Dream Team Studios
itch: avior
Contact:

Re: Tooltips for Nav and Another Menu appear in both tooltip boxes

#4 Post by Avior »

gas wrote: Tue Mar 24, 2020 4:32 am One idea is to use for the phone buttons an 'hovered' action that show another screen, with text inside, actually faking the Tooltip system.

Code: Select all

screen phone_menu:
    tag menu

    imagebutton:
        auto "gui/phone_return_%s.png"
        action [SetVariable('qm_use', True), Return()] 
        hovered Show("ex_tooltip", ttext = "Return to surviving.") 
        unhovered Hide("ex_tooltip")
        xpos 538
        ypos 319

screen ex_tooltip(ttext):
    text "[ttext]"  xpos 468 ypos 578 size 17
This create a fake tooltip. Just repeat the logic for all phone buttons, passing a different text. That way you have just one real tooltip (the invenntory one) that shouldn't be prone to bugs by pairing with others.
It's a little disappointing that they're bugged like that, but this seems like a workable solution. If I can't figure out a cleaner way, I'll give it a try, thanks!

Imperf3kt wrote: Tue Mar 24, 2020 3:08 pm I'd just use the one if tool tip and below that, add a further conditional which is set based on the button hovered. If the variable isn't true, the tool tip won't show, if it is, it will.
Thanks for the suggestion! I gave this a shot, and I've gotten a little closer to the intended result but there's still a bit of an issue.

Here's the code for the nav menu:

Code: Select all

    $ tooltip = GetTooltip()

    if tooltip_p:
        if tooltip:
            text "[tooltip]" xpos 468 ypos 578 size 17

    imagebutton:
        auto "gui/phone_return_%s.png"
        hovered SetVariable("tooltip_p", "True")
        unhovered SetVariable("tooltip_p", "False")
        action SetVariable('qm_use', True), Return()
        xpos 538
        ypos 319
        tooltip "Return to surviving."

And the code for the inventory menu:

Code: Select all

    $ tooltip = GetTooltip()

    if tooltip_i:
        if tooltip:
            text "[tooltip]" xpos 736 ypos 548 size 17

    imagebutton:
        hover "gui/inv_osphone.png"
        idle "gui/inv_osphone.png"
        hovered SetVariable("tooltip_i", "True")
        unhovered SetVariable("tooltip_i", "False")
        action NullAction()
        xpos 733
        ypos 283
        tooltip "{b}Ospina's Phone{/b}\nA smartphone you can wear on your wrist. The screen \nis cracked and the battery is dead, so it’s pretty useless \nright now."
I added a variable to trigger the tooltip for each menu, and assigned it to each button with hovered/unhovered. The hover/unhover actions are triggering the variables just fine, but it seems like the screens only evaluate the if statement once. So, when you scroll over a button, the tooltip displays only in its correct box, but every button hovered after that will display in both boxes again, even though the variables are correct. Any ideas on how to get it to evaluate the if statement each time?
Image Image

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3808
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Tooltips for Nav and Another Menu appear in both tooltip boxes

#5 Post by Imperf3kt »

Unfortunately, no, I couldn't say.
You understood my hurriedly blurted out thoughts pretty well, but I was unsure if they'd work. Theoretically, it should, but I haven't had a chance to test.

What I'd recommend is swapping the tool tip and tool tip p conditionals. You want the tool tip check first, then to check which variable is true (so you can determine if the tool tip appears, or if it stays hidden.


I'll add this to an ever growing list of examples of what I had in mind I have promised people.
Hopefully, tonight I will finally have a chance to sit down at my computer and get a round tuit
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Avior
Regular
Posts: 61
Joined: Sat Apr 30, 2016 8:57 pm
Completed: Voeux, That Bitter Taste, MISSION: Otome!, B.A.T., Assume Survival, Glass Rooms, The Candles Breathe
Projects: String Us Together
Organization: Avior Games, Dream Team Studios
itch: avior
Contact:

Re: Tooltips for Nav and Another Menu appear in both tooltip boxes

#6 Post by Avior »

Imperf3kt wrote: Tue Mar 24, 2020 7:47 pm What I'd recommend is swapping the tool tip and tool tip p conditionals. You want the tool tip check first, then to check which variable is true (so you can determine if the tool tip appears, or if it stays hidden.
Gave it a shot, but doesn't seem to have changed anything. I've fiddled with it some more but I'm thinking at this point there's probably not a viable fix. I think I'll go with gas' initial suggestion and pass one menu's tool tips as screens; it's not ideal but I've definitely written worse code!

Thanks to both of you for your help!
Image Image

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3808
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Tooltips for Nav and Another Menu appear in both tooltip boxes

#7 Post by Imperf3kt »

I will definitely still look into this once I have some time / fix my PC.

If I come up with something workable, I'll pass it along.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

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

Re: Tooltips for Nav and Another Menu appear in both tooltip boxes

#8 Post by philat »

There is an obvious solution in the docs...

https://www.renpy.org/doc/html/screen_a ... GetTooltip

Code: Select all

screen tooltip1():
    $ tooltip = GetTooltip("tooltip1")
    vbox:
        xalign 0.0
        textbutton "hover1" action NullAction tooltip "screen1"
        if tooltip:
            text tooltip

screen tooltip2():
    $ tooltip = GetTooltip("tooltip2")
    vbox:
        xalign 1.0
        textbutton "hover2" action NullAction tooltip "screen2"
        if tooltip:
            text tooltip

Post Reply

Who is online

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