Dynamic tooltip recommendation?

Game development with Board Game Arena Studio
Post Reply
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Dynamic tooltip recommendation?

Post by Victoria_La »

Current BGA API recommends to create static tooltips, i.e. all tooltip text statically assigned
to all element that you want to have tooltips, moreover BGA UI guidelines document tells us not to use
dynamic tooltips.
However even standard "tooltip action" depends of current state. i.e. sometime for same card it is 'click to buy', sometimes 'click to discard", sometime 'click to play'.
Moreover in some cases it nice to show lets say how many squares between your meeple and selected location, and I have
like 100 of locations. Currently I have to query and update all of these 100 tips on very meeple move. What I would
like is to just register a "hover" handler on element, and handler dynamically calculate tooltip, this way no need to store tons of html
snippets, and re-calculate on every move.
I suppose I can use PlainJS, but I was wondering if we have something already made in framework for that.
User avatar
Woodruff
Posts: 412
Joined: 08 March 2014, 00:53

Re: Dynamic tooltip recommendation?

Post by Woodruff »

Hi Victoria_La,

+1 for me on this facility. I am looking for quite the same thing. Currently I have tooltips for showing bigger version of a card in the help part, and no action part. But I'd like to indicate what happens if the player clicks on it which depends of where it comes from, and update that information accordingly when the card moves.
Now I want to finish the game first and reserve that update for version 2.0 since it would be a great among of work. But I am interested too for any solution that would make that update easier.

Tcheby
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: Dynamic tooltip recommendation?

Post by Victoria_La »

I finally figured it out, posting here.

Code: Select all

            new dijit.Tooltip({
                connectId: ["divItemId"],
                getContent: function(matchedNode){
                    return "... calculated ..."; 
                }
            });
This is out of the box djit.Tooltip, it has getContent method which is called dinamically,
the string function return becomes innherHTML of tooltip so can be anything, matchedNode in this case dojo node representing dom object with id of "divItemId" but there are more parameters which I am not posting here which allows more sophisticated subnode queries
https://dojotoolkit.org/reference-guide ... oltip.html

Its not part of bga API so use on your own risk I would say.
Post Reply

Return to “Developers”