Skip to content

Commit

Permalink
Added MLEM.KNI and friends, which are fully compatible with KNI
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellpeck committed Sep 2, 2024
1 parent 494a7eb commit ea8ec69
Show file tree
Hide file tree
Showing 29 changed files with 593 additions and 38 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 39 additions & 0 deletions Demos.DesktopGL/Demos.DesktopGL.KNI.csproj
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 1 addition & 1 deletion Demos.DesktopGL/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MLEM.Misc;
#if !FNA
#if !FNA && !KNI
using Microsoft.Xna.Framework;
#else
using Microsoft.Xna.Framework.Input;
Expand Down
2 changes: 1 addition & 1 deletion Demos/Content/Fonts/RobotoBold.spritefont
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Demos/Content/Fonts/RobotoItalic.spritefont
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions Demos/Content/Fonts/TestFontBold.spritefont
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ with.
-->
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">

<!--
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
the size of the font.
-->
<Size>32</Size>

<!--
Spacing is a float value, measured in pixels. Modify this value to change
the amount of spacing in between characters.
-->
<Spacing>0</Spacing>

<!--
UseKerning controls the layout of the font. If this value is true, kerning information
will be used when placing characters.
-->
<UseKerning>true</UseKerning>

<!--
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
or measure text that contains characters which were not included in the font.
-->
<DefaultCharacter>*</DefaultCharacter>

<!--
CharacterRegions control what letters are available in the font. Every
character from Start to End will be built and made available for drawing. The
Expand Down
18 changes: 9 additions & 9 deletions Demos/Content/Fonts/TestFontItalic.spritefont
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ with.
-->
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">

<!--
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
the size of the font.
-->
<Size>32</Size>

<!--
Spacing is a float value, measured in pixels. Modify this value to change
the amount of spacing in between characters.
-->
<Spacing>0</Spacing>

<!--
UseKerning controls the layout of the font. If this value is true, kerning information
will be used when placing characters.
-->
<UseKerning>true</UseKerning>

<!--
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
or measure text that contains characters which were not included in the font.
-->
<DefaultCharacter>*</DefaultCharacter>

<!--
CharacterRegions control what letters are available in the font. Every
character from Start to End will be built and made available for drawing. The
Expand Down
40 changes: 40 additions & 0 deletions Demos/Demos.KNI.csproj
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 1 addition & 1 deletion Docs/articles/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Docs/articles/ui.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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);
```
Expand Down
4 changes: 2 additions & 2 deletions MLEM.Data/Content/RawContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class RawContentManager : ContentManager, IGameComponent {
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

Expand Down Expand Up @@ -73,7 +73,7 @@ public override T Load<T>(string assetName) {
/// <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) {
Expand Down
2 changes: 1 addition & 1 deletion MLEM.Data/Content/Texture2DReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Texture2DReader : RawContentReader<Texture2D> {

/// <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;
Expand Down
61 changes: 61 additions & 0 deletions MLEM.Data/MLEM.Data.KNI.csproj
Original file line number Diff line number Diff line change
@@ -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>
Loading

0 comments on commit ea8ec69

Please sign in to comment.