PDA

View Full Version : scrollboxfortabs Frame type to display & sort multiple fields



brochr
November 27th, 2013, 09:48
Hi Guys

I have been looking through the modification documentation but can't seem to answer this question. I'm modifying bradmcadam's Town extension [which uses the scrollboxfortabs] frame but I want to modify the initial frame to display a field [location_type], then sort on the field [location_type] and entity name.

As far as I can see, the behaviour of the initial lists is controlled by the <windowclass section. However, there doesn't seem to be a property that controls displayed fields and sorting. However, it must be possible as the default "Notes" frame displays the heading, creator and if it shared.

Any suggestions on how to proceed?

Many thanks in advance

Toph

Trenloe
November 27th, 2013, 16:39
Looks like the good old issue of templates causing confusion. Check this section of the ruleset modification guide for info on templates: https://www.fantasygrounds.com/modguide/templates.xcp

The confusion here is that the window class called "townlist" uses a number of templates:

<windowclass name="townlist">
<frame>scrollboxfortabs</frame>
<dynamic />
<placement>
<size>
<width>275</width>
<height>350</height>
</size>
</placement>
<sizelimits>
<dynamic />
<minimum>
<width>200</width>
<height>220</height>
</minimum>
</sizelimits>
<softclose />
<nodelete />
<sheetdata>

<list_campaign name="list">
<datasource>.</datasource>
<class>townsmall</class>
<acceptdrop>
<class>town</class>
<field>*</field>
</acceptdrop>
</list_campaign>
<scroller_campaign>
<target>list</target>
</scroller_campaign>

<button_new>
<class>town</class>
<gmonly />
</button_new>
<categories>
<targetcontrol>list</targetcontrol>
</categories>

<filter name="filter">
<bounds>55,-70,-50,20</bounds>
</filter>
<button_filter name="filtertrigger">
<bounds>20,-85,21,41</bounds>
</button_filter>

<button_close_scrollbox />
</sheetdata>
</windowclass>

The "scrollboxfortabs" frame reference is just that - a frame (graphic and size) that is detailed in the 3.5e ruleset in \graphics\graphics_frames.xml. This has nothing to do with what is contained within the window - it is just a frame for the window.

The item of interest here is the list_campaign template (highlighted in red above). This is defined in the 3.5e ruleset in campaign\template_campaign.xml:

<template name="list_campaign">
<windowlist>
<bounds>50,25,-30,-34</bounds>
<footer>footer_narrow</footer>
<allowcreate />
<allowdelete />
<useallmodules />
<sortby><control>name</control></sortby>
<filter><control>filter</control></filter>
<filteron><control>name</control></filteron>
</windowlist>
</template>
It is here that the sort by and filter entries are defined.

Hint on templates: Whenever you see a control/tag name in a ruleset/extension that you don't recognise/can't find in the documentation - use a text editor that has the "find in files" functionality (a lot of people doing FG development use the free Notepad++) and look for the definition of the name you can't find as it is a good chance that the tag is actually a template. Search for ="XXXXX where XXXXX is the template name. This is how I found the above information.

brochr
November 28th, 2013, 09:32
Hi Trenloe

I unpacked the 3.5E.pak files and opened them in Notepad++ I can see how that hangs together now and if I am not wrong the way Notes displays two fields is controlled by the XML in the campaign_notes.xml listed below

So my understanding is that to do what I want to, I would need to modify the 3.5E ruleset. This will make it a bit too hard to maintain so I will park it for the moment and use meaningful "names" to sort the list. I'll PM you a copy of the extension but as it is a mod of bardmcadam's work and I haven't managed to contact him I don't think it is right to make it public.

All the best

Toph


<windowclass name="notesmall">
<sizelimits>
<minimum>
<height>10</height>
</minimum>
</sizelimits>
<playercontrol />
<nodelete />
<script file="campaign/scripts/campaign_list_record.lua" />
<sheetdata>
<link_list name="open">
<class>note</class>
</link_list>

<icon_access name="access" />
<icon_modified name="modified" />

<stringcontrol name="owner">
<anchored>
<right>
<parent>modified</parent>
<anchor>left</anchor>
<offset>-2</offset>
</right>
<top>
<offset>1</offset>
</top>
<size>
<height>20</height>
</size>
</anchored>
<font>sheettext</font>
<invisible />
<readonly />
</stringcontrol>

<string_campaignrecordname name="name">
<anchored>
<right>
<parent>owner</parent>
<anchor>left</anchor>
<offset>-5</offset>
</right>
</anchored>
<empty>&#171; New Note &#187;</empty>
</string_campaignrecordname>
</sheetdata>
</windowclass>

Bidmaron
November 28th, 2013, 17:22
You should be able to make an extension to replace the desired templates, since the extension overrides the base rule set.

Trenloe
November 28th, 2013, 17:50
I wouldn't recommend replacing/modifying the existing template if at all possible - make a new one with a different name. Make it in a separate XML file in your extension, which will have a minimal impact on how your extension changes the base ruleset. Then the chances of your extension breaking other extensions or breaking with a future release is significantly reduced.

Then you'll be adding a reference to your new XML file in extension.xml so that FG loads it and is aware of the new template name. And, of course, including a copy of the original campaign_notes.xml file (or whichever file you are changing) with the template reference changed to reference the new template you have created.

Trenloe
November 28th, 2013, 18:12
I can see how that hangs together now and if I am not wrong the way Notes displays two fields is controlled by the XML in the campaign_notes.xml listed below

So my understanding is that to do what I want to, I would need to modify the 3.5E ruleset.
So, if you want to add extra fields to the windowlist in campaign_notes you can do this by adding controls into the XML - as you have highlighted above.

If you want to allow ordering/filtering on these fields, you will need to change the "list_campaign_notes" template (ideally creating a new template based on this one as I outlined above). "list_campaign_notes" is used in the next section of the campaign_note.xml file (in the "notelist" window class) in a similar way to "list_campaign" that I mentioned in post #2.

<sheetdata>
<banner_campaign>
<icon>title_notes</icon>
</banner_campaign>

<list_campaign_notes name="list">
<datasource>.</datasource>
<class>notesmall</class>
</list_campaign_notes>
<scrollbar_campaign>
<target>list</target>
</scrollbar_campaign>
And this template is defined in template_campaign.xml:

<template name="list_campaign_notes">
<windowlist>
<bounds>50,25,-30,-34</bounds>
<footer>footer_narrow</footer>
<allowcreate />
<allowdelete />
<sortby><control>name</control></sortby>
</windowlist>
</template>
You'd be able to create a new template based on this one and modify the <sortby>, <filter> and <filteron> tags as detailed here: https://www.fantasygrounds.com/refdoc/windowlist.xcp