Page 1 of 1

Overlaping _some_ Stock cards _vertically

Posted: 29 January 2021, 15:23
by cpasbanal
Hello fellow developers and the BGA community,

I am currently working on Harbour (the base game is great and I hope you'll like it - and the implementation). If you want to have a look on the way I implemented it, you can just test a game on the Studio: https://studio.boardgamearena.com/lobby?game=4966 (just applied to Jurica to be pushed to alpha). Project is named harbourjc.

Now, I am considering developing the High Tides expansion. Yet, I have a (hopefully small) issue I have to solve: I need to make my building cards overlap some other cards. This overlap should be vertical to let players see each card. I used the Stock feature of the framework for the base game because I find it very convenient and it fitted well in my implementation.
Here is what I would love to achieve: https://imgur.com/a/l1oDSNp.

My main issue is that every time a user is resizing the window (or switching portrait / landscape on a mobile device), the Stock is recalculating the absolute position of each element. So my attempts to make some elements being childs of others (e.g. with top:-50% to shift them vertically) does not seem to work. If I remove any of those elements or if I do not use Stock anymore (with inline-blocks elements and wrapped children), it would probably work but I would have to reimplement the wheel, meanlingly the card creation and onSelectionChange among other features of the Stock.

I know some of you (Tisaac for instance) is very good at overriding some functions of the framework so some of you may have some advice to help me. Do I have to override? Or is there any better / nicer way? Or should I give up the Stock functionality this time because it will be harder to tamper than to hard code?

Thanks for any help, hints or advice you can give me,
And thank you all for this community, i really like being some small part of it :)

Jérémie / cpasbanal

Re: Overlaping _some_ Stock cards _vertically

Posted: 29 January 2021, 19:07
by Tisaac
cpasbanal wrote: 29 January 2021, 15:23 Or should I give up the Stock functionality this time because it will be harder to tamper than to hard code?
You already know my answer :D

Re: Overlaping _some_ Stock cards _vertically

Posted: 29 January 2021, 19:42
by thoun
I've the same problem. I copied the updateDisplay method of the Stock component to override it.

Here is code examples :
unobfuscated, not modified (I commented some things I won't use but you can uncomment them)
modified for my case (game Mow)

Hope it will help you !

Re: Overlaping _some_ Stock cards _vertically

Posted: 29 January 2021, 21:28
by cpasbanal
Thanks you both for your quick answers.

I'll try to override updateDisplay to see what I can use, thanks @thoun for your code.
And since @Tisaac's advice is to recode, I won't spend too much time if I can't manage to make it work... and I'll recode the functions I need;)

To be continued