Show / Hide Tooltips

Game development with Board Game Arena Studio
User avatar
tchobello
Posts: 526
Joined: 18 March 2012, 13:19

Show / Hide Tooltips

Post by tchobello »

hello !

I'm working on Dungeon Twister and there are tooltips explaining to beginners each token capacities.

Is there a way for advanced players to choose if tooltips can be shown or hidden ?
User avatar
RicardoRix
Posts: 2109
Joined: 29 April 2012, 23:43

Re: Show / Hide Tooltips

Post by RicardoRix »

you could add it as a user preference:

http://en.doc.boardgamearena.com/Game_o ... ns.inc.php
User avatar
tchobello
Posts: 526
Joined: 18 March 2012, 13:19

Re: Show / Hide Tooltips

Post by tchobello »

I think this affects the game for both players, no ?
User avatar
paramesis
Posts: 374
Joined: 28 April 2020, 05:00

Re: Show / Hide Tooltips

Post by paramesis »

It would if you used Game Options. See the bottom of the page RicardoRix linked for the User Preferences section. These are options you can set up that only affect the client side interface for each player. Example uses of User Preferences are Carcassonne, where players can choose to see the first edition tile graphics, and Stone Age, where each player can see the classic vs anniversary style meeples or the summer/winter side of the board. You can access these in-game by clicking on the hamburger menu in the upper right, or the "Options" tab below the play area.

In fact, the BGA framework already includes a built-in option to disable all tooltips, so you don't need to create a separate preference for it, unless you would like to only disable some of the tooltips.

Unfortunately, not many players at BGA know about User Preferences, but they are a great way to handle situations like this.
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: Show / Hide Tooltips

Post by Victoria_La »

There is already option for that that automatically applied to all games no? If you go to Preferences there is "Display tooltips" Enabled/Disabled
so you don't have to do anything
User avatar
tchobello
Posts: 526
Joined: 18 March 2012, 13:19

Re: Show / Hide Tooltips

Post by tchobello »

oh thanks a lot !

I really didn't know about the User Preferences in the hamburger menu !
User avatar
RavingWanderer
Posts: 66
Joined: 12 May 2020, 16:08

Re: Show / Hide Tooltips

Post by RavingWanderer »

Two questions which are relevant to this discussion:
1. How does one interrogate (get the current value of) the BGA-supplied "Display tooltips" preference?
2. How is one notified that it has changed? (It doesn't force a refresh.)

Answers to these questions should be documented someplace (in the options file doc, game.js doc, or other place?)
User avatar
Een
Posts: 3854
Joined: 16 June 2010, 19:52

Re: Show / Hide Tooltips

Post by Een »

RavingWanderer wrote: 10 September 2020, 02:47 Two questions which are relevant to this discussion:
1. How does one interrogate (get the current value of) the BGA-supplied "Display tooltips" preference?
2. How is one notified that it has changed? (It doesn't force a refresh.)

Answers to these questions should be documented someplace (in the options file doc, game.js doc, or other place?)
This feature disables all tooltips at the framework level for the ongoing game. Thus, it's not intended to need to be managed by the developer of the game module.
User avatar
RavingWanderer
Posts: 66
Joined: 12 May 2020, 16:08

Re: Show / Hide Tooltips

Post by RavingWanderer »

Een wrote: 10 September 2020, 14:39
RavingWanderer wrote: 10 September 2020, 02:47 Two questions which are relevant to this discussion:
1. How does one interrogate (get the current value of) the BGA-supplied "Display tooltips" preference?
2. How is one notified that it has changed? (It doesn't force a refresh.)

Answers to these questions should be documented someplace (in the options file doc, game.js doc, or other place?)
This feature disables all tooltips at the framework level for the ongoing game. Thus, it's not intended to need to be managed by the developer of the game module.
In Hand and Foot, I sometimes get *some* tooltips in the game area regardless of the setting when playing in studio. In the production version, I get tooltips for the played melds (these are created as dijit.Tooltip, not using this.addTooltip or this.addTooltipToClass, because of their dynamic content).
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Re: Show / Hide Tooltips

Post by quietmint »

RavingWanderer wrote: 10 September 2020, 02:47 Two questions which are relevant to this discussion:
1. How does one interrogate (get the current value of) the BGA-supplied "Display tooltips" preference?
2. How is one notified that it has changed? (It doesn't force a refresh.)

Answers to these questions should be documented someplace (in the options file doc, game.js doc, or other place?)
It's stored with the other preferences, number 200. Read with: this.prefs[200]

Regarding updates, the framework doesn't provide a callback, so you have to add your own. Something like this can be done during the setup, connected to each of the dropdowns (remember there are two spots with the same dropdowns -- the Options tab below the game, and the top-right corner):

Code: Select all

      var _this = this;
      var updatePreference = function (e) {
        var match = e.target.id.match(/^preference_[cf]ontrol_(\d+)$/)
        if (!match) {
          return;
        }
        var pref = +match[1];
        var prefValue = +e.target.value;
        _this.prefs[pref].value = prefValue;
        if (pref == 123) {
          // do something here if you care about pref #123 changing
        }
      };

      dojo.query('.preference_control').connect('onchange', updatePreference);
Post Reply

Return to “Developers”