PDA

View Full Version : Help with numbercontrols from the developers



Cantstanzya
July 23rd, 2005, 17:08
I have created a new button on the desktop next to the combattracker called countertracker. I have put several numbercontrols in it like this:

<root>
<windowclass name="countertracker">
<frame name="countertracker" />
<datasource />
<defaultsize width="300" height="33" />
<sheetdata>
<numbercontrol name="number1">
<bounds rect="2,5,28,23" />
</numbercontrol>
<numbercontrol name="number2">
<bounds rect="167,5,34,23" />
<nodrag />
<nodrop />
<source name="number1" op="+" />
</numbercontrol>
</sheetdata>
</windowclass>
</root>


The problem that I am having is that it locks FG up if I have the <source name="number1" op="+" />

line in there. Is the character sheet the only place where you can use the source name? If not, how can I get it to work here.

Goblin-King
July 25th, 2005, 18:19
Is the character sheet the only place where you can use the source name? If not, how can I get it to work here.

The character sheet is not, but you need to have a data source. In sheets without a data source, every element is separate from the others, and you can't link between them. You should, in most cases where you need linking, have the data source from the context (npc, character...). However, for sheets that are basically simple tools, you need to use a trick or make do without linking.

In your case, I'd recommend creating a dummy datasource (call it e.g. "numbertracker"), and linking to a certain record in there by adding the following to the bit defining the button on the desktop:


<datasource name="mynumbers" />

Essentially, this will create a branch in the database with the two names defined, and your number1 would be numbertracker.mynumbers.number1 in db.xml.

Cantstanzya
July 26th, 2005, 00:02
Thanks, I will give this a try. I may have some more questions and would definatly appreciate any help you can give me. I am trying to impliment a counter that will increment/decrement as each round passes to keep track of spell duration and such. Thanks again.

Cantstanzya
July 31st, 2005, 16:39
I have tried doing this many ways with no success, and this is how I have it right now (I think I am getting close).
In the base.xml file I have added the following line:

<staticdata source="rulesets\AD&D_UA\database\numbertracker.xml" />

I then added a file in the database directory called numbertracker.xml with the following code inside:

<root>
<node name="numbertracker">
<node name="mynumbers">
<intvalue name="number1" value="0" />
<intvalue name="number2" value="0" />
</node>
</node>
</root>
I have changed my button to add the datasource from above

<root>
<windowclass name="countertracker">
<frame name="countertracker" />
<datasource name="mynumbers"/>
<defaultsize width="300" height="33" />
<sheetdata>
<numbercontrol name="number1">
<bounds rect="2,5,28,23" />
</numbercontrol>
<numbercontrol name="number2">
<bounds rect="167,5,34,23" />
<nodrag />
<nodrop />
<source name="number1" op="+" />
</numbercontrol>
</sheetdata>
</windowclass>
</root>


Perhaps some explanation on nodes in the datasource and how to access them would help me better understand the structure.
Thanks in advance

Cantstanzya
August 4th, 2005, 02:32
Anything to help point me in the right direction?

Goblin-King
August 4th, 2005, 10:32
I have changed my button to add the datasource from above

<root>
<windowclass name="countertracker">
<frame name="countertracker" />
<datasource name="mynumbers"/>
<defaultsize width="300" height="33" />
<sheetdata>
<numbercontrol name="number1">
<bounds rect="2,5,28,23" />
</numbercontrol>
<numbercontrol name="number2">
<bounds rect="167,5,34,23" />
<nodrag />
<nodrop />
<source name="number1" op="+" />
</numbercontrol>
</sheetdata>
</windowclass>
</root>

Perhaps some explanation on nodes in the datasource and how to access them would help me better understand the structure.
Thanks in advance

You understood the structure of the database quite correctly. However, you do not need to define it - it will be created automatically into the campaign database when the node is needed. So you can forget about the staticdata tags (actually, making it static will make editing locked in the number control).

The windowclass definition and everything inside it can be thought of as the prototype for a particular piece of information. RPGs typically have lots of stat blocks or such, and one sheet type will typically represent one of them. This is the windowclass data source, and it will be the first node in the database (in this case, "numbertracker").

However, this is not enough information for the application to present the information needed. You also have to specify the specific item whose data you want to represent in the mentioned format. This is the record name of the data item. For the usual case, FG will count it up from "00001" (it could in theory also be e.g. an item's or a character's name, but this will cause some technical problems which is the reason why FG usually contains this simply in a field). In this case the record name is "mynumbers", and it is on the second level in the node tree.

Due to the difference in these two things, the windowclass never contains references to the exact data. It always needs the record name. Usually it comes from a window open control (e.g. the ones in the list scrolls) and is defined dynamically as the one for that list item. However, in your case you need to define it manually. Still, you need to define it outside the windowclass tag, and the correct place to do it is in the windowopencontrol tag.

So change your windowclass definition to:


<windowclass name="countertracker">
...
<datasource name="numbertracker"/>
...
</windowclass>

and the button on the desktop that opens the window to:



<windowopencontrol ...>
<class name="countertracker" />
<datasource name="mynumbers" />
</windowopencontrol>


To be honest, the tag inside the window open control definition is quite misleadingly named. It should really be <recordname> instead of <datasource>. I'll make sure this gets an alias in some future version.

Cantstanzya
August 4th, 2005, 17:24
Wow, it seems like a lot of information to wrap my head around. Now that I have read it twice it seems to make sense. I will give it a try when I get home from work. I almost want to leave work early to give it a try.

Cantstanzya
August 5th, 2005, 02:56
Thanks so much, that worked great! I am one step closer to making my round counter that will keep track of spell durations based off of what round it is. I am now creating a datasource in the Db.xml file. It looks like this:

<node name="numbertracker">
<node name="mynumbers">
<intvalue name="round" value="4" />
<node name="player">
<node name="00001">
<stringvalue name="effect" value="Held" />
<intvalue name="effectduration" value="8" />
<stringvalue name="name" value="Player 1" />
<intvalue name="roundeffect" value="0" />
</node>
<node name="00002">
<stringvalue name="effect" value="Sanctuary" />
<intvalue name="effectduration" value="6" />
<stringvalue name="name" value="Player 2" />
<intvalue name="roundeffect" value="0" />
</node>
</node>
</node>
</node>


It seems like every window that I create it is one more node that is added. I guess that is how it works right? Now that I think I understand this, is there a way to get data from one node into another node? For example, if I increment the "round" in the numbertracker.mynumbers node can I have that subtract from each of the "effectduration" of the numbertracker.mynumbers.player.0001 and numbertracker.mynumbers.player.0002 nodes? Do you have any tricks up your sleeve to do this?
With the knowledge I have now I am almost positive I can at least have a round counter that is a fixed number of nodes. If you have a way that I can access data from one node into another node I can make the list grow dynamically rather than it being fixed.

Toadwart
June 11th, 2006, 00:12
...snip...



<windowopencontrol ...>
<class name="countertracker" />
<datasource name="mynumbers" />
</windowopencontrol>


To be honest, the tag inside the window open control definition is quite misleadingly named. It should really be <recordname> instead of <datasource>. I'll make sure this gets an alias in some future version.

This is quite interesting and may help me with a different problem I've been struggling with for awhile.
Does the datasource name have to be hard-coded or is it possible to use a field to define it?
e.g.


<windowopencontrol ...>
<class name="countertracker" />
<datasource field="record_name" />
</windowopencontrol>