Difference between revisions of "Tile Systems (MenuQue)"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Kyoma
m (added See Also)
imported>Kyoma
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:




==General==
== General ==
In order for modders to easily mark an element as a TileSystem they need to use a specific string-constant for the <id> trait of the element in question. Then, whenever the game processes that particular XML the code will pick up on the desired tile system, create the needed background stuff and attach it to the element.  
In order for modders to easily mark an element as a TileSystem they need to use a specific string-constant for the <id> trait of the element in question. Then, whenever the game processes that particular XML the code will pick up on the desired tile system, create the needed background stuff and attach it to the element.  


There can be only one per element but a menu can contain any number of systems, even with the same type.
Only one system can be associated with a single element but there are no limits to the total amount. Atleast, not practical ones.
<pre>
 
<menu name="DemoMenu">
 
<class> &GenericMenu; </class>
== Types ==
<stackingtype> &no_click_past; </stackingtype>
There are a number of different types of TileSystems, each one dealing with a different aspect of user-to-UI interaction. Some have required traits for specific input data and some have optional traits for additional configuration.
<locus> &true; </locus>
 
<explorefade> 0.25 </explorefade>
A short list (more details on each induvidual system can be found below:
* Scroll System - This system responds to the mouse wheel movement and will increment or decrement a specific trait accordingly.
<rect name="background">
** ID is: '''&Scroll;'''
<include src="generic_background.xml" />
** (required) <user5> - the trait that gets altered by code.


<id> &TileSystemType; </id> <!-- this will mark the element as a TileSystem -->
* Drag System - This system responds to the mouse movement while the left mouse button is held down over the element. There are three different types of movement: horizontal, vertical or both.
<visible> &true; </visible>
** IDs are: '''&DragHorizontal;''' and '''&DragVertical;''' and '''&DragRect;''' respectively
<depth> 15 </depth>
** (required) <user8> - controls the step-distance for dragging.
<locus> &true; </locus>
** (required) <user9> - the trait that gets altered by code.
<target> &true; </target>
<user0> 400 </user0>
<user1> 580 </user1>
<x>
<copy src="screen()" trait="width" />
<sub src="me()" trait="width" />
<div> 2 </div>
</x>
<y>
<copy src="screen()" trait="height" />
<sub src="me()" trait="height" />
<div> 2 </div>
</y>
</rect>
</menu>
</pre>


==Types==
* TextEdit System - This system provides a simple field where the user, after clicking the element, can type in.
There are a number of different types of TileSystems, each one dealing with a different aspect of user-to-UI interaction. Depending on the system an element will also need to have certain <userX> traits in order to function properly.  
** ID is: '''&TextEdit;'''
** (optional) <user0> - controls the initial text upon activating.
** (optional) <user1> - controls the default text for when it is deactivated and the input string is empty


===Scroll===
* FocusBox System - This system will adjust the size and position of the designated element to match that of the active element, provided its <focus>, <target> and <visible> traits are true.
This will respond to the mousewheel and increment or decrement the <user5> trait. Most common use would be for custom scrollbars but how this value is used makes no difference. REQUIRES: <user5> trait.
** ID is: '''&FocusBox;'''
** (optional) <user15> - used as a static depth adjustment.


* A scroll system is only considered active (and thus invoked) when it is visible and targetable. When a menu has more than one scroll system (including the default scrolling behaviour) it will use the first active one it finds. Scroll systems always take precedence over the default scrolling behaviour.
== Details ==
* The code does not check for boundaries when it detects scrolling, that should be done in the XML using the <max> and <min> traits.
Below you will find more details on each system and a few examples. A useful guide to creating and using these systems is to start out with a snippet of code from the existing XML files. Then adjust things like position, size and perhaps names. Finally change the <id> trait to the proper code for what you want it to do.


Here is a quick template, when you see a trait with ... then that means it is of no importance to this system in particular and should be filled with whatever value you need it to be. They are listed for completeness and to better illustrate things.
Almost all examples listed below come from existing XML files, either as a direct copy or slightly modified to clean things up.
<pre>...
=== FocusBox ===
<image name="scroll_bar">
The size and position of a focus box can be adjusted using the <focussize> and <focusinset> traits. They control the additional size and additional offset of the focus box in relation to the active element in the following fashion:
<include src="vertical_scroll.xml" />
focusBox_X = (element_X - (focussize / 2) + focusinset)
<id> &Scroll; </id>
focusBox_Y = (element_Y - (focussize / 2) + focusinset)
<target> &true; </target>
focusBox_Width = (element_Width + focussize)
<locus> &true; </locus>
focusBox_Height = (element_Height + focussize)
<depth> 15 </depth>
<pre>
<user1> ... </user1>
<rect name="focus_box">
<user2> ... </user2>
<include src="focus_box.xml"/>
<user3> ... </user3> <!-- step distance -->
<id> &FocusBox; </id>
<user4> ... </user4> <!-- jump distance -->
<visible> &false; </visible>
<user5> 0 </user5> <!-- code set - scroll force value (must be 0 here) -->
</rect>
<!-- user7 --> <!-- current value -->
<user8> ... </user8> <!-- num visible -->
</image>
...
...
</pre>
<rect name="some_element">
<width> 200 </width>
<height> 50 </height>
<x> 45 </x>
<y> 160 </y>


===Drag===
<!-- when the mouse is over this element its dimension
These will respond to the mouse movement while holding down the left mouse button. There are three versions, two for movement along a single axis and one movement along both axis. There is a small limitation in that the moving of the dragged element should not affect the position of its parent element (or anything else higher up the chain).
and position will be copied to the focus box -->
<focus> &true; </focus>


The element itself does not have to move though. REQUIRES: <user8> and <user9> for horizontal -or- vertical dragging and <user11>, <user12>, <user13> and <user14> for dragging along both axis.
<!-- this gets added to the width and height before they are copied.
And half of it gets substracted from X and Y to even the increase in size
between the outline. -->
<focussize> 20 </focussize>  


===FocusBox===
<!-- this gets added to the X and Y before they are copied -->
A focus system will react to the active element (e.g. the mouse is over it). It will then get the same <width>,<height>, <x> and <y> traits as the active element. But this only happens if the active element has a "&true;" <focus> and a "&true;" <target> trait. The position offset can be adjusted with the <focusinset> trait. The difference in size can be adjusted with the <focussize> trait. REQUIRES: <user15> trait.
<focusinset> 0 </focusinset>
</rect>
</pre>With the example above, when the mouse is held over "some_element" the "focus_box" gets the following traits set:
<x> = 45 - (20 / 2) = 35
<y> = 160 - (20 / 2) = 150
<width> = 200 + 20 = 220
<height> = 50 + 20 = 70


===TextEdit===
=== TextEdit ===
A textedit system allows simple boxes that can be typed in. Although not as powerful as OBSE's TextInput it is much more flexible in terms of layout and can be added to any menu, even those that have a textedit box by default. It will match the default typing behaviour as seen in some menus.
In order to begin typing the user must first click on the element. Modders can also use ClickMenuButton to activate it through script. Once activated the user


* The initial value is determined by the <string> trait when it gets activated, any changes once it is active are ignored.
* The initial value is determined by the <string> trait when it gets activated, any changes once it is active are ignored.
Line 83: Line 80:
* The use of the Enter key will terminate the textedit.
* The use of the Enter key will terminate the textedit.


Here is a quick template, when you see a trait with ... then that means it is of no importance to this system in particular and should be filled with whatever value you need it to be. They are listed for completeness and to better illustrate things.
<pre>
<pre>
...
<rect name="_textedit">
<rect name="textedit">
<!-- this is the element that determines the size and position of the
clickable area needed to activate the typing. -->
<locus> &true; </locus>
<locus> &true; </locus>
<target> &true; </target>
<target> &true; </target>
<x> ... </x>
<y> ... </y>
<width> 240 </width>
<width> 240 </width>
<height> 40 </height>
<height> 40 </height>
<depth> 3 </depth>
<depth> 3 </depth>
 
<text name="_textedit_text">
<text name="textedit_text">
<id> &TextEdit; </id>
<id> &TextEdit; </id>
<string> My Initial Text </string>
<string> some text </string>
<depth> 3 </depth>
<depth> 3 </depth>
<locus> &true; </locus>
<locus> &true; </locus>
<target> &true; </target>
<target> &true; </target>
...
</text>
</text>
</rect>
</rect>
...
 
</pre>
</pre>


== See Also ==
== See Also ==

Latest revision as of 11:11, 29 June 2011

A TileSystem is an automated process that will do the same as certain hardcoded behaviour for the UI. Things like using the mouse wheel to scroll, dragging an element back and forth or a small yet effective textedit box.


General[edit | edit source]

In order for modders to easily mark an element as a TileSystem they need to use a specific string-constant for the <id> trait of the element in question. Then, whenever the game processes that particular XML the code will pick up on the desired tile system, create the needed background stuff and attach it to the element.

Only one system can be associated with a single element but there are no limits to the total amount. Atleast, not practical ones.


Types[edit | edit source]

There are a number of different types of TileSystems, each one dealing with a different aspect of user-to-UI interaction. Some have required traits for specific input data and some have optional traits for additional configuration.

A short list (more details on each induvidual system can be found below:

  • Scroll System - This system responds to the mouse wheel movement and will increment or decrement a specific trait accordingly.
    • ID is: &Scroll;
    • (required) <user5> - the trait that gets altered by code.
  • Drag System - This system responds to the mouse movement while the left mouse button is held down over the element. There are three different types of movement: horizontal, vertical or both.
    • IDs are: &DragHorizontal; and &DragVertical; and &DragRect; respectively
    • (required) <user8> - controls the step-distance for dragging.
    • (required) <user9> - the trait that gets altered by code.
  • TextEdit System - This system provides a simple field where the user, after clicking the element, can type in.
    • ID is: &TextEdit;
    • (optional) <user0> - controls the initial text upon activating.
    • (optional) <user1> - controls the default text for when it is deactivated and the input string is empty
  • FocusBox System - This system will adjust the size and position of the designated element to match that of the active element, provided its <focus>, <target> and <visible> traits are true.
    • ID is: &FocusBox;
    • (optional) <user15> - used as a static depth adjustment.

Details[edit | edit source]

Below you will find more details on each system and a few examples. A useful guide to creating and using these systems is to start out with a snippet of code from the existing XML files. Then adjust things like position, size and perhaps names. Finally change the <id> trait to the proper code for what you want it to do.

Almost all examples listed below come from existing XML files, either as a direct copy or slightly modified to clean things up.

FocusBox[edit | edit source]

The size and position of a focus box can be adjusted using the <focussize> and <focusinset> traits. They control the additional size and additional offset of the focus box in relation to the active element in the following fashion:

focusBox_X = (element_X - (focussize / 2) + focusinset)
focusBox_Y = (element_Y - (focussize / 2) + focusinset)
focusBox_Width = (element_Width + focussize)
focusBox_Height = (element_Height + focussize)
<rect name="focus_box">
<include src="focus_box.xml"/>
	<id> &FocusBox; </id>
	<visible> &false; </visible>
</rect>
...
<rect name="some_element">
	<width> 200 </width>
	<height> 50 </height>
	<x> 45 </x>
	<y> 160 </y>

	<!-- when the mouse is over this element its dimension
	and position will be copied to the focus box -->
	<focus> &true; </focus> 

	<!-- this gets added to the width and height before they are copied.
	And half of it gets substracted from X and Y to even the increase in size
	between the outline. -->
	<focussize> 20 </focussize> 

	<!-- this gets added to the X and Y before they are copied -->
	<focusinset> 0 </focusinset>
</rect>

With the example above, when the mouse is held over "some_element" the "focus_box" gets the following traits set:

<x> = 45 - (20 / 2) = 35
<y> = 160 - (20 / 2) = 150
<width> = 200 + 20 = 220
<height> = 50 + 20 = 70

TextEdit[edit | edit source]

In order to begin typing the user must first click on the element. Modders can also use ClickMenuButton to activate it through script. Once activated the user

  • The initial value is determined by the <string> trait when it gets activated, any changes once it is active are ignored.
  • The textedit is activated by clicking on either the element itself or the parent element.
  • To terminate the textedit the user has to click on any element (that can be targeted).
  • The use of the Enter key will terminate the textedit.
<rect name="_textedit">
	<!-- this is the element that determines the size and position of the
	clickable area needed to activate the typing. -->
	<locus> &true; </locus>
	<target> &true; </target>
	<width> 240 </width>
	<height> 40 </height>
	<depth> 3 </depth>
	<text name="_textedit_text">
		<id> &TextEdit; </id>
		<string> some text </string>
		<depth> 3 </depth>
		<locus> &true; </locus>
		<target> &true; </target>
	</text>
</rect>


See Also[edit | edit source]

Oblivion XML