/// <summary> /// Include or just save fileName into current KeyValues Class /// </summary> /// <returns> /// true if the sucessfully include file (KeyValue is valid); otherwise, false. /// </returns> /// <param name="fileName">File to include on current KeyValues Class</param> /// <param name="loadToKeyValues">if true will load file and in current KeyValues Class; otherwise false.</param> /// <param name="addToList"> /// if true on save KeyValues to HDD will put a #include macro for the fileName on correct place; /// otherwise false. /// </param> public bool AddIncludeFile(string fileName, bool loadToKeyValues, bool addToList) { if (addToList) { if (!ExistsInclude(fileName)) { IncludedFiles.Add(fileName); } } if (loadToKeyValues) { var incKv = new KeyValues("include"); if (!incKv.LoadFromFile(fileName)) { return(false); } /*incKv.FirstParent = Parent == null ? this : Parent.FirstParent; * incKv.Parent = this; * incKv.DistanceFromTop = DistanceFromTop + 1;*/ Update(incKv, true); KeyChilds.Add(incKv); } return(true); }
public void AddFile(string filepath) { var item = new ProjectItem(); item.RealPath = filepath; item.RelativePath = filepath.Replace(ProjDirectory, ""); IncludedFiles.Add(item); SaveProject(); }
public override void ReadProject(string filepath) { ProjFilepath = filepath; var proj = new XmlDocument(); proj.Load(filepath); var node = proj.SelectSingleNode("//Project"); this.ToolVer = node.Attributes["ToolVer"].Value; this.GameVer = node.Attributes["GameVer"].Value; if (node.Attributes["Platform"].Value == "WiiU") { this.Platform = ProjPlatform.WiiU; } else if (node.Attributes["Platform"].Value == "3DS") { this.Platform = ProjPlatform.ThreeDS; } var nodes = proj.SelectNodes("//Project/FileGroup"); foreach (XmlNode n in nodes) { foreach (XmlNode child in n.ChildNodes) { var item = new ProjectItem(); item.RelativePath = Runtime.CanonicalizePath(child.Attributes["Include"].Value); item.RealPath = Runtime.CanonicalizePath(Path.Combine(ProjDirectory, item.RelativePath)); if (child.HasChildNodes) { foreach (XmlNode child2 in child.ChildNodes) { if (child2.LocalName == "DependsUpon") { var path = Runtime.CanonicalizePath(Path.Combine(Path.GetDirectoryName(item.RelativePath), child2.InnerText)); item.Depends.Add(IncludedFiles.Find(x => x.RelativePath == path)); } } } if (child.Name == "Folder") { IncludedFolders.Add(item); } else { IncludedFiles.Add(item); } } } ProjFile = proj; }