private MapFile?LoadMap(MapLoader mapLoader, SgaRawFile scenario) { MapFile?mapFile = null; try { mapFile = mapLoader.Load(new MemoryStream(scenario.Data), scenario.Name); } catch (IOException ex) { logger.Write(ex, $"Failed to load {scenario.Name}", LogLevel.Warn); } return(mapFile); }
public string?GetMapImage(string fileName) { string noExt = Path.GetFileNameWithoutExtension(fileName); List <SgaRawFile> images = sgaFileReader.GetFiles(@"scenarios\mp", $@"{noExt}_(icon)(_custom)?\.tga$") .ToList(); if (images.Count == 0) { return(null); } images.Sort((a, b) => a.Name.CompareTo(b.Name)); SgaRawFile image = images.Last(); string imagesFolder = Path.Combine(cacheFolder, "data", "scenarios", "mp"); Directory.CreateDirectory(imagesFolder); File.WriteAllBytes(Path.Combine(imagesFolder, image.Name), image.Data); return(image.Name); }