PDA

View Full Version : Drag-and-drop spell entries



Dachannien
March 15th, 2006, 19:01
I've been working on a modified CRS for d20, and decided to implement dual spell lists where one is for all known spells and the other is for prepared spells. The intention is that you should be able to drag spells from the known spell list over to the prepared spell list. Aside from that, the spell lists are like the one on the default CRS, using the windowlist control. Works great.

However, I haven't been able to figure out how to get the dragging and dropping to work. I figured out that you need at least a dummy control (like a windowopencontrol) on the nested window in order to grab hold of it. But when I drop the item, it doesn't get added.

Here's the relevant portions of my code:



<windowclass name="charsheet_spellentryk">
<frame name="charsheet_spellentryk" />
<datasource name="spellk" />
<defaultsize width="350" height="40" />
<sheetdata>
<windowopencontrol>
<bounds rect="3,3,35,35" />
</windowopencontrol>
<stringcontrol name="name">
...
</stringcontrol>
</sheetdata>
</windowclass>


<windowclass name="charsheet_spellentryp">
<frame name="charsheet_spellentryp" />
<datasource name="spellp" />
<defaultsize width="350" height="40" />
<sheetdata>
<windowopencontrol>
<bounds rect="3,3,35,35" />
</windowopencontrol>
<stringcontrol name="name">
...
</stringcontrol>
</sheetdata>
</windowclass>


<windowclass name="charsheet_spells">
<frame name="charsheet_spells" />
<datasource name="charsheet" />
<defaultsize width="720" height="720" />
<sheetdata>
<windowlist class="charsheet_spellentryk" name="spellsknown">
<allowcreate />
<allowdelete />
<nestdata />
<bounds rect="8,45,350,520" />
<sort fields="name,level" />
<acceptdrop class="charsheet_spellentryp" fields="name,level,school,savedc,prepared,shortdescription" />
<acceptdrop class="spelldesc" fields="name,level,shortdescription" />
</windowlist>
<scroller>
...
</scroller>

<windowlist class="charsheet_spellentryp" name="spelllist">
<allowcreate />
<allowdelete />
<nestdata />
<bounds rect="362,45,350,520" />
<sort fields="name,level" />
<acceptdrop class="charsheet_spellentryk" fields="name,level,school,savedc,prepared,shortdescription" />
<acceptdrop class="spelldesc" fields="name,level,shortdescription" />
</windowlist>
<scroller>
...
</scroller>
</sheetdata>
</windowclass>

Any ideas on this? I looked through the default d20_reference.xml for clues, since the default CRS supports dragging and dropping from the spell descriptions in the D20 reference, but I didn't see anything special there that would make a difference. Might be something subtle, though.

Thanks much! :)

Toadwart
March 15th, 2006, 21:41
Hmm, I did something similar with inventory/treasure recently (they are on separate pages and I added a small windowlist control to allow drag-drop from one list to the other)
Can't see anything obvious in the xml. Will have another look at my ruleset after work today.

Dachannien
March 15th, 2006, 22:29
Thanks, much appreciated :)

Snikle
March 15th, 2006, 23:26
Thats a great idea! Let us know if you get that working.

Toadwart
March 16th, 2006, 05:40
I think the problem lies in the windowopen node. It needs to have a class name. Without it FG doesn't know what you are dragging.

<windowclass name="charsheet_spellentryp">

<frame name="charsheet_spellentryp" />
<datasource name="spellp" />
<defaultsize width="350" height="40" />
<sheetdata>
<windowopencontrol>
<bounds rect="3,3,35,35" />
<class name="charsheet_spellentryp" />
</windowopencontrol>
<stringcontrol name="name">
...
</stringcontrol>
</sheetdata>
</windowclass>

Now there is one side-effect: if you drag a spell onto the FG desktop you get a single spell entry on the desktop. Not sure how to avoid that...maybe by defining a duplicate of the charsheet_spellentryp class with invisible fields? no that doesn't sound right...hmm, anyone know how to prevent a windowopen control from being dragged to the desktop?

Dachannien
March 18th, 2006, 17:29
hmm, anyone know how to prevent a windowopen control from being dragged to the desktop?

Beats the heck outta me, but you know what? I actually think it's a good thing being able to drag the spells to the desktop :)

Thanks much for the help! I still have a few bugs here and there, but I'm planning on releasing my modified CRS here on the forums before too long.

Edit: Doh! I just noticed that the spell entries on the desktop end up both empty and uneditable, so I guess it's not that useful after all ;)