1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 04:53:29 +01:00

added mlem.startup

This commit is contained in:
Ellpeck 2019-08-06 16:33:49 +02:00
parent edb9b76f9d
commit 28e7584006
4 changed files with 104 additions and 0 deletions

View file

@ -21,4 +21,8 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MLEM\MLEM.csproj" />
</ItemGroup>
</Project>

View 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
View 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);
}
}
}

View file

@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM", "MLEM\MLEM.csproj",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Extended", "MLEM.Extended\MLEM.Extended.csproj", "{232A6513-A28C-4D7F-BA5A-89281BFC1538}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Startup", "MLEM.Startup\MLEM.Startup.csproj", "{997F4739-7BEC-4621-B9CA-68DEB2D74412}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
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}.Release|Any CPU.ActiveCfg = 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
EndGlobal