Skip to content

Commit

Permalink
Move config builder to core SadConsole
Browse files Browse the repository at this point in the history
  • Loading branch information
Thraka committed Mar 31, 2024
1 parent ce56de3 commit 4252a8e
Show file tree
Hide file tree
Showing 30 changed files with 369 additions and 945 deletions.
2 changes: 1 addition & 1 deletion SadConsole.Debug.MonoGame/ConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class ImGuiDebugConfig : RootComponent, IConfigurator
{
public Keys HotKey { get; set; }

public void Run(Builder config, Game game)
public void Run(Builder config, GameHost game)
{
game.RootComponents.Add(this);
}
Expand Down
5 changes: 4 additions & 1 deletion SadConsole.Host.FNA/SadConsole.Host.FNA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<Description>A graphics hosting library for SadConsole that targets FNA.</Description>
<PackageId>SadConsole.Host.FNA</PackageId>
<PackageTags>sadconsole;fna;roguelike;cli;xna;game;development;console;ansi;ascii;textmode;dotnet</PackageTags>
<PackageReleaseNotes>Reversioning the packages. No changes here, see previous release for changes.</PackageReleaseNotes>
<PackageReleaseNotes>
- Reversioned to follow new versioning scheme.
- Configuration namespace was moved to SadConsole directly. Only library specific config options are here now.
</PackageReleaseNotes>
</PropertyGroup>

<!-- Custom properties -->
Expand Down
216 changes: 6 additions & 210 deletions SadConsole.Host.FNA/SadConsole.Host.FNA.xml

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions SadConsole.Host.MonoGame/Game.Wpf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,16 @@ internal void MonoGameInit(Host.Game game)
InternalStartupData startupData = _configuration.Configs.OfType<InternalStartupData>().FirstOrDefault()
?? throw new Exception($"You must call {nameof(Configuration.Extensions.SetScreenSize)} to set a default screen size.");

if (startupData.InitialRenderWidth == 0 || startupData.InitialRenderHeight == 0)
throw new Exception($"You must call {nameof(Configuration.Extensions.SetInitialRenderPixels)} and set values greater than 0.");
InternalHostStartupData hostStartupData = _configuration.Configs.OfType<InternalHostStartupData>().FirstOrDefault() ?? new();

if (hostStartupData.InitialRenderWidth == 0 || hostStartupData.InitialRenderHeight == 0)
throw new Exception($"You must call {nameof(Configuration.ExtensionsHost.SetInitialRenderPixels)} and set values greater than 0.");

ScreenCellsX = startupData.ScreenCellsX;
ScreenCellsY = startupData.ScreenCellsY;

SadConsole.Settings.Rendering.RenderWidth = startupData.InitialRenderWidth;
SadConsole.Settings.Rendering.RenderHeight = startupData.InitialRenderHeight;
SadConsole.Settings.Rendering.RenderWidth = hostStartupData.InitialRenderWidth;
SadConsole.Settings.Rendering.RenderHeight = hostStartupData.InitialRenderHeight;

SetRenderer(Renderers.Constants.RendererNames.Default, typeof(Renderers.ScreenSurfaceRenderer));
SetRenderer(Renderers.Constants.RendererNames.ScreenSurface, typeof(Renderers.ScreenSurfaceRenderer));
Expand Down Expand Up @@ -172,7 +174,7 @@ internal void MonoGameInit(Host.Game game)
_configuration.Run(this);

var fontSize = DefaultFont.GetFontSize(DefaultFontSize);
if (fontSize.X > startupData.InitialRenderWidth || fontSize.Y > startupData.InitialRenderHeight)
if (fontSize.X > hostStartupData.InitialRenderWidth || fontSize.Y > hostStartupData.InitialRenderHeight)
throw new Exception("WPF control is too small to present a single cell in the font size.");

// Normal start
Expand Down
4 changes: 2 additions & 2 deletions SadConsole.Host.MonoGame/MonoGame/Game.Mono.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal Game()
Global.GraphicsDeviceManager.HardwareModeSwitch = Settings.UseHardwareFullScreen;
#endif

CallbackConfig config = SadConsole.Game.Instance._configuration.Configs.OfType<CallbackConfig>().FirstOrDefault();
MonoGameCallbackConfig config = SadConsole.Game.Instance._configuration.Configs.OfType<MonoGameCallbackConfig>().FirstOrDefault();
config?.MonoGameCtorCallback?.Invoke(this);
}

Expand Down Expand Up @@ -141,7 +141,7 @@ protected override void Initialize()
Global.SharedSpriteBatch = new SpriteBatch(GraphicsDevice);

// Invoke the monogame init callback
CallbackConfig monoGameConfig = SadConsole.Game.Instance._configuration.Configs.OfType<CallbackConfig>().FirstOrDefault();
MonoGameCallbackConfig monoGameConfig = SadConsole.Game.Instance._configuration.Configs.OfType<MonoGameCallbackConfig>().FirstOrDefault();
monoGameConfig?.MonoGameInitCallback?.Invoke(this);

ResetRendering();
Expand Down
9 changes: 8 additions & 1 deletion SadConsole.Host.MonoGame/SadConsole.Host.MonoGame.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<Description>A graphics hosting library for SadConsole that targets MonoGame.</Description>
<PackageId>SadConsole.Host.MonoGame</PackageId>
<PackageTags>sadconsole;monogame;roguelike;cli;xna;game;development;console;ansi;ascii;textmode;dotnet</PackageTags>
<PackageReleaseNotes>Reversioning the packages. No changes here, see previous release for changes.</PackageReleaseNotes>
<PackageReleaseNotes>
- Reversioned to follow new versioning scheme.
- Configuration namespace was moved to SadConsole directly. Only library specific config options are here now.
</PackageReleaseNotes>
</PropertyGroup>

<!-- Custom properties -->
Expand Down Expand Up @@ -37,6 +40,10 @@
<None Include="..\README.md" pack="true" PackagePath="." />
</ItemGroup>

<ItemGroup>
<Folder Include="Configuration\" />
</ItemGroup>

<Target Name="CopyPackage" AfterTargets="Pack">
<Copy SourceFiles="$(OutputPath)\$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$(OutputPath)..\..\..\nuget" />
<Copy SourceFiles="$(OutputPath)\$(PackageId).$(PackageVersion).snupkg" DestinationFolder="$(OutputPath)..\..\..\nuget" />
Expand Down
Loading

0 comments on commit 4252a8e

Please sign in to comment.