Skip to content

Extensions Class

Extensions to the Builder type.

C#
public static class Extensions

Inheritance object

Sets an event handler for the Started event.

C#
public static Builder OnStart(this Builder configBuilder, EventHandler<GameHost> instance_Started)

configBuilder Builder
The builder object that composes the game startup.

instance_Started EventHandler<GameHost>
The event handler

Builder
The configuration builder.

Sets an event handler for the Ending event.

C#
public static Builder OnEnd(this Builder configBuilder, EventHandler<GameHost> instance_Ending)

configBuilder Builder
The builder object that composes the game startup.

instance_Ending EventHandler<GameHost>
The event handler

Builder
The configuration builder.

AddFrameUpdateEvent(Builder, EventHandler<GameHost>)

Section titled “AddFrameUpdateEvent(Builder, EventHandler<GameHost>)”

Sets an event handler for the FrameUpdate event.

C#
public static Builder AddFrameUpdateEvent(this Builder configBuilder, EventHandler<GameHost> instance_FrameUpdate)

configBuilder Builder
The builder object that composes the game startup.

instance_FrameUpdate EventHandler<GameHost>
The event handler

Builder
The configuration builder.

AddFrameRenderEvent(Builder, EventHandler<GameHost>)

Section titled “AddFrameRenderEvent(Builder, EventHandler<GameHost>)”

Sets an event handler for the FrameRender event.

C#
public static Builder AddFrameRenderEvent(this Builder configBuilder, EventHandler<GameHost> instance_FrameRender)

configBuilder Builder
The builder object that composes the game startup.

instance_FrameRender EventHandler<GameHost>
The event handler

Builder
The configuration builder.

ConfigureWindow(Builder, Action<ConfigureWindowConfig, BuilderBase, GameHost>)

Section titled “ConfigureWindow(Builder, Action<ConfigureWindowConfig, BuilderBase, GameHost>)”

Configures the game window.

C#
public static Builder ConfigureWindow(this Builder configBuilder, Action<ConfigureWindowConfig, BuilderBase, GameHost> loader)

configBuilder Builder
The builder object that composes the game startup.

loader Action<ConfigureWindowConfig, BuilderBase, GameHost>
The method to invoke when this is run.

Builder
The configuration builder.

Sets the initial screen size of the window, in cells.

C#
[Obsolete("Use SetWindowSizeInCells instead.")]
public static Builder SetScreenSize(this Builder configBuilder, int width, int height)

configBuilder Builder
The builder object that composes the game startup.

width int
The cell count along the x-axis.

height int
The cell count along the y-axis.

Builder
The configuration builder.

SetWindowSizeInCells(Builder, int, int, bool)

Section titled “SetWindowSizeInCells(Builder, int, int, bool)”

Sets the desired resolution of the SadConsole window in cells using the default font.

C#
public static Builder SetWindowSizeInCells(this Builder configBuilder, int width, int height, bool zoom = false)

configBuilder Builder
The builder object that composes the game startup.

width int
How wide the window is in font cells.

height int
How tall the window is in font cells.

zoom bool
When true, creates a larger window to automatically zoom the contents.

Builder

The width and height values are used to generate the game window based on how large the font is. For example, if the font is 10x8, and you request window size of 20x20, a window is created with a width of 10 * 20 and a height of 8 * 20 in pixels, which is 200x160. When zoom is set to true, the window will try to get as big as possible while keeping the SadConsole output crisp.

Sets the desired resolution of the SadConsole window in pixels. The output surface and initial cell counts are calculated based on the current font, and set to a value that allows the most cells to appear on screen.

C#
public static Builder SetWindowSizeInPixels(this Builder configBuilder, int width, int height)

configBuilder Builder
The builder object that composes the game startup.

width int
The width of the window.

height int
The height of the window.

Builder

Sets the StartingConsole and Screen properties to new console when the game starts.

C#
public static Builder UseDefaultConsole(this Builder configBuilder)

configBuilder Builder
The builder object that composes the game startup.

Builder
The configuration builder.

ConfigureFonts(Builder, Action<FontConfig, GameHost>)

Section titled “ConfigureFonts(Builder, Action<FontConfig, GameHost>)”

Configures which default font to use during game startup, as well as which other fonts to load for the game.

C#
public static Builder ConfigureFonts(this Builder configBuilder, Action<FontConfig, GameHost> fontLoader)

configBuilder Builder
The builder object that composes the game startup.

fontLoader Action<FontConfig, GameHost>
A method that provides access to the FontConfig object that loads fonts.

Builder
The configuration builder.

ConfigureFonts(Builder, string, string[]?)

Section titled “ConfigureFonts(Builder, string, string[]?)”

Configures SadConsole to use the specified font file as the default font.

C#
public static Builder ConfigureFonts(this Builder configBuilder, string customDefaultFont, string[]? extraFonts = null)

configBuilder Builder
The builder object that composes the game startup.

customDefaultFont string
Creates the font config for SadConsole using this font file as the default.

extraFonts string[]
Extra fonts to load into SadConsole.

Builder
The configuration builder.

Configures SadConsole to use the built in default fonts.

C#
public static Builder ConfigureFonts(this Builder configBuilder, bool useExtendedDefault = false)

configBuilder Builder
The builder object that composes the game startup.

useExtendedDefault bool
When true, SadConsole sets the default font to EmbeddedFontExtended; otherwise EmbeddedFont is used.

Builder
The configuration builder.

Adds the embedded fonts to the font dictionary with the old incorrect name.

C#
public static Builder FixOldFontName(this Builder configBuilder)

configBuilder Builder
The builder object that composes the game startup.

Builder
The configuration builder.

Sets the default font size for the game. The default is One.

C#
public static Builder SetDefaultFontSize(this Builder configBuilder, IFont.Sizes size)

configBuilder Builder
The builder object that composes the game startup.

size IFont.Sizes
The size of the default font.

Builder
The configuration builder.

Sets the startup splash screen to the specified object.

C#
public static Builder SetSplashScreen<TSplashScreen>(this Builder configBuilder) where TSplashScreen : IScreenSurface, new()

configBuilder Builder
The builder object that composes the game startup.

Builder
The configuration builder.

SetSplashScreen(Builder, Func<GameHost, ScreenSurface[]>)

Section titled “SetSplashScreen(Builder, Func<GameHost, ScreenSurface[]>)”

Sets the startup splash screens to the array returned by the creator delegate.

C#
public static Builder SetSplashScreen(this Builder configBuilder, Func<GameHost, ScreenSurface[]> creator)

configBuilder Builder
The builder object that composes the game startup.

creator Func<GameHost, ScreenSurface[]>
A delegate that returns an array of surface objects.

Builder
The configuration builder.

Sets the Screen property to the specified type.

C#
public static Builder SetStartingScreen<TRootObject>(this Builder configBuilder) where TRootObject : IScreenObject, new()

configBuilder Builder
The builder object that composes the game startup.

Builder
The configuration builder.

SetStartingScreen(Builder, Func<GameHost, IScreenObject>)

Section titled “SetStartingScreen(Builder, Func<GameHost, IScreenObject>)”

Sets the Screen property to the return value of the creator parameter.

C#
public static Builder SetStartingScreen(this Builder configBuilder, Func<GameHost, IScreenObject> creator)

configBuilder Builder
The builder object that composes the game startup.

creator Func<GameHost, IScreenObject>
A method that returns an object as the starting screen.

Builder
The configuration builder.

Either focuses or unfocuses the starting screen.

C#
public static Builder IsStartingScreenFocused(this Builder configBuilder, bool value)

configBuilder Builder
The builder object that composes the game startup.

value bool
Indicates whether or not Screen is focused.

Builder
The configuration builder.