PDA

View Full Version : RMC Just out of curiosity



Veldehar
September 12th, 2009, 03:40
OK, let's try this post in the correct place!

Let's just say that I went totally insane and decided that I wanted to be able recreate weapon dragability, in very simplistic form, for a list of items into the inventory list on the character sheet. For the sake of this example let's say I want to drag a lantern into the inventory, and have it simply drop into the inventory as a "Lantern", clickable, which would then explain the radius it lights, its weight, burn time, etc. Which would be the most efficient way to do this? via a list in a book in the library? Or by universally making it so that a created Item is able to be dropped into the inventory? I see advantages to both, but at this juncture I've only begun to dig into drag code, and haven't even really contemplated the Item creation drag. Via item I could build both a set library of items and have on the fly creation... but organizationally, the list would be handier.

I don't know if I would ever do this, but I would like to at least look into it. A pointer in a direction or two, a couple pieces of code or such to check out would be highly appreciated. I either have to do it, to one degree or another, or prove to myself it isn't worth the effort... LOL.

Veldehar Snow-Elven

Foen
September 12th, 2009, 06:56
A few places for you to look are the adventure_xxx.xml files, the charsheet_listclasses.xml file and the reference_xxx.xml files. Different rulesets use different techniques, so the following advice isn't universally applicable.

adventure_xxx.xml files

These files typically define everything needed to support one of the 'books' down the righthand side of the FG window, such as notes, npcs, items etc. Each of these is different, but they tend to follow the same structure. Images (adventure_images.xml) is probably the simplist, so I'll use that as an example:

A definition for the expanded details window (imagewindow) which shows the actual image
A definition for the individual lines in the list of images (imagesmall)
A definition for the opened 'book' which contains the list of images (imagelist)

In each case, the adventure_xxx files also contain supporting definitions, usually because the expanded details window is complex, but in the case of adventure_images it contains the ruleset instruction on where image files are stored in the campaign directory (imageupdatefolder).

charsheet_listclass.xml

I use this file to keep all the list definitions for the charsheet in one place. In it you will find the definitions for entries in charsheet lists such as weapons, skills, etc. It contains the definition for the inventory entries (charsheet_inventorywindow). Editing this entry will alter the way that inventory items show on the face of the character sheet. An obvious extension to the current definition would be to add a windowopencontrol against each inventory item to allow you to look at the item in more detail (similar to the way that the imagesmall list entry has a windowopencontrol which brings up the imagewindow).

reference_xxx.xml files

These files contain the definitions for the various library module lists. Most of them are in reference_basicclasses, but a few of them have their own files, like reference_weapons. It is worth noting that the reference modules need to specify which reference classes they use, so you can't add a class to the ruleset and expect pre-existing reference modules to use it - you'll have to create a new reference module if you want to use new classes.

How these interact

Weapons are a good example of how this all fits together. Although they don't have their own 'book', weapons appear in many places and so they have their own adventure_weapons.xml file which (in this case) just defines what the expanded details window looks like (a windowclass called 'weapon').

On the character sheet, in charsheet_listclasses, there is a definition of the summary line for a weapon (charsheet_weaponwindow) which has a windowreferencecontrol to display the expanded details view.

For the library, there is a reference class (reference_weaponlistentry) which displays a summary line in the module data, with a windowreferencecontrol which shows the expanded details view.

Note that all three window definitions (weapon, charsheet_weaponwindow and reference_weaponlistentry) render the same underlying database entries, but show different levels of detail. When you see a summary line on the charsheet, you are looking at the full detail of the weapon, but with only some of the fields being shown. The windowreferencecontrol is just a link to a different 'view' of the same data.

Creating blank entries

Any list can have the ability to add blank entries by adding the allowcreate tag to its definition. It isn't always sensible to allow this, for example with read-only lists, such as the library. If it is enabled, then right-clicking on the list should bring up a menu option to create a new item in the list. This is certainly true for the weapons list on the character sheet, while being disabled for the lists of weapons in the library. It is enabled for the inventory and also for the items 'book'.

Dragging and dropping

This is the fun bit. To enable dragging and dropping requires a number of things to be in place:

The source item has to be draggable. Luckily windowreferencecontrols are draggable by design, so no extra work is needed there. If you want to be able to drag the name of something, rather than just the open box, then you'll need to add an onDrag handler for the name field which sets up the drag type (such as 'weapon' or 'shortcut-to-weapon'). The name field in reference_weaponlistentry does this.
The destination list has to be expecting the drop, and this is most easily accomplished by using an acceptdrop tag in the list definition. The acceptdrop tag specifies which type of drag data it allows (eg 'weapon') and the fields to be copied automatically from the source to the new entry. Make sure you include all the fields you need for the various 'views' of the new database node, not just those which are dsiplayed on the list one-line entry.
Some additional processing may be required. The acceptdrop mechanism covers most eventualities, but doesn't handle nested data. For example, when you drop an NPC, you don't just need to copy top-level items such as the NPC's name, but you typically also want to copy nested data such as the weapons carried by the NPC and their details. Acceptdrop doesn't do this, so a custom onDrop handler is required. This can be complex, but shouldn't trouble you for inventory items.


I hope that gives you some clues on where to start!

Foen

Valarian
September 12th, 2009, 08:29
Wow, sage advice indeed. A really good overview, Foen.

Ikael
September 12th, 2009, 08:59
I have implemented the draggable-items feature for my Unisystem ruleset and I must admit that implementing such a feature is well worth the work! It smooths the gameflow greatly when you don't have to manually add items to your inventory (actually I have made almost everything in character sheet drag-and-droppable because linking IS the most powerful feature of FG). I did this by altering the adventure_items.xml that GM could make either magical items or regular common items/gear (see the attached items). There is also feature of creating new spells but just ignore that at this point.

The gear window itself contain numerous different fields that could be filled, but they can also be filtered by choosing a type for an item. But in your case such a window would propably contain only few fields such like weight, cost and a description field. I implemented those various different fields in my gear window just because different type of gear could be dragged-and-dropped to different places on the character sheet and it's information would be filled to charsheet automatically when dropped (for example weapons dropped to 'weaponlist' would write down weapon's name, damage, possible ammo etc.)

After implementing the gearwindow and altering the itemlist I changed the character sheet's inventory that each item in inventory would have a linkbox for opening the gearwindow and did the onDrop script wich adds new item (writing it's name and weight) to inventory whenever specific type of drag was dropped on the list.

I can share the code if needed but the essential understanding part is shown on Foen's message (understand that before anything else)

Foen
September 12th, 2009, 09:08
That's a really good example Ikael. As you say, implementing this type of thing is very useful, but we concentrated development effort elsewhere for the RMC ruleset.

Foen

Veldehar
September 12th, 2009, 13:36
Excellent! Thank you Foen and Ikael. That gives me a good starting point, and an idea of the potential. Knowing where to look is always a great start. Once I get into it, it might be great to see your work, Ikael. But I will certainly try to keep from drowning in the first part before asking for more water ;)

Bidmaron
September 14th, 2009, 09:15
This thread should be stickied! I could have used such a description when I was playing with rulesets.

Foen
September 14th, 2009, 23:00
Perhaps it's one for the wiki?

Veldehar
December 2nd, 2009, 04:59
OK, so, long story short... I've got to the point where I have these nifty mods for all my custom creatures and weapons, which is when I turned my attention to adding another class of items to the game, with the plan of making them drag-n-drop down the road.

The data for my test backpack was easy enough, and I built my reference_equipment file and got a functional if not yet beautiful table that pulls up its data. From there I figured I might just be able to basically copy and reconfigure the adventure_weapons file to handle the data from the equipment. So, I took the basics of that file for a test run, tried to reference the equipment and got squat. So, I take the adventure_equipment file I just created, rename it back to weapons, go to pull up a weapon and the new equipment labels are sitting there in their pop-up box. So the basic code seems to work, but for whatever reason it is not pulling the data for my new items.

Foen mentioned in an earlier post "you can't add a class to the ruleset and expect pre-existing reference modules to use it - you'll have to create a new reference module if you want to use new classes." and I seem to have created a reference adequately, but is my new class (equipment) not properly defined to function with the adventure_equipment file?

I am a tinkerer, not a coder, so excuse any foolishness on my part, LOL.

Any help is greatly appreciated!

Veldehar the stumped

Veldehar
December 2nd, 2009, 23:47
Okay, I've actually managed to work on a cleaner, easier method of achieving my ends... I hope! Which is also pointing the way to my problem in general.

One way or another, I should be able to head bash my way through the obstacle, heh heh.

Veldehar the suddenly optimistic