<!-- This file is provided under the Open Game License version 1.0a
  -- For more information on OGL and related issues, see 
  --   http://www.wizards.com/WFRP2
  --
  -- For information on the Fantasy Grounds WFRP2 Ruleset licensing and
  -- the OGL license text, see the WFRP2 ruleset license in the program
  -- options.
  --
  -- All producers of work derived from this definition are adviced to
  -- familiarize themselves with the above licenses, and to take special
  -- care in providing the definition of Product Identity (as specified
  -- by the OGL) in their products.
  --
  -- Copyright 2006 SmiteWorks Ltd.
  -->

<?xml version="1.0" encoding="iso-8859-1"?>
<root version="2.0">
	<template name="npctoplabel">
		<stringcontrol>
			<font>sheetlabelsmall</font>
			<center />
			<script>
				function onInit()
					if anchor then
						setAnchor("bottom", anchor[1], "top", "absolute", 2);
						setAnchor("left", anchor[1], "left", "absolute",0);
						setAnchor("right", anchor[1], "right", "absolute", 0);
					end
				end
			</script>
		</stringcontrol>
	</template>

	<template name="npcmainprofile">
		<numberfield>
			<nodrop />
			<noreset />
			<hideonvalue>0</hideonvalue>
			<font>sheettextsmall</font>
			<frame>
				<name>modifier</name>
				<offset>2,1,3,4</offset>
			</frame>
			<script>
				function onInit()
					setAnchor("top", "specialqualities", "bottom", "absolute", 17);
					
					if anchor then
						setAnchor("left", anchor[1], "right", "relative", -3);
					else
						setAnchor("left", "specialqualities", "left", "absolute", -2);
					end
					
					setAnchoredWidth(6);
					setAnchoredHeight(18);
					
					if getDatabaseNode().isStatic() then
						setFont("chatfont");
					end
				end
			</script>
		</numberfield>
	</template>

	<template name="npcsecprofile">
		<numberfield>
			<nodrop />
			<noreset />
			<hideonvalue>0</hideonvalue>
			<font>sheettextsmall</font>
			<frame>
				<name>modifier</name>
				<offset>2,1,3,4</offset>
			</frame>
			<script>
				function onInit()
					setAnchor("top", "weaponskill", "bottom", "absolute", 17);
					
					if anchor then
						setAnchor("left", anchor[1], "right", "relative", -3);
					else
						setAnchor("left", "weaponskill", "left", "absolute", -2);
					end
					
					setAnchoredWidth(6);
					setAnchoredHeight(18);
					
					if getDatabaseNode().isStatic() then
						setFont("chatfont");
					end
				end
			</script>
		</numberfield>
	</template>

	<windowclass name="npc_combat">
		<datasource>npc</datasource>
		<script>
			--[[ If the size of the window changes, adjust the widths of abilities and saves ]]
			function sizeChanged()
				local winwidth, winheight = getSize();

				local abilitywidth = math.floor(20 + (winwidth - 235) / 8);

				weaponskill.setAnchoredWidth(abilitywidth);
				ballisticskill.setAnchoredWidth(abilitywidth);
				strength.setAnchoredWidth(abilitywidth);
				toughness.setAnchoredWidth(abilitywidth);
				agility.setAnchoredWidth(abilitywidth);
				intelligence.setAnchoredWidth(abilitywidth);
				perception.setAnchoredWidth(abilitywidth);
				willpower.setAnchoredWidth(abilitywidth);
				fellowship.setAnchoredWidth(abilitywidth);
				local savewidth = math.floor(21 + (winwidth - 235) / 8);

				attack.setAnchoredWidth(savewidth);
				wound.setAnchoredWidth(savewidth);
				move.setAnchoredWidth(savewidth);
				fatep.setAnchoredWidth(savewidth);
			end
			
			function onInit()
				self.onSizeChanged = sizeChanged;
			end
		</script>
		<sheetdata>
			<columnstringfield name="hd">
				<tabtarget next="specialqualities" prev="name" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>hd</anchor>
				<static>Folies</static>
			</columnfieldlabel>

			<columnstringfield name="specialqualities">
				<anchor>hd</anchor>
				<tabtarget next="weaponskill" prev="specialattacks" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>specialqualities</anchor>
				<static>Mutations</static>
			</columnfieldlabel>


			<npcmainprofile name="weaponskill">
				<tabtarget next="ballisticskill" prev="specialqualities" />
			</npcmainprofile>
			<npctoplabel>
				<anchor>weaponskill</anchor>
				<static>CC</static>
			</npctoplabel>
			<npcmainprofile name="ballisticskill">
				<anchor>weaponskill</anchor>
				<tabtarget next="strength" prev="weaponskill" />
			</npcmainprofile>
			<npctoplabel>
				<anchor>ballisticskill</anchor>
				<static>CT</static>
			</npctoplabel>
			<npcmainprofile name="strength">
				<anchor>weaponskill</anchor>
				<tabtarget next="toughness" prev="weaponskill" />
			</npcmainprofile>
			<npctoplabel>
				<anchor>strength</anchor>
				<static>F</static>
			</npctoplabel>
			<npcmainprofile name="toughness">
				<anchor>weaponskill</anchor>
				<tabtarget next="agility" prev="weaponskill" />
			</npcmainprofile>
			<npctoplabel>
				<anchor>toughness</anchor>
				<static>E</static>
			</npctoplabel>
			<npcmainprofile name="agility">
				<anchor>weaponskill</anchor>
				<tabtarget next="intelligence" prev="ballisticskill" />
			</npcmainprofile>
			<npctoplabel>
				<anchor>agility</anchor>
				<static>Ag</static>
			</npctoplabel>
			<npcmainprofile name="intelligence">
				<anchor>weaponskill</anchor>
				<tabtarget next="perception" prev="agility" />
			</npcmainprofile>
			<npctoplabel>
				<anchor>intelligence</anchor>
				<static>Int</static>
			</npctoplabel>
	
			<npcmainprofile name="perception">
				<anchor>weaponskill</anchor>
				<tabtarget next="willpower" prev="intelligence" />
			</npcmainprofile>
			<npctoplabel>
				<anchor>perception</anchor>
				<static>Per</static>
			</npctoplabel>
	
			<npcmainprofile name="willpower">
				<anchor>weaponskill</anchor>
				<tabtarget next="fellowship" prev="perception" />
			</npcmainprofile>
			<npctoplabel>
				<anchor>willpower</anchor>
				<static>FM</static>
			</npctoplabel>
			<npcmainprofile name="fellowship">
				<anchor>weaponskill</anchor>
				<tabtarget next="attack" prev="willpower" />
			</npcmainprofile>
			<npctoplabel>
				<anchor>fellowship</anchor>
				<static>Soc</static>
			</npctoplabel>

			<columnfieldlabel>
				<anchor>weaponskill</anchor>
				<static>Principal</static>
			</columnfieldlabel>


			<npcsecprofile name="attack">
				<tabtarget next="wound" prev="fellowship" />
			</npcsecprofile>
			<npctoplabel>
				<anchor>attack</anchor>
				<static>A</static>
			</npctoplabel>

			<npcsecprofile name="wound">
				<anchor>attack</anchor>
				<tabtarget next="move" prev="attack" />
			</npcsecprofile>
			<npctoplabel>
				<anchor>wound</anchor>
				<static>B</static>
			</npctoplabel>

<!--			<npcsecprofile name="strbonus">
				<anchor>attack</anchor>
				<tabtarget next="name" prev="reflexsave" />
			</npcsecprofile>
			<npctoplabel>
				<anchor>strbonus</anchor>
				<static>SB</static>
			</npctoplabel>

			<npcsecprofile name="toughbonus">
				<anchor>attack</anchor>
				<tabtarget next="reflexsave" prev="fellowship" />
			</npcsecprofile>
			<npctoplabel>
				<anchor>toughbonus</anchor>
				<static>TB</static>
			</npctoplabel> -->

			<npcsecprofile name="move">
				<anchor>attack</anchor>
				<tabtarget next="fatep" prev="attack" />
			</npcsecprofile>
			<npctoplabel>
				<anchor>move</anchor>
				<static>M</static>
			</npctoplabel>

<!--			<npcsecprofile name="magic">
				<anchor>attack</anchor>
				<tabtarget next="insanityp" prev="move" />
			</npcsecprofile>
			<npctoplabel>
				<anchor>magic</anchor>
				<static>Mag</static>
			</npctoplabel> -->

<!--			<npcsecprofile name="insanityp">
				<anchor>attack</anchor>
				<tabtarget next="fatep" prev="magic" />
			</npcsecprofile>
			<npctoplabel>
				<anchor>insanityp</anchor>
				<static>IP</static>
			</npctoplabel> -->

			<npcsecprofile name="fatep">
				<anchor>attack</anchor>
				<tabtarget next="willsave" prev="attack" />
			</npcsecprofile>
			<npctoplabel>
				<anchor>fatep</anchor>
				<static>PF</static>
			</npctoplabel>

			<columnfieldlabel>
				<anchor>attack</anchor>
				<static>Secondaire</static>
			</columnfieldlabel>

			<columnstringfield name="skills">
				<anchor>attack</anchor>
				<tabtarget next="talents" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>skills</anchor>
				<static>Comp.</static>
			</columnfieldlabel>

			<columnstringfield name="talents">
				<anchor>attack</anchor>
				<tabtarget next="armor" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>talents</anchor>
				<static>Talents</static>
			</columnfieldlabel>

			<columnstringfield name="armor">
				<anchor>attack</anchor>
				<tabtarget next="ac" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>armor</anchor>
				<static>Armure</static>
			</columnfieldlabel>

			<columnstringfield name="ac">
				<anchor>attack</anchor>
				<tabtarget next="weapons" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>ac</anchor>
				<static>Pts armure</static>
			</columnfieldlabel>

			<columnstringfield name="weapons">
				<anchor>attack</anchor>
				<tabtarget next="spacereach" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>weapons</anchor>
				<static>Armes</static>
			</columnfieldlabel>

			<columnstringfield name="spacereach">
				<anchor>weapons</anchor>
			</columnstringfield>
			<columnfieldlabel>
				<anchor>spacereach</anchor>
				<static>Spécial</static>
			</columnfieldlabel>
			
			<!-- Spacer -->
			<genericcontrol>
				<anchored>
					<to>attack</to>
					<position>below</position>
					<size>
						<height>25</height>
					</size>
				</anchored>
			</genericcontrol>
		</sheetdata>
	</windowclass>

	<windowclass name="npc_other">
		<datasource>npc</datasource>
		<sheetdata>
			<columnstringfield name="career">
				<tabtarget next="equipment" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>career</anchor>
				<static>Carrière</static>
			</columnfieldlabel>
			
			<columnstringfield name="equipment">
				<anchor>career</anchor>
				<tabtarget next="extrarules" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>equipment</anchor>
				<static>Equipement</static>
			</columnfieldlabel>

			<columnstringfield name="extrarules">
				<anchor>career</anchor>
				<tabtarget next="phrases" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>extrarules</anchor>
				<static>Règles spé.</static>
			</columnfieldlabel>

			<columnstringfield name="phrases">
				<anchor>career</anchor>
				<tabtarget next="appearance" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>phrases</anchor>
				<static>Psych</static>
			</columnfieldlabel>

			<columnstringfield name="appearance">
				<anchor>career</anchor>
				<tabtarget next="insanities" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>appearance</anchor>
				<static>Apparence</static>
			</columnfieldlabel>

			<columnstringfield name="insanities">
				<anchor>career</anchor>
				<tabtarget next="slaughtermargin" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>insanities</anchor>
				<static>Folies</static>
			</columnfieldlabel>

			<columnstringfield name="slaughtermargin">
				<anchor>career</anchor>
				<tabtarget next="feats" prev="type" />
			</columnstringfield>
			<columnfieldlabel>
				<anchor>slaughtermargin</anchor>
				<static>Autres</static>
			</columnfieldlabel>


			<!-- Spacer -->
			<genericcontrol>
				<anchored>
					<to>slaughtermargin</to>
					<position>below</position>
					<size>
						<height>15</height>
					</size>
				</anchored>
			</genericcontrol>
		</sheetdata>
	</windowclass>

	<windowclass name="npc_description">
		<datasource>npc</datasource>
		<sheetdata>
			<!-- DESCRIPTION -->
			<formattedtextfield name="text">
				<bounds>0,0,-1,-1</bounds>
				<font>
					<normal>chatfont</normal>
					<bold>narratorfont</bold>
					<italic>chatitalicfont</italic>
					<bolditalic>chatbolditalicfont</bolditalic>
					<title>defaultstringcontrol</title>
				</font>
				<linkicon>
					<link>button_openwindow</link>
					<emptylink>button_emptytarget</emptylink>
				</linkicon>
				<selectioncolor>#FFD296</selectioncolor>
				<footer>footer_narrow</footer>
				<empty>Cliquer pour entrer une description</empty>
			</formattedtextfield>
			<scrollercontrol>
				<bounds>-45,-27,45,27</bounds>
				<target>text</target>
				<button>
					<normal>button_scroller</normal>
					<pressed>button_scroller_down</pressed>
				</button>
			</scrollercontrol>
		</sheetdata>
	</windowclass>

	<windowclass name="npc">
		<datasource>npc</datasource>
		<frame>charsheet</frame>
		<placement>
			<size>
				<width>300</width>
				<height>400</height>
			</size>
		</placement>
		<sizelimits>
			<minimum>
				<width>270</width>
				<height>400</height>
			</minimum>
			<dynamic />
		</sizelimits>
		<minimize>minimized_npc</minimize>
		<tooltip>
			<field>name</field>
		</tooltip>
		<sheetdata>
			<!-- NAME -->
			<genericcontrol name="nameframe">
				<bounds>38,20,-35,35</bounds>
				<frame>
					<name>sheetgroup</name>
				</frame>
			</genericcontrol>
			<windowopencontrol>
				<anchored>
					<to>nameframe</to>
					<position>insidetopleft</position>
					<offset>13,8</offset>
					<size>
						<width>20</width>
						<height>20</height>
					</size>
				</anchored>
				<icon>
					<normal>button_openwindow</normal>
					<pressed>button_emptytarget</pressed>
				</icon>
				<class>npc</class>
				<description>
					<field>name</field>
				</description>
			</windowopencontrol>
			<stringfield name="name">
				<anchored>
					<top>
						<parent>nameframe</parent>
						<anchor>top</anchor>
						<offset>9</offset>
					</top>
					<left>
						<parent>nameframe</parent>
						<anchor>left</anchor>
						<offset>35</offset>
					</left>
					<right>
						<parent>nameframe</parent>
						<anchor>right</anchor>
						<offset>-15</offset>
					</right>
				</anchored>
				<empty>&#171; New Personality &#187;</empty>
				<font>sheettext</font>
			</stringfield>
			<tokenfield name="token">
				<bounds>13,25,25,25</bounds>
				<empty>indicator_emptytoken</empty>
			</tokenfield>
			<buttoncontrol>
				<bounds>-36,27,23,22</bounds>
				<icon>
					<normal>button_identityactivate</normal>
					<pressed>button_identityactivate_down</pressed>
				</icon>
				<script>
					function onButtonPress()
						GmIdentityManager.addIdentity(window.name.getValue());
					end
				</script>
			</buttoncontrol>

			<genericcontrol name="tabcontentframe">
				<bounds>10,54,-25,-15</bounds>
				<frame>
					<name>sheetgroup</name>
					<offset>0,1,0,0</offset>
				</frame>
			</genericcontrol>

			<!-- SUBWINDOWS -->
			<subwindow name="description">
				<anchored>
					<to>tabcontentframe</to>
					<position>over</position>
					<offset>-15,-7</offset>
				</anchored>
				<class>npc_description</class>
			</subwindow>
			<subwindow name="combat">
				<anchored>
					<to>tabcontentframe</to>
					<position>over</position>
					<offset>-15,-7</offset>
				</anchored>
				<class>npc_combat</class>
			</subwindow>
			<subwindow name="other">
				<anchored>
					<to>tabcontentframe</to>
					<position>over</position>
					<offset>-15,-7</offset>
				</anchored>
				<class>npc_other</class>
			</subwindow>

			<scrollercontrol name="combat_scroller">
				<bounds>-79,-50,45,27</bounds>
				<target>combat</target>
				<button>
					<normal>button_scroller</normal>
					<pressed>button_scroller_down</pressed>
				</button>
				<invisible />
			</scrollercontrol>
			<scrollercontrol name="other_scroller">
				<bounds>-79,-50,45,27</bounds>
				<target>other</target>
				<button>
					<normal>button_scroller</normal>
					<pressed>button_scroller_down</pressed>
				</button>
				<invisible />
			</scrollercontrol>

			<tabcontrol name="tabs">
				<bounds>-22,50,18,223</bounds>
				<tab>
					<icon>tab_main</icon>
					<subwindow>description</subwindow>
				</tab>
				<tab>
					<icon>tab_combat</icon>
					<subwindow>combat</subwindow>
					<scroller>combat_scroller</scroller>
				</tab>
				<tab>
					<icon>tab_other</icon>
					<subwindow>other</subwindow>
					<scroller>other_scroller</scroller>
				</tab>
				<activate>2</activate>
			</tabcontrol>
		</sheetdata>
	</windowclass>

	<windowclass name="npcsmall">
		<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>npc</class>
				<description>
					<field>name</field>
				</description>
			</windowreferencecontrol>
			<linkstringfield name="name">
				<bounds>25,1,-1,20</bounds>
				<empty>&#171; New Personality &#187;</empty>
				<selectioncolor>#90ffffff</selectioncolor>
				<font>sheettext</font>
				<linktarget>open</linktarget>
			</linkstringfield>
		</sheetdata>
	</windowclass>

	<windowclass name="npclist">
		<frame>scrollboxfortabs</frame>
		<softclose />
		<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,157</bounds>
				<icon>title_npcs</icon>
			</genericcontrol>
			<windowlist name="list">
				<bounds>50,25,-30,-34</bounds>
				<datasource>.</datasource>
				<class>npcsmall</class>
				<sortfields>name</sortfields>
				<footer>footer_narrow</footer>
				<allowcreate />
				<allowdelete />
				<acceptdrop>
					<class>npc</class>
					<field>name</field>
					<field>text</field>
					<field>hd</field>
					<field>hp</field>
					<field>init</field>
					<field>speed</field>
					<field>ac</field>
					<field>armor</field>
					<field>talents</field>
					<field>weapons</field>
					<field>career</field>
					<field>equipment</field>
					<field>extrarules</field>
					<field>phrases</field>
					<field>appearance</field>
					<field>slaughtermargin</field>
					<field>insanities</field>
					<field>babgrp</field>
					<field>atk</field>
					<field>fullatk</field>
					<field>spacereach</field>
					<field>specialattacks</field>
					<field>specialqualities</field>
					<field>weaponskill</field>
					<field>ballisticskill</field>
					<field>strength</field>
					<field>toughness</field>
					<field>agility</field>
					<field>intelligence</field>
					<field>perception</field>
					<field>willpower</field>
					<field>fellowship</field>
					<field>attack</field>
					<field>wound</field>
					<field>strbonus</field>
					<field>toughbonus</field>
					<field>move</field>
					<field>magic</field>
					<field>insanityp</field>
					<field>fatep</field>
					<field>reflexsave</field>
					<field>skills</field>
					<field>feats</field>
					<field>environment</field>
					<field>organization</field>
					<field>cr</field>
					<field>treasure</field>
					<field>alignment</field>
					<field>advancement</field>
					<field>leveladjustment</field>
				</acceptdrop>
				<script>
					function onSortCompare(w1, w2)
						return w1.name.getValue() &gt; 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>npc</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>

			<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>
</root>
