//============================================================ // <T>加载全部处理。</T> //============================================================ public virtual void LoadAll() { // 清空集合 if (_folders != null) { _folders.Clear(); } if (_objects != null) { _objects.Clear(); } // 加载所有子目录 foreach (string path in RDirectory.ListDirectories(_directory)) { // 跳过SVN目录 if (path.IndexOf(".svn") != -1) { continue; } // 加载子目录 OnLoadFolder(path); } if (_folders != null) { _folders.Sort(); } // 加载配置 if (RFile.Exists(ConfigFileName)) { FXmlDocument xdoc = new FXmlDocument(); xdoc.LoadFile(ConfigFileName); LoadConfig(xdoc.Root); } }
//============================================================ // <T>加载所有目录。</T> //============================================================ public virtual void LoadFolderAll() { // 加载所有子目录 foreach (string path in RDirectory.ListDirectories(_directory)) { // 跳过SVN目录 if (path.IndexOf(".svn") != -1) { continue; } // 加载子目录 OnLoadFolder(path); } if (_folders != null) { _folders.Sort(); } // 加载配置 if (RFile.Exists(ConfigFileName)) { FXmlDocument xdoc = new FXmlDocument(); try { xdoc.LoadFile(ConfigFileName); } catch (Exception e) { throw new FFatalException(e, "Open config file error. (file_name={0})", ConfigFileName); } LoadConfig(xdoc.Root); } }
//============================================================ // <T>加载文件夹信息,取得地址。</T> // <P>加载文件下文件信息,取得文件地址。</P> // // @param directory 文件路径。 //============================================================ public void LoadDirectory(string directory) { // 加载给定路径下面的文件夹. FStrings paths = RDirectory.ListDirectories(directory); int count = paths.Count; for (int n = 0; n < count; n++) { // 检查文件夹 string path = paths[n]; if (path.Contains(".svn")) { continue; } // 取得文件夹类型名称。 string name = path.Substring(path.LastIndexOf("\\") + 1); string id = name.Substring(0, name.IndexOf('-')); string label = name.Substring(name.IndexOf('-') + 1).Trim(); // 文件夹的全路径地址。 FDsMap map = new FDsMap(); map.Resource.Directory = path; map.Resource.Tid = RInt.Parse(id); map.Resource.Name = name; map.Resource.Label = label; map.Resource.LoadDirectory(); _maps.Push(map.Resource); } }
//============================================================ // <T>递归加载文件信息。</T> // // @param folders 文件集合 // @author TYFNG 1203024 //============================================================ protected void ScanFolder(FRsResourceFolder parentFolder) { // 处理所有子文件夹 FStrings directoryNames = RDirectory.ListDirectories(parentFolder.Directory); foreach (string directoryName in directoryNames) { if (-1 != directoryName.IndexOf(".svn")) { continue; } string fileName = directoryName.Substring(directoryName.LastIndexOf("\\") + 1); // 解析动画资源 if (fileName.StartsWith("RA-")) { string name = fileName.Substring(3); string fullName = name; string label = name; int codeIndex = name.IndexOf("-"); if (-1 != codeIndex) { name = name.Substring(0, codeIndex); } name = name.Replace(".", ""); // 创建图片资源 int code = RInt.Parse(name); FRsResourceAnimation animation = CreateResource(ERsResource.Animation, code) as FRsResourceAnimation; animation.Folder = parentFolder; animation.Code = code; animation.Name = name; animation.Label = label; animation.FullLabel = parentFolder.FullLabel + "\\" + label; animation.Keyword = label.Replace(".", ""); animation.Directory = directoryName; animation.Scan(); parentFolder.Resources.Push(animation); } else { // 创建子文件夹 FRsResourceFolder folder = new FRsResourceFolder(); folder.Label = fileName; folder.FullLabel = parentFolder.FullLabel + "\\" + fileName; folder.Directory = directoryName; parentFolder.Folders.Push(folder); // 扫描子文件夹 ScanFolder(folder); } } // 扫描文件夹 parentFolder.Scan(); }
//============================================================ // <T>加载文件夹信息,取得地址。</T> // <P>加载文件下文件信息,取得文件地址。</P> // // @param directory 文件路径。 //============================================================ public void LoadDirectory(string directory) { // 加载给定路径下面的文件夹. FStrings paths = RDirectory.ListDirectories(directory); int count = paths.Count; for (int n = 0; n < count; n++) { // 检查文件夹 string path = paths[n]; if (path.Contains(".svn")) { continue; } // 取得文件夹类型名称。 string fullName = path.Substring(path.LastIndexOf("\\") + 1); string id = fullName.Substring(0, fullName.IndexOf('-')); string label = fullName.Substring(fullName.IndexOf('-') + 1).Trim(); // 文件夹的全路径地址。 FDsMapTileCatalog mapTileCatalog = new FDsMapTileCatalog(); mapTileCatalog.Resource.Id = RInt.Parse(id); mapTileCatalog.Resource.FullName = fullName; mapTileCatalog.Resource.Lable = label; _mapTileCatalogs.Push(mapTileCatalog.Resource); //加载瓦片图片集合 FStrings files = RDirectory.ListFiles(path); int fileCount = files.Count; for (int i = 0; i < fileCount; i++) { string file = files[i]; if (!file.Contains(".png")) { continue; } // 取得文件名称。 string tileId = file.Substring(file.LastIndexOf("\\") + 1, 4); Bitmap resource = new Bitmap(file); // 文件的全路径地址 FDsMapTile mapTile = new FDsMapTile(); mapTile.Resource.Id = RInt.Parse(id + "" + tileId); mapTile.Resource.Resource = resource; mapTileCatalog.Resource.MapTiles.Push(mapTile.Resource); } } }
//============================================================ // <T>加载文件夹信息,取得地址。</T> // <P>加载文件下文件信息,取得文件地址。</P> // // @param directory 文件路径。 //============================================================ public void LoadDirectory(string rootDirectory) { // 加载给定路径下面的文件夹. FStrings directorys = RDirectory.ListDirectories(rootDirectory); foreach (string directory in directorys) { // 检查文件夹 if (directory.Contains(".svn")) { continue; } // 取得文件夹类型名称。 string fileName = directory.Substring(directory.LastIndexOf("\\") + 1); int codeIndex = fileName.IndexOf('-'); string code = fileName.Substring(0, codeIndex); int nameBeginIndex = fileName.IndexOf('('); int nameEndIndex = fileName.LastIndexOf(')'); string name = fileName.Substring(nameBeginIndex + 1, nameEndIndex - nameBeginIndex - 1).Trim(); string typeName = RString.FirstUpper(name.Substring(name.LastIndexOf('.') + 1)); string label = fileName.Substring(codeIndex + 1, nameBeginIndex - codeIndex - 1).Trim(); // 文件夹的全路径地址。 FRcFrame frame = CreateComponent(typeName) as FRcFrame; if (frame != null) { // 设置属性 frame.Code = RInt.Parse(code); frame.Name = name; frame.Label = label; // 设置信息 frame.FileName = directory + @"\config.xml"; frame.Directory = directory; // 放入集合 _frames.Set(name, frame); } } }