1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-10 00:39:09 +01:00

Added MLEM.KNI and friends, which are fully compatible with KNI

This commit is contained in:
Ell 2024-09-02 19:55:28 +02:00
parent 494a7ebdfe
commit ea8ec69dd6
29 changed files with 593 additions and 38 deletions

View file

@ -19,6 +19,23 @@ Jump to version:
### MLEM
Additions
- Added ColorExtensions.ToHsl and ColorHelper.FromHsl as well as ColorExtensions.ToHsv and ColorHelper.FromHsv
- Added MLEM.KNI, which is fully compatible with KNI
### MLEM.Ui
Additions
- Added MLEM.Ui.KNI, which is fully compatible with KNI
### MLEM.Extended
Additions
- Added MLEM.Extended.KNI, which is fully compatible with KNI
### MLEM.Data
Additions
- Added MLEM.Data.KNI, which is fully compatible with KNI
### MLEM.Startup
Additions
- Added MLEM.Startup.KNI, which is fully compatible with KNI
## 7.0.0

View file

@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ApplicationIcon>Icon.ico</ApplicationIcon>
<AssemblyName>MLEM Desktop Demos</AssemblyName>
<RootNamespace>Demos.DesktopGL</RootNamespace>
<DefineConstants>$(DefineConstants);KNI</DefineConstants>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Demos\Demos.KNI.csproj" />
<ProjectReference Include="..\MLEM.Startup\MLEM.Startup.KNI.csproj" />
<ProjectReference Include="..\MLEM.Ui\MLEM.Ui.KNI.csproj" />
<ProjectReference Include="..\MLEM\MLEM.KNI.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="nkast.Xna.Framework" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Content" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Audio" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Media" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Game" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Input" Version="3.13.9001" />
<PackageReference Include="MonoGame.Framework.DesktopGL.9000" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Content.Pipeline.Builder" Version="3.13.9001" />
</ItemGroup>
<ItemGroup>
<KniContentReference Include="..\Demos\Content\Content.mgcb" />
<Content Include="..\Demos\Content\*\**" />
<EmbeddedResource Include="Icon.ico" />
<EmbeddedResource Include="Icon.bmp" />
</ItemGroup>
</Project>

View file

@ -1,5 +1,5 @@
using MLEM.Misc;
#if !FNA
#if !FNA && !KNI
using Microsoft.Xna.Framework;
#else
using Microsoft.Xna.Framework.Input;

View file

@ -35,7 +35,7 @@ with.
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive.
-->
<Style>Regular</Style>
<Style>Bold</Style>
<!--
If you uncomment this line, the default character will be substituted if you draw

View file

@ -35,7 +35,7 @@ with.
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive.
-->
<Style>Regular</Style>
<Style>Italic</Style>
<!--
If you uncomment this line, the default character will be substituted if you draw

View file

@ -11,7 +11,7 @@ with.
<!--
Modify this string to change the font that will be imported.
-->
<FontName>CAYTANOB</FontName>
<FontName>CAYTANOB.ttf</FontName>
<!--
Size is a float value, measured in points. Modify this value to change
@ -35,7 +35,7 @@ with.
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive.
-->
<Style>Regular</Style>
<Style>Bold</Style>
<!--
If you uncomment this line, the default character will be substituted if you draw

View file

@ -11,7 +11,7 @@ with.
<!--
Modify this string to change the font that will be imported.
-->
<FontName>CAYETANI</FontName>
<FontName>CAYETANI.ttf</FontName>
<!--
Size is a float value, measured in points. Modify this value to change
@ -35,7 +35,7 @@ with.
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive.
-->
<Style>Regular</Style>
<Style>Italic</Style>
<!--
If you uncomment this line, the default character will be substituted if you draw

40
Demos/Demos.KNI.csproj Normal file
View file

@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Demos</RootNamespace>
<DefineConstants>$(DefineConstants);KNI</DefineConstants>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MLEM.Startup\MLEM.Startup.KNI.csproj" />
<ProjectReference Include="..\MLEM.Ui\MLEM.Ui.KNI.csproj" />
<ProjectReference Include="..\MLEM\MLEM.KNI.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="nkast.Xna.Framework" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Content" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Audio" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Media" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Input" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Game" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

View file

@ -4,7 +4,7 @@ The **MLEM** base package features an extended `InputHandler` class that allows
Rather than using an event-based structure, the MLEM input handler relies on the game's `Update` frames: To query input through the input handler, you have to query it every Update frame, and input information will only be available for a single update frame in most situations.
The input handler makes use of the `GenericInput` struct, which is a MLEM wrapper around the three main types of input that MonoGame and FNA provide: `Keys`, `Buttons` and `MouseButton` (the latter of which is a MLEM abstraction of mouse buttons). Values of all of these types can be converted into `GenericInput` implicitly, and a `GenericInput` can be converted back implicitly as well, so you will rarely ever have to interact with the `GenericInput` type manually.
The input handler makes use of the `GenericInput` struct, which is a MLEM wrapper around the three main types of input that MonoGame, FNA and KNI provide: `Keys`, `Buttons` and `MouseButton` (the latter of which is a MLEM abstraction of mouse buttons). Values of all of these types can be converted into `GenericInput` implicitly, and a `GenericInput` can be converted back implicitly as well, so you will rarely ever have to interact with the `GenericInput` type manually.
## Setting it up
To set it up, all you have to do is create a new instance. The constructor optionally accepts parameters to enable or disable certain kinds of input.

View file

@ -1,6 +1,6 @@
# MLEM.Ui
**MLEM.Ui** is a Ui framework for MonoGame and FNA that features elements with automatic positioning and sizing. It contains various ready-made element types like buttons, paragraphs, text fields and more, along with the ability to easily create custom controls. It supports **mouse**, **keyboard**, **gamepad** and **touch** input with little to no additional setup work required.
**MLEM.Ui** is a Ui framework for MonoGame, FNA and KNI that features elements with automatic positioning and sizing. It contains various ready-made element types like buttons, paragraphs, text fields and more, along with the ability to easily create custom controls. It supports **mouse**, **keyboard**, **gamepad** and **touch** input with little to no additional setup work required.
To see some of what MLEM.Ui can do, you can check out [the demo](https://github.com/Ellpeck/MLEM/blob/main/Demos/UiDemo.cs) as well.
@ -35,7 +35,7 @@ On desktop devices, MonoGame provides the `Window.TextInput` event that gets cal
To make MLEM compatible with all devices without publishing a separate version for each MonoGame platform, you have to set up the `MlemPlatform` class based on the system you're using MLEM.Ui with. This has to be done *before* initializing your `UiSystem`.
DesktopGL and WindowsDX using MonoGame:
DesktopGL and WindowsDX using MonoGame or KNI:
```cs
MlemPlatform.Current = new MlemPlatform.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
```

View file

@ -23,7 +23,7 @@ namespace MLEM.Data.Content {
private readonly List<IDisposable> disposableAssets = new List<IDisposable>();
private readonly List<RawContentReader> readers;
#if FNA
#if FNA || KNI
private Dictionary<string, object> LoadedAssets { get; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
#endif
@ -73,7 +73,7 @@ namespace MLEM.Data.Content {
/// <param name="currentAsset">The current asset instance.</param>
/// <typeparam name="T">The asset's type.</typeparam>
protected
#if !FNA
#if !FNA && !KNI
override
#endif
void ReloadAsset<T>(string originalAssetName, T currentAsset) {

View file

@ -9,7 +9,7 @@ namespace MLEM.Data.Content {
/// <inheritdoc />
protected override Texture2D Read(RawContentManager manager, string assetPath, Stream stream, Texture2D existing) {
#if !FNA
#if !FNA && !KNI
if (existing != null) {
existing.Reload(stream);
return existing;

View file

@ -0,0 +1,61 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<IsAotCompatible Condition="'$(TargetFramework)'=='net8.0'">true</IsAotCompatible>
<RootNamespace>MLEM.Data</RootNamespace>
<DefineConstants>$(DefineConstants);KNI</DefineConstants>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>
<PropertyGroup>
<Authors>Ellpeck</Authors>
<Description>Simple loading and processing of textures and other data for KNI, including the ability to load non-XNB content files easily</Description>
<PackageReleaseNotes>See the full changelog at https://mlem.ellpeck.de/CHANGELOG.html</PackageReleaseNotes>
<PackageTags>kni ellpeck mlem utility extensions data serialize</PackageTags>
<PackageProjectUrl>https://mlem.ellpeck.de/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Ellpeck/MLEM</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MLEM\MLEM.KNI.csproj" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Content" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Audio" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Media" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Input" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Game" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="../Media/Logo.png" Pack="true" PackagePath="" />
<None Include="../README.md" Pack="true" PackagePath="" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,70 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<IsAotCompatible Condition="'$(TargetFramework)'=='net8.0'">true</IsAotCompatible>
<RootNamespace>MLEM.Extended</RootNamespace>
<DefineConstants>$(DefineConstants);KNI</DefineConstants>
<NoWarn>NU1702</NoWarn>
</PropertyGroup>
<PropertyGroup>
<Authors>Ellpeck</Authors>
<Description>MLEM Library for Extending KNI extension that ties in with other KNI libraries</Description>
<PackageReleaseNotes>See the full changelog at https://mlem.ellpeck.de/CHANGELOG.html</PackageReleaseNotes>
<PackageTags>kni ellpeck mlem utility extensions extended</PackageTags>
<PackageProjectUrl>https://mlem.ellpeck.de/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Ellpeck/MLEM</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MLEM\MLEM.KNI.csproj" />
<PackageReference Condition="'$(TargetFramework)'=='net8.0'" Include="KNI.Extended" Version="4.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Content" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Audio" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Media" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Input" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Game" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Remove="Font/GenericStashFont.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'!='net8.0'">
<Compile Remove="Tiled/**" />
<Compile Remove="Graphics/SpriteBatchExtensions.cs" />
<Compile Remove="Graphics/TextureExtensions.cs" />
<Compile Remove="Maths/NumberExtensions.cs" />
<Compile Remove="Maths/RandomExtensions.cs" />
<Compile Remove="Font/GenericBitmapFont.cs" />
</ItemGroup>
<ItemGroup>
<None Include="../Media/Logo.png" Pack="true" PackagePath="" />
<None Include="../README.md" Pack="true" PackagePath="" />
</ItemGroup>
</Project>

78
MLEM.KNI.sln Normal file
View file

@ -0,0 +1,78 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.KNI", "MLEM\MLEM.KNI.csproj", "{C2C88AE6-6274-4395-8B03-52AE898BA070}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Ui.KNI", "MLEM.Ui\MLEM.Ui.KNI.csproj", "{1B47A40B-3BF6-4933-A7DB-57EADEBDFB61}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Startup.KNI", "MLEM.Startup\MLEM.Startup.KNI.csproj", "{FBE2C9B5-293D-47A7-9BA1-5A4BD1C4E816}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Data.KNI", "MLEM.Data\MLEM.Data.KNI.csproj", "{6587BC91-0640-43FB-988A-4F545B8ACFC5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.KNI", "Demos\Demos.KNI.csproj", "{D83D7D24-14CB-4A7C-A80B-BA4FEC66AB55}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.DesktopGL.KNI", "Demos.DesktopGL\Demos.DesktopGL.KNI.csproj", "{AB08FEC7-3AC3-4FDE-B632-226FAAD7F73F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.KNI", "Tests\Tests.KNI.csproj", "{C74FC4C5-3BE0-42A7-8BA6-4A9AD438A9E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Extended.KNI", "MLEM.Extended\MLEM.Extended.KNI.csproj", "{A5B22930-DF4B-4A62-93ED-A6549F7B666B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C2C88AE6-6274-4395-8B03-52AE898BA070}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2C88AE6-6274-4395-8B03-52AE898BA070}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2C88AE6-6274-4395-8B03-52AE898BA070}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2C88AE6-6274-4395-8B03-52AE898BA070}.Release|Any CPU.Build.0 = Release|Any CPU
{1B47A40B-3BF6-4933-A7DB-57EADEBDFB61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B47A40B-3BF6-4933-A7DB-57EADEBDFB61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B47A40B-3BF6-4933-A7DB-57EADEBDFB61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B47A40B-3BF6-4933-A7DB-57EADEBDFB61}.Release|Any CPU.Build.0 = Release|Any CPU
{FBE2C9B5-293D-47A7-9BA1-5A4BD1C4E816}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBE2C9B5-293D-47A7-9BA1-5A4BD1C4E816}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBE2C9B5-293D-47A7-9BA1-5A4BD1C4E816}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBE2C9B5-293D-47A7-9BA1-5A4BD1C4E816}.Release|Any CPU.Build.0 = Release|Any CPU
{6587BC91-0640-43FB-988A-4F545B8ACFC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6587BC91-0640-43FB-988A-4F545B8ACFC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6587BC91-0640-43FB-988A-4F545B8ACFC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6587BC91-0640-43FB-988A-4F545B8ACFC5}.Release|Any CPU.Build.0 = Release|Any CPU
{D83D7D24-14CB-4A7C-A80B-BA4FEC66AB55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D83D7D24-14CB-4A7C-A80B-BA4FEC66AB55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D83D7D24-14CB-4A7C-A80B-BA4FEC66AB55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D83D7D24-14CB-4A7C-A80B-BA4FEC66AB55}.Release|Any CPU.Build.0 = Release|Any CPU
{AB08FEC7-3AC3-4FDE-B632-226FAAD7F73F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB08FEC7-3AC3-4FDE-B632-226FAAD7F73F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB08FEC7-3AC3-4FDE-B632-226FAAD7F73F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB08FEC7-3AC3-4FDE-B632-226FAAD7F73F}.Release|Any CPU.Build.0 = Release|Any CPU
{C74FC4C5-3BE0-42A7-8BA6-4A9AD438A9E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C74FC4C5-3BE0-42A7-8BA6-4A9AD438A9E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C74FC4C5-3BE0-42A7-8BA6-4A9AD438A9E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C74FC4C5-3BE0-42A7-8BA6-4A9AD438A9E2}.Release|Any CPU.Build.0 = Release|Any CPU
{A5B22930-DF4B-4A62-93ED-A6549F7B666B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5B22930-DF4B-4A62-93ED-A6549F7B666B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5B22930-DF4B-4A62-93ED-A6549F7B666B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5B22930-DF4B-4A62-93ED-A6549F7B666B}.Release|Any CPU.Build.0 = Release|Any CPU
{35253CE1-C864-4CD3-8249-4D1319748E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35253CE1-C864-4CD3-8249-4D1319748E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|Any CPU.Build.0 = Release|Any CPU
{39249E92-EBF2-4951-A086-AB4951C3CCE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39249E92-EBF2-4951-A086-AB4951C3CCE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39249E92-EBF2-4951-A086-AB4951C3CCE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39249E92-EBF2-4951-A086-AB4951C3CCE1}.Release|Any CPU.Build.0 = Release|Any CPU
{458FFA5E-A1C4-4B23-A5D8-259385FEECED}.Debug|Any CPU.ActiveCfg = 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.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
EndGlobal

View file

@ -0,0 +1,56 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<IsAotCompatible Condition="'$(TargetFramework)'=='net8.0'">true</IsAotCompatible>
<RootNamespace>MLEM.Startup</RootNamespace>
<DefineConstants>$(DefineConstants);KNI</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<Authors>Ellpeck</Authors>
<Description>MLEM Library for Extending KNI combined with some other useful libraries into a quick Game startup class</Description>
<PackageReleaseNotes>See the full changelog at https://mlem.ellpeck.de/CHANGELOG.html</PackageReleaseNotes>
<PackageTags>kni ellpeck mlem utility extensions</PackageTags>
<PackageProjectUrl>https://mlem.ellpeck.de/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Ellpeck/MLEM</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Coroutine" Version="2.1.5" />
<ProjectReference Include="..\MLEM.Ui\MLEM.Ui.KNI.csproj" />
<ProjectReference Include="..\MLEM\MLEM.KNI.csproj" />
<PackageReference Include="nkast.Xna.Framework" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Content" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Audio" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Media" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Input" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Game" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="../Media/Logo.png" Pack="true" PackagePath="" />
<None Include="../README.md" Pack="true" PackagePath="" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<IsAotCompatible Condition="'$(TargetFramework)'=='net8.0'">true</IsAotCompatible>
<RootNamespace>MLEM.Ui</RootNamespace>
<DefineConstants>$(DefineConstants);KNI</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<Authors>Ellpeck</Authors>
<Description>A mouse, keyboard, gamepad and touch ready Ui system for KNI that features automatic anchoring, sizing and several ready-to-use element types</Description>
<PackageReleaseNotes>See the full changelog at https://mlem.ellpeck.de/CHANGELOG.html</PackageReleaseNotes>
<PackageTags>kni ellpeck mlem ui user interface graphical gui system mouse keyboard gamepad touch</PackageTags>
<PackageProjectUrl>https://mlem.ellpeck.de/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Ellpeck/MLEM</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TextCopy" Version="6.2.0" Condition="'$(TargetFramework)'!='net452'" />
<ProjectReference Include="..\MLEM\MLEM.KNI.csproj" />
<PackageReference Include="nkast.Xna.Framework" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Content" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Audio" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Media" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Input" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Game" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="../Media/Logo.png" Pack="true" PackagePath="" />
<None Include="../README.md" Pack="true" PackagePath="" />
</ItemGroup>
</Project>

View file

@ -47,6 +47,17 @@ namespace MLEM.Font {
#if FNA
// none of the copying is available with FNA
return font;
#elif KNI
// we copy the font here to set the default character to a space
return new SpriteFont(
font.Texture,
font.Glyphs.Select(g => g.Value.BoundsInTexture).ToList(),
font.Glyphs.Select(g => g.Value.Cropping).ToList(),
font.Characters.ToList(),
font.LineSpacing,
font.Spacing,
font.Glyphs.Select(g => new Vector3(g.Value.LeftSideBearing, g.Value.Width, g.Value.RightSideBearing)).ToList(),
' ');
#else
// we copy the font here to set the default character to a space
return new SpriteFont(

View file

@ -114,8 +114,8 @@ namespace MLEM.Graphics {
private TargetContext(GraphicsDevice device) {
this.device = device;
#if FNA
// RenderTargetCount doesn't exist in FNA but we still want the optimization in MG
#if FNA || KNI
// RenderTargetCount doesn't exist in FNA or KNI but we still want the optimization in MG
this.lastTargets = device.GetRenderTargets();
#else
this.lastTargets = device.RenderTargetCount <= 0 ? null : device.GetRenderTargets();

View file

@ -261,7 +261,7 @@ namespace MLEM.Input {
}
} else {
// mouse position and scroll wheel value should be preserved when the mouse is out of bounds
#if FNA
#if FNA || KNI
this.MouseState = new MouseState(state.X, state.Y, state.ScrollWheelValue, 0, 0, 0, 0, 0);
#else
this.MouseState = new MouseState(state.X, state.Y, state.ScrollWheelValue, 0, 0, 0, 0, 0, state.HorizontalScrollWheelValue);

53
MLEM/MLEM.KNI.csproj Normal file
View file

@ -0,0 +1,53 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<IsAotCompatible Condition="'$(TargetFramework)'=='net8.0'">true</IsAotCompatible>
<RootNamespace>MLEM</RootNamespace>
<DefineConstants>$(DefineConstants);KNI</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<Authors>Ellpeck</Authors>
<Description>The MLEM base package, which provides various small addons and abstractions for KNI, including a text formatting system and simple input handling</Description>
<PackageReleaseNotes>See the full changelog at https://mlem.ellpeck.de/CHANGELOG.html</PackageReleaseNotes>
<PackageTags>kni ellpeck mlem utility extensions</PackageTags>
<PackageProjectUrl>https://mlem.ellpeck.de/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Ellpeck/MLEM</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nkast.Xna.Framework" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Content" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Audio" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Media" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Input" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nkast.Xna.Framework.Game" Version="3.13.9001">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.ValueTuple" Version="4.5.0" Condition="'$(TargetFramework)'=='net452'" />
</ItemGroup>
<ItemGroup>
<None Include="../Media/Logo.png" Pack="true" PackagePath="" />
<None Include="../README.md" Pack="true" PackagePath="" />
</ItemGroup>
</Project>

View file

@ -1,8 +1,8 @@
![The MLEM logo](https://raw.githubusercontent.com/Ellpeck/MLEM/main/Media/Banner.png)
**MLEM Library for Extending MonoGame and FNA** is a set of multipurpose libraries for the game frameworks [MonoGame](https://www.monogame.net/) and [FNA](https://fna-xna.github.io/) that provides abstractions, quality of life improvements and additional features like an extensive ui system and easy input handling.
**MLEM Library for Extending MonoGame, FNA and KNI** is a set of multipurpose libraries for the game frameworks [MonoGame](https://www.monogame.net/), [FNA](https://fna-xna.github.io/) and [KNI](https://github.com/kniEngine/kni) that provides abstractions, quality of life improvements and additional features like an extensive ui system and easy input handling.
MLEM is platform-agnostic and multi-targets .NET Standard 2.0, .NET 8.0 and .NET Framework 4.5.2, which makes it compatible with MonoGame and FNA on Desktop, mobile devices and consoles.
MLEM is platform-agnostic and multi-targets .NET Standard 2.0, .NET 8.0 and .NET Framework 4.5.2, which makes it compatible with MonoGame, FNA and KNI on Desktop, mobile devices, consoles and web.
# What next?
- Get it on [NuGet](https://www.nuget.org/packages?q=ellpeck+mlem)
@ -14,7 +14,7 @@ MLEM is platform-agnostic and multi-targets .NET Standard 2.0, .NET 8.0 and .NET
- Join [the Discord server](https://link.ellpeck.de/discordweb) to ask questions
# Packages
- **MLEM** is the base package, which provides various small addons and abstractions for MonoGame and FNA, including a text formatting system and simple input handling
- **MLEM** is the base package, which provides various small addons and abstractions for MonoGame, FNA and KNI, including a text formatting system and simple input handling
- **MLEM.Ui** provides a mouse, keyboard, gamepad and touch ready Ui system that features automatic anchoring, sizing and several ready-to-use element types
- **MLEM.Extended** ties in with MonoGame.Extended and other MonoGame and FNA libraries
- **MLEM.Data** provides simple loading and processing of textures and other data, including the ability to load non-XNB content files easily
@ -42,7 +42,7 @@ MLEM's [text formatting system](https://mlem.ellpeck.de/articles/text_formatting
![An image showing text with various colors and other formatting](https://raw.githubusercontent.com/Ellpeck/MLEM/main/Media/Formatting.png)
# Friends of MLEM
There are several other libraries and tools that work well in combination with MonoGame, FNA and MLEM. Here are some of them:
There are several other libraries and tools that work well in combination with MonoGame, FNA, KNI and MLEM. Here are some of them:
- [Contentless](https://github.com/Ellpeck/Contentless), a tool that removes the need to add assets to the MonoGame Content Pipeline manually
- [GameBundle](https://github.com/Ellpeck/GameBundle), a tool that packages MonoGame and other .NET applications into several distributable formats
- [Coroutine](https://github.com/Ellpeck/Coroutine), a package that implements Unity-style coroutines for any project

Binary file not shown.

View file

@ -134,8 +134,11 @@ public class FontTests {
[Test]
public void TestConsistency() {
void CompareSizes(string s) {
var spriteFont = ((GenericSpriteFont) this.font).Font;
Assert.AreEqual(spriteFont.MeasureString(s), this.font.MeasureString(s));
var spriteFont = ((GenericSpriteFont) this.font).Font.MeasureString(s);
var genericFont = this.font.MeasureString(s);
Assert.AreEqual(spriteFont.X, genericFont.X);
// we leave a bit of room for the Y value since sprite fonts sometimes increase line height for specific characters, which generic fonts don't
Assert.AreEqual(spriteFont.Y, genericFont.Y, 10);
}
CompareSizes("This is a very simple test string");

View file

@ -9,12 +9,24 @@ public class TestGame : MlemGame {
public RawContentManager RawContent { get; private set; }
private TestGame() {}
private TestGame() {
#if KNI
// allow textures larger than 4096x4096 for our texture packer tests
this.GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.FL11_0;
#endif
}
protected override void LoadContent() {
base.LoadContent();
this.RawContent = new RawContentManager(this.Services, this.Content.RootDirectory);
this.UiSystem.Style.Font = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>("TestFont"));
// we use precompiled fonts and kni uses a different asset compilation system, so we just have both stored
this.UiSystem.Style.Font = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>(
#if KNI
"TestFontKni"
#else
"TestFont"
#endif
));
}
public static TestGame Create() {

44
Tests/Tests.KNI.csproj Normal file
View file

@ -0,0 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<VSTestLogger>nunit</VSTestLogger>
<VSTestResultsDirectory>TestResults.KNI</VSTestResultsDirectory>
<RunSettingsFilePath>Tests.KNI.runsettings</RunSettingsFilePath>
<RootNamespace>Tests</RootNamespace>
<DefineConstants>$(DefineConstants);KNI</DefineConstants>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MLEM.Extended\MLEM.Extended.KNI.csproj" />
<ProjectReference Include="..\MLEM.Startup\MLEM.Startup.KNI.csproj" />
<ProjectReference Include="..\MLEM.Data\MLEM.Data.KNI.csproj" />
<ProjectReference Include="..\MLEM.Ui\MLEM.Ui.KNI.csproj" />
<ProjectReference Include="..\MLEM\MLEM.KNI.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="nkast.Xna.Framework" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Content" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Audio" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Media" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Game" Version="3.13.9001" />
<PackageReference Include="nkast.Xna.Framework.Input" Version="3.13.9001" />
<PackageReference Include="MonoGame.Framework.DesktopGL.9000" Version="3.13.9001" />
<PackageReference Include="KNI.Extended" Version="4.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NunitXml.TestLogger" Version="3.1.15" />
</ItemGroup>
<ItemGroup>
<Content Include="Content/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage">
<Configuration>
<Include>[MLEM*.KNI]*</Include>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>

View file

@ -6,6 +6,7 @@
<Configuration>
<Include>[MLEM*]*</Include>
<Exclude>[*.FNA]*</Exclude>
<Exclude>[*.KNI]*</Exclude>
</Configuration>
</DataCollector>
</DataCollectors>

View file

@ -14,6 +14,7 @@ Task("Prepare").Does(() => {
DotNetRestore("MLEM.sln");
DotNetRestore("MLEM.FNA.sln");
DotNetRestore("MLEM.KNI.sln");
if (!gitRef.StartsWith("refs/tags/") && !string.IsNullOrEmpty(buildNum)) {
Information($"Appending {buildNum} to version");
@ -32,6 +33,7 @@ Task("Build").IsDependentOn("Prepare").Does(() =>{
};
DotNetBuild("MLEM.sln", settings);
DotNetBuild("MLEM.FNA.sln", settings);
DotNetBuild("MLEM.KNI.sln", settings);
});
Task("Test").IsDependentOn("Build").Does(() => {
@ -42,6 +44,7 @@ Task("Test").IsDependentOn("Build").Does(() => {
};
DotNetTest("MLEM.sln", settings);
DotNetTest("MLEM.FNA.sln", settings);
DotNetTest("MLEM.KNI.sln", settings);
});
Task("Pack").IsDependentOn("Test").Does(() => {
@ -51,6 +54,7 @@ Task("Pack").IsDependentOn("Test").Does(() => {
};
DotNetPack("MLEM.sln", settings);
DotNetPack("MLEM.FNA.sln", settings);
DotNetPack("MLEM.KNI.sln", settings);
});
Task("Push").WithCriteria(gitRef == "refs/heads/main" || gitRef.StartsWith("refs/tags/"), "Not on main branch or tag").IsDependentOn("Pack").Does(() => {