Index: binaries/data/mods/public/gui/session/diplomacy_window.xml
===================================================================
--- binaries/data/mods/public/gui/session/diplomacy_window.xml	(revision 0)
+++ binaries/data/mods/public/gui/session/diplomacy_window.xml	(working copy)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<objects>
+	<object name="diplomacyDialogPanel"
+		size="50%-300 50%-200 50%+300 50%+150"
+		type="image"
+		hidden="true"
+		sprite="ModernDialog"
+	>
+		<object type="text" style="TitleText" size="50%-96 -16 50%+96 16">
+			<translatableAttribute id="caption">Diplomacy</translatableAttribute>
+		</object>
+
+		<object name="diplomacyHeader" size="32 32 100%-32 64">
+			<object name="diplomacyHeaderName" size="0 0 150 100%" type="text" style="chatPanel" ghost="true">
+				<translatableAttribute id="caption">Name</translatableAttribute>
+			</object>
+			<object name="diplomacyHeaderCiv" size="150 0 250 100%" type="text" style="chatPanel" ghost="true">
+				<translatableAttribute id="caption">Civilization</translatableAttribute>
+			</object>
+			<object name="diplomacyHeaderTeam" size="250 0 300 100%" type="text" style="chatPanel" ghost="true">
+				<translatableAttribute id="caption">Team</translatableAttribute>
+			</object>
+			<object name="diplomacyHeaderTheirs" size="300 0 360 100%" type="text" style="chatPanel" ghost="true">
+				<translatableAttribute id="caption">Theirs</translatableAttribute>
+			</object>
+			<object name="diplomacyHeaderAlly" size="100%-180 0 100%-160 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
+				<translatableAttribute id="caption">A</translatableAttribute>
+				<translatableAttribute id="tooltip">Ally</translatableAttribute>
+			</object>
+			<object name="diplomacyHeaderNeutral" size="100%-160 0 100%-140 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
+				<translatableAttribute id="caption">N</translatableAttribute>
+				<translatableAttribute id="tooltip">Neutral</translatableAttribute>
+			</object>
+			<object name="diplomacyHeaderEnemy" size="100%-140 0 100%-120 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
+				<translatableAttribute id="caption">E</translatableAttribute>
+				<translatableAttribute id="tooltip">Enemy</translatableAttribute>
+			</object>
+			<object name="diplomacyHeaderTribute" size="100%-110 0 100% 100%" type="text" style="chatPanel">
+				<translatableAttribute id="caption">Tribute</translatableAttribute>
+			</object>
+		</object>
+		<object size="32 64 100%-32 384">
+			<repeat count="16">
+				<object name="diplomacyPlayer[n]" size="0 0 100% 20" type="image" hidden="false">
+					<object name="diplomacyPlayerName[n]" size="0 0 150 100%" type="text" style="chatPanel" ghost="true"/>
+					<object name="diplomacyPlayerCiv[n]" size="150 0 250 100%" type="text" style="chatPanel" ghost="true"/>
+					<object name="diplomacyPlayerTeam[n]" size="250 0 300 100%" type="text" style="chatPanel" ghost="true"/>
+					<object name="diplomacyPlayerTheirs[n]" size="300 0 360 100%" type="text" style="chatPanel" ghost="true"/>
+
+					<!-- Diplomatic stance - selection -->
+					<object name="diplomacyPlayerAlly[n]" size="100%-180 0 100%-160 100%" type="button" style="StoneButton" hidden="true"/>
+					<object name="diplomacyPlayerNeutral[n]" size="100%-160 0 100%-140 100%" type="button" style="StoneButton" hidden="true"/>
+					<object name="diplomacyPlayerEnemy[n]" size="100%-140 0 100%-120 100%" type="button" style="StoneButton" hidden="true"/>
+
+					<!-- Tribute -->
+					<object name="diplomacyPlayerTributeFood[n]" size="100%-110 0 100%-90 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
+						<object name="diplomacyPlayerTributeFoodImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/food.png" ghost="true"/>
+					</object>
+					<object name="diplomacyPlayerTributeWood[n]" size="100%-90 0 100%-70 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
+						<object name="diplomacyPlayerTributeWoodImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/wood.png" ghost="true"/>
+					</object>
+					<object name="diplomacyPlayerTributeStone[n]" size="100%-70 0 100%-50 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
+						<object name="diplomacyPlayerTributeStoneImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/stone.png" ghost="true"/>
+					</object>
+					<object name="diplomacyPlayerTributeMetal[n]" size="100%-50 0 100%-30 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
+						<object name="diplomacyPlayerTributeMetalImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/metal.png" ghost="true"/>
+					</object>
+				</object>
+			</repeat>
+		</object>
+
+		<object size="50%-64 100%-50 50%+64 100%-22" type="button" style="StoneButton">
+			<translatableAttribute id="caption">Close</translatableAttribute>
+			<action on="Press">closeDiplomacy();</action>
+		</object>
+	</object>
+</objects>

Property changes on: binaries/data/mods/public/gui/session/diplomacy_window.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/xml
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: binaries/data/mods/public/gui/session/session.xml
===================================================================
--- binaries/data/mods/public/gui/session/session.xml	(revision 15322)
+++ binaries/data/mods/public/gui/session/session.xml	(working copy)
@@ -8,15 +8,9 @@
 <script file="gui/common/music.js"/>
 <script file="gui/common/timer.js"/>
 <script file="gui/common/colorFades.js"/>
-<script file="gui/session/session.js"/>
-<script file="gui/session/selection.js"/>
+<!-- load the placement script befor all other session scripts -->
 <script file="gui/session/placement.js"/>
-<script file="gui/session/input.js"/>
-<script file="gui/session/menu.js"/>
-<script file="gui/session/selection_details.js"/>
-<script file="gui/session/unit_commands.js"/>
-<script file="gui/session/messages.js"/>
-<script file="gui/session/utility_functions.js"/>
+<script directory="gui/session/"/>
 
 <object name="sn" hotkey="session.gui.toggle">
 	<action on="Tick">
@@ -412,82 +406,8 @@
 	<!-- ================================  ================================ -->
 	<!-- Diplomacy Window -->
 	<!-- ================================  ================================ -->
-	<object name="diplomacyDialogPanel"
-		size="50%-300 50%-200 50%+300 50%+150"
-		type="image"
-		hidden="true"
-		sprite="ModernDialog"
-	>
-		<object type="text" style="TitleText" size="50%-96 -16 50%+96 16">
-			<translatableAttribute id="caption">Diplomacy</translatableAttribute>
-		</object>
+	<object include="gui/session/diplomacy_window.xml" />
 
-		<object name="diplomacyHeader" size="32 32 100%-32 64">
-			<object name="diplomacyHeaderName" size="0 0 150 100%" type="text" style="chatPanel" ghost="true">
-				<translatableAttribute id="caption">Name</translatableAttribute>
-			</object>
-			<object name="diplomacyHeaderCiv" size="150 0 250 100%" type="text" style="chatPanel" ghost="true">
-				<translatableAttribute id="caption">Civilization</translatableAttribute>
-			</object>
-			<object name="diplomacyHeaderTeam" size="250 0 300 100%" type="text" style="chatPanel" ghost="true">
-				<translatableAttribute id="caption">Team</translatableAttribute>
-			</object>
-			<object name="diplomacyHeaderTheirs" size="300 0 360 100%" type="text" style="chatPanel" ghost="true">
-				<translatableAttribute id="caption">Theirs</translatableAttribute>
-			</object>
-			<object name="diplomacyHeaderAlly" size="100%-180 0 100%-160 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
-				<translatableAttribute id="caption">A</translatableAttribute>
-				<translatableAttribute id="tooltip">Ally</translatableAttribute>
-			</object>
-			<object name="diplomacyHeaderNeutral" size="100%-160 0 100%-140 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
-				<translatableAttribute id="caption">N</translatableAttribute>
-				<translatableAttribute id="tooltip">Neutral</translatableAttribute>
-			</object>
-			<object name="diplomacyHeaderEnemy" size="100%-140 0 100%-120 100%" type="text" style="chatPanel" tooltip_style="sessionToolTipBold">
-				<translatableAttribute id="caption">E</translatableAttribute>
-				<translatableAttribute id="tooltip">Enemy</translatableAttribute>
-			</object>
-			<object name="diplomacyHeaderTribute" size="100%-110 0 100% 100%" type="text" style="chatPanel">
-				<translatableAttribute id="caption">Tribute</translatableAttribute>
-			</object>
-		</object>
-
-		<object size="32 64 100%-32 384">
-			<repeat count="16">
-				<object name="diplomacyPlayer[n]" size="0 0 100% 20" type="image" hidden="false">
-					<object name="diplomacyPlayerName[n]" size="0 0 150 100%" type="text" style="chatPanel" ghost="true"/>
-					<object name="diplomacyPlayerCiv[n]" size="150 0 250 100%" type="text" style="chatPanel" ghost="true"/>
-					<object name="diplomacyPlayerTeam[n]" size="250 0 300 100%" type="text" style="chatPanel" ghost="true"/>
-					<object name="diplomacyPlayerTheirs[n]" size="300 0 360 100%" type="text" style="chatPanel" ghost="true"/>
-
-					<!-- Diplomatic stance - selection -->
-					<object name="diplomacyPlayerAlly[n]" size="100%-180 0 100%-160 100%" type="button" style="StoneButton" hidden="true"/>
-					<object name="diplomacyPlayerNeutral[n]" size="100%-160 0 100%-140 100%" type="button" style="StoneButton" hidden="true"/>
-					<object name="diplomacyPlayerEnemy[n]" size="100%-140 0 100%-120 100%" type="button" style="StoneButton" hidden="true"/>
-
-					<!-- Tribute -->
-					<object name="diplomacyPlayerTributeFood[n]" size="100%-110 0 100%-90 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
-						<object name="diplomacyPlayerTributeFoodImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/food.png" ghost="true"/>
-					</object>
-					<object name="diplomacyPlayerTributeWood[n]" size="100%-90 0 100%-70 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
-						<object name="diplomacyPlayerTributeWoodImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/wood.png" ghost="true"/>
-					</object>
-					<object name="diplomacyPlayerTributeStone[n]" size="100%-70 0 100%-50 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
-						<object name="diplomacyPlayerTributeStoneImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/stone.png" ghost="true"/>
-					</object>
-					<object name="diplomacyPlayerTributeMetal[n]" size="100%-50 0 100%-30 100%" type="button" style="iconButton" tooltip_style="sessionToolTipBold" hidden="true">
-						<object name="diplomacyPlayerTributeMetalImage[n]" type="image" size="0 0 100% 100%" sprite="stretched:session/icons/resources/metal.png" ghost="true"/>
-					</object>
-				</object>
-			</repeat>
-		</object>
-
-		<object size="50%-64 100%-50 50%+64 100%-22" type="button" style="StoneButton">
-            <translatableAttribute id="caption">Close</translatableAttribute>
-		    <action on="Press">closeDiplomacy();</action>
-		</object>
-	</object>
-
 	<!-- ================================  ================================ -->
 	<!-- Trade Window -->
 	<!-- ================================  ================================ -->
Index: source/gui/CGUI.cpp
===================================================================
--- source/gui/CGUI.cpp	(revision 15322)
+++ source/gui/CGUI.cpp	(working copy)
@@ -65,6 +65,7 @@
 extern int g_yres;
 
 const double SELECT_DBLCLICK_RATE = 0.5;
+const u32 MAX_OBECT_DEPTH = 100; // Max number of nesting for GUI objects. Used to detect recursive inclusion
 
 InReaction CGUI::HandleEvent(const SDL_Event_* ev)
 {
@@ -930,7 +931,7 @@
 
 	// Check root element's (node) name so we know what kind of
 	//  data we'll be expecting
-	CStr root_name (XeroFile.GetElementString(node.GetNodeName()));
+	CStr root_name(XeroFile.GetElementString(node.GetNodeName()));
 
 	try
 	{
@@ -993,7 +994,7 @@
 			Xeromyces_ReadScript(child, pFile, Paths);
 		else
 			// Read in this whole object into the GUI
-			Xeromyces_ReadObject(child, pFile, m_BaseObject, subst, Paths);
+			Xeromyces_ReadObject(child, pFile, m_BaseObject, subst, Paths, 0);
 	}
 }
 
@@ -1036,7 +1037,7 @@
 
 		// Read in this whole object into the GUI
 
-		CStr name (pFile->GetElementString(child.GetNodeName()));
+		CStr name(pFile->GetElementString(child.GetNodeName()));
 
 		if (name == "scrollbar")
 		{
@@ -1064,8 +1065,14 @@
 	}
 }
 
-void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths)
+void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth)
 {
+	if (nesting_depth > MAX_OBECT_DEPTH)
+	{
+		LOGERROR(L"Too many nested GUI objects. Probably caused by a recursive include attribute. Abort rendering any deeper.");
+		return;
+	}
+
 	ENSURE(pParent);
 	int i;
 
@@ -1110,6 +1117,7 @@
 	ATTR(file);
 	ATTR(id);
 	ATTR(context);
+	ATTR(include);
 
 	//
 	//	Read Style and set defaults
@@ -1118,7 +1126,7 @@
 	//
 	//	Always load default (if it's available) first!
 	//
-	CStr argStyle (attributes.GetNamedItem(attr_style));
+	CStr argStyle(attributes.GetNamedItem(attr_style));
 
 	if (m_Styles.count("default") == 1)
 		object->LoadStyle(*this, "default");
@@ -1140,7 +1148,9 @@
 
 	bool NameSet = false;
 	bool ManuallySetZ = false; // if z has been manually set, this turn true
+	bool ExternalChildren = false;
 
+	CStrW inclusionPath;
 	CStr hotkeyTag;
 
 	// Now we can iterate all attributes and store
@@ -1159,7 +1169,7 @@
 		// Also the name needs some special attention
 		if (attr.Name == attr_name)
 		{
-			CStr name (attr.Value);
+			CStr name(attr.Value);
 
 			// Apply the requested substitutions
 			for (size_t j = 0; j < NameSubst.size(); ++j)
@@ -1170,6 +1180,13 @@
 			continue;
 		}
 
+		if (attr.Name == attr_include)
+		{
+			ExternalChildren = true;
+			inclusionPath = attr.Value.FromUTF8();
+			continue;
+		}
+
 		// Wire up the hotkey tag, if it has one
 		if (attr.Name == attr_hotkey)
 			hotkeyTag = attr.Value;
@@ -1197,8 +1214,8 @@
 	if (! hotkeyTag.empty())
 		m_HotkeyObjects[hotkeyTag].push_back(object);
 
-	CStrW caption (Element.GetText().FromUTF8());
-	if (! caption.empty())
+	CStrW caption(Element.GetText().FromUTF8());
+	if (!caption.empty())
 	{
 		// Set the setting caption to this
 		object->SetSetting("caption", caption, true);
@@ -1211,9 +1228,33 @@
 	//	Read Children
 	//
 
-	// Iterate children
 	XMBElementList children = Element.GetChildNodes();
+	CXeromyces XeroChildren;
+	if (ExternalChildren)
+	{
+		if (children.Count > 0)
+			LOGWARNING(L"GUI: Gui XML Object in has child nodes and an 'include' attribute (pointing to %ls). The child nodes will be ignored.", inclusionPath.c_str());
+		Paths.insert(inclusionPath);
 
+		if (XeroChildren.Load(g_VFS, inclusionPath) == PSRETURN_OK)
+		{
+			XMBElement node = XeroChildren.GetRoot();
+
+			CStr root_name(XeroChildren.GetElementString(node.GetNodeName()));
+
+			if (root_name == "objects")
+				children = node.GetChildNodes();
+			else
+				LOGERROR(L"GUI: Error reading included XML: %ls, root element must have the name 'objects'.", inclusionPath.c_str());
+		}
+		else
+			LOGERROR(L"GUI: Error reading included XML: %ls", inclusionPath.c_str());
+
+		// set pFile to the new CXeromyces file, as it's only used to handle the children from now on
+		pFile = &XeroChildren;
+	}
+
+	// Iterate children
 	for (i=0; i<children.Count; ++i)
 	{
 		// Get node
@@ -1225,7 +1266,7 @@
 		if (element_name == elmt_object)
 		{
 			// Call this function on the child
-			Xeromyces_ReadObject(child, pFile, object, NameSubst, Paths);
+			Xeromyces_ReadObject(child, pFile, object, NameSubst, Paths, nesting_depth + 1);
 		}
 		else if (element_name == elmt_action)
 		{
@@ -1232,12 +1273,12 @@
 			// Scripted <action> element
 
 			// Check for a 'file' parameter
-			CStrW filename (child.GetAttributes().GetNamedItem(attr_file).FromUTF8());
+			CStrW filename(child.GetAttributes().GetNamedItem(attr_file).FromUTF8());
 
 			CStr code;
 
 			// If there is a file, open it and use it as the code
-			if (! filename.empty())
+			if (!filename.empty())
 			{
 				Paths.insert(filename);
 				CVFSFile scriptfile;
@@ -1280,7 +1321,7 @@
 		}
 		else if (element_name == elmt_repeat)
 		{
-			Xeromyces_ReadRepeat(child, pFile, object, Paths);
+			Xeromyces_ReadRepeat(child, pFile, object, Paths, nesting_depth);
 		}
 		else if (element_name == elmt_translatableAttribute)
 		{
@@ -1388,7 +1429,7 @@
 	}
 }
 
-void CGUI::Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths)
+void CGUI::Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth)
 {
 	#define ELMT(x) int elmt_##x = pFile->GetElementID(#x)
 	#define ATTR(x) int attr_##x = pFile->GetAttributeID(#x)
@@ -1408,7 +1449,7 @@
 		{
 			if (child.GetNodeName() == elmt_object)
 			{
-				Xeromyces_ReadObject(child, pFile, pParent, subst, Paths);
+				Xeromyces_ReadObject(child, pFile, pParent, subst, Paths, nesting_depth + 1);
 			}
 		}
 	}
@@ -1417,10 +1458,10 @@
 void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, boost::unordered_set<VfsPath>& Paths)
 {
 	// Check for a 'file' parameter
-	CStrW file (Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("file") ).FromUTF8());
+	CStrW file(Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("file") ).FromUTF8());
 
 	// If there is a file specified, open and execute it
-	if (! file.empty())
+	if (!file.empty())
 	{
 		Paths.insert(file);
 		try
@@ -1433,11 +1474,34 @@
 		}
 	}
 
+	// If it has a directory attribute, read all JS files in that directory
+	CStrW directory(Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("directory") ).FromUTF8());
+	if (!directory.empty())
+	{
+		VfsPaths pathnames;
+		vfs::GetPathnames(g_VFS, directory, L"*.js", pathnames);
+		for (VfsPaths::iterator it = pathnames.begin(); it != pathnames.end(); ++it)
+		{
+			// only load new files (so when the insert succeeds)
+			if (Paths.insert(*it).second)
+			{
+				try
+				{
+					m_ScriptInterface->LoadGlobalScriptFile(*it);
+				}
+				catch (PSERROR_Scripting& e)
+				{
+					LOGERROR(L"GUI: Error executing script %ls: %hs", directory.c_str(), e.what());
+				}
+			}
+		}
+	}
+
 	// Execute inline scripts
 	try
 	{
-		CStr code (Element.GetText());
-		if (! code.empty())
+		CStr code(Element.GetText());
+		if (!code.empty())
 			m_ScriptInterface->LoadGlobalScript(L"Some XML file", code.FromUTF8());
 	}
 	catch (PSERROR_Scripting& e)
@@ -1478,7 +1542,7 @@
 		// Get node
 		XMBElement child = children.Item(i);
 
-		CStr ElementName (pFile->GetElementString(child.GetNodeName()));
+		CStr ElementName(pFile->GetElementString(child.GetNodeName()));
 
 		if (ElementName == "image")
 		{
@@ -1506,7 +1570,7 @@
 	// different effects)
 	if (effects)
 		for (std::vector<SGUIImage*>::iterator it = Sprite->m_Images.begin(); it != Sprite->m_Images.end(); ++it)
-			if (! (*it)->m_Effects)
+			if (!(*it)->m_Effects)
 				(*it)->m_Effects = new SGUIImageEffects(*effects); // do a copy just so it can be deleted correctly later
 
 	delete effects;
@@ -1539,8 +1603,8 @@
 	for (int i=0; i<attributes.Count; ++i)
 	{
 		XMBAttribute attr = attributes.Item(i);
-		CStr attr_name (pFile->GetAttributeString(attr.Name));
-		CStrW attr_value (attr.Value.FromUTF8());
+		CStr attr_name(pFile->GetAttributeString(attr.Name));
+		CStrW attr_value(attr.Value.FromUTF8());
 
 		if (attr_name == "texture")
 		{
@@ -1649,7 +1713,7 @@
 	for (int i=0; i<children.Count; ++i)
 	{
 		XMBElement child = children.Item(i);
-		CStr ElementName (pFile->GetElementString(child.GetNodeName()));
+		CStr ElementName(pFile->GetElementString(child.GetNodeName()));
 		if (ElementName == "effect")
 		{
 			if (Image->m_Effects)
@@ -1681,8 +1745,8 @@
 	for (int i=0; i<attributes.Count; ++i)
 	{
 		XMBAttribute attr = attributes.Item(i);
-		CStr attr_name (pFile->GetAttributeString(attr.Name));
-		CStrW attr_value (attr.Value.FromUTF8());
+		CStr attr_name(pFile->GetAttributeString(attr.Name));
+		CStrW attr_value(attr.Value.FromUTF8());
 
 		if (attr_name == "add_color")
 		{
@@ -1717,7 +1781,7 @@
 	for (int i=0; i<attributes.Count; ++i)
 	{
 		XMBAttribute attr = attributes.Item(i);
-		CStr attr_name (pFile->GetAttributeString(attr.Name));
+		CStr attr_name(pFile->GetAttributeString(attr.Name));
 
 		// The "name" setting is actually the name of the style
 		//  and not a new default
@@ -1756,7 +1820,7 @@
 	{
 		XMBAttribute attr = attributes.Item(i);
 		CStr attr_name = pFile->GetAttributeString(attr.Name);
-		CStr attr_value (attr.Value); 
+		CStr attr_value(attr.Value); 
 
 		if (attr_value == "null")
 			continue;
@@ -1853,8 +1917,8 @@
 	for (int i=0; i<attributes.Count; ++i)
 	{
 		XMBAttribute attr = attributes.Item(i);
-		CStr attr_name (pFile->GetAttributeString(attr.Name));
-		CStr attr_value (attr.Value);
+		CStr attr_name(pFile->GetAttributeString(attr.Name));
+		CStr attr_value(attr.Value);
 
 		if (attr_value == "null")
 			continue;
@@ -1901,8 +1965,8 @@
 	for (int i=0; i<attributes.Count; ++i)
 	{
 		XMBAttribute attr = attributes.Item(i);
-		CStr attr_name (pFile->GetAttributeString(attr.Name));
-		CStr attr_value (attr.Value);
+		CStr attr_name(pFile->GetAttributeString(attr.Name));
+		CStr attr_value(attr.Value);
 
 		if (attr_name == "name")
 		{
@@ -1929,8 +1993,8 @@
 	CStr name = attributes.GetNamedItem(pFile->GetAttributeID("name"));
 
 	// Try parsing value 
-	CStr value (Element.GetText());
-	if (! value.empty())
+	CStr value(Element.GetText());
+	if (!value.empty())
 	{
 		// Try setting color to value
 		if (!color.ParseString(value))
Index: source/gui/CGUI.h
===================================================================
--- source/gui/CGUI.h	(revision 15322)
+++ source/gui/CGUI.h	(working copy)
@@ -444,7 +444,7 @@
 	 *
 	 * @see LoadXmlFile()
 	 */
-	void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths);
+	void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth);
 
 	/**
 	 * Reads in the element \<repeat\>, which repeats its child \<object\>s
@@ -451,7 +451,7 @@
 	 * 'count' times, replacing the string "[n]" in its descendants' names
 	 * with "[0]", "[1]", etc.
 	 */
-	void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths);
+	void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth);
 
 	/**
 	 * Reads in the element \<script\> (the XMBElement) and executes
