diff --git a/Hezeru/Game1.cs b/Hezeru/Game1.cs index 8b680cd..31809f3 100644 --- a/Hezeru/Game1.cs +++ b/Hezeru/Game1.cs @@ -45,7 +45,8 @@ private void OnWindowResize(object sender, EventArgs e) protected override void Initialize() { - // TODO: Add your initialization logic here + // Initialize Kepler Engine's Gum UI service. + Globals.InitService(this); base.Initialize(); } diff --git a/KeplerEngine/Globals.cs b/KeplerEngine/Globals.cs index 9baecf4..77523c2 100644 --- a/KeplerEngine/Globals.cs +++ b/KeplerEngine/Globals.cs @@ -4,13 +4,16 @@ using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input.Touch; +using MonoGameGum; +using Gum.Forms; +using Gum.Forms.Controls; + namespace KeplerEngine; public class Globals { public static SpriteBatch SpriteBatch { get; set; } - public static RenderTarget2D RenderTarget { get; set; } /// @@ -21,7 +24,7 @@ public class Globals /// /// VisibleRenderTargetBounds: the rectangle (in native render-target coordinates) /// that is currently visible on screen after scaling (useful for anchoring) - /// +// public static Rectangle VisibleRenderTargetBounds { get; set; } = Rectangle.Empty; /// @@ -29,11 +32,17 @@ public class Globals /// public static Rectangle RenderTargetDisplayRect { get; set; } = Rectangle.Empty; + /// + /// The default Kepler Engine's Gum service + /// + public static GumService GumUI { get; } = GumService.Default; + + /// /// Returns the visible render target bounds if they're not empty. /// Otherwise, returns the bounds of the original render target. - /// - public static Rectangle GetVisibleRenderTargetBounds() { + public static Rectangle GetVisibleRenderTargetBounds() + { var visible = Globals.VisibleRenderTargetBounds; if (visible == Rectangle.Empty) visible = Globals.RenderTarget.Bounds; @@ -54,8 +63,8 @@ public enum ScalingMode Contain, /// - /// Fill window, may crop. - /// + /// Fi +// Cover, /// @@ -71,7 +80,6 @@ public enum ScalingMode public static MouseInputHandler Mouse { get; set; } = new MouseInputHandler(); public static TouchInputHandler Touch { get; set; } = new TouchInputHandler(); - public static SceneManager SceneManager { get; set; } = new SceneManager(); public static GameTime UpdateTime { get; set; } @@ -82,6 +90,11 @@ public enum ScalingMode public static ContentManager Content { get; set; } + public static void InitService(Game game) + { + GumUI.Initialize(game, DefaultVisualsVersion.V3); + } + public static void InitTouch() { TouchPanel.EnabledGestures = GestureType.Tap; @@ -93,8 +106,8 @@ public static void Update(GameTime gameTime) Keyboard.Update(); Mouse.Update(); Touch.Update(); - SceneManager.GetCurrentScene().Update(); + GumUI.Update(gameTime); OnUpdate(gameTime); } @@ -104,10 +117,11 @@ public static void Draw(GameTime gameTime) DrawTime = gameTime; DeltaTime = (float)DrawTime.ElapsedGameTime.TotalSeconds; SceneManager.GetCurrentScene().Draw(); + GumUI.Draw(); OnRender(gameTime); - } - + } + public static Action OnUpdate = (gt) => {}; public static Action OnRender = (gt) => {}; -} \ No newline at end of file +} diff --git a/KeplerEngine/KeplerEngine.csproj b/KeplerEngine/KeplerEngine.csproj index cbb91f8..1c9f06b 100644 --- a/KeplerEngine/KeplerEngine.csproj +++ b/KeplerEngine/KeplerEngine.csproj @@ -3,6 +3,7 @@ net8.0 + All