completesetup updates stock height based on item height

Game development with Board Game Arena Studio
Post Reply
qinsoon
Posts: 2
Joined: 05 July 2021, 08:05

completesetup updates stock height based on item height

Post by qinsoon »

Hi All. I am using the Stock component.

The stock is created with an item height, like this

Code: Select all

this.myStock.create( this, $('my_stock'), ..., itemHeight );
In some cases, I may need to stack items in this Stock. So I need to conditionally change its height in setup()

Code: Select all

dojo.style('my_stock', 'height', newHeight+'px');
This works fine. But at some point in the game setup, the 'completesetup()' method is called, and it will resize the stock based on 'itemHeight' that the Stock is created with, and the resizing overwrites the later update of 'newHeight'.

I am wondering how I should deal with this.
Is there a callback I can use after completesetup so I can update the height?
Is there a way to disable resizing stock in completesetup?
User avatar
AmadanNaBriona
Posts: 43
Joined: 17 March 2018, 18:52

Re: completesetup updates stock height based on item height

Post by AmadanNaBriona »

It's not documented on the wiki, but Stock has a resizeItems method.

Code: Select all

resizeItems(width, height, <background-width>, <background-height>)
(Last two arguments are optional).
User avatar
RicardoRix
Posts: 2112
Joined: 29 April 2012, 23:43

Re: completesetup updates stock height based on item height

Post by RicardoRix »

I added this to the wiki, but would be nice if it had some explanation....
https://en.doc.boardgamearena.com/index ... &section=8
Post Reply

Return to “Developers”