PDA

View Full Version : acceptDrop - again...



peterb
April 15th, 2009, 23:22
Searching for "acceptDrop" I found a few older threads dealing with this feature. However they do not adress my question. In the CoC ruleset you can drop a weapon from a weapon list in a library module onto the charactersheets weapon list. The windowlist in question has an acceptdrop tag listing all the fields of the weapon "object". How this acctually works is not that clear.

I'm trying to add a similar feature to the inventory (I'm still talking about the CoC ruleset). I have a table in a library module with the names and weights of weapons and armour. I've added a acceptdrop tag, to the windowlist of the inventory, with the two fields of my item - but nothing happens. Do I have to include all fields of the reciving list in my drop? I.e. need I add "count", "location" and "carried" to the fields of the drop - even though those fields make little sense in my library modules equipment list?

Foen
April 16th, 2009, 06:30
The table you are dragging from needs to have a well defined windowclass, and the acceptDrop tag then references that class. If you have snippets of code, I'd be happy to take a look.

Foen

peterb
April 16th, 2009, 10:54
Thanks for the offer Foen!

First let me do away with an ambiguity - I'm not referring to the HTML table in the CoC Game System module but a new table created by me.

I decided to keep it simple and base my table on the existing weaponlist design. So what I have is a windowclass called "referenceequipmentitem" that contains a windowreferencecontrol called "open", with a class tag containing "equipment". Then I have


<stringfield name="name">
<bounds>17,0,220,14</bounds>
<font>chatfont</font>
<static/>
</stringfield>

<stringcontrol name="weight">
<bounds>237,0,50,14</bounds>
<font>chatfont</font>
<static/>
<script>
function onInit()
local val = window.getDatabaseNode().createChild("weight", "number").getValue();
setValue(val);
end
</script>
</stringcontrol>

Next there is a windowclass called "referenceequipment". I originally intended to have one set of classes each for weapons, armour and equipment but I realised that indication the type of the item by using a flag (in the same way as in the weaponlist) was a much better and cleaner solution. This windowclass has three fields: itemType, name and weight. There is also a windowlist and a scrollercontrol.

In charsheet_inventory.xml I have added:

<acceptdrop>
<class>equipment</class>
<field>name</field>
<field>weight</field>
</acceptdrop>

to the windowlist "inventorylist".

Foen
April 17th, 2009, 06:26
The class tag in the windowopencontrol should be the name of a windowclass that is displayed when the opencontrol is clicked. Have you created an 'equipment' windowclass?

In the case of weapons, when you click the windowopencontrol, a small sheet pops up (the 'weapon' windowclass) showing the details of the weapon. It is this windowclass which is used as the basis of the drag and drop (when you drag an item from the weapon list, you are actually dragging a reference to the 'weapon' windowclass).

Hope that helps

Stuart

peterb
April 17th, 2009, 12:29
OK. Now I get it. I found the "weapon" class, it's in adventure_weapons.xml. So I need to create adventure_equipment.xml and use it to store a definition of the "equipment" class - right?

I note that the weapon class contains the same code for skill rolls and damage rolls as the charsheet_weaponlistitem class (in charsheet_listclasses.xml). Why is there a need of storing that functionality in two places? Does it serve any internal purpose - beside making it possible to open a weapon in the weapon list and roll it's damage?

peterb
April 17th, 2009, 14:27
Creating a adventure_weapons.xml and populating it with a equipment class did the job. Thanks for the pointer!

Foen
April 17th, 2009, 16:50
No problem. BTW that code is not Open, so you shouldn't redistribute it, nor any modified CoC ruleset.

Have fun with your mod!

Stuart

peterb
April 17th, 2009, 17:18
No problem. BTW that code is not Open, so you shouldn't redistribute it, nor any modified CoC ruleset.

I know. I could have based my mods on the d20 (or d20_JPG) but since it's BRP me and my friends wants to play it seemed easier (and faster) to base my customizations on something that delivers most of what we want up front. There are open d100 compatible rules available (MRQ, GORE and OpenQuest, and there might be more out there) so someday I might re-implement my mods on a foundation base.