Skip to content

Commit

Permalink
Add monogamedebugger config to template (when monogame and using proj…
Browse files Browse the repository at this point in the history
… refs)
  • Loading branch information
Thraka committed Oct 11, 2023
1 parent f92dfbb commit 903a8b4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace SadConsole.Configuration;

internal static class MonoGameDebuggerExtensions
{
public static Builder KeyhookMonoGameDebugger(this Builder builder)
{
builder.GetOrCreateConfig<MonoGameDebugger>();
return builder;
}

internal static void Game_FrameUpdate(object? sender, GameHost e)
{
if (e.Keyboard.IsKeyPressed(Input.Keys.F12))
{
#if PROJREFS && MONOGAME
SadConsole.Debug.MonoGame.Debugger.Start();
#endif
}
}
}

internal class MonoGameDebugger : IConfigurator
{
public void Run(Builder config, Game game) =>
game.FrameUpdate += MonoGameDebuggerExtensions.Game_FrameUpdate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@
<PropertyGroup>
<!-- Choose which game host you want to use, monogame or sfml. -->
<GameHost>monogame</GameHost>

<!-- Some constants for your game that can detect monogame or sfml. -->
<DefineConstants Condition=" '$(GameHost)' == 'monogame' ">$(DefineConstants);MONOGAME</DefineConstants>
<DefineConstants Condition=" '$(GameHost)' == 'sfml' ">$(DefineConstants);SFML</DefineConstants>

<!-- Use project references instead of NuGet packages. This assumes you're running from the git repo. -->
<!-- Most likely you always want this false. -->
<UseProjectReferences>true</UseProjectReferences>

<!-- Some constants for your game that can detect monogame or sfml. -->
<DefineConstants Condition=" '$(GameHost)' == 'monogame' ">$(DefineConstants);MONOGAME</DefineConstants>
<DefineConstants Condition=" '$(GameHost)' == 'sfml' ">$(DefineConstants);SFML</DefineConstants>
<DefineConstants Condition=" '$(UseProjectReferences)' == 'true' ">$(DefineConstants);PROJREFS</DefineConstants>
</PropertyGroup>

<!-- SadConsole related NuGet packages. -->
<ItemGroup Condition=" '$(UseProjectReferences)' != 'true' ">
<PackageReference Condition=" '$(GameHost)' == 'monogame' " Include="SadConsole.Host.MonoGame" Version="10.0.0-alpha4-debug" />
<PackageReference Condition=" '$(GameHost)' == 'sfml' " Include="SadConsole.Host.SFML" Version="10.0.0-alpha4-debug" />
<PackageReference Include="SadConsole.Extended" Version="10.0.0-alpha4-debug" />
<PackageReference Condition=" '$(GameHost)' == 'monogame' " Include="SadConsole.Host.MonoGame" Version="10.0.0-beta1-debug" />
<PackageReference Condition=" '$(GameHost)' == 'sfml' " Include="SadConsole.Host.SFML" Version="10.0.0-beta1-debug" />
<PackageReference Include="SadConsole.Extended" Version="10.0.0-beta1-debug" />
<PackageReference Include="SadConsole" Version="10.0.0-beta1-debug" />
</ItemGroup>

<!-- MonoGame host requires you to choose which library you want to use. -->
Expand All @@ -44,12 +46,7 @@
<!--<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.1.303" />-->
</ItemGroup>

<!-- If you're using the project references, like when running from the git repo, this section contains those references. -->
<ItemGroup Condition=" '$(UseProjectReferences)' == 'true' ">
<ProjectReference Condition=" '$(GameHost)' == 'monogame' " Include="..\..\..\SadConsole.Host.MonoGame\SadConsole.Host.MonoGame.csproj" />
<ProjectReference Condition=" '$(GameHost)' == 'sfml' " Include="..\..\..\SadConsole.Host.SFML\SadConsole.Host.SFML.csproj" />
<ProjectReference Include="..\..\..\SadConsole.Extended\SadConsole.Extended.csproj" />
</ItemGroup>
<!-- Files related to compiling and running the demos. -->
<ItemGroup>
<None Update="Res\**\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand All @@ -61,4 +58,17 @@
</None>
</ItemGroup>

<!--
The following settings are related to running from the SadConsole git repo and not
related to when you create the project through the template.
-->
<ItemGroup Condition=" '$(UseProjectReferences)' == 'true' ">
<ProjectReference Condition=" '$(GameHost)' == 'monogame' " Include="..\..\..\SadConsole.Host.MonoGame\SadConsole.Host.MonoGame.csproj" />
<ProjectReference Condition=" '$(GameHost)' == 'sfml' " Include="..\..\..\SadConsole.Host.SFML\SadConsole.Host.SFML.csproj" />
<ProjectReference Include="..\..\..\SadConsole.Extended\SadConsole.Extended.csproj" />

<!-- MonoGame Debugging, only available when running from the git repo -->
<ProjectReference Condition=" '$(GameHost)' == 'monogame' " Include="..\..\..\SadConsole.Debug.MonoGame\SadConsole.Debug.MonoGame.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ box so that you can preview each demo object. The second class is the actual con

Settings.WindowTitle = "SadConsole Examples";


Builder startup = new Builder()
.SetScreenSize(GameSettings.GAME_WIDTH, GameSettings.GAME_HEIGHT)
.SetStartingScreen<RootScreen>()
.IsStartingScreenFocused(false) // Dont want RootScreen to be focused because RootScreen automatically focuses the selected demo console
.ConfigureFonts((config, game) => config.UseBuiltinFontExtended())
.SetSplashScreen<SadConsole.SplashScreens.Ansi1>()
.KeyhookMonoGameDebugger()
;

Game.Create(startup);
Expand Down

0 comments on commit 903a8b4

Please sign in to comment.