[Change] Changed gui.xml to use a cleaner format.
This commit is contained in:
		
							parent
							
								
									5ab3eafc4d
								
							
						
					
					
						commit
						8f96995c8f
					
				
							
								
								
									
										73
									
								
								dat/gui.xml
									
									
									
									
									
								
							
							
						
						
									
										73
									
								
								dat/gui.xml
									
									
									
									
									
								
							| @ -1,70 +1,21 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <GUIs> | ||||
|  <gui gfx="minimal" name="minimal"> | ||||
|   <offset> | ||||
|    <x>-65</x> | ||||
|    <y>0</y> | ||||
|   </offset> | ||||
|   <radar type="circle"> | ||||
|    <w>70</w> | ||||
|    <x>72</x> | ||||
|    <y>72</y> | ||||
|   </radar> | ||||
|   <nav> | ||||
|    <x>40</x> | ||||
|    <y>151</y> | ||||
|    <w>112</w> | ||||
|    <h>42</h> | ||||
|   </nav> | ||||
|   <offset x="-65" y="0" /> | ||||
|   <radar type="circle" w="70" x="72" y="72" /> | ||||
|   <nav x="40" y="151" w="112" h="42" /> | ||||
|   <health> | ||||
|    <shield> | ||||
|     <w>98</w> | ||||
|     <h>8</h> | ||||
|     <x>52</x> | ||||
|     <y>201</y> | ||||
|    </shield> | ||||
|    <armour> | ||||
|     <w>98</w> | ||||
|     <h>8</h> | ||||
|     <x>52</x> | ||||
|     <y>212</y> | ||||
|    </armour> | ||||
|    <energy> | ||||
|     <w>98</w> | ||||
|     <h>8</h> | ||||
|     <x>52</x> | ||||
|     <y>223</y> | ||||
|    </energy> | ||||
|    <shield w="98" h="8" x="52" y="201" /> | ||||
|    <armour w="98" h="8" x="52" y="212" /> | ||||
|    <energy w="98" h="8" x="52" y="223" /> | ||||
|   </health> | ||||
|   <weapon> | ||||
|    <x>40</x> | ||||
|    <y>239</y> | ||||
|    <w>112</w> | ||||
|    <h>42</h> | ||||
|   </weapon> | ||||
|   <weapon x="40" y="239" w="112" h="42" /> | ||||
|   <target> | ||||
|    <gfx> | ||||
|     <x>34</x> | ||||
|     <y>312</y> | ||||
|    </gfx> | ||||
|    <name> | ||||
|     <x>40</x> | ||||
|     <y>291</y> | ||||
|    </name> | ||||
|    <faction> | ||||
|     <x>40</x> | ||||
|     <y>304</y> | ||||
|    </faction> | ||||
|    <health> | ||||
|     <x>40</x> | ||||
|     <y>401</y> | ||||
|    </health> | ||||
|    <gfx x="34" y="312" /> | ||||
|    <name x="40" y="291" /> | ||||
|    <faction x="40" y="304" /> | ||||
|    <health x="40" y="401" /> | ||||
|   </target> | ||||
|   <misc> | ||||
|    <x>40</x> | ||||
|    <y>424</y> | ||||
|    <w>112</w> | ||||
|    <h>100</h> | ||||
|   </misc> | ||||
|   <misc x="40" y="424" w="112" h="100" /> | ||||
|  </gui> | ||||
| </GUIs> | ||||
							
								
								
									
										75
									
								
								src/player.c
									
									
									
									
									
								
							
							
						
						
									
										75
									
								
								src/player.c
									
									
									
									
									
								
							| @ -1321,55 +1321,40 @@ int gui_load(const char* name) { | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| static void rect_parse(const xmlNodePtr parent, double* x, double* y, | ||||
|                        double* w, double* h) { | ||||
|   xmlNodePtr cur; | ||||
|   int param; | ||||
| /**
 | ||||
|  * @brief Parse a parameter of the rect node. | ||||
|  */ | ||||
| static void rect_parseParam(const xmlNodePtr parent, char* name, double* param) { | ||||
|   char* buf; | ||||
| 
 | ||||
|   param = 0; | ||||
|   /* Get the attribute. */ | ||||
|   xmlr_attr(parent, name, buf); | ||||
| 
 | ||||
|   cur = parent->children; | ||||
|   /* Wants attribute. */ | ||||
|   if(param != NULL) { | ||||
|     if(buf == NULL) | ||||
|       WARN("Node '%s' missing 'x' parameter.", parent->name); | ||||
|     else if(buf != NULL) | ||||
|       *param = atoi(buf); | ||||
|   } | ||||
|   /* Doesn't want it. */ | ||||
|   else if(buf != NULL) | ||||
|     WARN("Node '%s' has superfluous 'x' parameter.", parent->name); | ||||
| 
 | ||||
|   do { | ||||
|     if(xml_isNode(cur, "x")) { | ||||
|       if(x != NULL) { | ||||
|         *x = xml_getFloat(cur); | ||||
|         param |= (1<<0); | ||||
|       } else | ||||
|         WARN("Extra parameter 'x' found for GUI node '%s'", parent->name); | ||||
|     } | ||||
|     else if(xml_isNode(cur, "y")) { | ||||
|       if(y != NULL) { | ||||
|         *y = xml_getFloat(cur); | ||||
|         param |= (1<<1); | ||||
|       } else | ||||
|         WARN("Extra parameter 'y' found for GUI node '%s'", parent->name); | ||||
|     } | ||||
|     else if(xml_isNode(cur, "w")) { | ||||
|       if(w != NULL) { | ||||
|         *w = xml_getFloat(cur); | ||||
|         param |= (1<<2); | ||||
|       } else | ||||
|         WARN("Extra parameter 'w' found for GUI node '%s'", parent->name); | ||||
|     } | ||||
|     else if(xml_isNode(cur, "h")) { | ||||
|       if(h != NULL) { | ||||
|         *h = xml_getFloat(cur); | ||||
|         param |= (1<<3); | ||||
|       } else | ||||
|         WARN("Extra parameter 'h' found for GUI node '%s'", parent->name); | ||||
|     } | ||||
|   } while((cur = cur->next)); | ||||
|   /* Clean up. */ | ||||
|   if(buf != NULL) | ||||
|     free(buf); | ||||
| } | ||||
| 
 | ||||
|   /* Check to see if we got everything we asked for. */ | ||||
|   if(x && !(param & (1<<0))) | ||||
|     WARN("Missing parameter 'x' for GUI node '%s'", parent->name); | ||||
|   else if(y && !(param & (1<<1))) | ||||
|     WARN("Missing parameter 'y' for GUI node '%s'", parent->name); | ||||
|   else if(w && !(param & (1<<2))) | ||||
|     WARN("Missing parameter 'w' for GUI node '%s'", parent->name); | ||||
|   else if(h && !(param & (1<<3))) | ||||
|     WARN("Missing parameter 'h' for GUI node '%s'", parent->name); | ||||
| /**
 | ||||
|  * @brief Used to pull out a rect from an xml node. | ||||
|  */ | ||||
| static void rect_parse(const xmlNodePtr parent, | ||||
|     double* x, double* y, double* w, double* h) { | ||||
|   rect_parseParam(parent, "w", w); | ||||
|   rect_parseParam(parent, "h", h); | ||||
|   rect_parseParam(parent, "x", x); | ||||
|   rect_parseParam(parent, "y", y); | ||||
| } | ||||
| 
 | ||||
| /* Parse a gui node. */ | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis