PDA

View Full Version : I'm having trouble writing a position script


Mathias
February 24th, 2009, 08:35 AM
Rob or Colen,
I'm getting myself pretty confused trying to write a position script.

The traits (assets and complications) can have:
A domain
3 thing-based choosers
a menu array

I also need to fit in the name, info, delete, and value fields, and have it all look good. Looking through the existing lists of assets and complications, the three optional elements are exclusive of each other (the same asset won't have both a domain and choosers). The problem is, I shouldn't write the position script assuming that they'll always be exclusive of each other.

Where is the user selection component? I need to modify that to add a 3rd chooser (I only need it for one Asset in Demon Hunters so far).

Can you give me any advice on how you'd approach fitting all that into a menu?

I've checked in the position script I have. I think it will properly display everything in BSG. If you want examples to work with, the Talented Asset has 2 choosers, the Addiction Complication has a domain, and the Dull Sense Complication uses the menu array.

Colen
February 24th, 2009, 09:04 AM
In this case, it's not reasonable to expect things to work correctly when all 5 things are present. At most, you'll have a 400-ish pixel wide space, and unless you want to have a 2-row high table cell, you're just not going to be able to fit everything in and still have enough space.

In situations like this, I would think a reasonable assumption was "No more than 3 selections will be needed for any one pick". Then you can write a position script that operates as follows (pseudocode):

var nextleft as number
nextleft = right of name portal + 10
~nextleft is now the starting left position for the next visible portal

if domain portal is not used,
hide it
else
domain portal position = nextleft
domain portal width = 1/3 of space to the right of the name
nextleft = right of domain portal + 10
endif

if thing menu 1 is not used,
hide it
else
thing menu 1 position = nextleft
thing menu 1 width = 1/3 of space to the right of the name
nextleft = right of thing menu 1 + 10
endif

... repeat for other 3 portals ...

That way you're positioning all the portals one by one, putting them into an appropriate amount of space for each. If you have more than 3, the extras will be positioned off to the side, and not appear - you can also track the visible count and just hide them yourself.

The UserSelect component should be in the file "components.core", near the top.

rob
February 25th, 2009, 09:27 PM
There is also a "UserSelect" template defined in "visual.dat" that already contains most of what you are looking for. It works in conjunction with the "UserSelect" component. The only difference between what it provides and what you want is an extra menu. So adding one extra set of portals ought to be relatively easy compared to writing the full logic from scratch.