Page 1 of 1

[SOLVED] A tooltip for several images ?

Posted: Sun Jun 19, 2022 2:19 pm
by Gigan
Hey there ! Been trying to solve that mess for the past 3 hours, I figured it would be much easier to ask here...

I have a screen with several imagebuttons. I'd like some text and a preview of the image to show up when the player hovers it.
I figured how the change the text for each imagebutton using tooltips, but I don't know how to make the image be a different one depending on which imagebutton the player is hovering over.

Here's my code for the 2 cards displayed on the example below :

Code: Select all

screen upgrade_cards():
    tag menu
    modal True
    zorder 100
    add "bg/bg_cards_upgrade.png"

    $tooltip = GetTooltip()
    if tooltip:
        text "[tooltip]":
            pos (995, 95)
            size 25
            font "fonts/BaksoSapi.otf"
            color "#f8f7f7"
        image "cardgame/kaeli_card.png": ### <=== I know this line is the problem. It's the closest I got from the result I want :(
            pos (980, 260)
            at custom_zoom_card

    imagebutton: #carte kaeli
        focus_mask True
        xpos 180
        ypos 71
        idle "cardgame/ib_carte_ok.png"
        action Jump ("carte_lee_upgrade")
        tooltip "kaeli"
    imagebutton: #carte Candice
        focus_mask True
        xpos 557
        ypos 71
        idle "cardgame/ib_carte_ok.png"
        action Jump ("carte_candice_upgrade")
        tooltip "Candice"

transform custom_zoom_card:
    zoom 0.34
Image

Thank in advance anyone !

Re: A tooltip for several images ?

Posted: Sun Jun 19, 2022 3:14 pm
by Ocelot
You can pass objects different form string to tooltip:

Code: Select all

 $tooltip = GetTooltip()
    if tooltip:
        text tooltip[0]:
            pos (995, 95)
            size 25
            font "fonts/BaksoSapi.otf"
            color "#f8f7f7"
        add tooltip[1]
            pos (980, 260)
            at custom_zoom_card

    imagebutton: #carte kaeli
        focus_mask True
        xpos 180
        ypos 71
        idle "cardgame/ib_carte_ok.png"
        action Jump ("carte_lee_upgrade")
        tooltip ("kaeli", "cardgame/kaeli_card.png")
    imagebutton: #carte Candice
        focus_mask True
        xpos 557
        ypos 71
        idle "cardgame/ib_carte_ok.png"
        action Jump ("carte_candice_upgrade")
        tooltip ("Candice", "cardgame/Candice_card.png")

Re: A tooltip for several images ?

Posted: Sun Jun 19, 2022 3:19 pm
by Gigan
Works perfectly ! Thank you so much ! :)