Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Hezeru/Game1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
36 changes: 25 additions & 11 deletions KeplerEngine/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

/// <summary>
Expand All @@ -21,19 +24,25 @@ public class Globals
/// <summary>
/// VisibleRenderTargetBounds: the rectangle (in native render-target coordinates)
/// that is currently visible on screen after scaling (useful for anchoring)
/// </summary>
// </summary>
public static Rectangle VisibleRenderTargetBounds { get; set; } = Rectangle.Empty;

/// <summary>
/// Rectangle (in window coordinates) where the RenderTarget is drawn
/// </summary>
public static Rectangle RenderTargetDisplayRect { get; set; } = Rectangle.Empty;

/// <summary>
/// The default Kepler Engine's Gum service
/// </summary>
public static GumService GumUI { get; } = GumService.Default;


/// <summary>
/// Returns the visible render target bounds if they're not empty.
/// Otherwise, returns the bounds of the original render target.
/// </summary>
public static Rectangle GetVisibleRenderTargetBounds() {
public static Rectangle GetVisibleRenderTargetBounds()
{
var visible = Globals.VisibleRenderTargetBounds;
if (visible == Rectangle.Empty)
visible = Globals.RenderTarget.Bounds;
Expand All @@ -54,8 +63,8 @@ public enum ScalingMode
Contain,

/// <summary>
/// Fill window, may crop.
/// </summary>
/// Fi
// </summary>
Cover,

/// <summary>
Expand All @@ -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; }
Expand All @@ -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;
Expand All @@ -93,8 +106,8 @@ public static void Update(GameTime gameTime)
Keyboard.Update();
Mouse.Update();
Touch.Update();

SceneManager.GetCurrentScene().Update();
GumUI.Update(gameTime);

OnUpdate(gameTime);
}
Expand All @@ -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<GameTime> OnUpdate = (gt) => {};
public static Action<GameTime> OnRender = (gt) => {};
}
}
1 change: 1 addition & 0 deletions KeplerEngine/KeplerEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Gum.MonoGame" Version="2026.1.12.1" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
Expand Down