Skip to content

Commit

Permalink
Use AsepriteDotNet as core processing library
Browse files Browse the repository at this point in the history
  • Loading branch information
AristurtleDev committed Mar 26, 2024
1 parent 3139277 commit ab5b0d0
Show file tree
Hide file tree
Showing 127 changed files with 1,618 additions and 6,640 deletions.
54 changes: 54 additions & 0 deletions MonoGame.Aseprite.sln
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".root", ".root", "{780173B6
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{C177CFCE-9FD8-4EFA-9046-B5ECC55401CE}"
ProjectSection(SolutionItems) = preProject
examples\Directory.Build.props = examples\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnimatedTilemapExample", "examples\AnimatedTilemapExample\AnimatedTilemapExample.csproj", "{6E52E54B-E074-4CEE-86D2-F0E3D429F4F6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContentPipelineExample", "examples\ContentPipelineExample\ContentPipelineExample.csproj", "{615E3A66-5DDB-4691-88BA-6E10E71E1899}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpriteExample", "examples\SpriteExample\SpriteExample.csproj", "{2DEBEDB6-C604-4CC6-94CC-A6964E2781F4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpritesheetExample", "examples\SpritesheetExample\SpritesheetExample.csproj", "{7EBC52B4-982A-4CA1-AD88-CEEA4573E4EF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TextureAtlasExample", "examples\TextureAtlasExample\TextureAtlasExample.csproj", "{55C32452-39B1-4FD0-92D2-1037909B0571}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TilemapExample", "examples\TilemapExample\TilemapExample.csproj", "{813FAB91-CDF4-4F50-8C1A-B4987E84E45A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TilesetExample", "examples\TilesetExample\TilesetExample.csproj", "{385D0648-538D-4A90-A1EA-FEF44C9F9517}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -46,6 +65,34 @@ Global
{4E3BCA48-A076-4ECE-A80A-F254DAE2D18E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E3BCA48-A076-4ECE-A80A-F254DAE2D18E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E3BCA48-A076-4ECE-A80A-F254DAE2D18E}.Release|Any CPU.Build.0 = Release|Any CPU
{6E52E54B-E074-4CEE-86D2-F0E3D429F4F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E52E54B-E074-4CEE-86D2-F0E3D429F4F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E52E54B-E074-4CEE-86D2-F0E3D429F4F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E52E54B-E074-4CEE-86D2-F0E3D429F4F6}.Release|Any CPU.Build.0 = Release|Any CPU
{615E3A66-5DDB-4691-88BA-6E10E71E1899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{615E3A66-5DDB-4691-88BA-6E10E71E1899}.Debug|Any CPU.Build.0 = Debug|Any CPU
{615E3A66-5DDB-4691-88BA-6E10E71E1899}.Release|Any CPU.ActiveCfg = Release|Any CPU
{615E3A66-5DDB-4691-88BA-6E10E71E1899}.Release|Any CPU.Build.0 = Release|Any CPU
{2DEBEDB6-C604-4CC6-94CC-A6964E2781F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DEBEDB6-C604-4CC6-94CC-A6964E2781F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DEBEDB6-C604-4CC6-94CC-A6964E2781F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DEBEDB6-C604-4CC6-94CC-A6964E2781F4}.Release|Any CPU.Build.0 = Release|Any CPU
{7EBC52B4-982A-4CA1-AD88-CEEA4573E4EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EBC52B4-982A-4CA1-AD88-CEEA4573E4EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EBC52B4-982A-4CA1-AD88-CEEA4573E4EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EBC52B4-982A-4CA1-AD88-CEEA4573E4EF}.Release|Any CPU.Build.0 = Release|Any CPU
{55C32452-39B1-4FD0-92D2-1037909B0571}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55C32452-39B1-4FD0-92D2-1037909B0571}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55C32452-39B1-4FD0-92D2-1037909B0571}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55C32452-39B1-4FD0-92D2-1037909B0571}.Release|Any CPU.Build.0 = Release|Any CPU
{813FAB91-CDF4-4F50-8C1A-B4987E84E45A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{813FAB91-CDF4-4F50-8C1A-B4987E84E45A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{813FAB91-CDF4-4F50-8C1A-B4987E84E45A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{813FAB91-CDF4-4F50-8C1A-B4987E84E45A}.Release|Any CPU.Build.0 = Release|Any CPU
{385D0648-538D-4A90-A1EA-FEF44C9F9517}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{385D0648-538D-4A90-A1EA-FEF44C9F9517}.Debug|Any CPU.Build.0 = Debug|Any CPU
{385D0648-538D-4A90-A1EA-FEF44C9F9517}.Release|Any CPU.ActiveCfg = Release|Any CPU
{385D0648-538D-4A90-A1EA-FEF44C9F9517}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -54,6 +101,13 @@ Global
{B5D9570E-E9BF-482B-BD73-8EA6EC4330F8} = {CF520A36-B1B8-4CFA-9835-C3345A65D57B}
{49903681-88CC-4B14-AD02-C475E78D4CE2} = {CF520A36-B1B8-4CFA-9835-C3345A65D57B}
{4E3BCA48-A076-4ECE-A80A-F254DAE2D18E} = {78ECB0CA-72B0-4E08-BAB1-8BF2B98829D9}
{6E52E54B-E074-4CEE-86D2-F0E3D429F4F6} = {C177CFCE-9FD8-4EFA-9046-B5ECC55401CE}
{615E3A66-5DDB-4691-88BA-6E10E71E1899} = {C177CFCE-9FD8-4EFA-9046-B5ECC55401CE}
{2DEBEDB6-C604-4CC6-94CC-A6964E2781F4} = {C177CFCE-9FD8-4EFA-9046-B5ECC55401CE}
{7EBC52B4-982A-4CA1-AD88-CEEA4573E4EF} = {C177CFCE-9FD8-4EFA-9046-B5ECC55401CE}
{55C32452-39B1-4FD0-92D2-1037909B0571} = {C177CFCE-9FD8-4EFA-9046-B5ECC55401CE}
{813FAB91-CDF4-4F50-8C1A-B4987E84E45A} = {C177CFCE-9FD8-4EFA-9046-B5ECC55401CE}
{385D0648-538D-4A90-A1EA-FEF44C9F9517} = {C177CFCE-9FD8-4EFA-9046-B5ECC55401CE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {185C72A8-896C-42E7-93F4-99FCD65E0961}
Expand Down
36 changes: 36 additions & 0 deletions examples/AnimatedTilemapExample/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-mgcb": {
"version": "3.8.1.303",
"commands": [
"mgcb"
]
},
"dotnet-mgcb-editor": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor"
]
},
"dotnet-mgcb-editor-linux": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-linux"
]
},
"dotnet-mgcb-editor-windows": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-windows"
]
},
"dotnet-mgcb-editor-mac": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-mac"
]
}
}
}
34 changes: 34 additions & 0 deletions examples/AnimatedTilemapExample/AnimatedTilemapExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RollForward>Major</RollForward>
<PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<None Remove="Icon.ico" />
<None Remove="Icon.bmp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Icon.ico" />
<EmbeddedResource Include="Icon.bmp" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
</ItemGroup>
<ItemGroup>
<None Update="townmap.aseprite">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
<Exec Command="dotnet tool restore" />
</Target>
</Project>
15 changes: 15 additions & 0 deletions examples/AnimatedTilemapExample/Content/Content.mgcb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

#----------------------------- Global Properties ----------------------------#

/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:DesktopGL
/config:
/profile:Reach
/compress:False

#-------------------------------- References --------------------------------#


#---------------------------------- Content ---------------------------------#

87 changes: 87 additions & 0 deletions examples/AnimatedTilemapExample/Game1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using AsepriteDotNet.Aseprite;
using AsepriteDotNet.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Aseprite;

namespace AnimatedTilemapExample;

public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
private AnimatedTilemap _animatedTilemap;
private Vector2 _scale;

public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}


protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Load the file. In this example, we're not using the MGCB/Content Pipeline and have the Aseprite file set as
/// a file in our project that is copied the output directory. Because of this, we can use the
/// TitleContainer.OpenStream to get a stream to the file and use that to load it.
///
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
AsepriteFile aseFile;
using (Stream stream = TitleContainer.OpenStream("townmap.aseprite"))
{
aseFile = AsepriteFileLoader.FromStream("townmap", stream);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Create an animated tilemap from the file based on all frames.
///
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
_animatedTilemap = aseFile.CreateAnimatedTilemap(GraphicsDevice);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Size the tilemap is created 1:1 with the size it is in Aseprite, we're going to create a scale factor here
/// in this example to be the size of the game window.
///
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
_scale.X = _graphics.PreferredBackBufferWidth / (float)_animatedTilemap.GetFrame(0).GetLayer(0).Width;
_scale.Y = _graphics.PreferredBackBufferHeight / (float)_animatedTilemap.GetFrame(0).GetLayer(0).Height;

}

protected override void Update(GameTime gameTime)
{

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// The animated tilemap must be updated each frame to update the animations.
///
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
_animatedTilemap.Update(gameTime);

}

protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);


_spriteBatch.Begin(samplerState: SamplerState.PointClamp);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Spritebatch extension are provided to draw the tilemap
///
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
_spriteBatch.Draw(_animatedTilemap, Vector2.Zero, Color.White, _scale, 0.0f);

_spriteBatch.End();
}
}
Binary file added examples/AnimatedTilemapExample/Icon.bmp
Binary file not shown.
Binary file added examples/AnimatedTilemapExample/Icon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/AnimatedTilemapExample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

using var game = new AnimatedTilemapExample.Game1();
game.Run();
43 changes: 43 additions & 0 deletions examples/AnimatedTilemapExample/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="AnimatedTilemapExample"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->

<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />

<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />

<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />

<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />

<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

</application>
</compatibility>

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness>
</windowsSettings>
</application>

</assembly>
Binary file added examples/AnimatedTilemapExample/townmap.aseprite
Binary file not shown.
36 changes: 36 additions & 0 deletions examples/ContentPipelineExample/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-mgcb": {
"version": "3.8.1.303",
"commands": [
"mgcb"
]
},
"dotnet-mgcb-editor": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor"
]
},
"dotnet-mgcb-editor-linux": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-linux"
]
},
"dotnet-mgcb-editor-windows": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-windows"
]
},
"dotnet-mgcb-editor-mac": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-mac"
]
}
}
}
22 changes: 22 additions & 0 deletions examples/ContentPipelineExample/Content/Content.mgcb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

#----------------------------- Global Properties ----------------------------#

/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:DesktopGL
/config:
/profile:Reach
/compress:False

#-------------------------------- References --------------------------------#

/reference:..\..\..\.artifacts\bin\source\MonoGame.Aseprite.Content.Pipeline\Debug\net6.0\MonoGame.Aseprite.Content.Pipeline.dll

#---------------------------------- Content ---------------------------------#

#begin character_robot.aseprite
/importer:AsepriteFileContentImporter
/processor:AsepriteFileContentProcessor
/processorParam:PremultiplyAlpha=True
/build:character_robot.aseprite

Binary file not shown.
34 changes: 34 additions & 0 deletions examples/ContentPipelineExample/ContentPipelineExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RollForward>Major</RollForward>
<PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<None Remove="Icon.ico" />
<None Remove="Icon.bmp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Icon.ico" />
<EmbeddedResource Include="Icon.bmp" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
</ItemGroup>
<ItemGroup>
<None Update="Content\character_robot.aseprite">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
<Exec Command="dotnet tool restore" />
</Target>
</Project>
Loading

0 comments on commit ab5b0d0

Please sign in to comment.