/// <summary> /// Adds a format-specific archive to the list of available archives. /// </summary> /// <param name="gameFormat">game that the archive supports</param> /// <param name="library">archive to add</param> public void RegisterGame(string gameFormat, string globalsTagName, TypeTable types, ILibrary library) { if (archives.ContainsKey(gameFormat)) // halo pc and halo ce, for instance, use the same library. { return; } archives.Add(gameFormat, library); tables.Add(gameFormat, types); if (library == null) { return; } if (!String.IsNullOrEmpty(globalsTagName)) { TagPath path = new TagPath(globalsTagName, gameFormat, TagLocation.Archive); if (library.FileExists(globalsTagName)) { globals.Add(gameFormat, Open(path.ToPath(), types.LocateEntryByName(path.Extension).TagType, true, true)); } } }
void documentManager_DocumentRenamed(IDocument document, string oldPath) { Output.Write(OutputTypes.Debug, "Document renamed from " + oldPath + " to " + document.DocumentFilename); TagPath oldTagPath = new TagPath(oldPath); string testPath; if (oldTagPath.Location == TagLocation.Archive) { testPath = oldTagPath.ToPath(PathFormat.Relative); } else { testPath = oldTagPath.ToPath(PathFormat.ExplicitLocation); } foreach (ProjectTag tag in projectManager.Project.Templates.GetTemplateList()) { if (tag.Path == testPath) { projectManager.Project.Templates.UpdateElementPath( tag.TemplateElement, document.DocumentFilename); return; } } foreach (TemplateTag tag in projectManager.Project.Template.TagSet) { if (tag.DefaultFile + "." + tag.FileType == testPath) { projectManager.Project.Templates.Add(tag.Name, new TagPath(document.DocumentFilename)); return; } } }
/// <summary> /// Checks to see if the tag at the specified path exists. /// </summary> public bool TagExists(TagPath path) { if (path.Location == TagLocation.Archive) { GameDefinition def = Core.Prometheus.Instance.GetGameDefinitionByGameID(path.Game); if (def == null) { Output.Write(OutputTypes.Debug, "A tag was passed to 'Pool.TagExists()' that references a game that was not found in the GameDefinition list: " + path.ToPath()); return(false); } return(def.GlobalTagLibrary.FileExists(path.Path + "." + path.Extension)); } else if (path.Location == TagLocation.Project) { // Make sure that a project is loaded. ProjectManager pm = Core.Prometheus.Instance.ProjectManager; if (pm != null) { if (pm.ProjectLoaded) { if (pm.GameID == path.Game) { return(pm.ProjectFolder.FileExists(path.Path + "." + path.Extension)); } } } return(false); } else { throw new Exception("The specified tag source is invalid or not supported."); } }
/// <summary> /// Determines the initial state that subscribers of this state will be in. /// </summary> protected override bool DetermineState(NodeInfo info) { // Look up the document in the DocumentManager TagPath path = new TagPath(info.Identifier, gameID, tagLocation); return(manager.DocumentExists(path.ToPath())); }
public void RemoveByElementName(string elementName) { ProjectTag[] values = new ProjectTag[templateTags.Values.Count]; templateTags.Values.CopyTo(values, 0); foreach (ProjectTag tag in values) { if (tag.TemplateElement == elementName) { templateTags.Remove(tag.TemplateElement); TagPath basePath = new TagPath(tag.Path); if (basePath.Location == TagLocation.Project) { string relativePath = basePath.ToPath(PathFormat.Relative); templateTagHierarchy.RemoveFile(relativePath); } OnFileRemoved(tag.Path, elementName); TemplateTag templateTag = GetTemplateTag(elementName); if (templateTag != null) { // Generate the FileAdded event with the default filename - this is so that the // ProjectExplorer can update it's Essential Tags list. // This is kind of hackish, because the ProjectFile shouldn't be worrying // about the PE at all. A more appropriate place to put this functionality would // be in the ProjectNodeSource, but that would complicate some things and would // force me to write additional code. And we all know how lazy I am! :D TagPath path = new TagPath(templateTag.DefaultFile + "." + templateTag.FileType, "", TagLocation.Archive); OnFileAdded(path.ToPath(PathFormat.ExplicitLocation), templateTag.Name); } } } }
public Type GetTypeFromTagPath(TagPath path) { GameDefinition game = GetGameDefinitionByGameID(path.Game); Type tagType = game.TypeTable.LocateEntryByName(path.Extension).TagType; return(tagType); }
/// <summary> /// Retreive the TagFile object from the specified TagPath. /// </summary> public TagFile GetTagFile(TagPath path) { // Qualify the scope if necessary. if (path.Location == TagLocation.Auto) { string qualifiedPath = QualifyScope(path.Game, path.Path); TagPath newPath = new TagPath(qualifiedPath); path.Location = newPath.Location; } byte[] bin = null; if (path.Location == TagLocation.Archive) { bin = archives[path.Game].ReadFile(path.Path + "." + path.Extension); } else if (path.Location == TagLocation.Project) { if (library != null) { bin = library.ReadFile(path.Path + "." + path.Extension); } } if (bin == null) { throw new Exception("The specified tag was not found: " + path.ToPath()); } MemoryStream stream = new MemoryStream(bin); TagFile file = new TagFile(stream); return(file); }
/// <summary> /// Returns a value indicating if the specified NodeInfo contains children. /// </summary> public override bool HasChildren(NodeInfo info) { TagArchiveNodeSource source = (TagArchiveNodeSource)ParentSource; TagPath path = new TagPath(info.Identifier, source.Game.GameID, TagLocation.Archive); TagFile file = Core.Prometheus.Instance.Pool.GetTagFile(path); return(file.Attachments.Length > 0); }
/// <summary> /// Returns the specified named binary attachment from the TagFile located at the supplied TagPath. /// </summary> public byte[] GetTagAttachent(TagPath path) { // First, get the TagFile represented by this path. // TODO: This has no exception handling, so.. yeah.. TagFile file = GetTagFile(path); return(file.GetAttachmentRevision(path.AttachmentName)); }
/// <summary> /// Add the specified Archive tag to the currently active project. /// </summary> private static void AddGameTagToProject(TagPath path) { GameDefinition game = Core.Prometheus.Instance.GetGameDefinitionByGameID( Core.Prometheus.Instance.ProjectManager.GameID); Type tagType = game.TypeTable.LocateEntryByName( path.Extension.TrimStart('.')).TagType; PrometheusGUI.AddTagToProject(path, tagType); }
/// <summary> /// Reads tag binary metadata from the archive with highest priority. /// </summary> /// <param name="path">TagPath object representing the path to the requested metadata</param> /// <returns>binary metadata for tag or null if not found</returns> private byte[] GetTagBinary(TagPath path) { //ILibrary library = GetLibrary(path); //byte[] metadata = library.ReadFile(path.Path + '.' + path.Extension); TagFile tf = GetTagFile(path); //TagFile tf = new TagFile(new MemoryStream(metadata)); return(tf.GetBinary(tf.HeadRevision)); }
private bool previewTest(MultiSourceTreeNode node, NodeInfo info) { // Check to see if the tag is previewable and isn't already open. if (game.TypeTable.Previewable(Path.GetExtension(info.Identifier).TrimStart('.'))) { TagPath path = new TagPath(info.Identifier, game.GameID, TagLocation.Project); return(!RenderCore.ContainsScene(path.ToPath())); } return(false); }
/// <summary> /// Adds the the specified template element/path combination to the list. /// </summary> public void Add(string templateElement, TagPath tagPath) { // Make sure that the template element that is attempting to be added exists in // the related Template for this list. bool validTemplate = false; foreach (TemplateTag templateTag in baseTemplate.TagSet) { if (templateTag.Name == templateElement) { validTemplate = true; break; } } if (validTemplate) { // Get the explicit location and add that path to the elements // (Or update an existing path if the named element already exists.) string path = tagPath.ToPath(PathFormat.ExplicitLocation); ProjectTag tag = new ProjectTag(templateElement, path); if (!templateTags.ContainsKey(templateElement)) { templateTags.Add(templateElement, tag); } else { templateTags[templateElement].Path = path; } // If the tag is from the project, store the relative path // (no "p:\" prefix) to the templateTagHierarchy. if (tagPath.Location == TagLocation.Project) { templateTagHierarchy.Add(tagPath.ToPath(PathFormat.Relative)); // We added a new file yar!! OnFileAdded(path, templateElement); TemplateTag templateTag = GetTemplateTag(templateElement); if (templateTag != null) { // Again, haxzorzz!! TagPath lePath = new TagPath(templateTag.DefaultFile + "." + templateTag.FileType, "", TagLocation.Archive); OnFileRemoved(lePath.ToPath(PathFormat.ExplicitLocation), templateTag.Name); } } } else { throw new Exception("The specified element '" + templateElement + "' does not exist in the template '" + baseTemplate.Name + "'"); } }
/// <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); } } }
public void PerformTest() { Interfaces.Games.GameDefinition def = Core.Prometheus.Instance.GetGameDefinitionByGameID("halopc"); Core.Libraries.TagArchive tagArchive = (Core.Libraries.TagArchive)def.GlobalTagLibrary; string[] files = tagArchive.GetFileList("", "*", true); ProgressDialog pd = new ProgressDialog(); pd.Show(); pd.SuspendLayout(); pd.Maximum = files.Length; List <string> classes = new List <string>(100); for (int x = 0; x < files.Length; x++) { pd.Info2 = files[x]; pd.Value = x; pd.Refresh(); string fileExt = files[x].Substring(files[x].LastIndexOf('.')).ToLower(); if (classes.Contains(fileExt)) { continue; } // Open the tag. TagPath path = new TagPath(files[x], "halopc", TagLocation.Archive); Type type = Core.Prometheus.Instance.GetTypeFromTagPath(path); Tag tag = Core.Prometheus.Instance.Pool.Open(path.ToPath(), type, false); using (Prometheus.Controls.TagEditor.TagEditorControl tempTagEditorControl = new Prometheus.Controls.TagEditor.TagEditorControl()) { try { // Load the tag in the tag editor tempTagEditorControl.Create(def, def.TypeTable.LocateEntryByName(tag.FileExtension).FourCC, tag); } catch { Interfaces.Output.Write(Interfaces.OutputTypes.Error, "There was an error loading tag " + x + ": " + files[x]); } } classes.Add(fileExt); } System.Windows.Forms.MessageBox.Show("A total of " + classes.Count + " tags/classes were tested!"); }
/// <summary> /// Returns an array of NodeInfo entries that exist beneath the specified NodeInfo. /// </summary> public override NodeInfo[] GetChildNodes(NodeInfo info) { List <NodeInfo> children = new List <NodeInfo>(); TagArchiveNodeSource source = (TagArchiveNodeSource)ParentSource; TagPath tagPath = new TagPath(info.Identifier, source.Game.GameID, TagLocation.Archive); TagFile file = Core.Prometheus.Instance.Pool.GetTagFile(tagPath); foreach (string attachment in file.Attachments) { NodeInfo attachmentInfo = new NodeInfo(ParentSource.GetNodeType <AttachedScriptNodeType>(), info.Identifier + "|" + attachment); children.Add(attachmentInfo); } return(children.ToArray()); }
/// <summary> /// Returns a standardized tooltip to represent a TagPath. /// </summary> public static string GetTagPathToolTip(TagPath path, bool abridged) { StringBuilder sb = new StringBuilder(); if (path.Location == TagLocation.Archive) { sb.Append("<img src=\"global::Prometheus.Properties.Resources.joystick16\"/>"); if (!abridged) { if (!String.IsNullOrEmpty(path.Game)) { GameDefinition gd = Core.Prometheus.Instance.GetGameDefinitionByGameID(path.Game); if (gd != null) { sb.Append(" <b>" + gd.LongName + "</b>"); } } } } else if (path.Location == TagLocation.Project) { sb.Append("<img src=\"global::Prometheus.Properties.Resources.application16\"/>"); if (!abridged) { if (Core.Prometheus.Instance.ProjectManager.ProjectLoaded) { sb.Append(" <b>" + Core.Prometheus.Instance.ProjectManager.Project.MapName + "</b>"); } } } else { sb.Append("<i>Unknown Location</i>"); } if (!abridged) { sb.Append("<br/>"); } else { sb.Append(" "); } sb.Append(path.ToPath(PathFormat.Relative)); return(sb.ToString()); }
void TagEditorControl_OpenTag(string relativePath) { if (OpenTag != null) { TagPath path; if (TagPath.IsFullyQualifiedPath(relativePath)) { path = new TagPath(relativePath); } else { path = new TagPath(relativePath, gameDefinition.GameID, TagLocation.Auto); } OpenTag(path); } }
/// <summary> /// Removes the specified tag from the list of tag references for this project. /// </summary> /// <param name="path">The path of the reference to remove.</param> /// <param name="autoRevertTemplateTag">If the reference points to an essential tag, specifies if it will automatically be reverted to its default tag. Normally, the user is prompted in this scenario.</param> /// <returns>A value indicating if the reference was removed.</returns> public bool RemoveTagReference(string path, bool autoRevertEssentialTag) { // In order to see if this is a referenced essential tag, we need to // create a project-scoped explicit path to check against. // TODO: After shared folder / prefabs are implemented, we will also need to check those. TagPath projectPath = new TagPath(path); projectPath.Location = TagLocation.Project; string projectPathString = projectPath.ToPath(PathFormat.ExplicitLocation); // Check the essential tags collection (templates), not the normal references table (projectReferencesTable). if (templates.ContainsPath(projectPathString)) { // This is an essential tag, so get it's corresponding template name. // Ex: 'levels\test\bloodgulch\bloodgulch.scenario' would be the 'Scenario' template element. string templateName = templates.GetTemplateNameBypath(projectPathString); // If we aren't auto-reverting, generate the TemplateReverting event to prompt the user. bool revertEssentialTag = autoRevertEssentialTag; if (!autoRevertEssentialTag) { // The value returned here indicates whether the event was cancelled, so we want the inverse of it. revertEssentialTag = !OnTemplateReverting(projectPathString, templateName); } if (revertEssentialTag) { templates.RemoveByTagPath(projectPathString); // User chose to remove, or auto-revert was set. } else { return(false); // Nothing was removed. } } else // This was not an essential tag. { if (FileExists(path)) { // Remove the reference from the references table and raise the corresponding event. projectReferencesTable.RemoveFile(path); OnFileRemoved(path); } } return(true); // References were removed. }
void Templates_FileAdded(object sender, TemplateTagActionArgs e) { TagPath path = new TagPath(e.Filename); NodeInfo info; if (path.Location == TagLocation.Project) { info = new NodeInfo(GetNodeType <ProjectTemplateTagNodeType>(), path.ToPath(PathFormat.ExplicitLocation)); } else { info = new NodeInfo(GetNodeType <GlobalTemplateTagNodeType>(), path.ToPath(PathFormat.Relative)); } info.Tag = e.TemplateElement; OnItemAdded(info); }
/// <summary> /// Takes a non-qualified path and creates a fully-qualified path based on tag scope. /// This method takes into account scope priority rules. /// </summary> private string QualifyScope(string gameID, string path) { // TODO: Eventually, when we supoprt a shared folder and prefabs, we will need to look through them. // Check the Project folder first. TagPath tagPath = new TagPath(path, gameID, TagLocation.Project); if (TagExists(tagPath)) { return(tagPath.ToPath()); } // Next check the game archive. tagPath.Location = TagLocation.Archive; if (TagExists(tagPath)) { return(tagPath.ToPath()); } return(""); }
/// <summary> /// Gets the library associated with the given TagPath. /// </summary> /// <param name="path">TagPath to get the library for</param> /// <returns>an ILibrary implementation containing the specified TagPath</returns> private ILibrary GetLibrary(TagPath path) { switch (path.Location) { case TagLocation.Project: if (library == null) { return(archives[path.Game]); } else { return(library); } case TagLocation.Archive: return(archives[path.Game]); case TagLocation.Prefab: if (path.Game == format) { return(prefabs[path.LocationName]); } else { throw new PoolException("Tried to load a prefab of a differing game format than the currently registered project, if any."); } case TagLocation.Shared: if (path.Game == format) { return(shareds[path.LocationName]); } else { throw new PoolException("Tried to load a shared tag of a differing game format than the currently registered project, if any."); } default: throw new PoolException("Invalid path location was passed to GetLibrary."); } }
public void PerformTest() { ProjectManager projectManager = Core.Prometheus.Instance.ProjectManager; if (!projectManager.ProjectLoaded) { Output.Write(OutputTypes.Error, "This test cannot run unless a project is loaded"); return; } GameDefinition halo1 = Core.Prometheus.Instance.GetGameDefinitionByGameID("halopc"); Type tagType = halo1.TypeTable.LocateEntryByFourCC("test").TagType; TagPath testPath = new TagPath("nick.testing", "halopc", TagLocation.Project); Tag test = Core.Prometheus.Instance.Pool.Create(testPath, tagType, false); TagFile tagFile = new TagFile(new byte[0], "Prometheus", "Auto-generated Testing tag.", "test", "\0\0\0\0", "\0\0\0\0", Encoding.ASCII.GetBytes(testPath.Game)); Core.Prometheus.Instance.Pool.SaveTag(test, tagFile); projectManager.AddTagToProject(test, testPath); }
string GetIdentifierFromDocumentFilename(string documentFilename) { // TODO: This should really be implemented as a property of the TagPath. TagPath path = new TagPath(documentFilename); if (path.Game == gameID) { if (path.Location == tagLocation) { string identifier = path.Path + "." + path.Extension; if (path.AttachmentName != null) { if (path.AttachmentName.Length > 0) { identifier += "|" + path.AttachmentName; } } return(identifier); } } return(""); }
/// <summary> /// Returns an array of NodeInfo entries that exist beneath the specified NodeInfo. /// </summary> public override NodeInfo[] GetChildNodes(NodeInfo info) { List <NodeInfo> children = new List <NodeInfo>(); TagArchiveObjectViewNodeSource source = (TagArchiveObjectViewNodeSource)ParentSource; // Get a list of dependencies of the tag that matches the specified path. Pool pool = Core.Prometheus.Instance.Pool; string tagName = Path.GetExtension(info.Identifier).Trim('.'); Type tagType = source.Game.TypeTable.LocateEntryByName(tagName).TagType; TagPath poolPath = new TagPath(info.Identifier, source.Game.GameID, TagLocation.Archive); string[] references = new string[0]; try { references = pool.GetTagReferences(poolPath.ToPath(), tagType); } catch { //NodeInfo errorInfo = new NodeInfo("", "error", this); //MultiSourceTreeNode node = CreateNode("Error deserializing tag.", errorInfo); //children.Add(node); } foreach (string reference in references) { if (reference == "") { continue; } if (!source.Library.FileExists(reference)) { continue; } NodeInfo tagInfo = new NodeInfo(source.GetNodeType <TagNodeType>(), reference); children.Add(tagInfo); } return(children.ToArray()); }
public string OnAddScene(TagPath path) { GameDefinition game = instance.GetGameDefinitionByGameID(path.Game); string tagName = path.Path + "." + path.Extension; Type type = game.TypeTable.LocateEntryByName(path.Extension).TagType; if (!new List <Type>(type.GetInterfaces()).Contains(typeof(IInstanceable))) { throw new CoreException("Cannot preview tag; {0} does not implement {1}.", type.FullName, typeof(IInstanceable).Name); } Tag tag = pool.Open(path.ToPath(), type, true); string identifier = path.ToPath(); if (!scenes.ContainsKey(identifier)) { scenes.Add(identifier, tag); } Camera newCam = new Camera(); if (tag is ScenarioBase) { Interfaces.Rendering.Radiosity.WorldBounds totalBounds = (tag as ScenarioBase).BspList[0].WorldBounds; foreach (IBsp bsp in (tag as ScenarioBase).BspList) { totalBounds &= bsp.WorldBounds; } newCam.Position = new Vector3((totalBounds.X.Lower + totalBounds.X.Upper) / 2, (totalBounds.Y.Lower + totalBounds.Y.Upper) / 2, (totalBounds.Z.Lower + totalBounds.Z.Upper) / 2); } RenderCore.AddScene(identifier, tagName, newCam, ((IInstanceable)tag).Instance, RenderState.Textured, game.GetSceneType(tag)); // Temp using RenderState.Textured until we load the value from the project file. RenderCore.ActiveSceneName = identifier; //added this line to activate the latest Scene - gren return(identifier); }
/// <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); } }
/// <summary> /// Update the path that corresponds to the specified element. /// </summary> public void UpdateElementPath(string element, TagPath newTagPath) { string newPath = newTagPath.ToPath(PathFormat.ExplicitLocation); UpdateElementPath(element, newPath); }
/// <summary> /// Loads the specified project file into a ProjectFile object, optionally notifying /// the GUI to load the scenario file. /// </summary> public ProjectFile OpenProject(string filename, ScenarioAction action) { // TODO: Ensure that the file exists. StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open)); string xmlText = reader.ReadToEnd(); reader.Close(); XmlDocument projectDoc = new XmlDocument(); projectDoc.LoadXml(xmlText); // Setup the object and locate its GameDef/Template objects. ProjectFile project = new ProjectFile(projectDoc); Platform platform = (Platform)Enum.Parse(typeof(Platform), project.GamePlatform); string gameID = GameDefinition.GetGameID(project.GameName, platform); GameDefinition def = Prometheus.Instance.GetGameDefinitionByGameID(gameID); gameDefinition = def; foreach (ProjectTemplate template in def.ProjectTemplates) { if (template.Name == project.TemplateName) { project.Template = template; } } // Locate the scenario tag. if (project.Templates.ContainsTemplateElement("Scenario")) { scenarioTag = project.Templates["Scenario"].Path; } else { throw new Exception("The project does not reference a scenario, which is a required element."); } // Open the DiskFileLibrary for the project. string projectFolder = Path.GetDirectoryName(filename); DiskFileLibrary library = new DiskFileLibrary(projectFolder + "\\Tags", project.MapName); // TODO: Decide which one of these is neccessary. project.ProjectFolder = library; this.projectFolder = library; // Add the project to the list and register it with the Pool. this.filename = filename; this.project = project; this.project.Dirty += new EventHandler(project_Dirty); Prometheus.Instance.Pool.RegisterProject(def.Name, library); // Hey other code! Guess what we just did!!!!!11 OnOpenedProject(); bool loadScenario = false; if (action == ScenarioAction.Load) { loadScenario = true; } else if (action == ScenarioAction.PromptUser) { CancelEventArgs e = new CancelEventArgs(false); if (ScenarioOpening != null) { ScenarioOpening(this, e); } loadScenario = !e.Cancel; } if (loadScenario) { try { TagPath path = new TagPath(project.Templates["Scenario"].Path, GameID, TagLocation.Project); Prometheus.Instance.OnAddScene(path); } catch (TagAlreadyExistsException ex) { Output.Write(OutputTypes.Warning, ex.Message); } catch (PoolException ex) { Output.Write(OutputTypes.Warning, ex.Message); } } return(project); }
/// <summary> /// Adds the specified tag to the project file's tag references and saves it to the project folder. /// </summary> /// <param name="tag">The tag object to be saved.</param> /// <param name="path">The TagPath representing the file to save to.</param> public void AddTagToProject(Tag tag, TagPath path) { project.AddTagReference(path.Path + "." + path.Extension); Prometheus.Instance.Pool.SaveTag(tag, Prometheus.Instance.Pool.GetTagFile(path)); Output.Write(OutputTypes.Information, "Saved '" + tag.TagPath.Path + "." + tag.TagPath.Extension + "' to the project folder."); }