diff --git a/AndroidTests/Activity1.cs b/AndroidTests/Activity1.cs
deleted file mode 100644
index cf60926..0000000
--- a/AndroidTests/Activity1.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Android.App;
-using Android.Content.PM;
-using Android.OS;
-using Android.Views;
-
-namespace AndroidTests {
- [Activity(Label = "AndroidTests"
- , MainLauncher = true
- , Icon = "@drawable/icon"
- , Theme = "@style/Theme.Splash"
- , AlwaysRetainTaskState = true
- , LaunchMode = LaunchMode.SingleInstance
- , ScreenOrientation = ScreenOrientation.UserLandscape
- , ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize)]
- public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity {
-
- protected override void OnCreate(Bundle bundle) {
- base.OnCreate(bundle);
- var g = new GameImpl();
- this.SetContentView((View) g.Services.GetService(typeof(View)));
- g.Run();
- }
-
- }
-}
\ No newline at end of file
diff --git a/AndroidTests/AndroidTests.csproj b/AndroidTests/AndroidTests.csproj
deleted file mode 100644
index 9c259f5..0000000
--- a/AndroidTests/AndroidTests.csproj
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- 8.0.30703
- 2.0
- {410C0262-131C-4D0E-910D-D01B4F7143E0}
- {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- Library
- Properties
- 512
- true
- Resources\Resource.Designer.cs
- Off
- armeabi-v7a;x86
- .m4a
-
- v9.0
- Android
- Properties\AndroidManifest.xml
- True
- AndroidTests
-
-
- true
- full
- false
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;ANDROID
- prompt
- 4
- True
- None
-
-
- pdbonly
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;ANDROID
- prompt
- 4
- False
- SdkOnly
-
-
-
- ..\packages\Coroutine.1.0.1\lib\netstandard2.0\Coroutine.dll
- True
-
-
-
- ..\packages\MonoGame.Extended.3.7.0\lib\netstandard2.0\MonoGame.Extended.dll
- True
-
-
-
- ..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll
- True
-
-
-
-
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Android\MonoGame.Framework.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {232a6513-a28c-4d7f-ba5a-89281bfc1538}
- MLEM.Extended
-
-
- {997f4739-7bec-4621-b9ca-68deb2d74412}
- MLEM.Startup
-
-
- {6f00629a-8b87-4264-8896-19983285e32f}
- MLEM.Ui
-
-
- {1d6ab762-43c4-4775-8924-707c7ec3f142}
- MLEM
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/AndroidTests/Content/Content.mgcb b/AndroidTests/Content/Content.mgcb
deleted file mode 100644
index e25af4b..0000000
--- a/AndroidTests/Content/Content.mgcb
+++ /dev/null
@@ -1,34 +0,0 @@
-
-#----------------------------- Global Properties ----------------------------#
-
-/outputDir:bin/$(Platform)
-/intermediateDir:obj/$(Platform)
-/platform:Android
-/config:
-/profile:Reach
-/compress:False
-
-#-------------------------------- References --------------------------------#
-
-
-#---------------------------------- Content ---------------------------------#
-
-#begin Textures/Test.png
-/importer:TextureImporter
-/processor:TextureProcessor
-/processorParam:ColorKeyColor=255,0,255,255
-/processorParam:ColorKeyEnabled=True
-/processorParam:GenerateMipmaps=False
-/processorParam:PremultiplyAlpha=True
-/processorParam:ResizeToPowerOfTwo=False
-/processorParam:MakeSquare=False
-/processorParam:TextureFormat=Color
-/build:Textures/Test.png
-
-#begin Fonts/TestFont.spritefont
-/importer:FontDescriptionImporter
-/processor:FontDescriptionProcessor
-/processorParam:PremultiplyAlpha=True
-/processorParam:TextureFormat=Compressed
-/build:Fonts/TestFont.spritefont
-
diff --git a/AndroidTests/Content/Fonts/TestFont.spritefont b/AndroidTests/Content/Fonts/TestFont.spritefont
deleted file mode 100644
index 54ab9ac..0000000
--- a/AndroidTests/Content/Fonts/TestFont.spritefont
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
- Arial
-
-
- 32
-
-
- 0
-
-
- true
-
-
-
-
-
- *
-
-
-
-
-
- ɏ
-
-
-
-
diff --git a/AndroidTests/Content/Textures/Test.png b/AndroidTests/Content/Textures/Test.png
deleted file mode 100644
index 7d88c33..0000000
Binary files a/AndroidTests/Content/Textures/Test.png and /dev/null differ
diff --git a/AndroidTests/GameImpl.cs b/AndroidTests/GameImpl.cs
deleted file mode 100644
index 738ac56..0000000
--- a/AndroidTests/GameImpl.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using MLEM.Font;
-using MLEM.Startup;
-using MLEM.Textures;
-using MLEM.Ui;
-using MLEM.Ui.Elements;
-using MLEM.Ui.Style;
-
-namespace AndroidTests {
- public class GameImpl : MlemGame {
-
- protected override void LoadContent() {
- base.LoadContent();
- var tex = LoadContent("Textures/Test");
- var style = new UntexturedStyle(this.SpriteBatch) {
- Font = new GenericSpriteFont(LoadContent("Fonts/TestFont")),
- TextScale = 0.1F,
- PanelTexture = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8),
- ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4),
- TextFieldTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4),
- ScrollBarBackground = new NinePatch(new TextureRegion(tex, 12, 0, 4, 8), 1, 1, 2, 2),
- ScrollBarScrollerTexture = new NinePatch(new TextureRegion(tex, 8, 0, 4, 8), 1, 1, 2, 2),
- CheckboxTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4),
- CheckboxCheckmark = new TextureRegion(tex, 24, 0, 8, 8),
- RadioTexture = new NinePatch(new TextureRegion(tex, 16, 0, 8, 8), 3),
- RadioCheckmark = new TextureRegion(tex, 32, 0, 8, 8)
- };
- this.UiSystem.Style = style;
- this.UiSystem.GlobalScale = 15;
- this.UiSystem.AutoScaleWithScreen = true;
-
- var panel = new Panel(Anchor.Center, new Vector2(100, 50), Vector2.Zero, false, true, new Point(5, 10));
- this.UiSystem.Add("Panel", panel);
- panel.AddChild(new Paragraph(Anchor.AutoLeft, 1, "I am Android"));
-
- var image = new Image(Anchor.AutoCenter, new Vector2(50, 50), new TextureRegion(tex, 0, 0, 8, 8)) {IsHidden = true};
- panel.AddChild(image);
- panel.AddChild(new Button(Anchor.AutoCenter, new Vector2(0.5F, 10), "Toggle Image") {
- OnPressed = element => image.IsHidden = !image.IsHidden
- });
-
- panel.AddChild(new TextField(Anchor.AutoLeft, new Vector2(1, 10)) {PlaceholderText = "Tap to type"});
-
- panel.AddChild(new Paragraph(Anchor.AutoLeft, 1, "Here is some text that makes it so that the panel is actually long enough for me to try out the scroll behavior."));
- panel.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 10), 5, 100));
-
- panel.AddChild(new Paragraph(Anchor.AutoLeft, 1, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sapien elit, congue sit amet condimentum in, hendrerit iaculis leo. Phasellus mollis turpis felis, ac finibus elit tincidunt quis. Vestibulum maximus, velit non consequat porttitor, quam diam consequat eros, in cursus nunc mi id dui. Vivamus semper neque at feugiat semper. Nunc ultrices egestas placerat. Proin lectus felis, rutrum quis porta vel, eleifend eget eros. Morbi porttitor massa finibus felis vestibulum, quis faucibus dui volutpat. Nam enim mi, euismod a pharetra vel, suscipit eu tortor. Integer vehicula ligula at consectetur dictum. Etiam fringilla volutpat est, id egestas nunc. Maecenas turpis felis, eleifend non felis a, fringilla lobortis nibh. Morbi rhoncus vestibulum dignissim. Ut posuere nulla ipsum, non condimentum dui posuere sit amet."));
- }
-
- protected override void DoDraw(GameTime gameTime) {
- this.GraphicsDevice.Clear(Color.CornflowerBlue);
- base.DoDraw(gameTime);
- }
-
- }
-}
\ No newline at end of file
diff --git a/AndroidTests/Properties/AndroidManifest.xml b/AndroidTests/Properties/AndroidManifest.xml
deleted file mode 100644
index e775002..0000000
--- a/AndroidTests/Properties/AndroidManifest.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/AndroidTests/Properties/AssemblyInfo.cs b/AndroidTests/Properties/AssemblyInfo.cs
deleted file mode 100644
index 1224698..0000000
--- a/AndroidTests/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using Android.App;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("AndroidTests")]
-[assembly: AssemblyProduct("AndroidTests")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyCopyright("Copyright © 2017")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("6f377592-2266-4c47-855e-6260ff75e1f4")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
-
-// Add some common permissions, these can be removed if not needed
-[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
-[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
\ No newline at end of file
diff --git a/AndroidTests/Resources/Drawable/Icon.png b/AndroidTests/Resources/Drawable/Icon.png
deleted file mode 100644
index f6f4f41..0000000
Binary files a/AndroidTests/Resources/Drawable/Icon.png and /dev/null differ
diff --git a/AndroidTests/Resources/Drawable/Splash.png b/AndroidTests/Resources/Drawable/Splash.png
deleted file mode 100644
index 2f86107..0000000
Binary files a/AndroidTests/Resources/Drawable/Splash.png and /dev/null differ
diff --git a/AndroidTests/Resources/Resource.Designer.cs b/AndroidTests/Resources/Resource.Designer.cs
deleted file mode 100644
index 52ce691..0000000
--- a/AndroidTests/Resources/Resource.Designer.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-#pragma warning disable 1591
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-[assembly: global::Android.Runtime.ResourceDesignerAttribute("AndroidTests.Resource", IsApplication=true)]
-
-namespace AndroidTests
-{
-
-
- [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
- public partial class Resource
- {
-
- static Resource()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- public static void UpdateIdValues()
- {
- }
-
- public partial class Attribute
- {
-
- static Attribute()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- private Attribute()
- {
- }
- }
-
- public partial class Drawable
- {
-
- // aapt resource value: 0x7f020000
- public const int Icon = 2130837504;
-
- // aapt resource value: 0x7f020001
- public const int Splash = 2130837505;
-
- static Drawable()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- private Drawable()
- {
- }
- }
-
- public partial class String
- {
-
- // aapt resource value: 0x7f030001
- public const int ApplicationName = 2130903041;
-
- // aapt resource value: 0x7f030000
- public const int Hello = 2130903040;
-
- static String()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- private String()
- {
- }
- }
-
- public partial class Style
- {
-
- // aapt resource value: 0x7f040000
- public const int Theme_Splash = 2130968576;
-
- static Style()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- private Style()
- {
- }
- }
- }
-}
-#pragma warning restore 1591
diff --git a/AndroidTests/Resources/Values/Strings.xml b/AndroidTests/Resources/Values/Strings.xml
deleted file mode 100644
index 7448bbf..0000000
--- a/AndroidTests/Resources/Values/Strings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- Hello World, Click Me!
- AndroidTests
-
diff --git a/AndroidTests/Resources/Values/Styles.xml b/AndroidTests/Resources/Values/Styles.xml
deleted file mode 100644
index 5102134..0000000
--- a/AndroidTests/Resources/Values/Styles.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
diff --git a/AndroidTests/packages.config b/AndroidTests/packages.config
deleted file mode 100644
index 003ddcd..0000000
--- a/AndroidTests/packages.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Demos/AnimationDemo.cs b/Demos/AnimationDemo.cs
index 4168dbf..c838d19 100644
--- a/Demos/AnimationDemo.cs
+++ b/Demos/AnimationDemo.cs
@@ -7,12 +7,15 @@ using MLEM.Startup;
using MLEM.Textures;
namespace Demos {
- public class AnimationDemo : MlemGame {
+ public class AnimationDemo : Demo {
private SpriteAnimationGroup group;
private int facing;
- protected override void LoadContent() {
+ public AnimationDemo(MlemGame game) : base(game) {
+ }
+
+ public override void LoadContent() {
base.LoadContent();
var tex = LoadContent("Textures/Anim");
@@ -37,7 +40,7 @@ namespace Demos {
// you can also add a priority to an animation in the group (10 in this case, which is higher than the default of 0)
// if two animations' playing conditions are both true, then the one with the higher priority will be picked to play
// in this instance, a standing "animation" is displayed when we're facing down and also holding the space key
- this.group.Add(new SpriteAnimation(1F, tex, new Rectangle(0, 0, 8, 8)) {Name = "DownStanding"}, () => this.facing == 0 && Input.IsKeyDown(Keys.Space), 10);
+ this.group.Add(new SpriteAnimation(1F, tex, new Rectangle(0, 0, 8, 8)) {Name = "DownStanding"}, () => this.facing == 0 && this.InputHandler.IsKeyDown(Keys.Space), 10);
// you can also add a callback to see when the animation used changes
this.group.OnAnimationChanged += (anim, newAnim) => {
@@ -45,7 +48,7 @@ namespace Demos {
};
}
- protected override void Update(GameTime gameTime) {
+ public override void Update(GameTime gameTime) {
base.Update(gameTime);
if (this.InputHandler.IsKeyDown(Keys.Down))
@@ -62,7 +65,7 @@ namespace Demos {
this.group.Update(gameTime);
}
- protected override void DoDraw(GameTime gameTime) {
+ public override void DoDraw(GameTime gameTime) {
this.GraphicsDevice.Clear(Color.Black);
this.SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(10));
diff --git a/Demos/AutoTilingDemo.cs b/Demos/AutoTilingDemo.cs
index 37521c3..711259e 100644
--- a/Demos/AutoTilingDemo.cs
+++ b/Demos/AutoTilingDemo.cs
@@ -7,12 +7,15 @@ namespace Demos {
///
/// This is a demo for .
///
- public class AutoTilingDemo : MlemGame {
+ public class AutoTilingDemo : Demo {
private Texture2D texture;
private string[] layout;
- protected override void LoadContent() {
+ public AutoTilingDemo(MlemGame game) : base(game) {
+ }
+
+ public override void LoadContent() {
base.LoadContent();
// The layout of the texture is important for auto tiling to work correctly.
// It needs to be laid out as follows: Five tiles aligned horizontally within the texture file, with the following information
@@ -35,7 +38,7 @@ namespace Demos {
};
}
- protected override void DoDraw(GameTime gameTime) {
+ public override void DoDraw(GameTime gameTime) {
this.GraphicsDevice.Clear(Color.Black);
// the texture region supplied to the AutoTiling method should only encompass the first filler tile's location and size
diff --git a/Demos/Demo.cs b/Demos/Demo.cs
new file mode 100644
index 0000000..be050da
--- /dev/null
+++ b/Demos/Demo.cs
@@ -0,0 +1,37 @@
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using MLEM.Input;
+using MLEM.Startup;
+using MLEM.Ui;
+
+namespace Demos {
+ public class Demo {
+
+ public readonly MlemGame Game;
+ public SpriteBatch SpriteBatch => this.Game.SpriteBatch;
+ public GraphicsDevice GraphicsDevice => this.Game.GraphicsDevice;
+ public InputHandler InputHandler => this.Game.InputHandler;
+ public UiSystem UiSystem => this.Game.UiSystem;
+
+ public Demo(MlemGame game) {
+ this.Game = game;
+ }
+
+ public virtual void LoadContent() {
+ }
+
+ public virtual void Update(GameTime time) {
+ }
+
+ public virtual void DoDraw(GameTime time) {
+ }
+
+ public virtual void Clear() {
+ }
+
+ public static T LoadContent(string name) {
+ return MlemGame.LoadContent(name);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Demos/Demos.csproj b/Demos/Demos.csproj
index b0fecce..6ee6d31 100644
--- a/Demos/Demos.csproj
+++ b/Demos/Demos.csproj
@@ -1,8 +1,7 @@
- Exe
- net462
+ netstandard2.0
@@ -13,13 +12,9 @@
-
-
-
-
-
-
-
+
+ all
+
diff --git a/Demos/GameImpl.cs b/Demos/GameImpl.cs
new file mode 100644
index 0000000..38c5b40
--- /dev/null
+++ b/Demos/GameImpl.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using MLEM.Font;
+using MLEM.Startup;
+using MLEM.Textures;
+using MLEM.Ui;
+using MLEM.Ui.Elements;
+using MLEM.Ui.Style;
+
+namespace Demos {
+ public class GameImpl : MlemGame {
+
+ private static readonly Dictionary> Demos = new Dictionary>();
+ private Demo activeDemo;
+
+ static GameImpl() {
+ Demos.Add("Ui", game => new UiDemo(game));
+ Demos.Add("Animation", game => new AnimationDemo(game));
+ Demos.Add("AutoTiling", game => new AutoTilingDemo(game));
+ Demos.Add("Pathfinding", game => new PathfindingDemo(game));
+ }
+
+ public GameImpl() {
+ this.IsMouseVisible = true;
+ }
+
+ protected override void LoadContent() {
+ base.LoadContent();
+
+ var tex = LoadContent("Textures/Test");
+ this.UiSystem.Style = new UntexturedStyle(this.SpriteBatch) {
+ Font = new GenericSpriteFont(LoadContent("Fonts/TestFont")),
+ TextScale = 0.1F,
+ PanelTexture = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8),
+ ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4),
+ ScrollBarBackground = new NinePatch(new TextureRegion(tex, 12, 0, 4, 8), 1, 1, 2, 2),
+ ScrollBarScrollerTexture = new NinePatch(new TextureRegion(tex, 8, 0, 4, 8), 1, 1, 2, 2),
+ };
+ this.UiSystem.AutoScaleReferenceSize = new Point(1280, 720);
+ this.UiSystem.AutoScaleWithScreen = true;
+ this.UiSystem.GlobalScale = 5;
+
+ var selection = new Panel(Anchor.Center, new Vector2(100, 80), Vector2.Zero, false, true, new Point(5, 10));
+ this.UiSystem.Add("DemoSelection", selection);
+
+ var backButton = new Button(Anchor.TopRight, new Vector2(30, 10), "Back") {
+ OnPressed = e => {
+ this.activeDemo.Clear();
+ this.activeDemo = null;
+ this.UiSystem.Remove("BackButton");
+ this.UiSystem.Add("DemoSelection", selection);
+ }
+ };
+
+ selection.AddChild(new Paragraph(Anchor.AutoLeft, 1, "Select the demo you want to see below. Check the demos' source code for more in-depth explanations of their functionality."));
+ selection.AddChild(new VerticalSpace(5));
+ foreach (var demo in Demos) {
+ selection.AddChild(new Button(Anchor.AutoCenter, new Vector2(1, 10), demo.Key) {
+ OnPressed = e => {
+ this.UiSystem.Remove("DemoSelection");
+ this.UiSystem.Add("BackButton", backButton);
+
+ this.activeDemo = demo.Value.Invoke(this);
+ this.activeDemo.LoadContent();
+ },
+ PositionOffset = new Vector2(0, 1)
+ });
+ }
+ }
+
+ protected override void DoDraw(GameTime gameTime) {
+ if (this.activeDemo != null) {
+ this.activeDemo.DoDraw(gameTime);
+ } else {
+ this.GraphicsDevice.Clear(Color.CornflowerBlue);
+ }
+ base.DoDraw(gameTime);
+ }
+
+ protected override void Update(GameTime gameTime) {
+ base.Update(gameTime);
+ if (this.activeDemo != null)
+ this.activeDemo.Update(gameTime);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Demos/PathfindingDemo.cs b/Demos/PathfindingDemo.cs
index 770e6a2..c0ab53e 100644
--- a/Demos/PathfindingDemo.cs
+++ b/Demos/PathfindingDemo.cs
@@ -10,12 +10,16 @@ using MLEM.Startup;
using MonoGame.Extended;
namespace Demos {
- public class PathfindingDemo : MlemGame {
+ public class PathfindingDemo : Demo {
private bool[,] world;
private AStar2 pathfinder;
private List path;
+ public PathfindingDemo(MlemGame game) : base(game) {
+
+ }
+
private void Init() {
// generate a simple random world for testing, where true is walkable area, and false is a wall
var random = new Random();
@@ -53,21 +57,21 @@ namespace Demos {
Console.WriteLine("Couldn't find a path, press the left mouse button to try again");
}
- protected override void LoadContent() {
+ public override void LoadContent() {
base.LoadContent();
this.Init();
}
- protected override void Update(GameTime gameTime) {
+ public override void Update(GameTime gameTime) {
base.Update(gameTime);
// when pressing the left mouse button, generate a new world and find a new path
- if (Input.IsMouseButtonPressed(MouseButton.Left)) {
+ if (this.InputHandler.IsMouseButtonPressed(MouseButton.Left)) {
this.Init();
}
}
- protected override void DoDraw(GameTime gameTime) {
+ public override void DoDraw(GameTime gameTime) {
this.GraphicsDevice.Clear(Color.White);
this.SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(14));
diff --git a/Demos/Program.cs b/Demos/Program.cs
deleted file mode 100644
index 50716e3..0000000
--- a/Demos/Program.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.Xna.Framework;
-
-namespace Demos {
- public static class Program {
-
- private static readonly Dictionary> Demos = new Dictionary>();
-
- static Program() {
- Demos.Add("Ui", () => new UiDemo());
- Demos.Add("AutoTiling", () => new AutoTilingDemo());
- Demos.Add("Animation", () => new AnimationDemo());
- Demos.Add("Pathfinding", () => new PathfindingDemo());
- }
-
- public static void Main(string[] args) {
- Func demoUsed;
- if (args.Length <= 0 || !Demos.ContainsKey(args[0])) {
- beforeDemo:
- Console.WriteLine("Please type the name of the demo you want to see and press Enter.");
- Console.WriteLine("The following demos are available: " + string.Join(", ", Demos.Keys));
- Console.WriteLine("(Alternatively, you can supply the name of the demo you want to see as the first argument)");
- var demo = Console.ReadLine();
- if (!Demos.ContainsKey(demo)) {
- Console.WriteLine("Not a valid demo.");
- goto beforeDemo;
- } else {
- demoUsed = Demos[demo];
- }
- } else {
- demoUsed = Demos[args[0]];
- }
-
- using (var game = demoUsed.Invoke())
- game.Run();
- }
-
- }
-}
\ No newline at end of file
diff --git a/Demos/UiDemo.cs b/Demos/UiDemo.cs
index 322a608..b93f70a 100644
--- a/Demos/UiDemo.cs
+++ b/Demos/UiDemo.cs
@@ -22,16 +22,15 @@ namespace Demos {
/// - Call the instance's DrawEarly method before clearing your
/// - Call the instance's Draw method in your game's Draw method
///
- public class UiDemo : MlemGame {
+ public class UiDemo : Demo {
private Texture2D testTexture;
private NinePatch testPatch;
- public UiDemo() {
- this.IsMouseVisible = true;
+ public UiDemo(MlemGame game) : base(game) {
}
- protected override void LoadContent() {
+ public override void LoadContent() {
this.testTexture = LoadContent("Textures/Test");
this.testPatch = new NinePatch(new TextureRegion(this.testTexture, 0, 8, 24, 24), 8);
base.LoadContent();
@@ -55,7 +54,7 @@ namespace Demos {
RadioTexture = new NinePatch(new TextureRegion(this.testTexture, 16, 0, 8, 8), 3),
RadioCheckmark = new TextureRegion(this.testTexture, 32, 0, 8, 8)
};
- var untexturedStyle = this.UiSystem.Style;
+ var untexturedStyle = new UntexturedStyle(this.SpriteBatch);
// set the defined style as the current one
this.UiSystem.Style = style;
// scale every ui up by 5
@@ -200,7 +199,12 @@ namespace Demos {
button.AddedDisplayOffset = Vector2.Zero;
}
- protected override void DoDraw(GameTime gameTime) {
+ public override void Clear() {
+ this.UiSystem.Remove("Test");
+ this.UiSystem.Remove("TestTooltip");
+ }
+
+ public override void DoDraw(GameTime gameTime) {
this.GraphicsDevice.Clear(Color.CornflowerBlue);
base.DoDraw(gameTime);
}
diff --git a/MLEM.sln b/MLEM.sln
index 66892c2..c98fe0f 100644
--- a/MLEM.sln
+++ b/MLEM.sln
@@ -10,7 +10,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos", "Demos\Demos.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Ui", "MLEM.Ui\MLEM.Ui.csproj", "{6F00629A-8B87-4264-8896-19983285E32F}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidTests", "AndroidTests\AndroidTests.csproj", "{410C0262-131C-4D0E-910D-D01B4F7143E0}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.DesktopGL", "Demos.DesktopGL\Demos.DesktopGL.csproj", "{468A868F-FB75-4D48-BC03-6F9FCDB014C9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.Android", "AndroidDemos\Demos.Android.csproj", "{410C0262-131C-4D0E-910D-D01B4F7143E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -38,6 +40,10 @@ Global
{6F00629A-8B87-4264-8896-19983285E32F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F00629A-8B87-4264-8896-19983285E32F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F00629A-8B87-4264-8896-19983285E32F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {468A868F-FB75-4D48-BC03-6F9FCDB014C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {468A868F-FB75-4D48-BC03-6F9FCDB014C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {468A868F-FB75-4D48-BC03-6F9FCDB014C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {468A868F-FB75-4D48-BC03-6F9FCDB014C9}.Release|Any CPU.Build.0 = Release|Any CPU
{410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.ActiveCfg = Release|Any CPU