-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ragath
authored and
Ragath
committed
Jan 15, 2023
1 parent
3c001f4
commit ffbe63e
Showing
53 changed files
with
9,583 additions
and
9,620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# This workflow will build a .NET project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | ||
|
||
name: .NET | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
tags: [ "v*" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} # checkout the correct branch name | ||
fetch-depth: 0 | ||
|
||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
versionSpec: '5.x' | ||
|
||
- name: Determine Version | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
useConfigFile: true | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0.x | ||
|
||
- name: Build | ||
run: dotnet build -p:Version=$GITVERSION_NUGETVERSION | ||
|
||
- name: Test | ||
run: dotnet test --no-build --verbosity normal | ||
|
||
- name: Pack | ||
run: dotnet pack --no-build -o ./ -p:Version=$GITVERSION_NUGETVERSION | ||
|
||
- name: Push | ||
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | ||
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key $APIKey | ||
env: | ||
APIKey: ${{ secrets.NUGETKEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net45;net472;netstandard2.0</TargetFrameworks> | ||
<LangVersion>Latest</LangVersion> | ||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<Description>Tiled Map MonoGame pipeline extensions</Description> | ||
<PackageId>TiledLib.Pipeline</PackageId> | ||
<Product>TiledLib.Pipeline</Product> | ||
<Authors>Daniel Sör</Authors> | ||
<Company>Daniel Sör</Company> | ||
<PackageTags>Tiled MonoGame ContentPipeline Content Pipeline tmx map importer</PackageTags> | ||
<PackageProjectUrl>https://github.com/Ragath/TiledLib.Net</PackageProjectUrl> | ||
<PackageLicenseUrl>https://github.com/Ragath/TiledLib.Net/blob/master/LICENSE</PackageLicenseUrl> | ||
<RepositoryUrl>https://github.com/Ragath/TiledLib.Net</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<Description>Tiled Map MonoGame pipeline extensions</Description> | ||
<Product>TiledLib.Pipeline</Product> | ||
<Authors>Daniel Sör</Authors> | ||
<Company>Daniel Sör</Company> | ||
<PackageTags>Tiled MonoGame ContentPipeline Content Pipeline tmx map importer</PackageTags> | ||
<PackageProjectUrl>https://github.com/Ragath/TiledLib.Net</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/Ragath/TiledLib.Net</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
</PropertyGroup> | ||
|
||
<Choose> | ||
<When Condition="'$(TargetFramework)' == 'netstandard2.0'"> | ||
<ItemGroup> | ||
<PackageReference Include="MonoGame.Framework.Content.Pipeline" Version="3.8.0.1641" /> | ||
</ItemGroup> | ||
</When> | ||
<Otherwise> | ||
<ItemGroup> | ||
<PackageReference Include="MonoGame.Framework.Content.Pipeline.Portable" Version="3.7.1.189" /> | ||
</ItemGroup> | ||
</Otherwise> | ||
</Choose> | ||
<ItemGroup> | ||
<None Include="../LICENSE"> | ||
<Pack>True</Pack> | ||
<PackagePath>/</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\TiledLib\TiledLib.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="MonoGame.Framework.Content.Pipeline" Version="3.8.1.303"> | ||
<PrivateAssets>All</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303"> | ||
<PrivateAssets>All</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> | ||
<ItemGroup> | ||
<ProjectReference Include="..\TiledLib\TiledLib.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,35 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
namespace TiledLib.Tests; | ||
|
||
namespace TiledLib.Tests | ||
[TestClass] | ||
public class TilesetTests | ||
{ | ||
[TestClass] | ||
public class TilesetTests | ||
[DataTestMethod] | ||
[DataRow("Data/External_tileset_map.json")] | ||
[DataRow("Data/External_tileset_map.tmx")] | ||
[DataRow("Data/Level0.json")] | ||
public void TestTileIndexing(string file) | ||
{ | ||
[DataTestMethod] | ||
[DataRow("Data/External_tileset_map.json")] | ||
[DataRow("Data/External_tileset_map.tmx")] | ||
[DataRow("Data/Level0.json")] | ||
public void TestTileIndexing(string file) | ||
using (var mapStream = File.OpenRead(file)) | ||
{ | ||
using (var mapStream = File.OpenRead(file)) | ||
var map = Map.FromStream(mapStream); | ||
|
||
Tileset LoadTileset(ExternalTileset t) | ||
{ | ||
var map = Map.FromStream(mapStream); | ||
using var stream = File.OpenRead(Path.Combine(Path.GetDirectoryName(file)!, t.Source)); | ||
return Tileset.FromStream(stream); | ||
} | ||
|
||
Tileset LoadTileset(ExternalTileset t) | ||
{ | ||
using (var stream = File.OpenRead(Path.Combine(Path.GetDirectoryName(file), t.Source))) | ||
{ | ||
return Tileset.FromStream(stream); | ||
} | ||
} | ||
foreach (var ts in map.Tilesets.OfType<ExternalTileset>()) | ||
ts.LoadTileset(LoadTileset); | ||
|
||
foreach (var ts in map.Tilesets.OfType<ExternalTileset>()) | ||
ts.LoadTileset(LoadTileset); | ||
var q = from t in map.Tilesets | ||
from i in Enumerable.Range(t.FirstGid, t.Rows * t.Columns) | ||
select new | ||
{ | ||
index = i, | ||
tile = t[i] | ||
}; | ||
CollectionAssert.AllItemsAreUnique(q.ToArray().Select(i => i.index).ToArray()); | ||
} | ||
var q = from t in map.Tilesets | ||
from i in Enumerable.Range(t.FirstGid, t.Rows * t.Columns) | ||
select new | ||
{ | ||
index = i, | ||
tile = t[i] | ||
}; | ||
CollectionAssert.AllItemsAreUnique(q.ToArray().Select(i => i.index).ToArray()); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,63 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using TiledLib.Layer; | ||
using TiledLib.Layer; | ||
|
||
namespace TiledLib.Tests | ||
namespace TiledLib.Tests; | ||
|
||
[TestClass] | ||
public class LayerFormatTests | ||
{ | ||
[TestClass] | ||
public class LayerFormatTests | ||
[DataTestMethod] | ||
[DataRow("Data/External_tileset_map.json")] | ||
[DataRow("Data/External_tileset_map.tmx")] | ||
[DataRow("Data/External_tileset_map_base64.json")] | ||
[DataRow("Data/External_tileset_map_base64.tmx")] | ||
[DataRow("Data/Level0.json")] | ||
public void TestUncompressedDecoding(string file) | ||
{ | ||
[DataTestMethod] | ||
[DataRow("Data/External_tileset_map.json")] | ||
[DataRow("Data/External_tileset_map.tmx")] | ||
[DataRow("Data/External_tileset_map_base64.json")] | ||
[DataRow("Data/External_tileset_map_base64.tmx")] | ||
[DataRow("Data/Level0.json")] | ||
public void TestUncompressedDecoding(string file) | ||
using (var stream = File.OpenRead(file)) | ||
{ | ||
using (var stream = File.OpenRead(file)) | ||
{ | ||
var result = Map.FromStream(stream); | ||
var result = Map.FromStream(stream); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsNotNull(result.Layers); | ||
Assert.IsTrue(result.Layers.Any()); | ||
foreach (var tl in result.Layers.OfType<TileLayer>()) | ||
Assert.IsFalse(tl.Data.All(i => i == 0)); | ||
} | ||
Assert.IsNotNull(result); | ||
Assert.IsNotNull(result.Layers); | ||
Assert.IsTrue(result.Layers.Any()); | ||
foreach (var tl in result.Layers.OfType<TileLayer>()) | ||
Assert.IsFalse(tl.Data.All(i => i == 0)); | ||
} | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("Data/External_tileset_map_base64_gzip.tmx", "Data/External_tileset_map_base64.tmx")] | ||
[DataRow("Data/External_tileset_map_base64_zlib.tmx", "Data/External_tileset_map_base64.tmx")] | ||
[DataRow("Data/External_tileset_map_base64_zlib.json", "Data/External_tileset_map_base64.json")] | ||
[DataRow("Data/External_tileset_map_base64_gzip.json", "Data/External_tileset_map_base64.json")] | ||
public void TestCompression(string file, string referenceFile) | ||
[DataTestMethod] | ||
[DataRow("Data/External_tileset_map_base64_gzip.tmx", "Data/External_tileset_map_base64.tmx")] | ||
[DataRow("Data/External_tileset_map_base64_zlib.tmx", "Data/External_tileset_map_base64.tmx")] | ||
[DataRow("Data/External_tileset_map_base64_zlib.json", "Data/External_tileset_map_base64.json")] | ||
[DataRow("Data/External_tileset_map_base64_gzip.json", "Data/External_tileset_map_base64.json")] | ||
public void TestCompression(string file, string referenceFile) | ||
{ | ||
Map referenceMap; | ||
using (var stream = File.OpenRead(referenceFile)) | ||
{ | ||
Map referenceMap; | ||
using (var stream = File.OpenRead(referenceFile)) | ||
{ | ||
referenceMap = Map.FromStream(stream); | ||
} | ||
referenceMap = Map.FromStream(stream); | ||
} | ||
|
||
using (var stream = File.OpenRead(file)) | ||
{ | ||
var result = Map.FromStream(stream); | ||
using (var stream = File.OpenRead(file)) | ||
{ | ||
var result = Map.FromStream(stream); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.IsNotNull(result.Layers); | ||
Assert.IsTrue(result.Layers.Any()); | ||
foreach (var tl in result.Layers.OfType<TileLayer>()) | ||
Assert.IsFalse(tl.Data.All(i => i == 0)); | ||
Assert.IsNotNull(result); | ||
Assert.IsNotNull(result.Layers); | ||
Assert.IsTrue(result.Layers.Any()); | ||
foreach (var tl in result.Layers.OfType<TileLayer>()) | ||
Assert.IsFalse(tl.Data.All(i => i == 0)); | ||
|
||
Assert.AreEqual(referenceMap.Layers.Length, result.Layers.Length); | ||
for (int i = 0; i < referenceMap.Layers.Length; i++) | ||
if (referenceMap.Layers[i] is TileLayer refLayer) | ||
{ | ||
var layer = result.Layers[i] as TileLayer; | ||
Assert.IsNotNull(layer); | ||
Assert.IsNotNull(layer.Compression); | ||
Assert.AreEqual("base64", layer.Encoding); | ||
CollectionAssert.AreEqual(refLayer.Data, layer.Data); | ||
} | ||
} | ||
Assert.AreEqual(referenceMap.Layers.Length, result.Layers.Length); | ||
for (int i = 0; i < referenceMap.Layers.Length; i++) | ||
if (referenceMap.Layers[i] is TileLayer refLayer) | ||
{ | ||
var layer = result.Layers[i] as TileLayer; | ||
Assert.IsNotNull(layer); | ||
Assert.IsNotNull(layer.Compression); | ||
Assert.AreEqual("base64", layer.Encoding); | ||
CollectionAssert.AreEqual(refLayer.Data, layer.Data); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.