diff --git a/Demos.Android/Activity1.cs b/Demos.Android/Activity1.cs index 8b470b6..da5f6d5 100644 --- a/Demos.Android/Activity1.cs +++ b/Demos.Android/Activity1.cs @@ -18,6 +18,8 @@ namespace AndroidDemos { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var g = new GameImpl(); + // disable mouse handling for android to make emulator behavior more coherent + g.OnLoadContent += game => game.InputHandler.HandleMouse = false; this.SetContentView((View) g.Services.GetService(typeof(View))); g.Run(); } diff --git a/MLEM.Startup/MlemGame.cs b/MLEM.Startup/MlemGame.cs index 6acfea0..ac3238d 100644 --- a/MLEM.Startup/MlemGame.cs +++ b/MLEM.Startup/MlemGame.cs @@ -18,6 +18,10 @@ namespace MLEM.Startup { public InputHandler InputHandler { get; protected set; } public UiSystem UiSystem { get; protected set; } + public GenericCallback OnLoadContent; + public TimeCallback OnUpdate; + public TimeCallback OnDraw; + public MlemGame(int windowWidth = 1280, int windowHeight = 720, bool vsync = false, bool allowResizing = true, string contentDir = "Content") { instance = this; this.GraphicsDeviceManager = new GraphicsDeviceManager(this) { @@ -33,6 +37,7 @@ namespace MLEM.Startup { this.SpriteBatch = new SpriteBatch(this.GraphicsDevice); this.InputHandler = new InputHandler(); this.UiSystem = new UiSystem(this.Window, this.GraphicsDevice, new UntexturedStyle(this.SpriteBatch), this.InputHandler); + this.OnLoadContent?.Invoke(this); } protected override void Update(GameTime gameTime) { @@ -41,6 +46,7 @@ namespace MLEM.Startup { this.InputHandler.Update(); this.UiSystem.Update(gameTime); + this.OnUpdate?.Invoke(this, gameTime); CoroutineHandler.Tick(gameTime.GetElapsedSeconds()); CoroutineHandler.RaiseEvent(CoroutineEvents.Update); } @@ -49,6 +55,7 @@ namespace MLEM.Startup { this.UiSystem.DrawEarly(gameTime, this.SpriteBatch); this.DoDraw(gameTime); this.UiSystem.Draw(gameTime, this.SpriteBatch); + this.OnDraw?.Invoke(this, gameTime); CoroutineHandler.RaiseEvent(CoroutineEvents.Draw); } @@ -60,5 +67,9 @@ namespace MLEM.Startup { return instance.Content.Load(name); } + public delegate void GenericCallback(MlemGame game); + + public delegate void TimeCallback(MlemGame game, GameTime time); + } } \ No newline at end of file