Maelstrom: Added recursive template loading, and switched over the fonts to use the new template system.

https://github.com/libsdl-org/Maelstrom/commit/254ccdd058da5334490f0b42be70718cdf53b73e

From 254ccdd058da5334490f0b42be70718cdf53b73e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 27 Oct 2011 23:06:33 -0400
Subject: [PATCH] Added recursive template loading, and switched over the fonts
 to use the new template system.

---
 UI/UITemplates.xml            |  78 +++++++++++++++++++
 UI/about_credits.xml          |   5 +-
 UI/bonus.xml                  |  21 ++----
 UI/game.xml                   |  27 +++----
 UI/gameover.xml               |  15 ++--
 UI/loading.xml                |   3 +-
 UI/main.xml                   | 136 +++++++++++-----------------------
 UIElementIcon.cpp             |   8 +-
 UIElementIcon.h               |   2 +-
 UIElementKeyButton.cpp        |   4 +-
 UIElementKeyButton.h          |   2 +-
 UIElementLabel.cpp            |  48 ++++++------
 UIElementLabel.h              |   2 +-
 UIElementSprite.cpp           |   8 +-
 UIElementSprite.h             |   2 +-
 UIElementTitle.cpp            |   8 +-
 UIElementTitle.h              |   2 +-
 screenlib/UIElement.cpp       |  11 ++-
 screenlib/UIElement.h         |   3 +-
 screenlib/UIElementButton.cpp |   8 +-
 screenlib/UIElementButton.h   |   2 +-
 screenlib/UIElementLine.cpp   |   8 +-
 screenlib/UIElementLine.h     |   2 +-
 screenlib/UIElementRect.cpp   |   8 +-
 screenlib/UIElementRect.h     |   2 +-
 screenlib/UIManager.cpp       |   6 +-
 screenlib/UIManager.h         |   4 +-
 screenlib/UIPanel.cpp         |  29 +++++---
 screenlib/UIPanel.h           |   5 +-
 29 files changed, 253 insertions(+), 206 deletions(-)
 create mode 100644 UI/UITemplates.xml

diff --git a/UI/UITemplates.xml b/UI/UITemplates.xml
new file mode 100644
index 00000000..53b0c192
--- /dev/null
+++ b/UI/UITemplates.xml
@@ -0,0 +1,78 @@
+<UITemplates>
+	<UIPanel templateName="FramedPanel">
+		<Elements>
+			<Rectangle>
+				<Color r="0x75" g="0x75" b="0xFF"/>
+				<Size w="514" h="386"/>
+				<Anchor anchorFrom="CENTER" anchorTo="CENTER"/>
+			</Rectangle>
+			<Rectangle>
+				<Color r="0x75" g="0x75" b="0xFF"/>
+				<Size w="516" h="388"/>
+				<Anchor anchorFrom="CENTER" anchorTo="CENTER"/>
+			</Rectangle>
+			<Rectangle>
+				<Color r="0x9C" g="0x9C" b="0xFF"/>
+				<Size w="518" h="390"/>
+				<Anchor anchorFrom="CENTER" anchorTo="CENTER"/>
+			</Rectangle>
+			<Rectangle>
+				<Color r="0x9C" g="0x9C" b="0xFF"/>
+				<Size w="520" h="392"/>
+				<Anchor anchorFrom="CENTER" anchorTo="CENTER"/>
+			</Rectangle>
+			<Rectangle>
+				<Color r="0xC3" g="0xC3" b="0xFF"/>
+				<Size w="522" h="394"/>
+				<Anchor anchorFrom="CENTER" anchorTo="CENTER"/>
+			</Rectangle>
+			<Rectangle>
+				<Color r="0x9C" g="0x9C" b="0xFF"/>
+				<Size w="524" h="396"/>
+				<Anchor anchorFrom="CENTER" anchorTo="CENTER"/>
+			</Rectangle>
+			<Rectangle>
+				<Color r="0x75" g="0x75" b="0xFF"/>
+				<Size w="526" h="398"/>
+				<Anchor anchorFrom="CENTER" anchorTo="CENTER"/>
+			</Rectangle>
+		</Elements>
+	</UIPanel>
+
+	<Label templateName="Small" fontName="Geneva" fontSize="9" fontStyle="BOLD"/>
+	<Label templateName="SmallWhite" template="Small">
+		<Color r="0xFF" g="0xFF" b="0xFF"/>
+	</Label>
+	<Label templateName="SmallYellow" template="Small">
+		<Color r="0xFF" g="0xFF" b="0x00"/>
+	</Label>
+	<Label templateName="SmallBlue" template="Small">
+		<Color r="0x75" g="0x75" b="0xFF"/>
+	</Label>
+
+	<Label templateName="Medium" fontName="New York" fontSize="14" fontStyle="BOLD"/>
+	<Label templateName="MediumWhite" template="Medium">
+		<Color r="0xFF" g="0xFF" b="0xFF"/>
+	</Label>
+	<Label templateName="MediumYellow" template="Medium">
+		<Color r="0xFF" g="0xFF" b="0x00"/>
+	</Label>
+	<Label templateName="MediumBlue" template="Medium">
+		<Color r="0x75" g="0x75" b="0xFF"/>
+	</Label>
+
+	<Label templateName="Large" fontName="New York" fontSize="18"/>
+	<Label templateName="LargeWhite" template="Large">
+		<Color r="0xFF" g="0xFF" b="0xFF"/>
+	</Label>
+	<Label templateName="LargeYellow" template="Large">
+		<Color r="0xFF" g="0xFF" b="0x00"/>
+	</Label>
+	<Label templateName="LargeBlue" template="Large">
+		<Color r="0x75" g="0x75" b="0xFF"/>
+	</Label>
+	<Label templateName="LargeYellowUnderline" template="Large" fontStyle="UNDERLINE">
+		<Color r="0xFF" g="0xFF" b="0x00"/>
+	</Label>
+
+</UITemplates>
diff --git a/UI/about_credits.xml b/UI/about_credits.xml
index 8cf624b2..c146c34d 100644
--- a/UI/about_credits.xml
+++ b/UI/about_credits.xml
@@ -10,12 +10,11 @@
 			<Size w="338" h="62"/>
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="image" x="166" y="282"/>
 		</Rectangle>
-		<Label name="port_label" fontName="New York" fontSize="18" text="Port to SDL:   ">
+		<Label name="port_label" template="Large" text="Port to SDL:   ">
 			<Color r="0xFF" g="0xFF" b="0x55"/>
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="image" x="188" y="298"/>
 		</Label>
-		<Label fontName="New York" fontSize="18" text="Sam Lantinga">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label template="LargeWhite" text="Sam Lantinga">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="port_label"/>
 		</Label>
 
diff --git a/UI/bonus.xml b/UI/bonus.xml
index d0a15110..39b595ca 100644
--- a/UI/bonus.xml
+++ b/UI/bonus.xml
@@ -1,27 +1,21 @@
 <UIPanel fullscreen="false" enterSound="110">
 	<Elements>
-		<Label name="wave" fontName="Geneva" fontSize="9" fontStyle="BOLD">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label name="wave" template="SmallYellow">
 			<Anchor anchorFrom="TOP" anchorTo="CENTER" y="-90"/>
 		</Label>
-		<Label name="bonus_label" fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Bonus Score:     ">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="bonus_label" template="SmallBlue" text="Bonus Score:     ">
 			<Anchor anchorFrom="TOP" anchorTo="TOP" anchor="wave" x="-20" y="50"/>
 		</Label>
-		<Label name="bonus" fontName="Geneva" fontSize="9" fontStyle="BOLD">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="bonus" template="SmallWhite">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="bonus_label"/>
 		</Label>
-		<Label name="multiplied_bonus" fontName="Geneva" fontSize="9" fontStyle="BOLD">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="multiplied_bonus" template="SmallWhite">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="bonus_label" x="75"/>
 		</Label>
-		<Label name="score_label" fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Score:     ">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="score_label" template="SmallBlue" text="Score:     ">
 			<Anchor anchorFrom="TOP" anchorTo="TOP" anchor="wave" x="-3" y="70"/>
 		</Label>
-		<Label name="score" fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Score:     ">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="score" template="SmallWhite">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="score_label"/>
 		</Label>
 		<Sprite name="multiplier2" id="2000">
@@ -37,8 +31,7 @@
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="multiplier2"/>
 		</Sprite>
 
-		<Label name="next" fontName="Geneva" fontSize="9" fontStyle="BOLD">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label name="next" template="SmallYellow">
 			<Anchor anchorFrom="TOP" anchorTo="TOP" anchor="wave" y="109"/>
 		</Label>
 	</Elements>
diff --git a/UI/game.xml b/UI/game.xml
index c762d7b4..ef80764a 100644
--- a/UI/game.xml
+++ b/UI/game.xml
@@ -7,17 +7,14 @@
 			<Anchor anchorFrom="BOTTOM" anchorTo="BOTTOM" y="-13"/>
 		</Line>
 
-		<Label name="score_label" fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Score:">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="score_label" template="SmallBlue" text="Score:">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="status_line" x="3" y="1"/>
 		</Label>
-		<Label name="score" fontName="Geneva" fontSize="9" fontStyle="BOLD">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="score" template="SmallWhite">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="score_label" x="4"/>
 		</Label>
 
-		<Label name="shield_label" fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Shield:">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="shield_label" template="SmallBlue" text="Shield:">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="score_label" x="70"/>
 		</Label>
 		<Rectangle>
@@ -31,30 +28,24 @@
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="shield_label" x="5" y="1"/>
 		</Rectangle>
 
-		<Label name="wave_label" fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Wave:">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="wave_label" template="SmallBlue" text="Wave:">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="shield_label" x="70"/>
 		</Label>
-		<Label name="wave" fontName="Geneva" fontSize="9" fontStyle="BOLD">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="wave" template="SmallWhite">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="wave_label" x="4"/>
 		</Label>
 
-		<Label name="lives_label" fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Lives:">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="lives_label" template="SmallBlue" text="Lives:">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="wave_label" x="30"/>
 		</Label>
-		<Label name="lives" fontName="Geneva" fontSize="9" fontStyle="BOLD">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="lives" template="SmallWhite">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="lives_label" x="4"/>
 		</Label>
 
-		<Label name="bonus_label" fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Bonus:">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="bonus_label" template="SmallBlue" text="Bonus:">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="lives_label" x="30"/>
 		</Label>
-		<Label name="bonus" fontName="Geneva" fontSize="9" fontStyle="BOLD">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="bonus" template="SmallWhite">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="bonus_label" x="4"/>
 		</Label>
 
diff --git a/UI/gameover.xml b/UI/gameover.xml
index 809a1bf2..40537cf6 100644
--- a/UI/gameover.xml
+++ b/UI/gameover.xml
@@ -5,25 +5,20 @@
 		</Title>
 
 		<!-- Multiplayer rankings -->
-		<Label name="rank1" fontName="New York" fontSize="18">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="rank1" template="LargeBlue">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="CENTER" x="-160" y="121"/>
 		</Label>
-		<Label name="rank2" fontName="New York" fontSize="18">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="rank2" template="LargeBlue">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="BOTTOMLEFT" anchor="rank1"/>
 		</Label>
-		<Label name="rank3" fontName="New York" fontSize="18">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="rank3" template="LargeBlue">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="BOTTOMLEFT" anchor="rank2"/>
 		</Label>
 
-		<Label name="name_label" fontName="New York" fontSize="18" text="Enter your name: ">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="name_label" template="LargeBlue" text="Enter your name: ">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="CENTER" y="41"/>
 		</Label>
-		<Label name="name" fontName="New York" fontSize="18">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="name" template="LargeWhite">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="name_label"/>
 		</Label>
 	</Elements>
diff --git a/UI/loading.xml b/UI/loading.xml
index f5e46d4a..6b829d88 100644
--- a/UI/loading.xml
+++ b/UI/loading.xml
@@ -3,8 +3,7 @@
 		<Title name="image" id="130">
 			<Anchor anchorFrom="CENTER" anchorTo="CENTER"/>
 		</Title>
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Loading...">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label template="SmallYellow" text="Loading...">
 			<Anchor anchorFrom="CENTER" anchorTo="BOTTOM" anchor="image" y="20"/>
 		</Label>
 
diff --git a/UI/main.xml b/UI/main.xml
index 94f5a28e..0276074f 100644
--- a/UI/main.xml
+++ b/UI/main.xml
@@ -25,146 +25,111 @@
 		</Line>
 
 		<!-- high scores -->
-		<Label name="name_header" fontName="New York" fontSize="18" fontStyle="UNDERLINE" text="Name">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label name="name_header" template="LargeYellowUnderline" text="Name">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="BOTTOMLEFT" anchor="hdivider_left" x="5" y="23"/>
 		</Label>
-		<Label name="score_header" fontName="New York" fontSize="18" fontStyle="UNDERLINE" text="Score">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label name="score_header" template="LargeYellowUnderline" text="Score">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="BOTTOMLEFT" anchor="hdivider_left" x="185" y="23"/>
 		</Label>
-		<Label name="wave_header" fontName="New York" fontSize="18" fontStyle="UNDERLINE" text="Wave">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label name="wave_header" template="LargeYellowUnderline" text="Wave">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="BOTTOMLEFT" anchor="hdivider_left" x="245" y="23"/>
 		</Label>
 
-		<Label name="name_0" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_0" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_header" y="24"/>
 		</Label>
-		<Label name="score_0" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_0" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_header" y="24"/>
 		</Label>
-		<Label name="wave_0" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_0" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_header" x="-10" y="24"/>
 		</Label>
-		<Label name="name_1" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_1" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_0" y="18"/>
 		</Label>
-		<Label name="score_1" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_1" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_0" y="18"/>
 		</Label>
-		<Label name="wave_1" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_1" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_0" y="18"/>
 		</Label>
-		<Label name="name_2" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_2" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_1" y="18"/>
 		</Label>
-		<Label name="score_2" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_2" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_1" y="18"/>
 		</Label>
-		<Label name="wave_2" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_2" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_1" y="18"/>
 		</Label>
-		<Label name="name_3" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_3" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_2" y="18"/>
 		</Label>
-		<Label name="score_3" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_3" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_2" y="18"/>
 		</Label>
-		<Label name="wave_3" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_3" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_2" y="18"/>
 		</Label>
-		<Label name="name_4" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_4" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_3" y="18"/>
 		</Label>
-		<Label name="score_4" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_4" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_3" y="18"/>
 		</Label>
-		<Label name="wave_4" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_4" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_3" y="18"/>
 		</Label>
-		<Label name="name_5" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_5" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_4" y="18"/>
 		</Label>
-		<Label name="score_5" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_5" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_4" y="18"/>
 		</Label>
-		<Label name="wave_5" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_5" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_4" y="18"/>
 		</Label>
-		<Label name="name_6" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_6" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_5" y="18"/>
 		</Label>
-		<Label name="score_6" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_6" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_5" y="18"/>
 		</Label>
-		<Label name="wave_6" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_6" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_5" y="18"/>
 		</Label>
-		<Label name="name_7" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_7" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_6" y="18"/>
 		</Label>
-		<Label name="score_7" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_7" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_6" y="18"/>
 		</Label>
-		<Label name="wave_7" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_7" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_6" y="18"/>
 		</Label>
-		<Label name="name_8" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_8" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_7" y="18"/>
 		</Label>
-		<Label name="score_8" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_8" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_7" y="18"/>
 		</Label>
-		<Label name="wave_8" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_8" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_7" y="18"/>
 		</Label>
-		<Label name="name_9" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="name_9" template="Medium">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="name_8" y="18"/>
 		</Label>
-		<Label name="score_9" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="score_9" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="score_8" y="18"/>
 		</Label>
-		<Label name="wave_9" fontName="New York" fontSize="14" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0x00"/>
+		<Label name="wave_9" template="Medium">
 			<Anchor anchorFrom="TOPRIGHT" anchorTo="TOPRIGHT" anchor="wave_8" y="18"/>
 		</Label>
 
-		<Label name="last_score_label" fontName="New York" fontSize="18" text="Last Score: ">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="last_score_label" template="LargeWhite" text="Last Score: ">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="BOTTOMLEFT" anchor="hdivider_left" x="5" y="230"/>
 		</Label>
-		<Label name="last_score" fontName="New York" fontSize="18">
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label name="last_score" template="LargeWhite">
 			<Anchor anchorFrom="LEFT" anchorTo="RIGHT" anchor="last_score_label"/>
 		</Label>
 
@@ -172,50 +137,43 @@
 		<KeyButton name="PlayButton" hotkey="P" clickSound="114">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPRIGHT" anchor="vertical_divider" x="9" y="10"/>
 		</KeyButton>
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text=" Start playing Maelstrom">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label template="SmallYellow" text=" Start playing Maelstrom">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="TOPRIGHT" anchor="PlayButton" x="3" y="21"/>
 		</Label>
 		<KeyButton name="ControlsButton" hotkey="C" clickSound="119">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="PlayButton" y="34"/>
 		</KeyButton>
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text=" Configure the game controls">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label template="SmallYellow" text=" Configure the game controls">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="TOPRIGHT" anchor="ControlsButton" x="3" y="21"/>
 		</Label>
 		<KeyButton name="ZapButton" hotkey="Z" clickSound="107">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="ControlsButton" y="34"/>
 		</KeyButton>
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text=" Zap the high scores">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label template="SmallYellow" text=" Zap the high scores">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="TOPRIGHT" anchor="ZapButton" x="3" y="21"/>
 		</Label>
 		<KeyButton name="AboutButton" hotkey="A" clickSound="122">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="ZapButton" y="34"/>
 		</KeyButton>
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text=" About Maelstrom...">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label template="SmallYellow" text=" About Maelstrom...">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="TOPRIGHT" anchor="AboutButton" x="3" y="21"/>
 		</Label>
 		<KeyButton name="QuitButton" hotkey="Q" clickSound="106">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="AboutButton" y="68"/>
 		</KeyButton>
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text=" Quit Maelstrom">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label template="SmallYellow" text=" Quit Maelstrom">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="TOPRIGHT" anchor="QuitButton" x="3" y="21"/>
 		</Label>
 		<KeyButton name="VolumeDownButton" hotkey="0">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="QuitButton" y="34"/>
 		</KeyButton>
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text="-">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label template="SmallYellow" text="-">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="TOPRIGHT" anchor="VolumeDownButton" x="3" y="21"/>
 		</Label>
 		<KeyButton name="VolumeUpButton" hotkey="8">
 			<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" anchor="VolumeDownButton" x="40"/>
 		</KeyButton>
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text=" Set Sound Volume">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label template="SmallYellow" text=" Set Sound Volume">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="TOPRIGHT" anchor="VolumeUpButton" x="3" y="21"/>
 		</Label>
 
@@ -235,13 +193,10 @@
 		<Button name="SetVolume8" hotkey="8"/>
 
 		<!-- Credits -->
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text="Port to SDL by Sam Lantinga">
-			<Color r="0xFF" g="0xFF" b="0x00"/>
+		<Label template="SmallYellow" text="Port to SDL by Sam Lantinga">
 			<Anchor anchorFrom="CENTER" anchorTo="CENTER" anchor="image" y="52"/>
 		</Label>
-		<Label fontName="Geneva" fontSize="9" fontStyle="BOLD" text="1992-4 Ambrosia Software, Inc.">
-	
-			<Color r="0xFF" g="0xFF" b="0xFF"/>
+		<Label template="SmallWhite" text="1992-4 Ambrosia Software, Inc.">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="TOPLEFT" anchor="hdivider_right" x="9" y="-2"/>
 		</Label>
 		<Label name="version" fontName="Geneva" fontSize="9">
@@ -250,8 +205,7 @@
 		</Label>
 
 		<!-- Sound level -->
-		<Label name="volume" fontName="Geneva" fontSize="9" fontStyle="BOLD">
-			<Color r="0x75" g="0x75" b="0xFF"/>
+		<Label name="volume" template="SmallBlue">
 			<Anchor anchorFrom="BOTTOMLEFT" anchorTo="TOPLEFT" anchor="VolumeDownButton" x="-6" y="22"/>
 		</Label>
 	</Elements>
diff --git a/UIElementIcon.cpp b/UIElementIcon.cpp
index 9edd4368..be2f5e28 100644
--- a/UIElementIcon.cpp
+++ b/UIElementIcon.cpp
@@ -11,10 +11,14 @@ UIElementIcon::UIElementIcon(UIPanel *panel, const char *name) :
 }
 
 bool
-UIElementIcon::Load(rapidxml::xml_node<> *node)
+UIElementIcon::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
 {
 	rapidxml::xml_attribute<> *attr;
 
+	if (!UIElementTexture::Load(node, templates)) {
+		return false;
+	}
+
 	attr = node->first_attribute("id", 0, false);
 	if (!attr) {
 		SetError("Element '%s' missing attribute 'id'", node->name());
@@ -28,5 +32,5 @@ UIElementIcon::Load(rapidxml::xml_node<> *node)
 	}
 	SetTexture(texture);
 
-	return UIElementTexture::Load(node);
+	return true;
 }
diff --git a/UIElementIcon.h b/UIElementIcon.h
index a0622fb0..21850e30 100644
--- a/UIElementIcon.h
+++ b/UIElementIcon.h
@@ -13,7 +13,7 @@ class UIElementIcon : public UIElementTexture
 		return UIElementTexture::IsA(type) || type == GetType();
 	}
 
-	virtual bool Load(rapidxml::xml_node<> *node);
+	virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
 
 protected:
 	static UIElementType s_elementType;
diff --git a/UIElementKeyButton.cpp b/UIElementKeyButton.cpp
index acf3e872..bf2aaeb6 100644
--- a/UIElementKeyButton.cpp
+++ b/UIElementKeyButton.cpp
@@ -22,12 +22,12 @@ UIElementKeyButton::~UIElementKeyButton()
 }
 
 bool
-UIElementKeyButton::Load(rapidxml::xml_node<> *node)
+UIElementKeyButton::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
 {
 	m_rect.w = m_screen->GetImageWidth(gKeyIcon);
 	m_rect.h = m_screen->GetImageHeight(gKeyIcon);
 
-	if (!UIElementButton::Load(node)) {
+	if (!UIElementButton::Load(node, templates)) {
 		return false;
 	}
 
diff --git a/UIElementKeyButton.h b/UIElementKeyButton.h
index 701f799c..1871f6fd 100644
--- a/UIElementKeyButton.h
+++ b/UIElementKeyButton.h
@@ -14,7 +14,7 @@ class UIElementKeyButton : public UIElementButton
 		return UIElementButton::IsA(type) || type == GetType();
 	}
 
-	virtual bool Load(rapidxml::xml_node<> *node);
+	virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
 
 	virtual void Draw();
 
diff --git a/UIElementLabel.cpp b/UIElementLabel.cpp
index d5f382ae..857adc80 100644
--- a/UIElementLabel.cpp
+++ b/UIElementLabel.cpp
@@ -29,41 +29,46 @@ static Uint8 ParseStyle(const char *text)
 {
 	Uint8 style = STYLE_NORM;
 
-	if (strcasecmp(text, "bold") == 0) {
+	if (strcasecmp(text, "BOLD") == 0) {
 		style = STYLE_BOLD;
-	} else if (strcasecmp(text, "underline") == 0) {
+	} else if (strcasecmp(text, "UNDERLINE") == 0) {
 		style = STYLE_ULINE;
-	} else if (strcasecmp(text, "italic") == 0) {
+	} else if (strcasecmp(text, "ITALIC") == 0) {
 		style = STYLE_ITALIC;
 	}
 	return style;
 }
 
 bool
-UIElementLabel::Load(rapidxml::xml_node<> *node)
+UIElementLabel::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
 {
 	rapidxml::xml_node<> *child;
 	rapidxml::xml_attribute<> *attr;
-	const char *fontName;
-	int fontSize;
+	const char *fontName = NULL;
+	int fontSize = 0;
 
-	attr = node->first_attribute("fontName", 0, false);
-	if (!attr) {
-		SetError("Element 'Label' missing attribute 'font'");
+	if (!UIElement::Load(node, templates)) {
 		return false;
 	}
-	fontName = attr->value();
+
+	attr = node->first_attribute("fontName", 0, false);
+	if (attr) {
+		fontName = attr->value();
+	}
 
 	attr = node->first_attribute("fontSize", 0, false);
-	if (!attr) {
-		SetError("Element 'Label' missing attribute 'fontSize'");
-		return false;
+	if (attr) {
+		fontSize = SDL_atoi(attr->value());
 	}
-	fontSize = SDL_atoi(attr->value());
 
-	m_font = fontserv->NewFont(fontName, fontSize);
-	if (!m_font) {
-		SetError("Element 'Label' couldn't find font %s:%d", fontName, fontSize);
+	if (fontName && fontSize) {
+		m_font = fontserv->NewFont(fontName, fontSize);
+		if (!m_font) {
+			SetError("Element 'Label' couldn't find font %s:%d", fontName, fontSize);
+			return false;
+		}
+	} else if (!m_font) {
+		SetError("Element 'Label' missing attribute 'fontName' or 'fontSize'");
 		return false;
 	}
 
@@ -82,14 +87,7 @@ UIElementLabel::Load(rapidxml::xml_node<> *node)
 		SetText(attr->value());
 	}
 
-#ifdef UI_DEBUG
-	bool value = UIElement::Load(node);
-if (m_text)
-printf("Label: '%s' %d,%d\n", m_text, m_rect.x, m_rect.y);
-	return value;
-#else
-	return UIElement::Load(node);
-#endif
+	return true;
 }
 
 void
diff --git a/UIElementLabel.h b/UIElementLabel.h
index ac5cf8f3..523e8b3a 100644
--- a/UIElementLabel.h
+++ b/UIElementLabel.h
@@ -15,7 +15,7 @@ class UIElementLabel : public UIElement
 		return UIElement::IsA(type) || type == GetType();
 	}
 
-	virtual bool Load(rapidxml::xml_node<> *node);
+	virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
 
 	void SetText(const char *text);
 	void SetTextColor(Uint8 R, Uint8 G, Uint8 B);
diff --git a/UIElementSprite.cpp b/UIElementSprite.cpp
index 3ff27dbe..42ea147c 100644
--- a/UIElementSprite.cpp
+++ b/UIElementSprite.cpp
@@ -30,10 +30,14 @@ LoadSprite(FrameBuf *screen, int baseID)
 }
 
 bool
-UIElementSprite::Load(rapidxml::xml_node<> *node)
+UIElementSprite::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
 {
 	rapidxml::xml_attribute<> *attr;
 
+	if (!UIElementTexture::Load(node, templates)) {
+		return false;
+	}
+
 	attr = node->first_attribute("id", 0, false);
 	if (!attr) {
 		SetError("Element '%s' missing attribute 'id'", node->name());
@@ -47,5 +51,5 @@ UIElementSprite::Load(rapidxml::xml_node<> *node)
 	}
 	SetTexture(texture);
 
-	return UIElementTexture::Load(node);
+	return true;
 }
diff --git a/UIElementSprite.h b/UIElementSprite.h
index 2cf33f3b..ea658916 100644
--- a/UIElementSprite.h
+++ b/UIElementSprite.h
@@ -13,7 +13,7 @@ class UIElementSprite : public UIElementTexture
 		return UIElementTexture::IsA(type) || type == GetType();
 	}
 
-	virtual bool Load(rapidxml::xml_node<> *node);
+	virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
 
 protected:
 	static UIElementType s_elementType;
diff --git a/UIElementTitle.cpp b/UIElementTitle.cpp
index 62bf7f86..a6f185fc 100644
--- a/UIElementTitle.cpp
+++ b/UIElementTitle.cpp
@@ -11,10 +11,14 @@ UIElementTitle::UIElementTitle(UIPanel *panel, const char *name) :
 }
 
 bool
-UIElementTitle::Load(rapidxml::xml_node<> *node)
+U

(Patch may be truncated, please check the link at the top of this post.)