Skip to content

Commit

Permalink
Release/v4 (#914)
Browse files Browse the repository at this point in the history
* Make CurrentFrame return the actual frame index from the source atlas

* Start the animation controller playing, don't make the consumer manually call it initially

* Play is automatically called in the controller ctor

* Added property to get name of current animation

* Only copy reference files if user opts in by specifying property in csproj

* Update Kni solution to new project structure

* Update Fna solution to new project structure

* Bump version number to 4.0.0

* Update release workflow

* Remove old test

* Version 4.0.0 Release (#911)

* Remove duplicate fact

* Add .user file to gitignore

* Assert Rectangle translation transform

* Assert Rectangle transform not changing size

* Rectangle extents are rotated correctly

* Rebuilt effects with mgfxc 3.8.1.303

* Uncomment and fix tests

* Remove tests always passing

* Issue 707, Created test for null ptr during entity destroy

* Issue 707, Added null propagation inside component manager destroy method

* Create VelocityInterpolator

Allow particles to change velocity as they age.

* add power of two values to MouseButton

* Add parallaxFactor of layers in models.

* Add parallaxFactor in rendering logic.

* Add checking event == 'push'

* Fix looping animations incorrectly completing when an update contains a large elapsed time.
Ping pong waits until frame delay is complete on re-entry of the first frame before firing Complete rather than firing Complete immediately upon entering the frame.  This makes it consistent with a non ping pong animation which waits for the frame delay of the last frame before it fires Complete.
Ping Pong now finishes on the first frame rather than potentially finishing on a different frame if the elapsed time since last update was larger than the time remaining for the animation to become complete.
Add unit tests for SpriteSheetAnimation.

* Update README.md

* Use actual target bounds when testing collision

* Cleanup

* Refactor

Encapsulate a public property (Parents).
Added xml-comments (to fix some compilation warnings)

* Format comments and fix spelling

* Add comments for public fields and properties

* fix Bag so that it doesn't allocate during foreach enumeration

* add bag allocation test

* make WasKey/ButtonJustDown/Up obsolete and replace with clarified versions

* add support for class (nested) properties

* support type/class field in maps, layers, & tilemaps

* Update PrimitiveDrawing.cs

Add a new DrawSolidCircle to add a fill color

* fix allocating WasAnyKeyJustDown method; add GetPressedKeys non-alloc overload

* Use Directory.Build.targets
Moved common csproj properties for NuGet into Directory.Build.targets

* Added version tag
This is so we don't have to rely on github runner actions to generate the version number, and we can use it in the build scripts

* PackageIconUrl is deprecated
NuGet packages should use PacakgeIcon with a packed image inside the NuGet insetad of PackageIconUrl

* Pack README.md in NuGet packages

* Add common tags for NuGet packages
Added the `<RepositoryType>`, `<RepositoryBranch>`, `<NeutralLanguage>` and `<PacakgeLicenseExpression>` tags

* Added new Cake Frosting project

* Cleaned up
Cleaned up the Program.cs for the Cake Frosting project.  Added the working direcotry directive

* Added BuildContext

* Added BuildTask

* Added Test Task

* Added Package Task

* Added Default task

* Added namespace

* Cleanup using statements

* Ignore cake output directory

* Updated and automated for NuGet pushing

* Check for GCLatencyMode.NoGCRegion
This test fails occasionaly when run through the automated cake script.  Wrapped the EndNoGCREgion in a check for GCTatencyMode.NoGCRegion to resolve

* Forgot to add System.Runtime using statement

* Better name for package step

* NuGet Deploy only in craftworksgames repo

* Enable Nullable in build project

* Add additional context variables for build script

* Use same verbosity, restore, and logo flags as originally used

* Use same verbosity and nologo setting as original

* Created Restore task

Uses same verbosity as original workflow did

* Update TestTask to use same verbosity, nologo, and nobuild as original workflow

* Create DeployToGithubTask

* Create DeployToMyGetTask

* Create DeployToNuGetTask

* Added Deploy task

* Simplify, move most logic into cake build script

* Ignore Missing XML comment warnings on build

* Remove async, ignore NU5118 on package

* Apparently i forgot a semi colon....

* Remove old collision code.

* Move collision code to root folder

* Fix namespaces

* Add failing test for collisions.

* Add benchmarks for collisions

* Refactor collision update, correct reset map

* Add BoundingRectanglle property for IShape

* Refactor QuadTree - now we use static AABB intersection check

* Add layers for collisions

* Add interface for space splitting and impls

* Refactor layers for new interface

* Add comments for collision actor.

* Add comments for space algo interface.

* Add spatialHash algo for collision spacing

* Rename Quadtree to QuadTree

* Add inline for private methods of SpatialHash.cs

* Refactor benchmarks for collisions.

* Fix tests

* Refactor layers.

* Add method for set default layer

* Fix ctor call's

* Add constructor for CollisionComponent.cs

* Add extentions for ContentImporter.

* Add speical contentItem for referencing images.

* Fix tiledMap processing and writing.

* Add texture for tile.

* Add image tileset support

* Fix using ctor from remote

* Fix version

* Fix CiCD

* Add copy constructor for KeyboardListener.

* Revert "Add copy constructor for KeyboardListener."

* Add serializer for RectangleF

* Add test for new serizalizer

* Add RectangleFJsonConverter for default serializer.

* Fixed HSL lerp

* Move extracting linear operations into special class.

* Move impls of linear tweening into special class.

* Add ColorTween

* Add special TweenTo.

* Fix TweenTo

* Add tweening tests

* Fix activator inside tweener.

* Check for undefined layer and throw on collision actor insertion

* Add test coverage

* Add OrientedBoundingRectangle type

* Add Points property to OrientedBoundingRectangle

* Ignore Visual Studio cache

* Be explicit about conversion of geometries

Conversion from circle to rectangle should not pass unnoted and be explicit.

* OrientedBoundedRectangle implements ShapeF

In that way the OrientedBoundedRectangle can take part of collision tests.

* Add ascii art to describe intersection tests

* Update circle and oriented bound box intersection

* Update dependencies

* Add Intersects method for OBB

* Rename to OrientedRectangle

* Properly intersect circle and oriented rect

* Calc coll vector for circle and oriented rect

* Calc coll vector for oriented rects

* Fixes incorrect rendering of flipped animation tiles

* Call RectangleF.Intersects to resolve recursion bug
When both params `a` and `b` are of type `RectangleF` just calling `Shape.Intersects` creates a infinite recursion bug.

* Update Newtonsoft.Json.dll Dependency

* Removing MyGet Feed Deploy
Lithiums MyGet feed won't allow the NuGet push due to the SemVersions of the package containing a 4th build number value.

* Moved to `/src/cs`
Moved benchmark and tweening test projects into the `/src/cs` to keep project organization constancy.

* Move build into `/src/cs`

* Fix project reference

* Fix path for project on build task

* Capital B

* Changed the Flip Flag array to be private and readonly and added a public property that returns the backing field as a ReadOnlySpan.

* Move source projects into source directory

* Moved tests into test directory

* Moved benchmarks into benchmark directory

* Moved build into build directory

* Add root props file

* Add common props for all tests

* Added `<Authors>` to root props

* Add common props for source  directory

* Add props to build directory

* Moved props from targets file

* Removed targets file

* Update for new .artifacts directory

* nuget.config is not needed

* Renamed 'Logos' directory to 'logos'
Case sensitivity matters depending on operating system, so it's more convenient where possible to keep directory names lower case

* Use correct working directory after moving

* Remove duplicate import statement

* Read from props file not targets file.

* Use new .artifacts directory

* Updated .gitattributes

* Updated .gitignore

* Set ArtifactPath within the project category directory

* Drop CAKE build and move Build CI to github workflow

* Setup code analysis with .editorconfig

* Don't use nullable reference in a non-nullable context

* Correct spelling of minimal

* Fix GitHub Nuget Push (#859)

* Fix github url for nuget push

* forgot the h in https

* Remove GitHub Deploy (#860)

* Fix github url for nuget push

* forgot the h in https

* Remove github push for now, need to check repository settings

* Cleanup (#862)

* Removed Roadmap
The Roadmap seems to have been initially added to show the plans to switch to an FNA fork and act as a bridge for katabasis.  This is no longer the case for this repository as it will remain focused at the moment on MonoGame support only.

* Added new note at top of readme

* updated information for installing nuget

* Made using content pipeline extensions a section and not a quote

* Removed information about MyGet feed

* Removed patreon from readme

* Update License

* renamed master branch to main

* Remove community forum link
MonoGame is closing the community forums in favor of discord and github discussions

* Update workflows

* Removed patreon added aristurtledev (#863)

* Fix funding (#864)

* Use ArtifactsPath to resolve include dlls for pack (#865)

* Add additional input parameters (#866)

* Only specify source and prerelease (#867)

* Update prerelease version (#868)

* Replace Newtonsoft.Json with System.Text.Json (#869)

* Converted to use `System.Text.Json`

* Remove Newtonsoft.Json Dependency
Newtonsoft.Json dependency has been removed in favor of System.Text.Json

* Treat MGFXO file as binary

* Replace `Matrix2` with `Matrix3x2` (#870)

* Replace `Matrix2` with `Matrix3x2`

* Update benchmarks

* Add XML documentation for `Matrix3x2`

* Add Edge Test for `Polygon.Contains` (#871)

* Added Assert for edge contains
Reference: #214

* Renamed to PolygonTests

* Replace `Size3` with `Vector3` (#872)

* Rename `Size2` to `SizeF` (#873)

* Remove `Point3` (#874)

* Remove `Point2` (#875)

* Added `CalculateMinimumVector2` and `CalculateMaximumVector2` as replacement for `Point2.Minimum` and `Point2.Maximum`

* Remove `Point2`

* Added unit test to ensure issue is resolved (#876)

* Add unit test for `ContentReaderExtensions.GetRelativeAssetName` (#877)

* Implements standard IDispose pattern (#879)

* upgrade solution to VS2022 (#880)

* update project types to net.Sdk

* upgrade solution to VS2022

* Remove unnecessary dependencies to SharpDX and Content.Pipeline from the core library (#881)

* remove unused SharpDX using

introduces in #840

* remove Content.Pipeline reference from the core library

introduced in #692

* use System ZLibStream (#882)

ZLibStream was added in net6

https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zlibstream?view=net-8.0

* Added changelog (#883)

* Added changelog

* Added note about unreleased

* Make links for users (#884)

* Copy Reference DLLs from NuGet Automatically (#885)

* Pack value should be `true` not `True`

* Copy content pipeline dll references to project directory for ease of use

* Forgot `/` in path

* Updated Changelog (#886)

Added information about #885

* Refactor `BitmapFont` (#887)

* Update file header

* Created initial project to move BitmapFont too

* XMl, Text, and Binar reading now supported for BMFont

* Refactor BittmapFont

* Update content pipeline from BitmapFont refactor

* Update changelog

* Updated ComponentManager to implement IEnumerable<ComponentMapper> (#823) (#888)

* Update Changelog (#889)

* Updated so all projects have changelog in root when viewing in visual studio

* Updated changelog

* Texture Atlas Refactor (#890)

* Moved `TextureRegion2D` and `NinePatchRegion2D` into Graphics namespace
These are used for more than just texture atlas related things and are primarly for working with `Texture2D` instances and creating sub textures from them.  Moving them to Graphics namespace where `Texture2D` lives in MonoGame

* Dropped the `2D` suffix from `TextureRegion2D` and `NinePatchRegion2D`

* Moved `RectanglExtensions` to project root
This moves the extensions for `Rectangle` to the same relative namespace location as `Rectangle` is in MonoGame.

* Renamed to `Rectangle.Extensions.cs`

* Separate `Rectangle` from `RectangleF` extensions

* Added `GetRelativeRectangle` method

* Updated documentation

* Added `GetRelativeRectangle` method

* Updated documentation

* Top-level namespace

* Remove whitespace

* Move properties up

* Top-level namespace

* Don't recreate structs for `Bounds` and Size`
By having the property return a new struct, this allocates on the stack during situations like a loop during draw.

* Size should be `Size` not `SizeF` value
Textures deal in pixels (ints not floats)

* Removed setter for `Texture` property
Texture should not be set after region is created

* Added UV properties

* Refactor constructors

* Added documentation

* Added license header

* Make it an actual extension method

* Added `GetSubRegion` extension methods for `TextureRegion`

* Update documentation about ObjectDisposedException

* Move const values to top

* Resolve errors from`TextureRegion` refactor

* Update unit tests for TextureRegion refactor

* Started NinePatch rework

* Refactored NinePatch

* Update for texture region constructor change

* Remove ninepatch from atlas

* Moved `TextureAtlasExtensions` into `SpriteBatch.Extensions`
These are extension methods for the sprite batch

* Updated to use new `DrawTextureRegion` method after rename

* Renamed to NinePatchJsonConverter

* Removed `GetRegion<T>`
TextureAtlas no longer contains nine patch regions, so this method isn't needed

* Update after `NinePatchRegion2DJsonConverter` name change

* Resolve errors from NinePatch refactor

* TextureAtlas rework

* Renamed `TextureRegion` to `Texture2DRegion`

* Moved ContentReaders to new Content\ContentReaders directory

* Moved TextureAtlasJsonConvert to Serialization directory

* Adjusted name from `Texture*` to `Texture2D*`

* Update runtimereader and runtimettype strings

* Kni.Extended (#892)

* KNI projects

* update actions

fixes MSBUILD : error MSB1011: Specify which project or solution file to
use because this folder contains more than one project or solution file.

* remove test for issue #633

* build tests

* KNI TypeReaders

* KNI/XNA compatible code

* GetRuntimeReader from runtime types

* remove MockGameWindow

* Fna.Extended (#893)

* FNA projects

* update actions

fixes MSBUILD : error MSB1011: Specify which project or solution file to
use because this folder contains more than one project or solution file.

* build tests

* remove test for issue #633

* FNA/XNA compatible

* GraphicsDevice Extensions

* remove MockGameWindow

---------

Co-authored-by: Christopher Whitley <[email protected]>

* Sprite Rework (#897)

* Add file header

* Refator to file-scoped namespace

* Least complex to most complext method ordering

* Refactor: Group properties at top before constructor

* Use the new UV properties from Texture2DRegion.
This removes the dependency on the texture size in the calculations if the TextureRegion property is changed.

* No longer need to cache normalized origin to preserve it

* Use ArgumentNullException instead

* Use ArgumentNullException.ThrowIfNull

* Refactor:  Use brackets for readability

* Add xml documentation

* Add check for disposed texture

* Moved `Sprite` to `MonoGame.Extended.Graphics`

* Moved extension methods for rendering sprite into `SpriteBatch.Extensions`

* `ISpriteBatchDrawable` is not used by anything
It was originally part of the ScreneGraph implementation in MonoGame.Extended which was replaced by the ECS system.  It appears that this interface was forgotten to be removed and is not used for anything anymore.

* Add `CreateSprite` methods

* Add file header

* Moved `SpriteSheetAnimationFrame` to `MonoGame.Extended.Graphics`

* Move properties before constructor.

* Changed `Duration` to `TimeSpan` type

* Renamed `Index` to `FrameIndex`

* Add `TextureRegion` property

* Make property get only

* Cleanup whitespace

* Remove `SpriteSheetAnimationFrameJsonConverter`

* Cleanup unused namespaces

* Make file-scoped namespace

* Added xml documentation

* Added file header

* marked constructor as internal.
This will be created from a spritesheet itself

* Move `SpriteSheetAnimationCycle` to `MonoGame.Extended.Graphcis`

* File scoped namespace

* Add file header

* Reorganize: Move properties above constructor

* Make `Frames` property a read-only span

* Remove duration, this is being moved to the frame itself

* Add `Name` property

* Set looping, reversed, and ping pong properties in ctor

* Make ctor internal
This will be an object created by a spritesheet instane itself.

* Cleanup: Whitespace

* Add `FrameCount` property

* Add `GetFrame` method and accompanying `this[int]` method.

* Documentation: Added missing documentation.

* WIP: Temporary commit for workstation change

* WIP: Temporary commit for workstation change

* WIP: Temporary commit for workstation change

* WIP: Temporary commit for workstation change

* Refactor: Animation Refactor Completed

* Refactor: Sprite stuff finished

* Remove tests that can't be run on GitHub CI
Need to find alternative

* Make optional name param the last param in Texture2DRegion ctors

* Resolve merge conflicts

* Add Kni Package (#898)

* Capitalize KNI (#899)

* Resolves NullReferenceException When Getting Invalid Key From TiledMapProperties (#903)

* Add test to validate issue

* Resolve issue

* Fix `NullReferenceException` in `ObjectPool` when reusing all returned items (#904)

* Replaced delegate with Action<T>

* Change delegate to Action<T>

* Add unit test to confirm issue

* Fix NullReferenceException in ObjectPool when reusing all returned items

The ObjectPool's Use() method was throwing a NullReferenceException when
all items had been returned to the pool and New() was called again. This
was due to _tailNode being null in this scenario.

Added a null check for _tailNode in Use() method to properly reinitialize
the linked list structure when the pool has been emptied and refilled.

* Moved MonoGame.Extended.Gui to its own repository (#905)

* Update animated sprite so the constructor api is similar to original MGE (#906)

* Update animated sprite so the constructor api is similar to original MGE

* Fix tests from changes

* Add pitch support to Camera & OrthographicCamera (#907)

* Added pitch support to OrthographicCamera

* Added pitch functions to base Camera class

* Reorganization (#909)

* Removed MonoGame.Extended.Animations
This project was just a shell that referenced MonoGame.Extended.csproj. It added no additional functionality.

* Rework BitmapFonts for new project organization.

* Cleanup namespaces

* Cleanup namespaces

* Move MonoGame.Extended.Collision into base project

* Moved MonoGame.Extended.Entities into base project

* Moved MonoGame.Extended.Graphics into base project

* Moved MonoGame.Extended.Graphics into base project

* Moved MonoGame.Extended.Input into base project

* Moved MonoGame.Extended.Particles into base project

* Moved MonoGame.Extended.Tiled into base project

* Moved MonoGame.Extended.Tiled into base project

* Moved MonoGame.Extended.Tweening into base project

* Removing SpriteFactory support
This will be added back in at a later date once the SpriteFactory application has been updated

* Update TexturePacker content import support

* Only needs to reference base project now

* Moved to Serialization namespace

* Moved  Json serialization to Serialization.Json namespace

* Moved TexturePacker content DTOs to the Content namespace

* Renamed to Texture2DRegion.Extensions.cs

* Cleaned up namespace

* Moved ReadTiledMapProperties into the ContentReaderExtensions

* Created an Extended content manager

* Moved Tweening tests to base test project

* Moved Tiled test to base test project

* Moved Entities Tests to base test project

* Moved Entities tests to base test project

* Moved Collisions tests to base test project

* Moved Pipeline Tiled test to Pipeline tests project

* Use `var` instead of full type name

* Add Tiled namespace

* Correct `Metadata` property name to new `Meta` property name

* Cleanup namespace

* Add effects namespace

* Add Content namespace

* Update using statements to new namespaces

* Move Pipeline Tiled tests to Pipeline test project

* Use correct namespace

* Use `var` instead of typing out nested types

* Remove unused namespaces

* Update to new namespaces

* Remove unused namespaces

* Update to new namespaces

* Remove dependency on Particles csproj

* Update included content on build

* Add embedded resources

* Merge multi csproj structure into single csproj structure

* TexturePackerPoint properties should be `double` not `int`

* Update csproj

* Use dotnet tool to rebuild effects

* Move effect compilation to targets file
This will ensure the effects are always built

* Fix workflow to build effects on linux

* Set wine path

* Export instead of using actions env section

* Revert back to manual effect compile until automation can be solved on GitHub Ubuntu runner

* Make CurrentFrame return the actual frame index from the source atlas

* Start the animation controller playing, don't make the consumer manually call it initially

* Play is automatically called in the controller ctor

* Added property to get name of current animation

* Only copy reference files if user opts in by specifying property in csproj

* Update Kni solution to new project structure

* Update Fna solution to new project structure

* Bump version number to 4.0.0

* Update release workflow

* Remove old test

---------

Co-authored-by: Andreas Torebring <[email protected]>
Co-authored-by: Lucas Girouard-Stranks <[email protected]>
Co-authored-by: Matt Johnson <[email protected]>
Co-authored-by: Kus <[email protected]>
Co-authored-by: slakedclay <[email protected]>
Co-authored-by: Cairo Batista <[email protected]>
Co-authored-by: Gandifil <[email protected]>
Co-authored-by: David Fidge <[email protected]>
Co-authored-by: Lucas Girouard-Stranks <[email protected]>
Co-authored-by: Lilith Silver <anon>
Co-authored-by: KatDevsGames <[email protected]>
Co-authored-by: LACOMBE Dominique <[email protected]>
Co-authored-by: Apllify <[email protected]>
Co-authored-by: Stephen <[email protected]>
Co-authored-by: jimmy b <[email protected]>
Co-authored-by: Nikos Kastellanos <[email protected]>
Co-authored-by: Mike Bowers <[email protected]>
Co-authored-by: James <[email protected]>

* Fix KNI specific issues

* Update for Fna

---------

Co-authored-by: Andreas Torebring <[email protected]>
Co-authored-by: Lucas Girouard-Stranks <[email protected]>
Co-authored-by: Matt Johnson <[email protected]>
Co-authored-by: Kus <[email protected]>
Co-authored-by: slakedclay <[email protected]>
Co-authored-by: Cairo Batista <[email protected]>
Co-authored-by: Gandifil <[email protected]>
Co-authored-by: David Fidge <[email protected]>
Co-authored-by: Lucas Girouard-Stranks <[email protected]>
Co-authored-by: KatDevsGames <[email protected]>
Co-authored-by: LACOMBE Dominique <[email protected]>
Co-authored-by: Apllify <[email protected]>
Co-authored-by: Stephen <[email protected]>
Co-authored-by: jimmy b <[email protected]>
Co-authored-by: Nikos Kastellanos <[email protected]>
Co-authored-by: Mike Bowers <[email protected]>
Co-authored-by: James <[email protected]>
  • Loading branch information
18 people authored Jul 8, 2024
1 parent 0fe1064 commit 1d440c9
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
4 changes: 2 additions & 2 deletions source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</ItemGroup>

<ItemGroup Condition="$(DefineConstants.Contains('FNA'))">
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\FNA\FNA.NetStandard.csproj" />
</ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\FNA\FNA.NetStandard.csproj" />
</ItemGroup>

<ItemGroup Condition="$(DefineConstants.Contains('KNI'))">
<PackageReference Include="nkast.Xna.Framework"
Expand Down
70 changes: 69 additions & 1 deletion source/MonoGame.Extended/Content/ExtendedContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@ public List<IDisposable> DisposeableAssets
}
}


#if KNI || FNA
private Dictionary<string, object> _loadedAssets;
public Dictionary<string, object> LoadedAssets
{
get
{
if(_loadedAssets is null)
{
// KNI please make this public so I don't have to use reflection
FieldInfo field = typeof(ContentManager).GetField(nameof(_loadedAssets), BindingFlags.NonPublic | BindingFlags.Instance);
if (field is null)
{
throw new InvalidOperationException("Unable to get source loaded assets field");
}
_loadedAssets = field.GetValue(this) as Dictionary<string, object>;
}

return _loadedAssets;
}
}
#endif

public ExtendedContentManager(IServiceProvider serviceProvider) : base(serviceProvider)
{
_graphicsDeviceService = serviceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;
Expand All @@ -51,7 +74,40 @@ public ExtendedContentManager(IServiceProvider serviceProvider, string rootDirec
{
_graphicsDeviceService = serviceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;
}

#if KNI || FNA
/// <summary>
/// Loads a <see cref="Texture2D"/> asset.
/// </summary>
/// <remarks>
/// If the <paramref name="path"/> parameter is a relative path, it must be relative to the
/// <see cref="ContentManager.RootDirectory"/> path.
/// </remarks>
/// <param name="path">The path to the asset to load</param>
/// <param name="premultiplyAlpha">
/// Specifies whether the color data of the texture should be premultiplied by its alpha value.
/// </param>
/// <returns></returns>
public Texture2D LoadTexture2D(string path)
{
if (TryGetCachedAsset<Texture2D>(path, out Texture2D texture))
{
return texture;
}

if (NoExtension(path))
{
return Load<Texture2D>(path);
}

using Stream stream = GetStream(path);
texture = Texture2D.FromStream(_graphicsDeviceService.GraphicsDevice, stream);
texture.Name = path;
CacheAsset(path, texture);
return texture;
}

#else
/// <summary>
/// Loads a <see cref="Texture2D"/> asset.
/// </summary>
Expand Down Expand Up @@ -95,6 +151,7 @@ public Texture2D LoadTexture2D(string path, bool premultiplyAlpha)
CacheAsset(path, texture);
return texture;
}
#endif

/// <summary>
/// Loads a <see cref="SoundEffect"/> asset.
Expand Down Expand Up @@ -178,11 +235,18 @@ public BitmapFont LoadBitmapFont(string path)
/// Loads a <see cref="Texture2DAtlas"/> from a TexturePacker JSON file.
/// </summary>
/// <param name="path">The path to the TexturePacker JSON file</param>

#if !KNI && !FNA
/// <param name="premultiplyAlpha">
/// Specifies whether the color data of the texture should be premultiplied by its alpha value.
/// </param>
#endif
/// <returns>The <see cref="Texture2DAtlas"/> created from the TexturePacker JSON file content.</returns>
#if KNI || FNA
public Texture2DAtlas LoadTexturePacker(string path)
#else
public Texture2DAtlas LoadTexturePacker(string path, bool premultiplyAlpha)
#endif
{
if (TryGetCachedAsset<Texture2DAtlas>(path, out var atlas))
{
Expand All @@ -199,8 +263,12 @@ public Texture2DAtlas LoadTexturePacker(string path, bool premultiplyAlpha)
var tpFile = TexturePackerFileReader.Read(stream);
var dir = Path.GetDirectoryName(path);
var imageAssetPath = Path.Combine(dir, tpFile.Meta.Image);
var texture = LoadTexture2D(imageAssetPath, premultiplyAlpha);

#if KNI || FNA
var texture = LoadTexture2D(imageAssetPath);
#else
var texture = LoadTexture2D(imageAssetPath, premultiplyAlpha);
#endif
atlas = new Texture2DAtlas(Path.GetFileNameWithoutExtension(tpFile.Meta.Image), texture);

foreach(var region in tpFile.Regions)
Expand Down
4 changes: 3 additions & 1 deletion source/MonoGame.Extended/KNI.Extended.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<_Parameter1>Kni.Extended.Content.Pipeline</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<PackageReference Include="nkast.Xna.Framework.Audio" Version="3.12.9001" />
</ItemGroup>

</Project>
1 change: 0 additions & 1 deletion tests/MonoGame.Extended.Tests/FNA.Extended.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<ItemGroup>
<ProjectReference Include="..\..\source\MonoGame.Extended\FNA.Extended.csproj" />
<ProjectReference Include="..\..\source\MonoGame.Extended.Particles\FNA.Extended.Particles.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 1d440c9

Please sign in to comment.