mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 14:08:34 +01:00
Compare commits
No commits in common. "e673ccea615cdf3fa3724175ec5e2f9fe7ee060a" and "08e28cb95ba05e603f6ba5e0029da3d3afb8892f" have entirely different histories.
e673ccea61
...
08e28cb95b
7 changed files with 18 additions and 21 deletions
|
@ -80,7 +80,6 @@ Improvements
|
|||
- Allow enumerating all region names of a DataTextureAtlas
|
||||
- Cache RuntimeTexturePacker texture data while packing to improve performance
|
||||
- Greatly improved RuntimeTexturePacker performance
|
||||
- Allow specifying multiple names for a DataTextureAtlas region
|
||||
|
||||
Fixes
|
||||
- Fixed SoundEffectReader incorrectly claiming it could read ogg and mp3 files
|
||||
|
|
2
FNA
2
FNA
|
@ -1 +1 @@
|
|||
Subproject commit 700a6f096ad359cc12634eeb5608ee9c8d29798c
|
||||
Subproject commit 62cbf1c3180c31de0265b267a7ed080efd20150c
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
@ -85,8 +84,9 @@ namespace MLEM.Data {
|
|||
}
|
||||
var atlas = new DataTextureAtlas(texture);
|
||||
|
||||
// parse each texture region: "<names> loc <u> <v> <w> <h> [piv <px> <py>] [off <ox> <oy>]"
|
||||
// parse each texture region: "<name> loc <u> <v> <w> <h> [piv <px> <py>] [off <ox> <oy>]"
|
||||
foreach (Match match in Regex.Matches(text, @"(.+)\W+loc\W+([0-9]+)\W+([0-9]+)\W+([0-9]+)\W+([0-9]+)\W*(?:piv\W+([0-9.]+)\W+([0-9.]+))?\W*(?:off\W+([0-9.]+)\W+([0-9.]+))?")) {
|
||||
var name = match.Groups[1].Value.Trim();
|
||||
// offset
|
||||
var off = !match.Groups[8].Success ? Vector2.Zero : new Vector2(
|
||||
float.Parse(match.Groups[8].Value, CultureInfo.InvariantCulture),
|
||||
|
@ -103,16 +103,11 @@ namespace MLEM.Data {
|
|||
float.Parse(match.Groups[6].Value, CultureInfo.InvariantCulture) - (pivotRelative ? 0 : loc.X),
|
||||
float.Parse(match.Groups[7].Value, CultureInfo.InvariantCulture) - (pivotRelative ? 0 : loc.Y));
|
||||
|
||||
foreach (var name in Regex.Split(match.Groups[1].Value, @"\W")) {
|
||||
var trimmed = name.Trim();
|
||||
if (trimmed.Length <= 0)
|
||||
continue;
|
||||
var region = new TextureRegion(texture, loc) {
|
||||
PivotPixels = piv,
|
||||
Name = trimmed
|
||||
};
|
||||
atlas.regions.Add(trimmed, region);
|
||||
}
|
||||
var region = new TextureRegion(texture, loc) {
|
||||
PivotPixels = piv,
|
||||
Name = name
|
||||
};
|
||||
atlas.regions.Add(name, region);
|
||||
}
|
||||
|
||||
return atlas;
|
||||
|
|
|
@ -13,6 +13,6 @@ LongTableUp
|
|||
loc 0 32 64 48
|
||||
piv 16 48
|
||||
|
||||
LongTableRight LongTableDown LongTableLeft
|
||||
LongTableRight
|
||||
loc 64 32 64 48
|
||||
piv 112 48
|
||||
piv 112 48
|
|
@ -169,8 +169,11 @@ namespace Sandbox {
|
|||
var region2 = new TextureRegion(round);
|
||||
|
||||
var atlas = this.Content.LoadTextureAtlas("Textures/Furniture");
|
||||
foreach (var r in atlas.Regions)
|
||||
foreach (var r in atlas.Regions) {
|
||||
Console.WriteLine(r.Name + ": " + r.U + " " + r.V + " " + r.Width + " " + r.Height + " " + r.PivotPixels);
|
||||
foreach (var key in r.GetDataKeys())
|
||||
Console.WriteLine(key + " " + r.GetData<Vector2>(key));
|
||||
}
|
||||
|
||||
this.OnDraw += (g, time) => {
|
||||
this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp);
|
||||
|
|
|
@ -13,7 +13,7 @@ LongTableUp
|
|||
loc 0 32 64 48
|
||||
piv 16 48
|
||||
|
||||
LongTableRight LongTableDown LongTableLeft
|
||||
LongTableRight
|
||||
loc 32 30 64 48
|
||||
piv 80 46
|
||||
off 32 2
|
||||
off 32 2
|
|
@ -13,7 +13,7 @@ namespace Tests {
|
|||
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");
|
||||
Assert.AreEqual(atlas.Regions.Count(), 7);
|
||||
Assert.AreEqual(atlas.Regions.Count(), 5);
|
||||
|
||||
// no added offset
|
||||
var table = atlas["LongTableUp"];
|
||||
|
@ -21,7 +21,7 @@ namespace Tests {
|
|||
Assert.AreEqual(table.PivotPixels, new Vector2(16, 48 - 32));
|
||||
|
||||
// added offset
|
||||
var table2 = atlas["LongTableLeft"];
|
||||
var table2 = atlas["LongTableRight"];
|
||||
Assert.AreEqual(table2.Area, new Rectangle(64, 32, 64, 48));
|
||||
Assert.AreEqual(table2.PivotPixels, new Vector2(112 - 64, 48 - 32));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue