This is a documentation for Board Game Arena: play board games online !

BgaZoom: Difference between revisions

From Board Game Arena
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 61: Line 61:


== Changelog ==
== Changelog ==
'''1.0.2''': fix default state if at min/max
'''1.0.1''': handle light/dark theme
'''1.0.1''': handle light/dark theme


'''1.0.0''': Initial version
'''1.0.0''': Initial version
[[Category:Studio]]
[[Category:Studio]]

Latest revision as of 14:12, 9 July 2026


Game File Reference



Useful Components

Official

  • ItemManager: a PHP component to manage cards or other game items.
  • PlayerCounter and TableCounter: PHP components to manage counters.
  • Draggable: a JS component to manage drag'n'drop actions.
  • Counter: a JS component to manage a counter that can increase/decrease (ex: player's score).
  • ExpandableSection: a JS component to manage a rectangular block of HTML than can be displayed/hidden.
  • Scrollmap: a JS component to manage a scrollable game area (useful when the game area can be infinite. Examples: Saboteur or Takenoko games).
  • Zone: a JS component to manage a zone of the board where several game elements can come and leave, but should be well displayed together (See for example: token's places at Can't Stop).
  • bga-zoom : a JS component for zoom controls.
  • bga-animations : a JS component for animations.
  • bga-cards : a JS component for cards.
  • bga-dice : a JS component for dice.
  • bga-autofit : a JS component to make text fit on a fixed size div.
  • bga-score-sheet : a JS component to help you display an animated score sheet at the end of the game.
  • bga-jump-to : a JS component to add board shortcuts

Deprecated

  • Deck: a PHP component to manage cards (deck, hands, picking cards, moving cards, shuffle deck, ...).
  • Stock: a JS component to manage and display a set of game elements displayed at a position.

Unofficial



Game Development Process



Guides for Common Topics



Miscellaneous Resources

Overview

bga-zoom is a component to add zoom controls on your game area.

It also includes an autoscale feature, to automatically zoom out on game load so the requested width fits on the screen size.

The game Azul: Queens garden is an example of usage.

To see how its work and access examples of source code (via browser dev tools) see Demo

For comprehensive API docs see Doc

Usage

Load the lib:

const BgaZoom = await importEsmLib('bga-zoom', '1.x');

This line should be placed on top of the JS file, before any class declaration.

Legacy way;

define([
    "dojo","dojo/_base/declare",
    "ebg/core/gamegui",
    "ebg/counter",
    getLibUrl('bga-zoom', '1.x'),
],
function (dojo, declare, gamegui, counter, BgaZoom) { // note that the index of `BgaZoom` must match the index of the define array

In your game setup:

        new BgaZoom.Manager({
            element: document.getElementById('full-table')!,
            zoomControls: {
                color: 'black',
            },
            localStorageZoomKey: LOCAL_STORAGE_ZOOM_KEY,
            autoZoom: {
                expectedWidth: 1600, // for the main board to fit
                minZoomLevel: 0.25,
            },
        });

Also define const LOCAL_STORAGE_ZOOM_KEY = '<yourgamename>-zoom'; so the user prefered zoom level is stored on his device.

Versioning

The lib is using semver, so you can require 1.x to be sure to have the last fixes without risking a breaking change. Any breaking change will be noted on the Changelog section.

Using with TypeScript

If you use TypeScript and this lib, you can download the d.ts file to put in on your game folder to benefit from auto-completion. Depending on the way you build, you might need to remove the last line (the export instruction) to be able to use it.


Developer notes

The scaled game area is scaled using CSS zoom. Old dojo animations are not compatible with it, but bga-animation lib is.

Changelog

1.0.2: fix default state if at min/max

1.0.1: handle light/dark theme

1.0.0: Initial version