public void ShouldReadCreatedWadFile() { var fileInfo = new FileInfo(Path.GetTempFileName()); try { var map = DemoMap.Create(); var wadWriter = new WadWriter(); wadWriter.Append("MAP01", map); wadWriter.SaveTo(fileInfo.FullName); using (var wadReader = WadReader.Read(fileInfo.FullName)) { Assert.That(wadReader.Directory.Length, Is.EqualTo(3), "Did not return correct count."); Assert.That( wadReader.Directory.Select(l => l.Name).ToArray(), Is.EquivalentTo(new[] { new LumpName("MAP01"), new LumpName("TEXTMAP"), new LumpName("ENDMAP"), }), "Did not return correct lump names."); var roundTripped = MapData.LoadFrom(wadReader.GetTextmapStream("MAP01")); Assert.That(roundTripped, Is.DeepEqualTo(map)); } } finally { if (fileInfo.Exists) { fileInfo.Delete(); } } }
/// <summary> /// Create a WAD with the given map /// </summary> /// <param name="lumps">The lumps of the WAD to load</param> /// <param name="wadFilePath"> /// (Optional) The path to the WAD to create. If not specified, something will be created in the temporary directory. /// </param> public void CreateAndLoadWad( IEnumerable <ILump> lumps, string?wadFilePath = null) { wadFilePath ??= Path.Combine(Path.GetTempPath(), "demo.lumps"); var pathToLoad = Path.GetFullPath(wadFilePath); WadWriter.SaveTo(lumps, pathToLoad); LoadWad(pathToLoad); }
public void ShouldCreateWadFile() { var fileInfo = new FileInfo(Path.GetTempFileName()); try { var wad = new WadWriter(); wad.Append("MAP01", DemoMap.Create()); wad.SaveTo(fileInfo.FullName); } finally { if (fileInfo.Exists) { fileInfo.Delete(); } } }
private static void LoadMaps(params MapData[] maps) { string wadFilePath = "demo.wad"; var enginePath = GetEngineExePath(); var wadWriter = new WadWriter(); foreach (var(map, index) in maps.Select((map, index) => (map, index))) { wadWriter.Append($"E3M{index + 1}", map); } wadWriter.SaveTo(wadFilePath); Process.Start( enginePath, $"-file {wadFilePath} -skill 4 -iwad doom.wad -warp 3 1"); }
public void ShouldCreateWadFile() { var fileInfo = new FileInfo(Path.GetTempFileName()); try { var lumps = new List <ILump> { new Marker("MAP01"), new UwmfLump("TEXTMAP", ThingDemoMap.Create()), new Marker("ENDMAP") }; WadWriter.SaveTo(lumps, fileInfo.FullName); } finally { if (fileInfo.Exists) { fileInfo.Delete(); } } }
public void ShouldReadCreatedWadFile() { var fileInfo = new FileInfo(Path.GetTempFileName()); try { var map = ThingDemoMap.Create(); var lumps = new List <ILump> { new Marker("MAP01"), new UwmfLump("TEXTMAP", ThingDemoMap.Create()), new Marker("ENDMAP") }; WadWriter.SaveTo(lumps, fileInfo.FullName); var wad = WadFile.Read(fileInfo.FullName); wad.Should().HaveCount(3); wad.Select(l => l.Name).Should().BeEquivalentTo( new[] { new LumpName("MAP01"), new LumpName("TEXTMAP"), new LumpName("ENDMAP"), }, "correct lump names should have been read."); var mapBytes = wad[1].GetData(); using var ms = new MemoryStream(mapBytes); var roundTripped = UwmfReader.Read(ms); UwmfComparison.AssertEqual(roundTripped, map); } finally { if (fileInfo.Exists) { fileInfo.Delete(); } } }