<?xml version="1.0" encoding="iso-8859-1"?>

<!-- 
  -- Please see the readme.txt file included with this distribution for 
  -- attribution and copyright information.
  -->

<root version="2.0">
	<windowclass name="clienttracker_entry">
		<frame>ctentrybox</frame>
		<sizelimits>
			<minimum>
				<height>40</height>
			</minimum>
		</sizelimits>
		<script file="scripts/clienttracker_entry.lua" />
		<sheetdata>
			<!-- Hidden values -->
			<stringfield name="type">
				<invisible />
				<bounds>0,0,1,1</bounds>
				<script>
					function onValueChanged()
						window.onTypeChanged();
					end
				</script>
			</stringfield>
			<stringfield name="tokenrefid">
				<invisible />
				<bounds>0,0,1,1</bounds>
			</stringfield>
			<stringfield name="tokenrefnode">
				<invisible />
				<bounds>0,0,1,1</bounds>
				<script>
					function onValueChanged()
						window.linkToken();
					end
				</script>
			</stringfield>
			<windowreferencefield name="link">
				<invisible />
				<bounds>0,0,1,1</bounds>
			</windowreferencefield>
			<numberfield name="init">
				<invisible />
				<bounds>0,0,1,1</bounds>
			</numberfield>
			<numberfield name="show_npc">
				<invisible />
				<bounds>0,0,1,1</bounds>
			</numberfield>

			<!-- Basics -->
			<tokenfield name="token">
				<bounds>33,6,23,23</bounds>
				<empty>indicator_emptytoken</empty>
			</tokenfield>
			<jpgnumberfield name="initresult">
				<anchored>
					<position>righthigh</position>
					<offset>-150,7</offset>
					<size>
						<width>34</width>
						<height>23</height>
					</size>
				</anchored>
				<hideonvalue>0</hideonvalue>
				<font>sheetnumbersmall</font>
				<frame>
					<name>modifier</name>
					<offset>2,2,2,2</offset>
				</frame>
				<readonly />
				<script>
					function onValueChanged()
						window.windowlist.applySort();
					end
				</script>
			</jpgnumberfield>
			<stringfield name="name">
				<anchored>
					<to>token</to>
					<position>righthigh</position>
					<offset>2,4</offset>
					<right>
						<parent>initresult</parent>
						<anchor>left</anchor>
						<offset>-4,0</offset>
					</right>
				</anchored>
				<font>sheettextsmall</font>
				<frame>
					<name>textlinesmall</name>
					<offset>0,-1,0,0</offset>
				</frame>
				<script>
					function onInit()
						setReadOnly(true);
					end
				</script>
			</stringfield>
			<stringfield name="status">
				<anchored>
					<top>
						<parent>name</parent>
						<anchor>top</anchor>
					</top>
					<left>
						<parent>initresult</parent>
						<anchor>right</anchor>
						<offset>9</offset>
					</left>
				</anchored>
				<font>sheettextsmall</font>
				<invisible />
				<readonly />
				<script>
					function onInit()
						setReadOnly(true);
						onValueChanged();
					end
					
					function onValueChanged()
						local s = getValue();

						if s == "Healthy" then
							setFont("ct_healthy_font");
						elseif s == "Light" then
							setFont("ct_ltwound_font");
						elseif s == "Moderate" then
							setFont("ct_modwound_font");
						elseif s == "Disabled" or s == "Heavy" then
							setFont("ct_hvywound_font");
						else
							setFont("ct_dead_font");
						end
					end
				</script>
			</stringfield>
			<jpgnumberfield name="hp">
				<anchored>
					<to>initresult</to>
					<position>right</position>
					<offset>5,0</offset>
					<size>
						<width>34</width>
					</size>
				</anchored>
				<font>sheetnumbersmall</font>
				<frame>
					<name>modifier</name>
					<offset>2,2,2,2</offset>
				</frame>
				<readonly />
				<script>
					function onValueChanged()
						window.onWoundsChanged();
					end
				</script>
			</jpgnumberfield>
			<jpgnumberfield name="wounds">
				<anchored>
					<to>hp</to>
					<position>right</position>
					<offset>5,0</offset>
					<size>
						<width>34</width>
					</size>
				</anchored>
				<hideonvalue value="0" />
				<font>sheetnumbersmall</font>
				<frame>
					<name>modifier</name>
					<offset>2,2,2,2</offset>
				</frame>
				<readonly />
				<script>
					function onValueChanged()
						window.onWoundsChanged();
					end
				</script>
			</jpgnumberfield>
			<stringfield name="friendfoe">
				<invisible />
				<bounds>0,0,1,1</bounds>
				<script>
					function onInit()
						onValueChanged();
					end
					
					function onValueChanged()
						window.friendfoe_icon.updateIcon(getValue());
					end
				</script>
			</stringfield>
			<genericcontrol name="friendfoe_icon">
				<anchored>
					<position>righthigh</position>
					<offset>-32,8</offset>
					<size>
						<width>20</width>
						<height>20</height>
					</size>
				</anchored>
				<script>
					function updateIcon(value)
						if value == "friend" then
							setIcon("indicator_ctfffriend");
							setTooltipText("Friend");
						elseif value == "neutral" then
							setIcon("indicator_ctffneutral");
							setTooltipText("Neutral");
						elseif value == "foe" then
							setIcon("indicator_ctfffoe");
							setTooltipText("Foe");
						else
							setIcon("indicator_ctffempty");
							setTooltipText("");
						end
					end
				</script>
			</genericcontrol>

			<numberfield name="active">
				<invisible />
				<bounds>0,0,1,1</bounds>
				<script>
					function onInit()
						onValueChanged();
					end
					
					function onValueChanged()
						if getValue() == 0 then
							window.active_icon.setVisible(false);
						else
							window.active_icon.setVisible(true);
						end
					end
				</script>
			</numberfield>
			<genericcontrol name="passive_icon">
				<anchored>
					<top>
						<anchor>top</anchor>
					</top>
					<bottom>
						<anchor>bottom</anchor>
					</bottom>
					<left>
						<anchor>left</anchor>
					</left>
					<size>
						<width>33</width>
					</size>
				</anchored>
				<icon>indicator_ctpassive</icon>
			</genericcontrol>
			<genericcontrol name="active_icon">
				<anchored>
					<top>
						<anchor>top</anchor>
					</top>
					<bottom>
						<anchor>bottom</anchor>
					</bottom>
					<left>
						<anchor>left</anchor>
					</left>
					<size>
						<width>33</width>
					</size>
				</anchored>
				<icon>indicator_ctactive</icon>
				<invisible />
			</genericcontrol>
		</sheetdata>
	</windowclass>

	<windowclass name="clienttracker_window">
		<frame>ctbox</frame>
		<placement>
			<size>
				<width>527</width>
				<height>512</height>
			</size>
		</placement>
		<sizelimits>
			<minimum>
				<width>320</width>
				<height>210</height>
			</minimum>
			<dynamic>
				<resize>both</resize>
			</dynamic>
		</sizelimits>
		<nodelete />
		<tooltip>
			<text>Client Tracker</text>
		</tooltip>
		<script>
			function onInit()
				updateHealthDisplay();
			end
			
			function updateHealthDisplay()
				local showdetails = OptionsManager.isOption("SHPH", "on");
				
				label_hp.setVisible(showdetails);
				label_wounds.setVisible(showdetails);

				label_status.setVisible(not showdetails);

				for k,w in pairs(list.getWindows()) do
					w.updateHealthDisplay();
				end
			end
		</script>
		<sheetdata>
			<stringfield name="opt_shph" source="..options.SHPH">
				<bounds>0,0,1,1</bounds>
				<invisible />
				<script>
					function onValueChanged()
						window.updateHealthDisplay();
					end
				</script>
			</stringfield>
			
			<stringcontrol>
				<bounds>60,15,30,10</bounds>
				<font>sheetlabelsmall</font>
				<color>#ffffffff</color>
				<static>Name</static>
			</stringcontrol>
			<stringcontrol>
				<anchored>
					<position>right</position>
					<offset>-161,-15</offset>
				</anchored>
				<font>sheetlabelsmall</font>
				<color>#ffffffff</color>
				<static>Init</static>
			</stringcontrol>
			<stringcontrol name="label_hp">
				<anchored>
					<position>right</position>
					<offset>-120,-15</offset>
				</anchored>
				<font>sheetlabelsmall</font>
				<color>#ffffffff</color>
				<static>HP</static>
			</stringcontrol>
			<stringcontrol name="label_wounds">
				<anchored>
					<position>right</position>
					<offset>-97,-15</offset>
				</anchored>
				<font>sheetlabelsmall</font>
				<color>#ffffffff</color>
				<static>Wounds</static>
			</stringcontrol>
			<stringcontrol name="label_status">
				<anchored>
					<right>
						<anchor>right</anchor>
						<offset>-113</offset>
					</right>
					<top>
						<anchor>top</anchor>
						<offset>15</offset>
					</top>
				</anchored>
				<font>sheetlabelsmall</font>
				<color>#ffffffff</color>
				<static>Status</static>
			</stringcontrol>

			<windowlist name="list">
				<class>clienttracker_entry</class>
				<datasource>.</datasource>
				<skipemtpy />
				<bounds>0,30,-20,-50</bounds>
				<script file="scripts/clienttracker.lua" />
			</windowlist>

			<scrollercontrol>
				<anchored>
					<to>list</to>
					<position>insidebottomright</position>
					<size>
						<width>45</width>
						<height>27</height>
					</size>
				</anchored>
				<target>list</target>
				<button>
					<normal>button_scroller</normal>
					<pressed>button_scroller_down</pressed>
				</button>
			</scrollercontrol>
			
			<buttoncontrol name="turn_complete">
				<bounds>62,-45,33,26</bounds>
				<icon>
					<normal>button_ctnextactor</normal>
					<pressed>button_ctnextactor_down</pressed>
				</icon>
				<tooltip>
					<text>Turn complete</text>
				</tooltip>
				<script>
					function onButtonPress()
						ChatManager.sendSpecialMessage(ChatManager.SPECIAL_MSGTYPE_ENDTURN, {});
					end
				</script>
			</buttoncontrol>
			
			<stringcontrol name="roundcounterlabel">
				<anchored>
					<right>
						<anchor>right</anchor>
						<offset>-108</offset>
					</right>
					<top>
						<anchor>bottom</anchor>
						<offset>-39</offset>
					</top>
					<size>
						<width>50</width>
						<height>15</height>
					</size>
				</anchored>
				<font>sheetlabel</font>
				<color>#ffffffff</color>
				<static>Round</static>
			</stringcontrol>
			<jpgnumberfield name="roundcounter" source="..combattracker_props.round">
				<anchored>
					<left>
						<parent>roundcounterlabel</parent>
						<anchor>right</anchor>
					</left>
					<top>
						<parent>roundcounterlabel</parent>
						<anchor>top</anchor>
						<offset>-6</offset>
					</top>
					<size>
						<width>40</width>
						<height>25</height>
					</size>
				</anchored>
				<frame>
					<name>modifier</name>
					<offset>3,3,3,3</offset>
				</frame>
				<font>sheetnumber</font>
				<gmonly />
			</jpgnumberfield>

			<closebutton_combattracker />
		</sheetdata>
	</windowclass>
</root>
