mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-15 15:09:29 +00:00
Version 4.0.3 (#953)
* fix(Matrix3x2): decompose method (#941) * Fix bug when using `NinePatch` with `Texture2DRegion`. (#945) Resolves #943 * BitmapFont now always loads from TitleContainer. (#946) Fixes KNI web builds when using BitmapFont (#944) * Fix bug when creating a NinePatch using the Texture2DRegion extension method (#948) * Revert UV code (#951) * [Weekly] Version 4.0.3 (#952) * Starting 4.0.2 release prep * Update changelog * Bump version number to 4.0.3 * Updated workflows to use dotnet 8 --------- Co-authored-by: Ilia Bahrebar <150489740+Std-Enigma@users.noreply.github.com> Co-authored-by: Dwergi <sebastian.nordgren@gmail.com> Co-authored-by: Joseph Newman <greenstack@users.noreply.github.com> Co-authored-by: Jeremy Swartwood <jeremy.swartwood@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c814a65aea
commit
e22c2cc058
@@ -42,7 +42,7 @@ jobs:
|
||||
- name: Setup Dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 6.0.x
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Build MonoGame.Extended
|
||||
run: dotnet build MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
|
||||
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
- name: Setup DotNet
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 6.0.x
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Test MonoGame.Extended
|
||||
run: dotnet test MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
|
||||
|
||||
@@ -11,6 +11,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
> Unreleased changes exist in the current `develop` branch but have not been pushed as either a stable or prerelease NuGet package.
|
||||
>
|
||||
|
||||
## [4.0.3]
|
||||
## Fixed
|
||||
- Resoled issue where `Matrix3x2.Decompose` returned incorrect values for transformation [@Std-Enigma](https://github.com/Std-Enigma) [#941](https://github.com/craftworkgames/MonoGame.Extended/pull/941)
|
||||
- Resolved bug in NinePatch where padding calculations were incorrect [@Dwergi](https://github.com/Dwergi) [#945](https://github.com/craftworkgames/MonoGame.Extended/pull/945)
|
||||
- Resoled bug in `Texture2DExtensions.CreateNinePatch` where source rectangles were calculated that overlapped. [@greenstack](https://github.com/greenstack) [#948](https://github.com/craftworkgames/MonoGame.Extended/pull/948)
|
||||
|
||||
## Changed
|
||||
- `BitmapFont` uses `TitleContainer` to load stream of file [@Dwergi](https://github.com/Dwergi) [#946](https://github.com/craftworkgames/MonoGame.Extended/pull/946)
|
||||
- Revert UV code for `Sprite.OriginNormalize`, resolving incorrect calculations [@kaltinril](https://github.com/kaltinril) [#951](https://github.com/craftworkgames/MonoGame.Extended/pull/951)
|
||||
|
||||
|
||||
## [4.0.2]
|
||||
### Fixed
|
||||
- Resolved issue when reading .particle files for a ParticleEffect that cause a recursion loop bug creating a stack overflow exception [@AristurtleDev](https://github.com/AristurtleDev) [#938](https://github.com/craftworkgames/MonoGame.Extended/pull/938)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<MonoGameExtendedVersion>4.0.2</MonoGameExtendedVersion>
|
||||
<MonoGameExtendedVersion>4.0.3</MonoGameExtendedVersion>
|
||||
<IsPrerelease Condition="'$(IS_PRERELEASE)' != ''">-prerelease</IsPrerelease>
|
||||
<BuildNumber Condition="'$(BUILD_NUMBER)' != ''">.$(BUILD_NUMBER)</BuildNumber>
|
||||
<Version>$(MonoGameExtendedVersion)$(IsPrerelease)$(BuildNumber)</Version>
|
||||
|
||||
@@ -364,13 +364,19 @@ public sealed class BitmapFont
|
||||
|
||||
public static BitmapFont FromFile(GraphicsDevice graphicsDevice, string path)
|
||||
{
|
||||
using FileStream stream = File.OpenRead(path);
|
||||
return FromStream(graphicsDevice, stream);
|
||||
using Stream stream = TitleContainer.OpenStream(path);
|
||||
return FromStream(graphicsDevice, stream, path);
|
||||
}
|
||||
|
||||
[Obsolete("Use the FromStream() overload that takes an explicit name.")]
|
||||
public static BitmapFont FromStream(GraphicsDevice graphicsDevice, FileStream stream)
|
||||
{
|
||||
var bmfFile = BitmapFontFileReader.Read(stream);
|
||||
return FromStream(graphicsDevice, stream, stream.Name);
|
||||
}
|
||||
|
||||
public static BitmapFont FromStream(GraphicsDevice graphicsDevice, Stream stream, string name)
|
||||
{
|
||||
var bmfFile = BitmapFontFileReader.Read(stream, name);
|
||||
|
||||
// Load page textures
|
||||
Dictionary<string, Texture2D> pages = new Dictionary<string, Texture2D>();
|
||||
@@ -379,7 +385,7 @@ public sealed class BitmapFont
|
||||
if (!pages.ContainsKey(bmfFile.Pages[i]))
|
||||
{
|
||||
string texturePath = Path.Combine(Path.GetDirectoryName(bmfFile.Path), bmfFile.Pages[i]);
|
||||
using (Stream textureStream = File.OpenRead(texturePath))
|
||||
using (Stream textureStream = TitleContainer.OpenStream(texturePath))
|
||||
{
|
||||
Texture2D texture = Texture2D.FromStream(graphicsDevice, textureStream);
|
||||
pages.Add(bmfFile.Pages[i], texture);
|
||||
|
||||
@@ -28,18 +28,33 @@ public static class BitmapFontFileReader
|
||||
public static BitmapFontFileContent Read(string path)
|
||||
{
|
||||
using var stream = File.OpenRead(path);
|
||||
return Read(stream);
|
||||
return Read(stream, path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the content of the font file at the path specified.
|
||||
/// </summary>
|
||||
/// <param name="stream">A <see cref="FileStream"/> containing the font file contents to read.</param>
|
||||
/// <param name="stream">A <see cref="Stream"/> containing the font file contents to read.</param>
|
||||
/// <returns>A <see cref="BitmapFontFileContent"/> instance containing the results of the read operation.</returns>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown if the header for the file contents does not match a known header format.
|
||||
/// </exception>
|
||||
[Obsolete("Use the overload that takes an explicit name parameter.")]
|
||||
public static BitmapFontFileContent Read(FileStream stream)
|
||||
{
|
||||
return Read(stream, stream.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the content of the font file at the path specified.
|
||||
/// </summary>
|
||||
/// <param name="stream">A <see cref="Stream"/> containing the font file contents to read.</param>
|
||||
/// <param name="name">The name or path that uniquely identifies this <see cref="BitmapFontFileContent"/>.</param>
|
||||
/// <returns>A <see cref="BitmapFontFileContent"/> instance containing the results of the read operation.</returns>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown if the header for the file contents does not match a known header format.
|
||||
/// </exception>
|
||||
public static BitmapFontFileContent Read(Stream stream, string name)
|
||||
{
|
||||
long position = stream.Position;
|
||||
var sig = stream.ReadByte();
|
||||
@@ -60,7 +75,7 @@ public static class BitmapFontFileReader
|
||||
_ => throw new InvalidOperationException("This does not appear to be a valid BMFont file!")
|
||||
};
|
||||
|
||||
bmfFile.Path = stream.Name;
|
||||
bmfFile.Path = name;
|
||||
|
||||
return bmfFile;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,9 @@ public class NinePatch
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The size of the border patches around the middle patch.
|
||||
/// </summary>
|
||||
public Thickness Padding { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -90,7 +93,11 @@ public class NinePatch
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NinePatch"/> class with the specified patches and name.
|
||||
/// </summary>
|
||||
/// <param name="patches">An array of nine <see cref="Texture2DRegion"/> objects.</param>
|
||||
/// <param name="patches">
|
||||
/// An array of nine <see cref="Texture2DRegion"/> objects.
|
||||
/// The top, left, bottom and right regions must to be of exactly the same size.
|
||||
/// Mid patches can be as small as 1x1.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// The name of the nine-patch. If null or empty, a default name will be generated based on the texture name of the
|
||||
/// top-left patch.
|
||||
@@ -113,8 +120,11 @@ public class NinePatch
|
||||
}
|
||||
|
||||
_patches = patches;
|
||||
Rectangle mid = patches[NinePatch.Middle].Bounds;
|
||||
Padding = new Thickness(mid.Left, mid.Top, mid.Right, mid.Bottom);
|
||||
|
||||
Size topLeft = patches[NinePatch.TopLeft].Size;
|
||||
Size bottomRight = patches[NinePatch.BottomRight].Size;
|
||||
Padding = new Thickness(topLeft.Width, topLeft.Height, bottomRight.Width, bottomRight.Height);
|
||||
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,18 +79,8 @@ public class Sprite : IColorable
|
||||
/// </remarks>
|
||||
public Vector2 OriginNormalized
|
||||
{
|
||||
get
|
||||
{
|
||||
float normalizedX = (Origin.X - TextureRegion.LeftUV) / (TextureRegion.RightUV - TextureRegion.LeftUV);
|
||||
float normalizedY = (Origin.Y - TextureRegion.TopUV) / (TextureRegion.BottomUV - TextureRegion.TopUV);
|
||||
return new Vector2(normalizedX, normalizedY);
|
||||
}
|
||||
set
|
||||
{
|
||||
float actualX = value.X * (TextureRegion.RightUV - TextureRegion.LeftUV) + TextureRegion.LeftUV;
|
||||
float actualY = value.Y * (TextureRegion.BottomUV - TextureRegion.TopUV) + TextureRegion.TopUV;
|
||||
Origin = new Vector2(actualX, actualY);
|
||||
}
|
||||
get { return new Vector2(Origin.X / TextureRegion.Width, Origin.Y / TextureRegion.Height); }
|
||||
set { Origin = new Vector2(value.X * TextureRegion.Width, value.Y * TextureRegion.Height); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -141,18 +141,20 @@ public static class Texture2DRegionExtensions
|
||||
|
||||
int middleWidth = textureRegion.Width - leftPadding - rightPadding;
|
||||
int middleHeight = textureRegion.Height - topPadding - bottomPadding;
|
||||
int rightX = textureRegion.Width - rightPadding;
|
||||
int bottomY = textureRegion.Height - bottomPadding;
|
||||
|
||||
patches[NinePatch.TopLeft] = textureRegion.GetSubregion(0, 0, leftPadding, topPadding);
|
||||
patches[NinePatch.TopMiddle] = textureRegion.GetSubregion(leftPadding, 0, middleWidth, topPadding);
|
||||
patches[NinePatch.TopRight] = textureRegion.GetSubregion(middleWidth, 0, rightPadding, topPadding);
|
||||
patches[NinePatch.TopRight] = textureRegion.GetSubregion(rightX, 0, rightPadding, topPadding);
|
||||
|
||||
patches[NinePatch.MiddleLeft] = textureRegion.GetSubregion(0, topPadding, leftPadding, middleHeight);
|
||||
patches[NinePatch.Middle] = textureRegion.GetSubregion(leftPadding, topPadding, middleWidth, middleHeight);
|
||||
patches[NinePatch.MiddleRight] = textureRegion.GetSubregion(middleWidth, topPadding, rightPadding, middleHeight);
|
||||
patches[NinePatch.MiddleRight] = textureRegion.GetSubregion(rightX, topPadding, rightPadding, middleHeight);
|
||||
|
||||
patches[NinePatch.BottomLeft] = textureRegion.GetSubregion(0, middleHeight, leftPadding, bottomPadding);
|
||||
patches[NinePatch.BottomMiddle] = textureRegion.GetSubregion(leftPadding, middleHeight, middleWidth, bottomPadding);
|
||||
patches[NinePatch.BottomRight] = textureRegion.GetSubregion(middleWidth, middleHeight, rightPadding, bottomPadding);
|
||||
patches[NinePatch.BottomLeft] = textureRegion.GetSubregion(0, bottomY, leftPadding, bottomPadding);
|
||||
patches[NinePatch.BottomMiddle] = textureRegion.GetSubregion(leftPadding, bottomY, middleWidth, bottomPadding);
|
||||
patches[NinePatch.BottomRight] = textureRegion.GetSubregion(rightX, bottomY, rightPadding, bottomPadding);
|
||||
|
||||
return new NinePatch(patches);
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ public struct Matrix3x2 : IEquatable<Matrix3x2>
|
||||
public void Decompose(out Vector2 translation, out float rotation, out Vector2 scale)
|
||||
{
|
||||
translation.X = M31;
|
||||
translation.Y = M31;
|
||||
translation.Y = M32;
|
||||
|
||||
rotation = (float)Math.Atan2(M21, M11);
|
||||
|
||||
|
||||
@@ -102,8 +102,9 @@ public class BitmapFontFileReaderTests
|
||||
[Fact]
|
||||
public void Read_BinaryFile_Test()
|
||||
{
|
||||
using FileStream stream = File.OpenRead("BitmapFonts/files/bmfont/test-font-binary.fnt");
|
||||
var actual = BitmapFontFileReader.Read(stream);
|
||||
string path = "BitmapFonts/files/bmfont/test-font-binary.fnt";
|
||||
using FileStream stream = File.OpenRead(path);
|
||||
var actual = BitmapFontFileReader.Read(stream, path);
|
||||
Assert.Equal(_expected.Header, actual.Header);
|
||||
Assert.Equal(_expected.Info, actual.Info);
|
||||
Assert.Equal(_expected.Common, actual.Common);
|
||||
@@ -116,8 +117,9 @@ public class BitmapFontFileReaderTests
|
||||
[Fact]
|
||||
public void Read_XmlFile_Test()
|
||||
{
|
||||
using FileStream stream = File.OpenRead("BitmapFonts/files/bmfont/test-font-xml.fnt");
|
||||
var actual = BitmapFontFileReader.Read(stream);
|
||||
string path = "BitmapFonts/files/bmfont/test-font-xml.fnt";
|
||||
using FileStream stream = File.OpenRead(path);
|
||||
var actual = BitmapFontFileReader.Read(stream, path);
|
||||
Assert.Equal(_expected.Header, actual.Header);
|
||||
Assert.Equal(_expected.Info, actual.Info);
|
||||
Assert.Equal(_expected.Common, actual.Common);
|
||||
@@ -130,8 +132,9 @@ public class BitmapFontFileReaderTests
|
||||
[Fact]
|
||||
public void Read_Text_Test()
|
||||
{
|
||||
using FileStream stream = File.OpenRead("BitmapFonts/files/bmfont/test-font-text.fnt");
|
||||
var actual = BitmapFontFileReader.Read(stream);
|
||||
string path = "BitmapFonts/files/bmfont/test-font-text.fnt";
|
||||
using FileStream stream = File.OpenRead(path);
|
||||
var actual = BitmapFontFileReader.Read(stream, path);
|
||||
Assert.Equal(_expected.Header, actual.Header);
|
||||
Assert.Equal(_expected.Info, actual.Info);
|
||||
Assert.Equal(_expected.Common, actual.Common);
|
||||
|
||||
Reference in New Issue
Block a user