2021-03-18 17:28:08 +01:00
|
|
|
using System.Linq;
|
|
|
|
using Microsoft.Xna.Framework;
|
2021-04-02 17:12:27 +02:00
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2021-03-18 17:28:08 +01:00
|
|
|
using MLEM.Data;
|
2021-04-02 17:12:27 +02:00
|
|
|
using MLEM.Textures;
|
2021-03-18 17:28:08 +01:00
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace Tests {
|
|
|
|
public class TestDataTextureAtlas {
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test() {
|
2021-04-02 17:12:27 +02:00
|
|
|
using var game = TestGame.Create();
|
|
|
|
using var texture = new Texture2D(game.GraphicsDevice, 1, 1);
|
|
|
|
var atlas = DataTextureAtlas.LoadAtlasData(new TextureRegion(texture), game.RawContent, "Texture.atlas");
|
2021-03-18 17:28:08 +01:00
|
|
|
Assert.AreEqual(atlas.Regions.Count(), 5);
|
|
|
|
|
2021-07-12 03:14:05 +02:00
|
|
|
// no added offset
|
2021-03-18 17:28:08 +01:00
|
|
|
var table = atlas["LongTableUp"];
|
|
|
|
Assert.AreEqual(table.Area, new Rectangle(0, 32, 64, 48));
|
|
|
|
Assert.AreEqual(table.PivotPixels, new Vector2(16, 48 - 32));
|
2021-07-12 03:14:05 +02:00
|
|
|
|
|
|
|
// added offset
|
|
|
|
var table2 = atlas["LongTableRight"];
|
|
|
|
Assert.AreEqual(table2.Area, new Rectangle(64, 32, 64, 48));
|
|
|
|
Assert.AreEqual(table2.PivotPixels, new Vector2(112 - 64, 48 - 32));
|
2021-03-18 17:28:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|