Difference between revisions of "Category:Oblivion XML"

601 bytes added ,  10:58, 31 March 2010
imported>JRoush
imported>JRoush
Line 27: Line 27:


=== Oblivion XML Schema ===
=== Oblivion XML Schema ===
XML is a general syntax - the meaning of specific elements depends entirely on the program parsing the file.   
<!-- An example of an '[[Object Element#Image|Image]]' Object Element -->
<image name="MyImage">    &lt;!-- This image has it's [[Trait|'name' trait]] set to 'MyImage', --&gt;
    <height> 10 </height>  &lt;!-- and it's [[Property Element#Sizeable|'height' property]] set to 10 pixels. --&gt;
    <width>                &lt;!-- It's [[Property Element#Sizeable|width]] is set to twice it's height --&gt;
      <copy src="MyImage" trait="height" />
      <mul> 2 </mul>      &lt;!-- using the '[[Operator Element#Copy Operator|copy]]' and '[[Operator Element#Algebraic Operators|mul]]' operators --&gt;
    </width>
</image>
 
XML is a general syntax - the meaning of a given element depends entirely on the program parsing the file.   


The elements recognized by the Oblivion parser can be divided into three basic categories.  [[Object Element|"Object" Elements]] define actual objects in the menu, such as buttons, text, images, etc.  There are only a few different kinds of object elements, but they are used repeatedly to create the complex menu structures.
The Oblivion XML parser divides elements into three basic categories.  They don't really have official names, so the names chosen below ("Object", "Property", and "Operator" Elements) were chosen just for this page.  This is important to remember when using the OBSE UI functions, which tend to refer to Property Elements as "Traits", even though they are not, strictly speaking, XML traits.
 
[[Object Element|"Object" Elements]] define actual objects in the menu, such as buttons, text, images, etc.  There are only a few different kinds of object elements, but they are used repeatedly to create the complex menu structures.


[[Property Element|"Property" Elements]] are always children of Object Elements,  
[[Property Element|"Property" Elements]] are always children of Object Elements,  
defining things like the position, color, transparency, etc. of their parent.  
defining things like the position, color, transparency, etc. of their parent.  
For example, an <image> object element might have <width> and <height> elements as children, which Oblivion will use to determine the size of the displayed image.
For example, an <image> object element might have <width> and <height> elements as children, which Oblivion will use to determine the size of the displayed image.
Different Object Elements can have different sets of Property Elements.


Property elements can have literal values, written directly into the xml code.   
Property elements can have literal text or numeric values, written directly into the xml code.  However, they can instead contain arrangements of [[Operator Element|"Operator" Elements]] as children.  These Operator Elements basically describe simple mathematical formulas, which Oblivion uses to ''calculate'' the value of the Property Element in ''real time''.  This concept is what makes the Oblivion XML schema so powerful and customizable - and confusing.
They can also contain mathematical "formulas" - for example the <width> property of an <image> element might contain a formula to make the image twice as wide as it is tall.  Then, if some code in the game engine (or a mod script) changes the height of the image, the game's parser will automatically use the formula to recalculate the width.  These formulas are expressed as series of [[Operator Element|"Operator" Elements]] - most basic mathematical operators like +, - , *, FLOOR, AND, etc. have a corresponding Operator Element.


There are a few special elements that don't fit into a category.  The most common is the [[Include Element]].  It's use is similar to the ''include'' statement in C-style programming language - it allows the menu designer to copy in bits of commonly used xml code from other files.
There are also a few special elements that don't fit into these three categories.  The most common is the [[Include Element]].  It's use is similar to the ''include'' statement in C-style programming languages - it allows the menu designer to insert  xml code from another file.


Elements that aren't part of the Oblivion XML schema are assumed to be Property ElementsThey will be parsed by the game engine, can be referred to by name from Operator elements and OBSE script functions, and may contain Operator Elements as children.  It is common to break up long formulas by inventing an unrecognized element to hold intermediate values.
It's also possible to insert new element types into a menu document.  Oblivion will
interpret any element whose type it doesn't recognize as a Property ElementSuch elements obviously won't have any built-in affects, but they can be referred to by name from Operator Elements and OBSE script functions, and may contain Operator Elements as children.  It is common to break up long formulas by inventing one of these "psuedo-Property" elements to intermediate values.


Oblivion only recognizes three XML [[Trait]]s: "name", "src", and "trait".
Because most aspects of menu objects like buttons, icons, etc. are controlled by their Property Elements, Oblivion doesn't make much use of conventional XML traits.  However, the three [[Trait]]s it that are used ("name", "src", and "trait") are essential to the use of Operator and Include elements. See those pages for more detail.
 
&lt;!-- An example of an 'image' [[Object Element]] --&gt;
<image name="MyImage">    &lt;!-- This image has it's [[Trait|'name' trait]] set to 'MyImage', --&gt;
    <height> 10 </height>  &lt;!-- and it's [[Property Element#Sizeable|'height' property]] set to 10 pixels. --&gt;
    <width>                &lt;!-- It's [[Property Element#Sizeable|width]] is set to twice it's height --&gt;
      <copy src="MyImage" trait="height" />
      <mul> 2 </mul>      &lt;!-- using the '[[Operator Element#Copy Operator|copy]]' and '[[Operator Element#Algebraic Operators|mul]]' operators --&gt;
    </width>
  </image>


=== Oblivion Menu Files ===
=== Oblivion Menu Files ===
Menu xml data is stored in the ''Oblivion\Data\Menus'' directory.  Each menu is stored in it's own file.  Oblivion reloads a menu from disk every time it is opened, so changes to the file can be seen by closing and re-opening the menu - a very useful trick for editing.  Note, however, that some menus are never closed (e.g. the HUD).  These menus can be reloaded in game using "Reload ''menuname''" [[:Category:Console Functions|console function]].
Menu xml data is stored in the ''Oblivion\Data\Menus'' directory.  Each menu is stored in it's own file.  Oblivion reloads a menu from disk every time it is opened, so changes to the file can be seen by closing and re-opening the menu - a very useful trick for editing.  Note, however, that some menus are never closed (e.g. the HUD).  These menus can be reloaded in game using "Reload ''menuname''" [[:Category:Console Functions|console function]].
Anonymous user