public static bool LoadSections( Action <int> progressCallback, Func <bool> cancelCallback, out LoadResult <Section> result) { var loader = new SectionLoader(); if (!loader.LoadFiles(progressCallback, cancelCallback)) { result = null; return(false); } result = loader.GetResult(); return(true); }
public static bool LoadFeatures( Action <int> progressCallback, Func <bool> cancelCallback, out LoadResult <Feature> result) { var recordLoader = new FeatureTdfLoader(); if (!recordLoader.LoadFiles(i => progressCallback((i * 33) / 100), cancelCallback)) { result = null; return(false); } var records = new Dictionary <string, FeatureRecord>(); foreach (var f in recordLoader.Records) { records[f.Name] = f; } var filenameMap = records.Values .GroupBy(x => x.AnimFileName, StringComparer.OrdinalIgnoreCase) .ToDictionary(x => x.Key, x => (IList <FeatureRecord>)x.ToList(), StringComparer.OrdinalIgnoreCase); var bitmapLoader = new FeatureBitmapLoader(filenameMap); if (!bitmapLoader.LoadFiles(i => progressCallback(33 + ((i * 33) / 100)), cancelCallback)) { result = null; return(false); } var frames = new Dictionary <string, OffsetBitmap>(); foreach (var f in bitmapLoader.Records) { frames[f.Key] = f.Value; } var objectMap = records.Values .GroupBy(x => x.ObjectName, StringComparer.OrdinalIgnoreCase) .ToDictionary(x => x.Key, x => (IList <FeatureRecord>)x.ToList(), StringComparer.OrdinalIgnoreCase); var renderLoader = new FeatureRenderLoader(objectMap); if (!renderLoader.LoadFiles(i => progressCallback(66 + ((i * 33) / 100)), cancelCallback)) { result = null; return(false); } var renders = new Dictionary <string, OffsetBitmap>(); foreach (var r in renderLoader.Records) { renders[r.Key] = r.Value; } var features = LoadFeatureObjects(records.Values, frames, renders).ToList(); progressCallback(100); result = new LoadResult <Feature> { Records = features, Errors = recordLoader.HpiErrors .Concat(bitmapLoader.HpiErrors) .Concat(renderLoader.HpiErrors) .GroupBy(x => x.HpiPath) .Select(x => x.First()) .ToList(), FileErrors = recordLoader.FileErrors .Concat(bitmapLoader.FileErrors) .Concat(renderLoader.FileErrors) .ToList(), }; return(true); }