Changes between Initial Version and Version 1 of GUI_-_XML_Files


Ignore:
Timestamp:
Feb 23, 2008, 4:19:00 AM (16 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GUI_-_XML_Files

    v1 v1  
     1There are several types of GUI XML files, their main difference is the ''root element''.
     2
     3Here's an example of an XML file with the root element '''<objects>'''.
     4
     5{{{
     6  <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
     7 
     8  <!DOCTYPE <font color="green">objects</font> SYSTEM "../gui.dtd">
     9 
     10  <<font color="green">objects</font>>
     11 
     12  <<font color="green">/objects</font>>
     13}}}
     14
     15The root element's name is highlighted in green, if you're creating a file with another root element, the text should be changed in all those three places.
     16
     17== Style Files ==
     18Root element: ''<styles>''
     19
     20Styles XML files are explained in the [wiki:GUI_-_Styles Styles Documentation]. Here's an example file nonetheless.
     21
     22{{{
     23  <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
     24 
     25  <!DOCTYPE styles SYSTEM "../gui.dtd">
     26 
     27  <styles>
     28    <!-- Style that will hide the object as new default -->
     29    <style name="style_name1"
     30           hidden="true"
     31    />
     32   
     33    <!-- Style that helps us create a nice edit box -->
     34    <style name="editbox_nice"
     35           sprite="sprite1"
     36           font="font1"
     37    />
     38  </styles>
     39}}}
     40
     41== Sprite Files ==
     42Root element: ''<sprites>''
     43
     44Sprite files are explained in the [wiki:GUI_-_Sprites Sprites Documentation]. Again, still here's an example.
     45
     46{{{
     47  <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
     48 
     49  <!DOCTYPE sprites SYSTEM "../gui.dtd">
     50 
     51  <sprites>
     52      <!-- Here's a sprite with two images next to each other -->
     53      <sprite  name="sprite1">
     54               <image texture="texture1.jpg"
     55                     size="0 0 50% 100%"
     56                     texture_size="0 0 20 20"
     57               />
     58               <image texture="texture2.jpg"
     59                     size="50% 0 100% 100%"
     60                     texture_size="0 0 20 20"
     61               />
     62      </sprite>
     63     
     64      <!-- Here's a simple sprite that is just one image stretched to fit the whole area -->
     65      <sprite  name="sprite2">
     66               <image texture="texture1.jpg"
     67                     size="0 0 100% 100%"
     68                     texture_size="0 0 100% 100%"
     69               />
     70      </sprite>
     71  </sprites>
     72}}}
     73
     74== Setup Files ==
     75Root element: ''<setup>''
     76
     77Within the <setup> tag a number of templates can be defined on a stack, in no specific order.
     78
     79{{{
     80 <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
     81 
     82 <!DOCTYPE setup SYSTEM "../gui.dtd">
     83 
     84 <setup> 
     85    <scrollbar name="sb"
     86               width="18"
     87               minimum_bar_size="5"
     88               sprite_button_top="sprite2"
     89               sprite_button_top_over="null"
     90               sprite_button_bottom="sprite2"
     91               sprite_button_bottom_over="null"
     92               sprite_back_vertical="grey"
     93               sprite_bar_vertical="sprite2"
     94               sprite_bar_vertical_over="null"
     95               sprite_bar_vertical_pressed="null"
     96               sprite_button_bottom_pressed="sprite2_pressed"
     97               sprite_button_top_pressed="sprite2_pressed"
     98    />
     99 
     100    <icon      name="0ad_icon"
     101               texture="0ad_icon"
     102               size="16 16"
     103    />
     104 
     105    <tooltip   name="pregame_mainmenu_tooltip"
     106               use_object="pregame_mainmenu_tooltip"
     107               delay="0"
     108               hide_object="true"
     109    />
     110 </setup>
     111}}}
     112
     113The templates are actually called [wiki:GUI_-_Custom_Objects Custom Objects], click the link to find out more specific information.
     114
     115== Object Files ==
     116Root element: ''<objects>''
     117
     118How to build the GUI is easiest explained with an example XML file:
     119
     120{{{
     121  <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
     122 
     123  <!DOCTYPE objects SYSTEM "../gui.dtd">
     124 
     125  <objects>
     126      <object name="object_name"
     127              type="button"
     128              size="50%+2 50%+5 50%+10 50%+10"
     129              hotkey="example_button.toggle"
     130              sprite="example_button"
     131              sprite_pressed="example_button_pressed"
     132      >This is the button's caption.
     133              <action on="Press"><![CDATA[
     134                    DoSomething();
     135              ]]></action>
     136 
     137              <!-- Example child objects -->
     138              <object name="child1"
     139                      type="text"
     140              />
     141              <object name="child2"
     142                      type="image"
     143              />
     144      </object>
     145  </objects>
     146}}}
     147
     148The GUI defined above has got one uppermost object, or '''root object''' (i.e. it is parentless as it is placed within the <objects> tag, and not another object), and it has got two children objects and one [wiki:GUI_-_Actions action] assigned to it. Objects can have any number of children, and they are placed anywhere within the parent. You can have as many root objects in one file as you like, just place them next to each other. Within the object tag you define its [wiki:GUI_-_Properties properties] as shown above. If an object has got a caption, it should be placed just after the opening tag, and
     149before any other sub-elements. Read more about actions [wiki:GUI_-_Actions here].