Skip to content

Commit

Permalink
chore: imguinet is ran only on debug
Browse files Browse the repository at this point in the history
  • Loading branch information
cherrynik committed Oct 31, 2023
1 parent a013d92 commit 46c0eb0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// using Features.Debugging;
using LightInject;
using MonoGame.ImGuiNet;

namespace GameDesktop.CompositionRoots.DebugFeatures;

Expand All @@ -13,6 +14,8 @@ public void Compose(IServiceRegistry serviceRegistry)

private static void RegisterSystems(IServiceRegistry serviceRegistry)
{
serviceRegistry.RegisterSingleton(factory => new ImGuiRenderer(factory.GetInstance<Game>()));

// serviceRegistry.RegisterSingleton(factory =>
// {
// return new DrawRectangleCollisionComponentsSystem(factory.GetInstance<ILogger>());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using GameDesktop.Resources.Internal;
using LightInject;
using Microsoft.Xna.Framework;
using MonoGame.ImGuiNet;
using Serilog;

namespace GameDesktop.CompositionRoots;
Expand Down
15 changes: 12 additions & 3 deletions src/Apps/GameDesktop/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Components.Tags;
using Entities;
using GameDesktop.CompositionRoots.Features;
using ImGuiNET;
using MonoGame.ImGuiNet;
using LightInject;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
Expand All @@ -17,9 +19,11 @@ public class Game : Microsoft.Xna.Framework.Game
private readonly ILogger _logger;
private readonly IServiceContainer _container;

private ImGuiRenderer _guiRenderer;
private SpriteBatch _spriteBatch;

// TODO: Frames updating

// https://gafferongames.com/post/fix_your_timestep/
// https://lajbert.wordpress.com/2021/05/02/fix-your-timestep-in-monogame/

Expand Down Expand Up @@ -64,9 +68,6 @@ protected override void LoadContent()
var dummy = _container.GetInstance<DummyEntity>();
dummy.Create(@in: world);

// _logger.ForContext<Game>().Verbose(e.ToString()!);
// _logger.ForContext<Game>().Verbose(e2.ToString()!);

_logger.ForContext<Game>().Verbose("LoadContent(): end");
}

Expand Down Expand Up @@ -110,6 +111,14 @@ protected override void Draw(GameTime gameTime)
GraphicsDevice.Clear(Color.CornflowerBlue);

base.Draw(gameTime);

#if DEBUG
_guiRenderer.BeginLayout(gameTime);

ImGui.Text("Hi!");

_guiRenderer.EndLayout();
#endif
}

protected override void Dispose(bool disposing)
Expand Down
1 change: 1 addition & 0 deletions src/Libs/Systems.Debugging/EntitiesList.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Components.Data;
using ImGuiNET;
using Scellecs.Morpeh;

namespace Systems.Debugging;
Expand Down
1 change: 1 addition & 0 deletions src/Libs/Systems.Debugging/Systems.Debugging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<ItemGroup>
<ProjectReference Include="..\Components\Components.csproj" />
<ProjectReference Include="..\External\MonoGame.ImGuiNet\Monogame.ImGuiNet.csproj" />
</ItemGroup>

</Project>

0 comments on commit 46c0eb0

Please sign in to comment.