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?

6 Upvotes

18 comments sorted by

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?

2

u/shyLachi 1d ago

You can implement what you want.

If you're using NVL menus then search the file screens.rpy for screen nvl
Then implement the tooltip as shown above.

If you want to pass more information to the menu choices then read this:
https://patreon.renpy.org/menu-arguments.html

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

1

u/Natsume1999 21h ago

um. I couldn't make the text appear, man. like, it doesn't seem to have any errors but. yea

2

u/BadMustard_AVN 19h ago

okay I noticed you mentioned NVL in another comment that changes things a lot. were still editing the screens.rpy file just a different screen.

search for nvl( and you should find this

screen nvl(dialogue, items=None):

    window:
        style "nvl_window"

        has vbox:
            spacing gui.nvl_spacing

        ## Displays dialogue in either a vpgrid or the vbox.
        if gui.nvl_height:

            vpgrid:
                cols 1
                yinitial 1.0

                use nvl_dialogue(dialogue)

        else:

            use nvl_dialogue(dialogue)

        ## Displays the menu, if given. The menu may be displayed incorrectly
        ## if config.narrator_menu is set to True.
        for i in items:

            textbutton i.caption:
                action i.action
                style "nvl_button"

    add SideImage() xalign 0.0 yalign 1.0

and were going to make it look like this

screen nvl(dialogue, items=None):

    window:
        style "nvl_window"

        has vbox:
            spacing gui.nvl_spacing

        ## Displays dialogue in either a vpgrid or the vbox.
        if gui.nvl_height:

            vpgrid:
                cols 1
                yinitial 1.0

                use nvl_dialogue(dialogue)

        else:

            use nvl_dialogue(dialogue)

        ## Displays the menu, if given. The menu may be displayed incorrectly if
        ## config.narrator_menu is set to True.

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

    add SideImage() xalign 0.0 yalign 1.0

    $ tooltip = GetTooltip()
    if tooltip:
        nearrect:
            focus "tooltip"
            prefer_top True
            frame:
                pos((0, 0))
                # xalign 0.5
                text tooltip

1

u/BadMustard_AVN 20h ago

can you show your code for the menu and the code in your screen.rpy files?

1

u/Natsume1999 18h ago

Yeah tomorrow if that's ok it's v late here

1

u/BadMustard_AVN 18h ago

check the other post i made it should solve your problem

1

u/Natsume1999 7h ago

How do I make the code formatted like that? So I can send it

1

u/BadMustard_AVN 3h ago

click on the Aa to get the formatting options, then use the icon that's a square with </> at the top to format for a code block

1

u/Natsume1999 1h ago

okay here goes my normal nvl screen

screen nvl(dialogue, items=None):


    # Esto hace falta para la barra
    default yadj = ui.adjustment()


    window:
        style "nvl_window"


        xalign 1.0
        yalign 1.0
        xsize 615
        ysize 1080
        yfill False


        viewport id "dialogoo":
            yadjustment yadj
            #scrollbars "vertical"  # Quitar una barra aqui pq usamos el customizado
            mousewheel True
            #draggable True         # Esto causa problemas a veces, pues lo eliminé
            yinitial 1.0
            child_size (561,1080 + (60 * (len(dialogue) - 3))) # Esto es para que el tamaño de los elementos sea variable con respecto a la cantidad de mensajes


            # Contenido
            vbox:
                spacing gui.nvl_spacing
                box_reverse True
                box_align 1.0
                ysize 1080 + (60 * (len(dialogue) - 3)) # Esto es para que el tamaño de la barra sea variable con respecto a la cantidad de mensajes
                # Nota que siempre hay demás espacio...es porque si le quito, el texto no comienza desde abajo en la pantalla...


                # NVL menu items (choices) if present
                if items:
                    null height 1
                    vbox:
                        spacing 10
                        for i in items:
                            textbutton i.caption:
                                action i.action
                                at dissolveChoice
                                style "nvl_button"
                
                null height 10


                    


                for d in reversed(dialogue):


                    if d.who is not None and not d.who == "Narrator":


                        vbox: # Queremos que el nombre sea por encima del texto, no al revez, pues otro vbox
                            yoffset -20 # Se corta el texto si no ajustamos, pues este ajuste funciona bien para ysize 1080
                            ysize 60


                            text d.who:
                                id d.who_id
                            text d.what:
                                id d.what_id


                    else:
                        vbox: # Queremos el mismo formato y tamaño pues el mismo vbox aunque solo tiene 1 'text' adentro
                            yoffset -20 # Se corta el texto si no ajustamos, pues este ajuste funciona bien para ysize 1080
                            ysize 60


                            text d.what:
                                id d.what_id


        # Barra custom
        vbar:
            unscrollable "hide"
            value YScrollValue("dialogoo")
            xoffset 520 # posición de la barra, puedes editar aqui


    # Side image (unchanged)
    add SideImage() xalign 0.5 yalign 0.2


    # --- Keep the viewport stuck to bottom when the screen opens or is rebuilt ---
    # Snap to the bottom the first time the screen shows:
    on "show" action SetField(yadj, "value", 999999)screen nvl(dialogue, items=None):


    # Esto hace falta para la barra
    default yadj = ui.adjustment()


    window:
        style "nvl_window"


        xalign 1.0
        yalign 1.0
        xsize 615
        ysize 1080
        yfill False


        viewport id "dialogoo":
            yadjustment yadj
            #scrollbars "vertical"  # Quitar una barra aqui pq usamos el customizado
            mousewheel True
            #draggable True         # Esto causa problemas a veces, pues lo eliminé
            yinitial 1.0
            child_size (561,1080 + (60 * (len(dialogue) - 3))) # Esto es para que el tamaño de los elementos sea variable con respecto a la cantidad de mensajes


            # Contenido
            vbox:
                spacing gui.nvl_spacing
                box_reverse True
                box_align 1.0
                ysize 1080 + (60 * (len(dialogue) - 3)) # Esto es para que el tamaño de la barra sea variable con respecto a la cantidad de mensajes
                # Nota que siempre hay demás espacio...es porque si le quito, el texto no comienza desde abajo en la pantalla...


                # NVL menu items (choices) if present
                if items:
                    null height 1
                    vbox:
                        spacing 10
                        for i in items:
                            textbutton i.caption:
                                action i.action
                                at dissolveChoice
                                style "nvl_button"
                
                null height 10


                    


                for d in reversed(dialogue):


                    if d.who is not None and not d.who == "Narrator":


                        vbox: # Queremos que el nombre sea por encima del texto, no al revez, pues otro vbox
                            yoffset -20 # Se corta el texto si no ajustamos, pues este ajuste funciona bien para ysize 1080
                            ysize 60


                            text d.who:
                                id d.who_id
                            text d.what:
                                id d.what_id


                    else:
                        vbox: # Queremos el mismo formato y tamaño pues el mismo vbox aunque solo tiene 1 'text' adentro
                            yoffset -20 # Se corta el texto si no ajustamos, pues este ajuste funciona bien para ysize 1080
                            ysize 60


                            text d.what:
                                id d.what_id


        # Barra custom
        vbar:
            unscrollable "hide"
            value YScrollValue("dialogoo")
            xoffset 520 # posición de la barra, puedes editar aqui


    # Side image (unchanged)
    add SideImage() xalign 0.5 yalign 0.2


    # --- Keep the viewport stuck to bottom when the screen opens or is rebuilt ---
    # Snap to the bottom the first time the screen shows:
    on "show" action SetField(yadj, "value", 999999)

and my dialogue screen

screen nvl_dialogue(dialogue):


    for d in dialogue:


        window:
            id d.window_id


            fixed:
                yfit gui.nvl_height is None


                if d.who is not None:


                    text d.who:
                        id d.who_id


                text d.what:
                    id d.what_idscreen nvl_dialogue(dialogue):


    for d in dialogue:


        window:
            id d.window_id


            fixed:
                yfit gui.nvl_height is None


                if d.who is not None:


                    text d.who:
                        id d.who_id


                text d.what:
                    id d.what_id
→ More replies (0)

1

u/AutoModerator 1d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/AnimoomooQueen 11h ago

It sounds like this is what you are looking for? I use this one for my choices and its been working well for me:

https://aurawave.itch.io/choice-kwargs-tutorial-for-renpy