/// <summary> /// Adds the specified template element to the list of explicit references. /// If the element already exists, the path is updated with the supplied value. /// </summary> public void AddTemplateReference(TagPath tagPath, string templateElement) { if (templateElement != "") { if (!templates.ContainsTemplateElement(templateElement)) { templates.Add(templateElement, tagPath); } else { templates.UpdateElementPath(templateElement, tagPath); } } }
/// <summary> /// Reads and parses a previously emitted XML document representing the project. /// </summary> protected void ParseProjectFile(XmlDocument document) { // Loading data from various XML nodes. XmlNode projectNode = document.SelectSingleNode("//project"); XmlNode gameNode = projectNode.SelectSingleNode("game"); string gameName = gameNode.Attributes["name"].Value; // Make sure that we have a valid platform here. string gamePlatform = gameNode.Attributes["platform"].Value; if (!Enum.IsDefined(typeof(Platform), gamePlatform)) { throw new ProjectFileNotValidException("The specified platform does not exist: " + gamePlatform); } Platform platform = (Platform)Enum.Parse(typeof(Platform), gamePlatform); if (GameDefinitionRequest != null) { GameDefinitionRequestEventArgs e = new GameDefinitionRequestEventArgs(gameName, platform); GameDefinitionRequest(this, e); game = e.GameDefinition; if (game == null) { throw new ProjectFileNotValidException("Could not identify the referenced game id: " + e.GameID); } } else { throw new Exception( "Cannot retrieve game definition - the GameDefinitionRequest event is not handled by the Core."); } XmlNode infoNode = projectNode.SelectSingleNode("info"); author = infoNode.SelectSingleNode("author").InnerText; description = infoNode.SelectSingleNode("description").InnerText; version = new ProjectVersion(infoNode.SelectSingleNode("version").InnerText); XmlNode templatesNode = projectNode.SelectSingleNode("template"); templateName = templatesNode.InnerText; XmlNode mapInfoNode = projectNode.SelectSingleNode("mapinfo"); mapName = mapInfoNode.SelectSingleNode("name").InnerText; filename = mapInfoNode.SelectSingleNode("filename").InnerText; uiText = mapInfoNode.SelectSingleNode("uitext").InnerText; uiScreenShotFile = mapInfoNode.SelectSingleNode("uiscreenshot").InnerText; projectReferencesTable = new FileHierarchy(); XmlNodeList referencesNodeList = projectNode.SelectNodes("references//tag"); foreach (XmlNode tagNode in referencesNodeList) { string path = tagNode.InnerText; AddTagReference(path); } templates = new TemplateTagList(game.GetProjectTemplate(templateName)); templates.FileAdded += templates_FileAdded; templates.FileRemoved += templates_FileRemoved; XmlNodeList templatesNodeList = projectNode.SelectNodes("essentialTags//tag"); foreach (XmlNode tagNode in templatesNodeList) { string templateID = tagNode.Attributes["template_id"].InnerText; TagPath path = new TagPath(tagNode.InnerText); templates.Add(templateID, path); } }