Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Ren'Py Gallery Framework

A (hopefully) easy way to add a CG gallery to your Ren'Py game · By bobcgames

Adding tooltips to unlocked gallery images

A topic by Solerer created 39 days ago Views: 64 Replies: 2
Viewing posts 1 to 3

Thank you so much for the wonderful gallery framework! It has been very useful and easy to use.

I'm trying to make it to that when the user hovers over an unlocked gallery image, a tooltip pops up with a description of the gallery image. I've tried a couple different things but no luck yet. I think the issue might be that I would need to define the imagebuttons individually? Does anyone have any suggestions? 

Developer

Oops... sorry I missed this!

You can do this without separately defining the buttons, but the easiest way to do it would be to add a description to each item in the list of gallery images, and not use auto import.

So you'd want something like:

("eileen asleep", "images/cg/eileen_asleep.png", _("Eileen falls asleep after a nice date")),

And then update the processing on line 255:

            allimgs.append((itm[0], bobcgallery_get_thumb(itm[1]), itm[1], itm[-1]))
            if len(itm) > 3:
                variantmap[itm[0]] = itm[1:-1]

And then add the tooltip to the screen buttons (line 104):

            for name, thm, img, desc in BOBCGALLERY_IMAGE_SETS[pagenum]:
                if name in persistent.bobcgallery_unlocked:
                    if name in BOBCGALLERY_VARIANT_MAP:
                        fixed:
                            xysize (BOBCGALLERY_THUMB_XMAXIMUM, BOBCGALLERY_THUMB_YMAXIMUM)
                            imagebutton idle thm at bobcgallery_thumb action Show("bobcgallery_showcg", imgname=name, idx=0, transition=BOBCGALLERY_TRANSITION) tooltip desc
                            if BOBCGALLERY_VARIANT_ICON:
                                add "bobcgallery_variant_icon" xalign 0.95 yalign 0.95
                    else:
                        imagebutton idle thm at bobcgallery_thumb action Show("bobcgallery_showcg", imgname=name, transition=BOBCGALLERY_TRANSITION)

You'd also need to actually show the tooltip text with something like a NearRect and GetTooltip(), since adding the tooltip just makes the text available to GetTooltip().

(You may need to make further changes to the auto-import functionality, or remove that portion of the code.)

If you're having trouble with this, I can take a stab at it.

Developer

Actually, a simpler (but less elegant) way that would work with autoimport is to define an entirely new dict:

define BOBCGALLERY_DESCRIPTIONS = {
    "eileen asleep" : _("Eileen falls asleep after a nice date"),
}

And then just add that in the tooltips:

imagebutton idle thm at bobcgallery_thumb action Show("bobcgallery_showcg", imgname=name, idx=0, transition=BOBCGALLERY_TRANSITION):
    if name in BOBCGALLERY_DESCRIPTIONS:
        tooltip BOBCGALLERY_DESCRIPTIONS[name]

(And then use NearRect and GetTooltip() to add the actual hover tooltip.)