1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

Compare commits

...

5 commits

47 changed files with 3331 additions and 41 deletions

View file

@ -2,7 +2,8 @@
MLEM tries to adhere to [semantic versioning](https://semver.org/). Potentially breaking changes are written in **bold**. MLEM tries to adhere to [semantic versioning](https://semver.org/). Potentially breaking changes are written in **bold**.
Jump to version: Jump to version:
- [7.1.0](#710-in-development) - [7.1.1](#711-in-development)
- [7.1.0](#710)
- [7.0.0](#700) - [7.0.0](#700)
- [6.3.1](#631) - [6.3.1](#631)
- [6.3.0](#630) - [6.3.0](#630)
@ -14,11 +15,32 @@ Jump to version:
- [5.1.0](#510) - [5.1.0](#510)
- [5.0.0](#500) - [5.0.0](#500)
## 7.1.0 (In Development) ## 7.1.1 (In Development)
No code changes
## 7.1.0
### MLEM ### MLEM
Additions Additions
- Added ColorExtensions.ToHsl and ColorHelper.FromHsl as well as ColorExtensions.ToHsv and ColorHelper.FromHsv - 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 ## 7.0.0

View file

@ -0,0 +1,41 @@
<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" />
<!-- The builder appears to only support Windows right now. We build for Linux in the CI but don't run there, so we don't need the content files. -->
<PackageReference Include="nkast.Xna.Framework.Content.Pipeline.Builder" Version="3.13.9001" Condition="$(Os.Contains('Windows'))"/>
</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; using MLEM.Misc;
#if !FNA #if !FNA && !KNI
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
#else #else
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;

12
Demos.Web/App.razor Normal file
View file

@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>

View file

@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>MLEM Web Demos</AssemblyName>
<RootNamespace>Demos.Web</RootNamespace>
<DefineConstants>$(DefineConstants);KNI</DefineConstants>
<IsPackable>false</IsPackable>
<KniPlatform>BlazorGL</KniPlatform>
</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="nkast.Xna.Framework.Blazor" Version="3.13.9001" />
<!-- The builder appears to only support Windows right now. We build for Linux in the CI but don't run there, so we don't need the content files. -->
<PackageReference Include="nkast.Xna.Framework.Content.Pipeline.Builder" Version="3.13.9001" Condition="$(Os.Contains('Windows'))" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<KniContentReference Include="..\Demos\Content\Content.mgcb" />
<Content Include="..\Demos\Content\*\**" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,7 @@
@inherits LayoutComponentBase
<div class="page">
<main>
@Body
</main>
</div>

View file

@ -0,0 +1,98 @@
.page
{
position: relative;
display: flex;
flex-direction: column;
}
main
{
flex: 1;
}
.sidebar
{
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}
.top-row
{
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}
.top-row ::deep a, .top-row ::deep .btn-link
{
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover
{
text-decoration: underline;
}
.top-row ::deep a:first-child
{
overflow: hidden;
text-overflow: ellipsis;
}
@media (max-width: 640.98px)
{
.top-row:not(.auth)
{
display: none;
}
.top-row.auth
{
justify-content: space-between;
}
.top-row ::deep a, .top-row ::deep .btn-link
{
margin-left: 0;
}
}
@media (min-width: 641px)
{
.page
{
flex-direction: row;
}
.sidebar
{
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}
.top-row
{
position: sticky;
top: 0;
z-index: 1;
}
.top-row.auth ::deep a:first-child
{
flex: 1;
text-align: right;
width: 0;
}
.top-row, article
{
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}

View file

@ -0,0 +1,19 @@
@page "/"
@page "/index.html"
@inject IJSRuntime JsRuntime
<PageTitle>MLEM Web Demos</PageTitle>
<div id="canvasHolder" style="
background: #000;
margin:0%;
position: fixed;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
width:100vw;
height:100vh;
">
<canvas id="theCanvas" style="touch-action:none;"></canvas>
</div>

View file

@ -0,0 +1,29 @@
using System.Threading.Tasks;
using Microsoft.JSInterop;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using MLEM.Misc;
namespace Demos.Web.Pages;
public partial class Index {
private Game game;
protected override async Task OnAfterRenderAsync(bool firstRender) {
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
await this.JsRuntime.InvokeAsync<object>("initRenderJS", DotNetObjectReference.Create(this));
}
[JSInvokable]
public void TickDotNet() {
if (this.game == null) {
MlemPlatform.Current = new MlemPlatform.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
this.game = new GameImpl();
this.game.Run();
}
this.game.Tick();
}
}

22
Demos.Web/Program.cs Normal file
View file

@ -0,0 +1,22 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace Demos.Web;
internal static class Program {
private static async Task Main(string[] args) {
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(_ => new HttpClient {
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
});
await builder.Build().RunAsync();
}
}

View file

@ -0,0 +1,30 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:56897",
"sslPort": 0
}
},
"profiles": {
"Demos.Web": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5259",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

10
Demos.Web/_Imports.razor Normal file
View file

@ -0,0 +1,10 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using nkast.Wasm.Canvas
@using Demos.Web

2
Demos.Web/wwwroot/Content/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

View file

@ -0,0 +1,94 @@

html, body
{
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
h1:focus
{
outline: none;
}
a, .btn-link
{
color: #0077cc;
}
.btn-primary
{
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.content
{
padding-top: 1.1rem;
}
.valid.modified:not([type=checkbox])
{
outline: 1px solid #26b050;
}
.invalid
{
outline: 1px solid red;
}
.validation-message
{
color: red;
}
#blazor-error-ui
{
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss
{
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}
.blazor-error-boundary
{
background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
padding: 1rem 1rem 1rem 3.7rem;
color: white;
}
.blazor-error-boundary::after
{
content: "An error has occurred."
}
#theCanvas
{
position: fixed;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}
#canvas
{
position: fixed;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -0,0 +1,111 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>MLEM Web Demos</title>
<base href="./" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/app.css" rel="stylesheet" />
<link href="Demos.Web.styles.css" rel="stylesheet" />
</head>
<body>
<div id="app">
<div id="loading" style="display: table-cell; margin: auto; width:100vw; height:100vh; vertical-align: middle; background: #ffcc10;">
<div style="display: block; margin: auto; width: 9em; color: white;font-family: 'Segoe UI', sans-serif;">
<div style="text-align: center; font-size: 0.85em;">Made with<br/><a href="https://github.com/kniEngine/kni"><img src="kni.png" border="0" alt="Kni"></a></div>
<div style="text-align: center; font-size: 1.8em;">loading&nbsp;<marquee style="width:0.9em; vertical-align: bottom;">.&nbsp;.&nbsp;.&nbsp;&nbsp;&nbsp;</marquee></div>
</div>
</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">?</a>
</div>
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
<script type="module">
import { BrotliDecode } from './js/decode.min.js';
// Set this to enable Brotli (.br) decompression on static webServers
// that don't support content compression and http://.
var enableBrotliDecompression = false;
Blazor.start({
loadBootResource: function (type, name, defaultUri, integrity)
{
if (enableBrotliDecompression === true && type !== 'dotnetjs' && location.hostname !== 'localhost')
{
return (async function()
{
const response = await fetch(defaultUri + '.br', { cache: 'no-cache' });
if (!response.ok)
throw new Error(response.statusText);
const originalResponseBuffer = await response.arrayBuffer();
const originalResponseArray = new Int8Array(originalResponseBuffer);
const contentType = (type === 'dotnetwasm')
? 'application/wasm'
: 'application/octet-stream';
const decompressedResponseArray = BrotliDecode(originalResponseArray);
return new Response(decompressedResponseArray,
{ headers: { 'content-type': contentType }
});
})();
}
}
});
</script>
<script src="_content/nkast.Wasm.Dom/js/JSObject.8.0.1.js"></script>
<script src="_content/nkast.Wasm.Dom/js/Window.8.0.1.js"></script>
<script src="_content/nkast.Wasm.Dom/js/Document.8.0.1.js"></script>
<script src="_content/nkast.Wasm.Dom/js/Navigator.8.0.1.js"></script>
<script src="_content/nkast.Wasm.Dom/js/Gamepad.8.0.1.js"></script>
<script src="_content/nkast.Wasm.Dom/js/Media.8.0.1.js"></script>
<script src="_content/nkast.Wasm.XHR/js/XHR.8.0.1.js"></script>
<script src="_content/nkast.Wasm.Canvas/js/Canvas.8.0.1.js"></script>
<script src="_content/nkast.Wasm.Canvas/js/CanvasGLContext.8.0.1.js"></script>
<script src="_content/nkast.Wasm.Audio/js/Audio.8.0.1.js"></script>
<script>
function tickJS()
{
window.theInstance.invokeMethod('TickDotNet');
window.requestAnimationFrame(tickJS);
}
window.initRenderJS = (instance) =>
{
window.theInstance = instance;
// set initial canvas size
var canvas = document.getElementById('theCanvas');
var holder = document.getElementById('canvasHolder');
canvas.width = holder.clientWidth;
canvas.height = holder.clientHeight;
// disable context menu on right click
canvas.addEventListener("contextmenu", e => e.preventDefault());
// begin game loop
window.requestAnimationFrame(tickJS);
};
window.onkeydown = function(event)
{
// Prevent Arrows Keys and Spacebar scrolling the outer page
// when running inside an iframe. e.g: itch.io embedding.
if ([32, 37, 38, 39, 40].indexOf(event.keyCode) > -1)
event.preventDefault();
};
window.onmousewheel = function(event)
{
// Prevent Mousewheel scrolling the outer page
// when running inside an iframe. e.g: itch.io embedding.
event.preventDefault();
};
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

1
Demos.Web/wwwroot/js/decode.min.js vendored Normal file

File diff suppressed because one or more lines are too long

BIN
Demos.Web/wwwroot/kni.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

View file

@ -35,7 +35,7 @@ with.
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic", Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive. 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 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", Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive. 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 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. 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 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", Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive. 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 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. 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 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", Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive. 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 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. 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 ## 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. 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
**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. 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`. 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 ```cs
MlemPlatform.Current = new MlemPlatform.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c); 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<IDisposable> disposableAssets = new List<IDisposable>();
private readonly List<RawContentReader> readers; private readonly List<RawContentReader> readers;
#if FNA #if FNA || KNI
private Dictionary<string, object> LoadedAssets { get; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); private Dictionary<string, object> LoadedAssets { get; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
#endif #endif
@ -73,7 +73,7 @@ namespace MLEM.Data.Content {
/// <param name="currentAsset">The current asset instance.</param> /// <param name="currentAsset">The current asset instance.</param>
/// <typeparam name="T">The asset's type.</typeparam> /// <typeparam name="T">The asset's type.</typeparam>
protected protected
#if !FNA #if !FNA && !KNI
override override
#endif #endif
void ReloadAsset<T>(string originalAssetName, T currentAsset) { void ReloadAsset<T>(string originalAssetName, T currentAsset) {

View file

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

84
MLEM.KNI.sln Normal file
View file

@ -0,0 +1,84 @@

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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.Web.KNI", "Demos.Web\Demos.Web.KNI.csproj", "{F2C126BD-CB8A-4BE9-AD7A-4809D9308023}"
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
{F2C126BD-CB8A-4BE9-AD7A-4809D9308023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2C126BD-CB8A-4BE9-AD7A-4809D9308023}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2C126BD-CB8A-4BE9-AD7A-4809D9308023}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2C126BD-CB8A-4BE9-AD7A-4809D9308023}.Release|Any CPU.Build.0 = Release|Any CPU
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 #if FNA
// none of the copying is available with FNA // none of the copying is available with FNA
return font; 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 #else
// we copy the font here to set the default character to a space // we copy the font here to set the default character to a space
return new SpriteFont( return new SpriteFont(

View file

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

View file

@ -261,7 +261,7 @@ namespace MLEM.Input {
} }
} else { } else {
// mouse position and scroll wheel value should be preserved when the mouse is out of bounds // 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); this.MouseState = new MouseState(state.X, state.Y, state.ScrollWheelValue, 0, 0, 0, 0, 0);
#else #else
this.MouseState = new MouseState(state.X, state.Y, state.ScrollWheelValue, 0, 0, 0, 0, 0, state.HorizontalScrollWheelValue); 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) ![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? # What next?
- Get it on [NuGet](https://www.nuget.org/packages?q=ellpeck+mlem) - 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 - Join [the Discord server](https://link.ellpeck.de/discordweb) to ask questions
# Packages # 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.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.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 - **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) ![An image showing text with various colors and other formatting](https://raw.githubusercontent.com/Ellpeck/MLEM/main/Media/Formatting.png)
# Friends of MLEM # 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 - [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 - [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 - [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] [Test]
public void TestConsistency() { public void TestConsistency() {
void CompareSizes(string s) { void CompareSizes(string s) {
var spriteFont = ((GenericSpriteFont) this.font).Font; var spriteFont = ((GenericSpriteFont) this.font).Font.MeasureString(s);
Assert.AreEqual(spriteFont.MeasureString(s), this.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"); CompareSizes("This is a very simple test string");

View file

@ -9,12 +9,24 @@ public class TestGame : MlemGame {
public RawContentManager RawContent { get; private set; } 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() { protected override void LoadContent() {
base.LoadContent(); base.LoadContent();
this.RawContent = new RawContentManager(this.Services, this.Content.RootDirectory); 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() { 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> <Configuration>
<Include>[MLEM*]*</Include> <Include>[MLEM*]*</Include>
<Exclude>[*.FNA]*</Exclude> <Exclude>[*.FNA]*</Exclude>
<Exclude>[*.KNI]*</Exclude>
</Configuration> </Configuration>
</DataCollector> </DataCollector>
</DataCollectors> </DataCollectors>

View file

@ -2,7 +2,7 @@
#tool dotnet:?package=docfx&version=2.75.3 #tool dotnet:?package=docfx&version=2.75.3
// this is the upcoming version, for prereleases // this is the upcoming version, for prereleases
var version = Argument("version", "7.1.0"); var version = Argument("version", "7.1.1");
var target = Argument("target", "Default"); var target = Argument("target", "Default");
var gitRef = Argument("ref", "refs/heads/main"); var gitRef = Argument("ref", "refs/heads/main");
var buildNum = Argument("buildNum", ""); var buildNum = Argument("buildNum", "");
@ -14,6 +14,7 @@ Task("Prepare").Does(() => {
DotNetRestore("MLEM.sln"); DotNetRestore("MLEM.sln");
DotNetRestore("MLEM.FNA.sln"); DotNetRestore("MLEM.FNA.sln");
DotNetRestore("MLEM.KNI.sln");
if (!gitRef.StartsWith("refs/tags/") && !string.IsNullOrEmpty(buildNum)) { if (!gitRef.StartsWith("refs/tags/") && !string.IsNullOrEmpty(buildNum)) {
Information($"Appending {buildNum} to version"); Information($"Appending {buildNum} to version");
@ -32,6 +33,7 @@ Task("Build").IsDependentOn("Prepare").Does(() =>{
}; };
DotNetBuild("MLEM.sln", settings); DotNetBuild("MLEM.sln", settings);
DotNetBuild("MLEM.FNA.sln", settings); DotNetBuild("MLEM.FNA.sln", settings);
DotNetBuild("MLEM.KNI.sln", settings);
}); });
Task("Test").IsDependentOn("Build").Does(() => { Task("Test").IsDependentOn("Build").Does(() => {
@ -42,6 +44,7 @@ Task("Test").IsDependentOn("Build").Does(() => {
}; };
DotNetTest("MLEM.sln", settings); DotNetTest("MLEM.sln", settings);
DotNetTest("MLEM.FNA.sln", settings); DotNetTest("MLEM.FNA.sln", settings);
DotNetTest("MLEM.KNI.sln", settings);
}); });
Task("Pack").IsDependentOn("Test").Does(() => { Task("Pack").IsDependentOn("Test").Does(() => {
@ -51,6 +54,7 @@ Task("Pack").IsDependentOn("Test").Does(() => {
}; };
DotNetPack("MLEM.sln", settings); DotNetPack("MLEM.sln", settings);
DotNetPack("MLEM.FNA.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(() => { Task("Push").WithCriteria(gitRef == "refs/heads/main" || gitRef.StartsWith("refs/tags/"), "Not on main branch or tag").IsDependentOn("Pack").Does(() => {