<?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="modifiersmall">
		<playercontrol />
		<sizelimits>
			<minimum>
				<height>10</height>
			</minimum>
		</sizelimits>
		<script>
			function onInit()
				if User.isHost() then
					registerMenuItem("Delete Item", "delete", 6);
				end
			end

			function onMenuSelection(selection)
				if selection == 6 then
					getDatabaseNode().delete();
				end
			end
			
			function onDrag(button, x, y, draginfo)
				if label.getValue() ~= "" then
					draginfo.setType("number");
					draginfo.setDescription(label.getValue());
					draginfo.setStringData(label.getValue());
					draginfo.setNumberData(bonus.getValue());
				end

				return true;
			end
			
			function onDoubleClick(x, y)
				ModifierStack.addSlot(label.getValue(), bonus.getValue());
			end

			function onDrop(x, y, draginfo)
				return windowlist.onDrop(x, y, draginfo);
			end
		</script>
		<sheetdata>
			<jpgnumberfield name="bonus">
				<anchored>
					<right>
						<anchor>right</anchor>
					</right>
					<top>
						<anchor>top</anchor>
					</top>
					<size>
						<width>30</width>
						<height>22</height>
					</size>
				</anchored>
				<font>sheetnumbersmall</font>
				<frame>
					<name>bonus</name>
					<offset>2,2,2,1</offset>
				</frame>
				<keyeditframe>
					<name>sheetfocus</name>
					<offset>2,2,2,2</offset>
				</keyeditframe>
				<stateframe>
					<drophilight>
						<name>sheetfocus</name>
						<offset>2,2,2,2</offset>
					</drophilight>
				</stateframe>
				<displaysign />
				<droptypes>
					<type>number</type>
				</droptypes>
				<gmonly />
				<script>
					function onDrag(button, x, y, draginfo)
						return window.onDrag(button, x, y, draginfo);
					end
					
					function onDoubleClick(x, y)
						return window.onDoubleClick(x, y);
					end

					function onDrop(x, y, draginfo)
						if draginfo.getType() ~= "number" then
							return false;
						end
					end
				</script>
			</jpgnumberfield>

			<textlistitemvalue name="label">
				<anchored>
					<left>
						<anchor>left</anchor>
						<offset>2</offset>
					</left>
					<right>
						<parent>bonus</parent>
						<anchor>left</anchor>
					</right>
					<top>
						<anchor>top</anchor>
						<offset>3</offset>
					</top>
					<size>
						<height>17</height>
					</size>
				</anchored>
				<gmonly />
				<script>
					function onDrag(button, x, y, draginfo)
						return window.onDrag(button, x, y, draginfo);
					end
					
					function onDoubleClick(x, y)
						return window.onDoubleClick(x, y);
					end
				</script>
			</textlistitemvalue>
		</sheetdata>
	</windowclass>
	
	<windowclass name="modifierlist">
		<frame>charsheet</frame>
		<playercontrol />
		<nodelete />
		<tooltip>
			<text>Modifier list</text>
		</tooltip>
		<placement>
			<size>
				<width>275</width>
				<height>350</height>
			</size>
		</placement>
		<sizelimits>
			<dynamic />
			<minimum>
				<width>200</width>
				<height>220</height>
			</minimum>
		</sizelimits>
		<sheetdata>
			<genericcontrol name="nameframe">
				<bounds>10,20,-15,35</bounds>
				<frame>
					<name>sheetgroup</name>
				</frame>
			</genericcontrol>

			<stringcontrol name="name">
				<anchored>
					<to>nameframe</to>
					<position>over</position>
					<offset>-15,-10</offset>
				</anchored>
				<center />
				<static>MODIFIERS</static>
				<font>narratorfont</font>
			</stringcontrol>

			<genericcontrol name="listframe">
				<bounds>10,54,-15,-15</bounds>
				<frame>
					<name>sheetgroup</name>
				</frame>
			</genericcontrol>

			<windowlist name="list">
				<anchored>
					<to>listframe</to>
					<position>over</position>
					<offset>-15,-8</offset>
				</anchored>
				<datasource>.</datasource>
				<class>modifiersmall</class>
				<footer>footer_narrow</footer>
				<script>
					function onInit()
						if User.isHost() then
							registerMenuItem("Create Item", "insert", 5);
						end
					end
					
					function createItem()
						local wnd = NodeManager.createSafeWindow(self);
						if wnd then
							wnd.label.setFocus();
						end
						return wnd;
					end

					function onMenuSelection(selection)
						if selection == 5 then
							createItem();
						end
					end
					
					function onClickDown(button, x, y)
						return true;
					end
					
					function onClickRelease(button, x, y)
						if User.isHost() then
							if not getNextWindow(nil) then
								createItem();
							end
						end
						return true;
					end
					
					function onSortCompare(w1, w2)
						return w1.label.getValue() &gt; w2.label.getValue();
					end
					
					function onDrop(x, y, draginfo)
						if User.isHost() then
							if draginfo.getType() == "number" then
								local win = NodeManager.createSafeWindow(self);
								if win then
									win.label.setValue(draginfo.getDescription());
									win.bonus.setValue(draginfo.getNumberData());
								end
								return true;
							end
						end
					end

					function onFilter(w)
						local f = string.lower(window.filter.getValue());
						if f == "" then
							return true;
						end
						
						if string.find(string.lower(w.label.getValue()), f, 0, true) then
							return true;
						end
						
						return false;
					end
				</script>
			</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>
			<filter name="filter">
				<bounds>55,-40,-50,20</bounds>
				<target>list</target>
				<trigger>filtertrigger</trigger>
			</filter>
			<filtertrigger name="filtertrigger">
				<bounds>20,-55,21,41</bounds>
				<target>filter</target>
			</filtertrigger>			
			
			<closebutton_charsheetmini />
		</sheetdata>
	</windowclass>
</root>
