PDA

View Full Version : What does the datasource element of windowclass do ?



phantomwhale
December 18th, 2010, 08:30
What I'm trying to do is set up the following in the database node structure :



<id-000001>
<name>Merlin</name>
<powers>
<spelllist>
<id-000001>
<!-- Spell(s) go here -->
</id-000001>
</spelllist>
</powers>
</id-000001>


The main window class is a character sheet. Within the window control is a stringfield (name), which apeears in the database xml file as shown.

My query is about how to store the "spells" windowlist under the "powers" tag. It's currently setup as follows :


<windowclass name="charsheet_powers">
<sheetdata>
<subwindow name="trappings_sub">
<class>trappings_subwindow</class>
</subwindow>
</sheetdata>
</windowclass>

<windowclass name="powers_subwindow">
<datasource>powers</datasource>
<sheetdata>
<windowlist name="spells">
<datasource>.spelllist</datasource>
...
</windowlist>
</sheetdata>
</windowclass>


But this doesn't create the "powers" tag - instead it just creates the spelllist. In the end, I needed to adjust the windowlist datasource to ".powers.spelllist"

I did a similar experiment with a Stringfield, and found it ignored the windowclass datasource tag.

So my question at the end of all of this is... what does the datasource tag on the windowclass actually DO ?

Ben

drahkar
December 18th, 2010, 17:10
It creates the root data point that the list would be stored within. For example:



<category name="" mergeid="" baseicon="0" decalicon="0">
<id-00001>
<charisma type="number">0</charisma>
<constitution type="number">0</constitution>
<dexterity type="number">0</dexterity>
<fortitudesave type="number">0</fortitudesave>
<hp type="number">0</hp>
<init type="number">0</init>
<intelligence type="number">0</intelligence>
<name type="string">Beast</name>
<reflexsave type="number">0</reflexsave>
<strength type="number">0</strength>
<text type="formattedtext">
<p> </p>
</text>
<token type="token"></token>
<willsave type="number">0</willsave>
<wisdom type="number">0</wisdom>
</id-00001>
</category>

Without a datasource setting, thatcategory/id-000001 will be saved wherever the window control happens to put it based on where it is nested within the code. But when you set the datasource, that node, will always be set, right off the root, at whatever your datasource is. ie. if your datasource is set to <datasource>creatures</datasource> then you will find all of the data under it stored like:



<?xml version="1.0" encoding="iso-8859-1"?>
<root version="2.7" release="0.5">
<creatures>
<category name="" mergeid="" baseicon="0" decalicon="0">
<id-00001>
<charisma type="number">0</charisma>
<constitution type="number">0</constitution>
<dexterity type="number">0</dexterity>
<fortitudesave type="number">0</fortitudesave>
<hp type="number">0</hp>
<init type="number">0</init>
<intelligence type="number">0</intelligence>
<name type="string">Beast</name>
<reflexsave type="number">0</reflexsave>
<strength type="number">0</strength>
<text type="formattedtext">
<p> </p>
</text>
<token type="token"></token>
<willsave type="number">0</willsave>
<wisdom type="number">0</wisdom>
</id-00001>
</category>
</creatures>
</root>


Does that help?

phantomwhale
December 18th, 2010, 23:54
I think your talking about the effect of the <datasource> tag within a windowlist - as that certainly sounds like what I'd expect. Apologies if I'm wrong there.

I was wondering about the effect of the <datasource> tag for a windowclass, specifically one being used as a subwindow. It doesn't seem to effect anything so far ?

I nest stringfields and windowlists within them, but they all seem to be binding to the database node owned by the parent window, with the subwindow's values being ignored.

In the example above, I show the subwindow's windowclass have a datasource tag of ".powers", but the windowlist within that, which has a datasource tag of ".spelllist" just binds to the "id-000001" character sheet tag.

I don't see the datasource tag used within windowclasses much at all - perhaps it only works at a top level ? The documentation suggests


A database identifier forming the base from which the actual data source is derived. For top level windows the identifier is relative to the root node of the database, for subwindows and windowlists it is relative to the containing control.

Although I've needed to prefix a "." on a windowlist datasource to ensure it is relative (otherwise it's bound to the root node), so that doesn't seem to tally with that quote. But equally it talks about "for subwindows..." a similar thing - what would get stored in a subwindow datasource node, if not the contained database aware windowcontrol's within it ?

Still a bit puzzled...

Moon Wizard
December 19th, 2010, 05:47
From your description of the issue and a quick review of the code, it seems that the API documentation may be incorrect. The subwindow control appears to always share the same database root as the parent window.

I'll review and update the documentation.

Thanks,
JPG

drahkar
December 19th, 2010, 10:32
*nods* It would seem. I was describing how it works based on actually using it, not the documentation.

phantomwhale
December 20th, 2010, 13:44
From your description of the issue and a quick review of the code, it seems that the API documentation may be incorrect. The subwindow control appears to always share the same database root as the parent window.

I'll review and update the documentation.

Thanks,
JPG

Vaguely related note, I was looking up the definition of the <center /> tag for StringControls, and could not find it documented anywhere.

Perhaps another small addition for the documentation ? (or me being blind and missing it, of course, which is also quite possible !)

Thanks,
Ben

Ikael
December 20th, 2010, 14:13
StringControl inherits the <center/> tag from textbasecontrol, you can find it's documentation there.