chore: updated engine
This commit is contained in:
36
Platforms/Desktop/.config/dotnet-tools.json
Normal file
36
Platforms/Desktop/.config/dotnet-tools.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-mgcb": {
|
||||
"version": "3.8.2.1105",
|
||||
"commands": [
|
||||
"mgcb"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor": {
|
||||
"version": "3.8.2.1105",
|
||||
"commands": [
|
||||
"mgcb-editor"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-linux": {
|
||||
"version": "3.8.2.1105",
|
||||
"commands": [
|
||||
"mgcb-editor-linux"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-windows": {
|
||||
"version": "3.8.2.1105",
|
||||
"commands": [
|
||||
"mgcb-editor-windows"
|
||||
]
|
||||
},
|
||||
"dotnet-mgcb-editor-mac": {
|
||||
"version": "3.8.2.1105",
|
||||
"commands": [
|
||||
"mgcb-editor-mac"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
15
Platforms/Desktop/Content/Content.mgcb
Normal file
15
Platforms/Desktop/Content/Content.mgcb
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
#----------------------------- Global Properties ----------------------------#
|
||||
|
||||
/outputDir:bin/$(Platform)
|
||||
/intermediateDir:obj/$(Platform)
|
||||
/platform:DesktopGL
|
||||
/config:
|
||||
/profile:Reach
|
||||
/compress:False
|
||||
|
||||
#-------------------------------- References --------------------------------#
|
||||
|
||||
|
||||
#---------------------------------- Content ---------------------------------#
|
||||
|
47
Platforms/Desktop/Desktop.csproj
Normal file
47
Platforms/Desktop/Desktop.csproj
Normal file
@@ -0,0 +1,47 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RollForward>Major</RollForward>
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
<TieredCompilation>false</TieredCompilation>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Pong.Platforms.Desktop</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Icon.ico" />
|
||||
<None Remove="Icon.bmp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Icon.ico">
|
||||
<LogicalName>Icon.ico</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Icon.bmp">
|
||||
<LogicalName>Icon.bmp</LogicalName>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.2.1105" />
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.2.1105" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../Shared/Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MonoGameContentReference Include="../../Shared/Content/Content.mgcb">
|
||||
<Link>Content/Content.mgcb</Link>
|
||||
</MonoGameContentReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../Shared/Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
|
||||
<Message Text="Restoring dotnet tools" Importance="High" />
|
||||
<Exec Command="dotnet tool restore" />
|
||||
</Target>
|
||||
</Project>
|
BIN
Platforms/Desktop/Icon.bmp
Normal file
BIN
Platforms/Desktop/Icon.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 256 KiB |
BIN
Platforms/Desktop/Icon.ico
Normal file
BIN
Platforms/Desktop/Icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 144 KiB |
112
Platforms/Desktop/KeyboardInputsBehaviour.cs
Normal file
112
Platforms/Desktop/KeyboardInputsBehaviour.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
using Syntriax.Engine.Core;
|
||||
using Syntriax.Engine.Systems.Input;
|
||||
|
||||
namespace Pong.Platforms.Desktop;
|
||||
|
||||
public class KeyboardInputsBehaviour : Behaviour, IButtonInputs<Keys>
|
||||
{
|
||||
private readonly Dictionary<Keys, IButtonInputs<Keys>.ButtonCallbackEventHandler> OnPressed = new(256);
|
||||
private readonly Dictionary<Keys, IButtonInputs<Keys>.ButtonCallbackEventHandler> OnReleased = new(256);
|
||||
|
||||
private int cachePressedCurrentlyCount = 0;
|
||||
private readonly Keys[] cachePressedCurrently = new Keys[256];
|
||||
|
||||
private int cachePressedPreviouslyCount = 0;
|
||||
private readonly Keys[] cachePressedPreviously = new Keys[256];
|
||||
|
||||
public event IButtonInputs<Keys>.ButtonCallbackEventHandler? OnAnyButtonPressed = null;
|
||||
public event IButtonInputs<Keys>.ButtonCallbackEventHandler? OnAnyButtonReleased = null;
|
||||
|
||||
public void RegisterOnPress(Keys key, IButtonInputs<Keys>.ButtonCallbackEventHandler callback)
|
||||
{
|
||||
if (OnPressed.TryGetValue(key, out var action))
|
||||
{
|
||||
action += callback;
|
||||
return;
|
||||
}
|
||||
|
||||
OnPressed.Add(key, callback);
|
||||
}
|
||||
|
||||
public void UnregisterOnPress(Keys key, IButtonInputs<Keys>.ButtonCallbackEventHandler callback)
|
||||
{
|
||||
if (OnPressed.TryGetValue(key, out var action))
|
||||
action -= callback;
|
||||
}
|
||||
|
||||
public void RegisterOnRelease(Keys key, IButtonInputs<Keys>.ButtonCallbackEventHandler callback)
|
||||
{
|
||||
if (OnReleased.TryGetValue(key, out var action))
|
||||
{
|
||||
action += callback;
|
||||
return;
|
||||
}
|
||||
|
||||
OnReleased.Add(key, callback);
|
||||
}
|
||||
|
||||
public void UnregisterOnRelease(Keys key, IButtonInputs<Keys>.ButtonCallbackEventHandler callback)
|
||||
{
|
||||
if (OnReleased.TryGetValue(key, out var action))
|
||||
action -= callback;
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
KeyboardState keyboardState = Keyboard.GetState();
|
||||
keyboardState.GetPressedKeys(cachePressedCurrently);
|
||||
cachePressedCurrentlyCount = keyboardState.GetPressedKeyCount();
|
||||
|
||||
for (int i = 0; i < cachePressedCurrentlyCount; i++)
|
||||
{
|
||||
Keys currentlyPressedKey = cachePressedCurrently[i];
|
||||
|
||||
if (!OnPressed.TryGetValue(currentlyPressedKey, out var action))
|
||||
continue;
|
||||
|
||||
if (WasPressed(currentlyPressedKey))
|
||||
continue;
|
||||
|
||||
action.Invoke(this, currentlyPressedKey);
|
||||
OnAnyButtonPressed?.Invoke(this, currentlyPressedKey);
|
||||
}
|
||||
|
||||
for (int i = 0; i < cachePressedPreviouslyCount; i++)
|
||||
{
|
||||
Keys previouslyPressedKey = cachePressedPreviously[i];
|
||||
|
||||
if (!OnReleased.TryGetValue(previouslyPressedKey, out var action))
|
||||
continue;
|
||||
|
||||
if (IsPressed(previouslyPressedKey))
|
||||
continue;
|
||||
|
||||
action.Invoke(this, previouslyPressedKey);
|
||||
OnAnyButtonReleased?.Invoke(this, previouslyPressedKey);
|
||||
}
|
||||
|
||||
Array.Copy(cachePressedCurrently, cachePressedPreviously, cachePressedCurrentlyCount);
|
||||
cachePressedPreviouslyCount = cachePressedCurrentlyCount;
|
||||
}
|
||||
|
||||
public bool IsPressed(Keys key)
|
||||
{
|
||||
for (int i = 0; i < cachePressedCurrentlyCount; i++)
|
||||
if (cachePressedCurrently[i] == key)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool WasPressed(Keys key)
|
||||
{
|
||||
for (int i = 0; i < cachePressedPreviouslyCount; i++)
|
||||
if (cachePressedPreviously[i] == key)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
7
Platforms/Desktop/Program.cs
Normal file
7
Platforms/Desktop/Program.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Pong.Platforms.Desktop;
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
Syntriax.Engine.Core.Abstract.IHierarchyObject hierarchyObject = Syntriax.Engine.Core.Factory.HierarchyObjectFactory.Instantiate().SetHierarchyObject("Desktop HO");
|
||||
hierarchyObject.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
||||
using var game = new Pong.GamePong(hierarchyObject);
|
||||
game.Run();
|
43
Platforms/Desktop/app.manifest
Normal file
43
Platforms/Desktop/app.manifest
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="Desktop"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on and is
|
||||
is designed to work with. Uncomment the appropriate elements and Windows will
|
||||
automatically selected the most compatible environment. -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
</assembly>
|
Reference in New Issue
Block a user