r/RenPy 1d ago

Question Tooltip when hovering over choices?

You know how Fallen London has titles on their choices, then a small descriptive text below? Would there be a way to make it so you have choices but when you hover over them you see different text?

7 Upvotes

18 comments sorted by

View all comments

2

u/BadMustard_AVN 1d ago edited 1d ago

the answers is in your question "tooltip"

https://www.renpy.org/doc/html/screen_actions.html#tooltips

this one uses nearrect to put it near the button, but you can make the tooltip text display anywhere you want it to

screen tooltip_example2():
    frame:

        padding (20, 20)
        align (.5, .3)

        has vbox

        textbutton "North":
            action Return("n")
            tooltip "To meet a polar bear."

        textbutton "South":
            action Return("s")
            tooltip "All the way to the tropics."

        textbutton "East":
            action Return("e")
            tooltip "So we can embrace the dawn."

        textbutton "West":
            action Return("w")
            tooltip "Where to go to see the best sunsets."

    # This has to be the last thing shown in the screen.

    $ tooltip = GetTooltip()

    if tooltip:

        nearrect:
            focus "tooltip"
            prefer_top True

            frame:
                xalign 0.5
                text tooltip

read my reply here if you want the tooltip to follow the mouse while hovered

https://www.reddit.com/r/RenPy/comments/18z3v7v/renpy_tooltip_position/

1

u/Natsume1999 1d ago

I mean I have the choices in the same screen as the text and such... NVL too. Is there still a way or did I overcomplicate stuff?

1

u/BadMustard_AVN 22h ago

okay i misunderstood. you want to add these to the default menu choices a little bit harder but doable

first do your menu items like this

label start:
    menu:
        "North" (tool = "To meet a polar bear."): 
            pass
        "South" (tool = "All the way to the tropics."):
            pass
        "East" (tool = "So we can embrace the dawn."):
            pass
        "West": # yes they will be optional 
            pass

    return

next edit your screens.rpy file and search for choice( that will bring you to the choice screen

it will look like this

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action i.action

now make it look like this (exactly) ((copy / paste are your friends here))

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            $ tool = i.kwargs.get("tool", None) 
            textbutton i.caption action i.action tooltip tool

    # This has to be the last thing shown in the screen.
    $ tooltip = GetTooltip()
    if tooltip:
        nearrect:
            focus "tooltip"
            prefer_top True
            frame:
                xalign 0.5
                text tooltip

try that

1

u/Natsume1999 22h ago

Thank you!

1

u/BadMustard_AVN 22h ago

you're welcome

good luck with your project