-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
123 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,40 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Numerics; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Sledge.Formats.Map.Formats; | ||
using Sledge.Formats.Map.Objects; | ||
|
||
namespace Sledge.Formats.Map.Tests.Formats | ||
{ | ||
[TestClass] | ||
public class TestJackhammerFormat | ||
{ | ||
[TestMethod] | ||
public void TestJmfFormatLoading() | ||
public void TestJmf121() | ||
{ | ||
using var file = typeof(TestJackhammerFormat).Assembly.GetManifestResourceStream("Sledge.Formats.Map.Tests.Resources.jmf.default-room-121.jmf"); | ||
var format = new JackhammerJmfFormat(); | ||
foreach (var file in Directory.GetFiles(@"D:\Downloads\formats\jmf", "1group.jmf")) | ||
{ | ||
using (var r = File.OpenRead(file)) | ||
{ | ||
try | ||
{ | ||
format.Read(r); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Assert.Fail($"Unable to read file: {Path.GetFileName(file)}. {ex.Message}"); | ||
} | ||
} | ||
} | ||
var map = format.Read(file); | ||
Assert.AreEqual("worldspawn", map.Worldspawn.ClassName); | ||
} | ||
|
||
[TestMethod] | ||
public void TestJmf122() | ||
{ | ||
using var file = typeof(TestJackhammerFormat).Assembly.GetManifestResourceStream("Sledge.Formats.Map.Tests.Resources.jmf.default-room-122.jmf"); | ||
var format = new JackhammerJmfFormat(); | ||
var map = format.Read(file); | ||
Assert.AreEqual("worldspawn", map.Worldspawn.ClassName); | ||
Assert.AreEqual(3, map.BackgroundImages.Count); | ||
|
||
var front = map.BackgroundImages.Single(x => x.Viewport == ViewportType.OrthographicFront); | ||
Assert.AreEqual("C:/Test/Viewport.png", front.Path); | ||
Assert.IsTrue(Math.Abs(front.Scale - 2.5) < 0.0001); | ||
Assert.AreEqual(175, front.Luminance); | ||
Assert.AreEqual(FilterMode.Linear, front.Filter); | ||
Assert.AreEqual(true, front.InvertColours); | ||
Assert.AreEqual(new Vector2(6, -7), front.Offset); | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Numerics; | ||
using System.Text; | ||
|
||
namespace Sledge.Formats.Map.Objects | ||
{ | ||
public class BackgroundImage | ||
{ | ||
public ViewportType Viewport { get; set; } | ||
public string Path { get; set; } | ||
public double Scale { get; set; } | ||
public byte Luminance { get; set; } | ||
public FilterMode Filter { get; set; } | ||
public bool InvertColours { get; set; } | ||
public Vector2 Offset { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Sledge.Formats.Map.Objects | ||
{ | ||
public enum FilterMode | ||
{ | ||
Nearest = 0, | ||
Linear = 1, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Sledge.Formats.Map.Objects | ||
{ | ||
public enum ViewportType | ||
{ | ||
/// <summary> | ||
/// 3D view | ||
/// </summary> | ||
Perspective, | ||
|
||
/// <summary> | ||
/// X/Y | ||
/// </summary> | ||
OrthographicTop, | ||
|
||
/// <summary> | ||
/// X/Z | ||
/// </summary> | ||
OrthographicSide, | ||
|
||
/// <summary> | ||
/// Y/Z | ||
/// </summary> | ||
OrthographicFront, | ||
} | ||
} |