public Dictionary <Language, byte[]> LoadLocalizedBuffer(string search, bool startsWithElseContains) { Dictionary <Language, byte[]> result = new Dictionary <Language, byte[]>(); search = search.ToLower(); List <LotdFile> files = Root.GetAllFiles(); foreach (LotdFile file in files) { if (file.FileType == LotdFileType.Zib) { ZibData zibData = file.LoadData <ZibData>(); foreach (ZibFile zibFile in zibData.Files.Values) { Language language = LotdFile.GetLanguageFromFileName(zibFile.FileName); if (language != Language.Unknown) { if ((startsWithElseContains && zibFile.FileName.ToLower().StartsWith(search)) || (!startsWithElseContains && zibFile.FileName.ToLower().Contains(search))) { result.Add(language, zibFile.LoadBuffer()); } } } } else { Language language = LotdFile.GetLanguageFromFileName(file.Name); if (language != Language.Unknown) { if ((startsWithElseContains && file.Name.ToLower().StartsWith(search)) || (!startsWithElseContains && file.Name.ToLower().Contains(search))) { result.Add(language, file.LoadBuffer()); } } } } return(result); }
public T LoadLocalizedFile <T>() where T : FileData, new() { LotdFileType targetFileType = LotdFile.GetFileType(typeof(T)); T result = new T(); if (!result.IsLocalized) { throw new InvalidOperationException("Attempted to load a file with localization which has none"); } List <LotdFile> files = Root.GetAllFiles(); foreach (LotdFile file in files) { if (file.FileType == LotdFileType.Zib) { ZibData zibData = file.LoadData <ZibData>(); foreach (ZibFile zibFile in zibData.Files.Values) { if (zibFile.FileType == targetFileType) { result.File = null; result.ZibFile = zibFile; result.Load(); } } } else if (file.FileType == targetFileType) { result.File = file; result.ZibFile = null; result.Load(); } } return(result); }
public List <T> LoadFiles <T>() where T : FileData { LotdFileType targetFileType = LotdFile.GetFileType(typeof(T)); List <T> result = new List <T>(); List <LotdFile> files = Root.GetAllFiles(); foreach (LotdFile file in files) { if (file.FileType == LotdFileType.Zib) { ZibData zibData = file.LoadData <ZibData>(); foreach (ZibFile zibFile in zibData.Files.Values) { if (zibFile.FileType == targetFileType) { T data = zibFile.LoadData <T>(); if (data != null) { result.Add(data); } } } } else if (file.FileType == targetFileType) { T data = file.LoadData <T>(); if (data != null) { result.Add(data); } } } return(result); }