mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
added mlem.startup
This commit is contained in:
parent
edb9b76f9d
commit
28e7584006
4 changed files with 104 additions and 0 deletions
|
@ -21,4 +21,8 @@
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MLEM\MLEM.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
30
MLEM.Startup/MLEM.Startup.csproj
Normal file
30
MLEM.Startup/MLEM.Startup.csproj
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Authors>Ellpeck</Authors>
|
||||||
|
<Description>A startup GameImpl class that uses (M)LEM (L)ibrary by (E)llpeck for (M)onoGame as well as some other useful stuff</Description>
|
||||||
|
<PackageTags>monogame ellpeck mlem utility extensions</PackageTags>
|
||||||
|
<PackageProjectUrl>https://github.com/Ellpeck/MLEM</PackageProjectUrl>
|
||||||
|
<RepositoryUrl>https://github.com/Ellpeck/MLEM</RepositoryUrl>
|
||||||
|
<PackageLicenseUrl>https://github.com/Ellpeck/MLEM/blob/master/LICENSE</PackageLicenseUrl>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Coroutine" Version="1.0.1"/>
|
||||||
|
<PackageReference Include="MonoGame.Extended" Version="3.6.0-beta0001"/>
|
||||||
|
<PackageReference Include="MonoGame.Extended.Input" Version="3.6.0-beta0001"/>
|
||||||
|
<PackageReference Include="MonoGame.Framework.Portable" Version="3.7.0.1708">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MLEM.Extended\MLEM.Extended.csproj"/>
|
||||||
|
<ProjectReference Include="..\MLEM\MLEM.csproj"/>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
64
MLEM.Startup/MlemGame.cs
Normal file
64
MLEM.Startup/MlemGame.cs
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
using Coroutine;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
using MonoGame.Extended;
|
||||||
|
using MonoGame.Extended.Input;
|
||||||
|
|
||||||
|
namespace MLEM.Startup {
|
||||||
|
public class MlemGame : Game {
|
||||||
|
|
||||||
|
private static MlemGame instance;
|
||||||
|
public static KeyboardStateExtended Keyboard => instance.keyboardState;
|
||||||
|
public static MouseStateExtended Mouse => instance.mouseState;
|
||||||
|
|
||||||
|
public readonly GraphicsDeviceManager GraphicsDeviceManager;
|
||||||
|
public SpriteBatch SpriteBatch { get; private set; }
|
||||||
|
|
||||||
|
private KeyboardStateExtended keyboardState;
|
||||||
|
private MouseStateExtended mouseState;
|
||||||
|
|
||||||
|
public MlemGame(int windowWidth = 1280, int windowHeight = 720, bool vsync = false, bool allowResizing = true, string contentDir = "Content") {
|
||||||
|
instance = this;
|
||||||
|
this.GraphicsDeviceManager = new GraphicsDeviceManager(this) {
|
||||||
|
PreferredBackBufferWidth = windowWidth,
|
||||||
|
PreferredBackBufferHeight = windowHeight,
|
||||||
|
SynchronizeWithVerticalRetrace = vsync
|
||||||
|
};
|
||||||
|
this.Content.RootDirectory = contentDir;
|
||||||
|
|
||||||
|
this.Window.AllowUserResizing = allowResizing;
|
||||||
|
this.Window.ClientSizeChanged += (win, args) => this.OnWindowSizeChange(this.GraphicsDevice.Viewport);
|
||||||
|
this.Window.TextInput += (win, args) => this.OnTextInput(args.Key, args.Character);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnWindowSizeChange(Viewport viewport) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnTextInput(Keys key, char character) {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadContent() {
|
||||||
|
this.SpriteBatch = new SpriteBatch(this.GraphicsDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Initialize() {
|
||||||
|
base.Initialize();
|
||||||
|
this.OnWindowSizeChange(this.GraphicsDevice.Viewport);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update(GameTime gameTime) {
|
||||||
|
base.Update(gameTime);
|
||||||
|
|
||||||
|
CoroutineHandler.Tick(gameTime.GetElapsedSeconds());
|
||||||
|
|
||||||
|
this.keyboardState = KeyboardExtended.GetState();
|
||||||
|
this.mouseState = MouseExtended.GetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T LoadContent<T>(string name) {
|
||||||
|
return instance.Content.Load<T>(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
6
MLEM.sln
6
MLEM.sln
|
@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM", "MLEM\MLEM.csproj",
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Extended", "MLEM.Extended\MLEM.Extended.csproj", "{232A6513-A28C-4D7F-BA5A-89281BFC1538}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Extended", "MLEM.Extended\MLEM.Extended.csproj", "{232A6513-A28C-4D7F-BA5A-89281BFC1538}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Startup", "MLEM.Startup\MLEM.Startup.csproj", "{997F4739-7BEC-4621-B9CA-68DEB2D74412}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -18,5 +20,9 @@ Global
|
||||||
{232A6513-A28C-4D7F-BA5A-89281BFC1538}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{232A6513-A28C-4D7F-BA5A-89281BFC1538}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{232A6513-A28C-4D7F-BA5A-89281BFC1538}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{232A6513-A28C-4D7F-BA5A-89281BFC1538}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{232A6513-A28C-4D7F-BA5A-89281BFC1538}.Release|Any CPU.Build.0 = Release|Any CPU
|
{232A6513-A28C-4D7F-BA5A-89281BFC1538}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{997F4739-7BEC-4621-B9CA-68DEB2D74412}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{997F4739-7BEC-4621-B9CA-68DEB2D74412}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{997F4739-7BEC-4621-B9CA-68DEB2D74412}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{997F4739-7BEC-4621-B9CA-68DEB2D74412}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
Loading…
Reference in a new issue