Logo Mibo

MonoGameProgram Module

MonoGame-specific program builder extensions.

Types

Type Description

BankEntry

One entry of a sound bank: a game-vocabulary key bound to the source that plays under it. The whole bank loads before user init runs.

Functions and values

Function or value Description

ofProgram program

Full Usage: ofProgram program

Parameters:
Returns: MonoGameProgram<'Model, 'Msg>
Type parameters: 'Model, 'Msg

Wraps a Core Program into a MonoGameProgram with no device-level configuration.

program : Program<'Model, 'Msg>
Returns: MonoGameProgram<'Model, 'Msg>

withBank bank program

Full Usage: withBank bank program

Parameters:
Returns: MonoGameProgram<'Model, 'Msg>
Type parameters: 'Model, 'Msg

Configures the game's sound bank: every entry loads before user init runs, so Audio.play/Audio.playMusic can start sounds from the very first message.

Each entry names its own SourcePipeline for MGCB assets, File for loose files (WAV sound effects; music goes through the platform decoders). The bank is an ordinary F# value: a list literal for small games, or a generated value for large ones (a naming convention, a manifest, a directory scan). List order is load order. One call configures the whole bank.

Keys are game vocabulary ("jump", "overworld"); a key registered twice keeps the first entry. A missing pipeline asset throws at startup, where a configuration mistake belongs.

bank : BankEntry list
program : MonoGameProgram<'Model, 'Msg>
Returns: MonoGameProgram<'Model, 'Msg>
Example

 let mgProgram =
   Program.mkProgram init update
   |> MonoGameProgram.ofProgram
   |> MonoGameProgram.withBank
     [ Sound("jump", Pipeline "audio/jump")
       Music("overworld", File "music/overworld.ogg") ]
val mgProgram: obj

withConfig configure program

Full Usage: withConfig configure program

Parameters:
Returns: MonoGameProgram<'Model, 'Msg>
Type parameters: 'Model, 'Msg

Adds a device-level configuration callback that receives the Game instance and GraphicsDeviceManager for low-level setup.

Invoked in the MiboGame constructor, after the Core Program.withConfig callbacks and before Initialize / GraphicsDevice creation — so settings like GraphicsProfile and PreferredBackBufferWidth/Height take effect.

Use this for properties that require direct GraphicsDeviceManager/Game access: GraphicsProfile, SynchronizeWithVerticalRetrace (vsync), IsFullScreen, HardwareModeSwitch, Window.AllowUserResizing, Content.RootDirectory, etc.

configure : Game * GraphicsDeviceManager -> unit
program : MonoGameProgram<'Model, 'Msg>
Returns: MonoGameProgram<'Model, 'Msg>
Example

 program
 |> MonoGameProgram.ofProgram
 |> MonoGameProgram.withConfig(fun (game, graphics) ->
     graphics.GraphicsProfile <- GraphicsProfile.HiDef
     graphics.SynchronizeWithVerticalRetrace <- false
     game.IsMouseVisible <- true)

withInputMapper initialMap program

Full Usage: withInputMapper initialMap program

Parameters:
Returns: MonoGameProgram<'Model, 'Msg>
Type parameters: 'Model, 'Msg, 'Action (requires comparison)

Configures the game to register an IInputMapper service backed by MonoGame's polling API.

This registers IInput automatically (equivalent to Program.withInput).

The mapper is registered as a service via a Program.ServiceRegistrations callback that MiboGame runs before Init, so the Core Program type never references a backend factory.

The service is registered, not driven: nothing polls Update() automatically — call it yourself each frame if you read CurrentState, or prefer the subscription path below, which the input deltas drive on their own.

If you want to stay fully "Elmish" (no service access), consider using InputMapper.subscribe instead and handle a single message (adaptive programs: InputMapper.subscribeAdaptive).

initialMap : InputMap<'Action>
program : MonoGameProgram<'Model, 'Msg>
Returns: MonoGameProgram<'Model, 'Msg>
Example

 program
 |> MonoGameProgram.ofProgram
 |> MonoGameProgram.withInputMapper inputMap

Type something to start searching.