1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-25 22:18:34 +01:00

Compare commits

..

No commits in common. "b012c65990fc46c219ff267035707627d444321a" and "02b46269968311b5fd75226160159198a3050e54" have entirely different histories.

4 changed files with 3 additions and 19 deletions

View file

@ -22,13 +22,6 @@ Improvements
- Allow elements to auto-adjust their size even when their children are aligned oddly
- Close other dropdowns when opening a dropdown
### MLEM.Data
Improvements
- Allow data texture atlas pivots and offsets to be negative
Fixes
- Fixed data texture atlases not allowing most characters in their region names
## 6.0.0
### MLEM
Additions

View file

@ -86,7 +86,7 @@ namespace MLEM.Data {
var atlas = new DataTextureAtlas(texture);
// parse each texture region: "<names> loc <u> <v> <w> <h> [piv <px> <py>] [off <ox> <oy>]"
foreach (Match match in Regex.Matches(text, @"(.+)\s+loc\s+([0-9+]+)\s+([0-9+]+)\s+([0-9+]+)\s+([0-9+]+)\s*(?:piv\s+([0-9.+-]+)\s+([0-9.+-]+))?\s*(?:off\s+([0-9.+-]+)\s+([0-9.+-]+))?")) {
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.]+))?")) {
// offset
var off = !match.Groups[8].Success ? Vector2.Zero : new Vector2(
float.Parse(match.Groups[8].Value, CultureInfo.InvariantCulture),
@ -103,7 +103,7 @@ 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, @"\s")) {
foreach (var name in Regex.Split(match.Groups[1].Value, @"\W")) {
var trimmed = name.Trim();
if (trimmed.Length <= 0)
continue;

View file

@ -9,10 +9,6 @@ piv 80 16
Plant
loc 96 0 16 32
TestRegionNegativePivot
loc 0 32 +16 16
piv -32 +46
LongTableUp
loc 0 32 64 48
piv 16 48

View file

@ -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(), 8);
Assert.AreEqual(atlas.Regions.Count(), 7);
// no added offset
var table = atlas["LongTableUp"];
@ -24,11 +24,6 @@ namespace Tests {
var table2 = atlas["LongTableLeft"];
Assert.AreEqual(table2.Area, new Rectangle(64, 32, 64, 48));
Assert.AreEqual(table2.PivotPixels, new Vector2(112 - 64, 48 - 32));
// negative pivot
var negativePivot = atlas["TestRegionNegativePivot"];
Assert.AreEqual(negativePivot.Area, new Rectangle(0, 32, 16, 16));
Assert.AreEqual(negativePivot.PivotPixels, new Vector2(-32, 46 - 32));
}
}