Thread: Custom Dialog?
-
March 31st, 2009, 00:08 #1
- Join Date
- Mar 2009
- Location
- Lidingö, Sweden, Europe
- Posts
- 374
Custom Dialog?
I was wondering if anyone could point me to an example of a custom dialog (for example in a ruleset). I've studied the section on windows and controls so it is clearly possible to create your own windows, I just like to study a working example before I jump right in...
-
March 31st, 2009, 06:20 #2
Just about all windows in FGII are 'custom' (there are very few built in to the FG engine, even the d20 and Foundation rulesets use custom windows).
A relatively simple example is the code for showing 'story' entries. It comprises a windowclass for listing the story entries (encounterlist), a windowclass which shows a single entry in the list (encountersmall), and a windowclass which displays the full story details (encounter):
Code:<windowclass name="encounter"> <datasource>encounter</datasource> <frame>storybox</frame> <placement> <size> <width>400</width> <height>650</height> </size> </placement> <sizelimits> <dynamic /> </sizelimits> <minimize>minimized_encounter</minimize> <sharable /> <tooltip> <field>name</field> </tooltip> <sheetdata> <windowreferencecontrol> <bounds>15,11,20,20</bounds> <icon> <normal>button_openwindow</normal> </icon> <class>encounter</class> <description> <field>name</field> </description> </windowreferencecontrol> <stringfield name="name"> <bounds>40,13,-15,20</bounds> <empty>« New Story »</empty> <font>sheettext</font> </stringfield> <formattedtextfield name="text"> <bounds>25,44,-28,-23</bounds> <font> <normal>chatfont</normal> <bold>narratorfont</bold> <italic>chatitalicfont</italic> <bolditalic>chatbolditalicfont</bolditalic> <title>sheetlabel</title> </font> <linkicon> <link>button_openwindow</link> <emptylink>button_emptytarget</emptylink> </linkicon> <footer>footer_wide</footer> <selectioncolor>#FFD296</selectioncolor> <empty>Click to enter text</empty> </formattedtextfield> <viewerlist> <anchored> <left> <anchor>left</anchor> <offset>11</offset> </left> <bottom> <anchor>bottom</anchor> <offset>-43</offset> </bottom> </anchored> </viewerlist> <scrollercontrol> <bounds>-53,-35,45,27</bounds> <target>text</target> <button> <normal>button_scroller</normal> <pressed>button_scroller_down</pressed> </button> </scrollercontrol> </sheetdata> </windowclass> <windowclass name="encountersmall"> <sizelimits> <minimum> <height>10</height> </minimum> </sizelimits> <sheetdata> <windowreferencecontrol name="open"> <bounds>0,0,20,20</bounds> <icon> <normal>button_openwindow</normal> <pressed>button_emptytarget</pressed> </icon> <class>encounter</class> <description> <field>name</field> </description> <script file="scripts/adventurelistshortcut.lua" /> </windowreferencecontrol> <linkstringfield name="name"> <bounds>25,1,-1,20</bounds> <empty>« New Story »</empty> <selectioncolor>#90ffffff</selectioncolor> <font>sheettext</font> <linktarget>open</linktarget> </linkstringfield> </sheetdata> </windowclass> <windowclass name="encounterlist"> <frame>scrollboxfortabs</frame> <s-oftclose /> <placement> <size> <width>275</width> <height>350</height> </size> </placement> <sizelimits> <dynamic /> <minimum> <width>200</width> <height>290</height> </minimum> </sizelimits> <nodelete /> <sheetdata> <genericcontrol> <bounds>16,21,30,177</bounds> <icon>title_story</icon> </genericcontrol> <windowlist name="list"> <bounds>50,25,-30,-34</bounds> <datasource>.</datasource> <class>encountersmall</class> <sortfields>name</sortfields> <footer>footer_narrow</footer> <allowcreate /> <allowdelete /> <script> function onSortCompare(w1, w2) return w1.name.getValue() > w2.name.getValue(); end; function onFilter(w) local f = string.lower(window.filter.getValue()); if f == "" then return true; end if string.find(string.lower(w.name.getValue()), f, 0, true) then return true; end return false; end </script> </windowlist> <scrollercontrol> <bounds>-105,-61,45,27</bounds> <target>list</target> <button> <normal>button_scroller</normal> <pressed>button_scroller_down</pressed> </button> </scrollercontrol> <buttoncontrol> <bounds>-55,-58,34,25</bounds> <icon> <normal>button_newwindow</normal> <pressed>button_newwindowdown</pressed> </icon> <class>encounter</class> <script> function onButtonPress() local node = window.getDatabaseNode(); if node then node = node.createChild(); if node then Interface.openWindow(class[1], node.getNodeName()); end end end </script> </buttoncontrol> <categoryselectioncontrol> <bounds>24,-39,-24,-1</bounds> <targetcontrol>list</targetcontrol> </categoryselectioncontrol> <filter name="filter"> <bounds>55,-70,-50,20</bounds> <target>list</target> <trigger>filtertrigger</trigger> </filter> <filtertrigger name="filtertrigger"> <bounds>20,-85,21,41</bounds> <target>filter</target> </filtertrigger> </sheetdata> </windowclass>
Hope that helps
Foen
-
March 31st, 2009, 11:20 #3
- Join Date
- Mar 2009
- Location
- Lidingö, Sweden, Europe
- Posts
- 374
Great! Thanks! You even pointed me to a description of how to create exactly the ruleset I planned to build!
-
March 31st, 2009, 18:22 #4
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks