mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-21 20:43:29 +01:00
Added compatibility for MonoGame.Extended 4.0.0 and FNA.Extended
This commit is contained in:
parent
24277ba494
commit
fa1cafd751
12 changed files with 52 additions and 31 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -4,3 +4,6 @@
|
||||||
[submodule "FontStashSharp"]
|
[submodule "FontStashSharp"]
|
||||||
path = ThirdParty/FontStashSharp
|
path = ThirdParty/FontStashSharp
|
||||||
url = https://github.com/FontStashSharp/FontStashSharp
|
url = https://github.com/FontStashSharp/FontStashSharp
|
||||||
|
[submodule "ThirdParty/MonoGame.Extended"]
|
||||||
|
path = ThirdParty/MonoGame.Extended
|
||||||
|
url = https://github.com/craftworkgames/MonoGame.Extended
|
||||||
|
|
|
@ -43,6 +43,11 @@ Fixes
|
||||||
- Fixed auto-sized elements sometimes updating their location based on outdated parent positions
|
- Fixed auto-sized elements sometimes updating their location based on outdated parent positions
|
||||||
- Fixed Panel.ScrollToElement not scrolling correctly when the panel's area is dirty
|
- Fixed Panel.ScrollToElement not scrolling correctly when the panel's area is dirty
|
||||||
|
|
||||||
|
### MLEM.Extended
|
||||||
|
Improvements
|
||||||
|
- **Added compatibility for MonoGame.Extended 4.0.0**
|
||||||
|
- Added compatibility for FNA.Extended
|
||||||
|
|
||||||
## 6.3.1
|
## 6.3.1
|
||||||
|
|
||||||
No code changes
|
No code changes
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using MLEM.Extensions;
|
using MLEM.Extensions;
|
||||||
using MonoGame.Extended;
|
using ShapeExtensions = MonoGame.Extended.ShapeExtensions;
|
||||||
|
using RectangleF = MonoGame.Extended.RectangleF;
|
||||||
|
|
||||||
namespace MLEM.Extended.Extensions {
|
namespace MLEM.Extended.Extensions {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -54,11 +55,11 @@ namespace MLEM.Extended.Extensions {
|
||||||
public static void DrawGrid(this SpriteBatch batch, Vector2 start, Vector2 tileSize, Point tileCount, Color gridColor, float gridThickness = 1) {
|
public static void DrawGrid(this SpriteBatch batch, Vector2 start, Vector2 tileSize, Point tileCount, Color gridColor, float gridThickness = 1) {
|
||||||
for (var y = 0; y < tileCount.Y; y++) {
|
for (var y = 0; y < tileCount.Y; y++) {
|
||||||
for (var x = 0; x < tileCount.X; x++)
|
for (var x = 0; x < tileCount.X; x++)
|
||||||
batch.DrawRectangle(start + new Vector2(x, y) * tileSize, tileSize, gridColor, gridThickness / 2);
|
ShapeExtensions.DrawRectangle(batch, start + new Vector2(x, y) * tileSize, tileSize, gridColor, gridThickness / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
var size = tileSize * tileCount.ToVector2() + new Vector2(gridThickness);
|
var size = tileSize * tileCount.ToVector2() + new Vector2(gridThickness);
|
||||||
batch.DrawRectangle(start - new Vector2(gridThickness / 2), size, gridColor, gridThickness / 2);
|
ShapeExtensions.DrawRectangle(batch, start - new Vector2(gridThickness / 2), size, gridColor, gridThickness / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using MLEM.Extensions;
|
using MLEM.Extensions;
|
||||||
using MLEM.Textures;
|
using MLEM.Textures;
|
||||||
using MonoGame.Extended.TextureAtlases;
|
using MonoGame.Extended.Graphics;
|
||||||
|
using NinePatch = MLEM.Textures.NinePatch;
|
||||||
|
using ExtNinePatch = MonoGame.Extended.Graphics.NinePatch;
|
||||||
|
|
||||||
namespace MLEM.Extended.Extensions {
|
namespace MLEM.Extended.Extensions {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -9,38 +11,29 @@ namespace MLEM.Extended.Extensions {
|
||||||
public static class TextureExtensions {
|
public static class TextureExtensions {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts a MLEM <see cref="NinePatch"/> to a MonoGame.Extended <see cref="NinePatchRegion2D"/>.
|
/// Converts a MLEM <see cref="Textures.NinePatch"/> to a MonoGame.Extended <see cref="ExtNinePatch"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="patch">The nine patch to convert</param>
|
/// <param name="patch">The nine patch to convert</param>
|
||||||
/// <returns>The converted nine patch</returns>
|
/// <returns>The converted nine patch</returns>
|
||||||
public static NinePatchRegion2D ToExtended(this NinePatch patch) {
|
public static ExtNinePatch ToExtended(this NinePatch patch) {
|
||||||
return new NinePatchRegion2D(patch.Region.ToExtended(), patch.Padding.Left.Floor(), patch.Padding.Top.Floor(), patch.Padding.Right.Floor(), patch.Padding.Bottom.Floor());
|
return patch.Region.ToExtended().CreateNinePatch(patch.Padding.Left.Floor(), patch.Padding.Top.Floor(), patch.Padding.Right.Floor(), patch.Padding.Bottom.Floor());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts a MLEM <see cref="TextureRegion"/> to a MonoGame.Extended <see cref="TextureRegion2D"/>.
|
/// Converts a MLEM <see cref="TextureRegion"/> to a MonoGame.Extended <see cref="Texture2DRegion"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="region">The nine patch to convert</param>
|
/// <param name="region">The nine patch to convert</param>
|
||||||
/// <returns>The converted nine patch</returns>
|
/// <returns>The converted nine patch</returns>
|
||||||
public static TextureRegion2D ToExtended(this TextureRegion region) {
|
public static Texture2DRegion ToExtended(this TextureRegion region) {
|
||||||
return new TextureRegion2D(region.Name, region.Texture, region.U, region.V, region.Width, region.Height);
|
return new Texture2DRegion(region.Texture, region.U, region.V, region.Width, region.Height, region.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts a MonoGame.Extended <see cref="NinePatchRegion2D"/> to a MLEM <see cref="NinePatch"/>.
|
/// Converts a MonoGame.Extended <see cref="Texture2DRegion"/> to a MLEM <see cref="TextureRegion"/>.
|
||||||
/// </summary>
|
|
||||||
/// <param name="patch">The nine patch to convert</param>
|
|
||||||
/// <returns>The converted nine patch</returns>
|
|
||||||
public static NinePatch ToMlem(this NinePatchRegion2D patch) {
|
|
||||||
return new NinePatch(((TextureRegion2D) patch).ToMlem(), patch.LeftPadding, patch.RightPadding, patch.TopPadding, patch.BottomPadding);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a MonoGame.Extended <see cref="TextureRegion2D"/> to a MLEM <see cref="TextureRegion"/>.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="region">The nine patch to convert</param>
|
/// <param name="region">The nine patch to convert</param>
|
||||||
/// <returns>The converted nine patch</returns>
|
/// <returns>The converted nine patch</returns>
|
||||||
public static TextureRegion ToMlem(this TextureRegion2D region) {
|
public static TextureRegion ToMlem(this Texture2DRegion region) {
|
||||||
return new TextureRegion(region.Texture, region.Bounds) {Name = region.Name};
|
return new TextureRegion(region.Texture, region.Bounds) {Name = region.Name};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace MLEM.Extended.Font {
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override float MeasureCharacter(int codePoint) {
|
protected override float MeasureCharacter(int codePoint) {
|
||||||
var region = this.Font.GetCharacterRegion(codePoint);
|
var region = this.Font.GetCharacter(codePoint);
|
||||||
return region != null ? new Vector2(region.XAdvance, region.Height).X : 0;
|
return region != null ? new Vector2(region.XAdvance, region.TextureRegion.Height).X : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -24,13 +24,18 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MLEM\MLEM.FNA.csproj" />
|
<ProjectReference Include="..\MLEM\MLEM.FNA.csproj" />
|
||||||
|
|
||||||
|
<ProjectReference Condition="'$(TargetFramework)'=='net8.0'" Include="..\ThirdParty\MonoGame.Extended\source\MonoGame.Extended\FNA.Extended.csproj">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\ThirdParty\FontStashSharp\src\XNA\FontStashSharp.FNA.csproj">
|
<ProjectReference Include="..\ThirdParty\FontStashSharp\src\XNA\FontStashSharp.FNA.csproj">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\ThirdParty\FNA\FNA.csproj">
|
<ProjectReference Include="..\ThirdParty\FNA\FNA.csproj">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)'!='net8.0'">
|
||||||
<Compile Remove="Tiled/**" />
|
<Compile Remove="Tiled/**" />
|
||||||
<Compile Remove="Extensions/**" />
|
<Compile Remove="Extensions/**" />
|
||||||
<Compile Remove="Font/GenericBitmapFont.cs" />
|
<Compile Remove="Font/GenericBitmapFont.cs" />
|
||||||
|
|
|
@ -21,10 +21,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MLEM\MLEM.csproj" />
|
<ProjectReference Include="..\MLEM\MLEM.csproj" />
|
||||||
|
|
||||||
<PackageReference Include="MonoGame.Extended" Version="3.8.0">
|
<PackageReference Condition="'$(TargetFramework)'=='net8.0'" Include="MonoGame.Extended" Version="4.0.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="MonoGame.Extended.Tiled" Version="3.8.0">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="FontStashSharp.MonoGame" Version="1.3.3">
|
<PackageReference Include="FontStashSharp.MonoGame" Version="1.3.3">
|
||||||
|
@ -35,6 +32,12 @@
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)'!='net8.0'">
|
||||||
|
<Compile Remove="Tiled/**" />
|
||||||
|
<Compile Remove="Extensions/**" />
|
||||||
|
<Compile Remove="Font/GenericBitmapFont.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="../Media/Logo.png" Pack="true" PackagePath="" />
|
<None Include="../Media/Logo.png" Pack="true" PackagePath="" />
|
||||||
<None Include="../README.md" Pack="true" PackagePath="" />
|
<None Include="../README.md" Pack="true" PackagePath="" />
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace MLEM.Extended.Tiled {
|
||||||
var tilesetTile = tileset.Tiles.FirstOrDefault(t => t.LocalTileIdentifier == localId);
|
var tilesetTile = tileset.Tiles.FirstOrDefault(t => t.LocalTileIdentifier == localId);
|
||||||
if (tilesetTile == null && createStub) {
|
if (tilesetTile == null && createStub) {
|
||||||
if (!TiledExtensions.StubTilesetTiles.TryGetValue(localId, out tilesetTile)) {
|
if (!TiledExtensions.StubTilesetTiles.TryGetValue(localId, out tilesetTile)) {
|
||||||
tilesetTile = new TiledMapTilesetTile(localId);
|
tilesetTile = new TiledMapTilesetTile(localId, null, null);
|
||||||
TiledExtensions.StubTilesetTiles.Add(localId, tilesetTile);
|
TiledExtensions.StubTilesetTiles.Add(localId, tilesetTile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
MLEM.FNA.sln
12
MLEM.FNA.sln
|
@ -20,7 +20,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FNA", "ThirdParty\FNA\FNA.c
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FontStashSharp.FNA", "ThirdParty\FontStashSharp\src\XNA\FontStashSharp.FNA.csproj", "{39249E92-EBF2-4951-A086-AB4951C3CCE1}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FontStashSharp.FNA", "ThirdParty\FontStashSharp\src\XNA\FontStashSharp.FNA.csproj", "{39249E92-EBF2-4951-A086-AB4951C3CCE1}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FNA.Core", "ThirdParty\FNA\FNA.Core.csproj", "{458FFA5E-A1C4-4B23-A5D8-259385FEECED}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FNA.Extended", "ThirdParty\MonoGame.Extended\source\MonoGame.Extended\FNA.Extended.csproj", "{B7F73499-9BF0-487D-B20E-B4B67EB3A4EA}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FNA.NetStandard", "ThirdParty\FNA\FNA.NetStandard.csproj", "{1A736385-E931-40A9-BBE0-A9286AB2F6B2}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -72,5 +74,13 @@ Global
|
||||||
{458FFA5E-A1C4-4B23-A5D8-259385FEECED}.Debug|Any CPU.Build.0 = Debug|x64
|
{458FFA5E-A1C4-4B23-A5D8-259385FEECED}.Debug|Any CPU.Build.0 = Debug|x64
|
||||||
{458FFA5E-A1C4-4B23-A5D8-259385FEECED}.Release|Any CPU.ActiveCfg = Release|x64
|
{458FFA5E-A1C4-4B23-A5D8-259385FEECED}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
{458FFA5E-A1C4-4B23-A5D8-259385FEECED}.Release|Any CPU.Build.0 = Release|x64
|
{458FFA5E-A1C4-4B23-A5D8-259385FEECED}.Release|Any CPU.Build.0 = Release|x64
|
||||||
|
{B7F73499-9BF0-487D-B20E-B4B67EB3A4EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B7F73499-9BF0-487D-B20E-B4B67EB3A4EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B7F73499-9BF0-487D-B20E-B4B67EB3A4EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B7F73499-9BF0-487D-B20E-B4B67EB3A4EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1A736385-E931-40A9-BBE0-A9286AB2F6B2}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||||
|
{1A736385-E931-40A9-BBE0-A9286AB2F6B2}.Debug|Any CPU.Build.0 = Debug|x64
|
||||||
|
{1A736385-E931-40A9-BBE0-A9286AB2F6B2}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
|
{1A736385-E931-40A9-BBE0-A9286AB2F6B2}.Release|Any CPU.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
2
ThirdParty/FNA
vendored
2
ThirdParty/FNA
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 354e2161b759fa052b25e94209d6ea463aaf098f
|
Subproject commit 31dab885817ddaece9758f480027373f0ad74bea
|
2
ThirdParty/FontStashSharp
vendored
2
ThirdParty/FontStashSharp
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 2d40e9f0f681595dbd4341a3e5a64ed6e31f9556
|
Subproject commit c5ab7bc22a0db85d1b43880a016ee1c968e522e8
|
1
ThirdParty/MonoGame.Extended
vendored
Submodule
1
ThirdParty/MonoGame.Extended
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 4beea37b25f014ef4925365ea56ade23028af3d7
|
Loading…
Reference in a new issue