Class Extensions
Extensions to the Builder type.
Inherited Members
Namespace: SadConsole.Configuration
Assembly: SadConsole.dll
Syntax
public static class Extensions
Methods
AddFrameRenderEvent(Builder, EventHandler<GameHost>)
Sets an event handler for the FrameRender event.
Declaration
public static Builder AddFrameRenderEvent(this Builder configBuilder, EventHandler<GameHost> instance_FrameRender)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| EventHandler<GameHost> | instance_FrameRender | The event handler |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
AddFrameUpdateEvent(Builder, EventHandler<GameHost>)
Sets an event handler for the FrameUpdate event.
Declaration
public static Builder AddFrameUpdateEvent(this Builder configBuilder, EventHandler<GameHost> instance_FrameUpdate)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| EventHandler<GameHost> | instance_FrameUpdate | The event handler |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
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.
Declaration
public static Builder ConfigureFonts(this Builder configBuilder, Action<FontConfig, GameHost> fontLoader)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| Action<FontConfig, GameHost> | fontLoader | A method that provides access to the FontConfig object that loads fonts. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
ConfigureFonts(Builder, bool)
Configures SadConsole to use the built in default fonts.
Declaration
public static Builder ConfigureFonts(this Builder configBuilder, bool useExtendedDefault = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| bool | useExtendedDefault | When true, SadConsole sets the default font to EmbeddedFontExtended; otherwise EmbeddedFont is used. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
ConfigureFonts(Builder, string, string[]?)
Configures SadConsole to use the specified font file as the default font.
Declaration
public static Builder ConfigureFonts(this Builder configBuilder, string customDefaultFont, string[]? extraFonts = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| string | customDefaultFont | Creates the font config for SadConsole using this font file as the default. |
| string[] | extraFonts | Extra fonts to load into SadConsole. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
ConfigureWindow(Builder, Action<ConfigureWindowConfig, BuilderBase, GameHost>)
Configures the game window.
Declaration
public static Builder ConfigureWindow(this Builder configBuilder, Action<ConfigureWindowConfig, BuilderBase, GameHost> loader)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| Action<ConfigureWindowConfig, BuilderBase, GameHost> | loader | The method to invoke when this is run. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
FixOldFontName(Builder)
Adds the embedded fonts to the font dictionary with the old incorrect name.
Declaration
public static Builder FixOldFontName(this Builder configBuilder)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
IsStartingScreenFocused(Builder, bool)
Either focuses or unfocuses the starting screen.
Declaration
public static Builder IsStartingScreenFocused(this Builder configBuilder, bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| bool | value | Indicates whether or not Screen is focused. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
OnEnd(Builder, EventHandler<GameHost>)
Sets an event handler for the Ending event.
Declaration
public static Builder OnEnd(this Builder configBuilder, EventHandler<GameHost> instance_Ending)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| EventHandler<GameHost> | instance_Ending | The event handler |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
OnStart(Builder, EventHandler<GameHost>)
Sets an event handler for the Started event.
Declaration
public static Builder OnStart(this Builder configBuilder, EventHandler<GameHost> instance_Started)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| EventHandler<GameHost> | instance_Started | The event handler |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
SetDefaultFontSize(Builder, Sizes)
Sets the default font size for the game. The default is One.
Declaration
public static Builder SetDefaultFontSize(this Builder configBuilder, IFont.Sizes size)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| IFont.Sizes | size | The size of the default font. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
SetScreenSize(Builder, int, int)
Sets the initial screen size of the window, in cells.
Declaration
[Obsolete("Use SetWindowSizeInCells instead.")]
public static Builder SetScreenSize(this Builder configBuilder, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| int | width | The cell count along the x-axis. |
| int | height | The cell count along the y-axis. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
SetSplashScreen(Builder, Func<GameHost, ScreenSurface[]>)
Sets the startup splash screens to the array returned by the creator delegate.
Declaration
public static Builder SetSplashScreen(this Builder configBuilder, Func<GameHost, ScreenSurface[]> creator)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| Func<GameHost, ScreenSurface[]> | creator | A delegate that returns an array of surface objects. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
SetSplashScreen<TSplashScreen>(Builder)
Sets the startup splash screen to the specified object.
Declaration
public static Builder SetSplashScreen<TSplashScreen>(this Builder configBuilder) where TSplashScreen : IScreenSurface, new()
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
Type Parameters
| Name | Description |
|---|---|
| TSplashScreen | A parameterless IScreenSurface object. |
SetStartingScreen(Builder, Func<GameHost, IScreenObject>)
Sets the Screen property to the return value of the creator parameter.
Declaration
public static Builder SetStartingScreen(this Builder configBuilder, Func<GameHost, IScreenObject> creator)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| Func<GameHost, IScreenObject> | creator | A method that returns an object as the starting screen. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
SetStartingScreen<TRootObject>(Builder)
Sets the Screen property to the specified type.
Declaration
public static Builder SetStartingScreen<TRootObject>(this Builder configBuilder) where TRootObject : IScreenObject, new()
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |
Type Parameters
| Name | Description |
|---|---|
| TRootObject | A parameterless IScreenObject object. |
SetWindowSizeInCells(Builder, int, int, bool)
Sets the desired resolution of the SadConsole window in cells using the default font.
Declaration
public static Builder SetWindowSizeInCells(this Builder configBuilder, int width, int height, bool zoom = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| int | width | How wide the window is in font cells. |
| int | height | How tall the window is in font cells. |
| bool | zoom | When true, creates a larger window to automatically zoom the contents. |
Returns
| Type | Description |
|---|---|
| Builder |
Remarks
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.
SetWindowSizeInPixels(Builder, int, int)
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.
Declaration
public static Builder SetWindowSizeInPixels(this Builder configBuilder, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
| int | width | The width of the window. |
| int | height | The height of the window. |
Returns
| Type | Description |
|---|---|
| Builder |
UseDefaultConsole(Builder)
Sets the StartingConsole and Screen properties to new console when the game starts.
Declaration
public static Builder UseDefaultConsole(this Builder configBuilder)
Parameters
| Type | Name | Description |
|---|---|---|
| Builder | configBuilder | The builder object that composes the game startup. |
Returns
| Type | Description |
|---|---|
| Builder | The configuration builder. |