/// <summary> /// Prepares the engine for use. This must be the first method you call on the engine, then call <see cref="Run"/> to start SadConsole. /// </summary> /// <param name="font">The font to load as the <see cref="DefaultFont"/>.</param> /// <param name="consoleWidth">The width of the default root console (and game window).</param> /// <param name="consoleHeight">The height of the default root console (and game window).</param> /// <param name="ctorCallback">Optional callback from the MonoGame Game class constructor.</param> /// <returns>The default active console.</returns> public static void Initialize(string font, int consoleWidth, int consoleHeight, Action <SadConsoleGame> ctorCallback = null) { MonoGameInstance = new SadConsoleGame(font, consoleWidth, consoleHeight, ctorCallback); MonoGameInstance.Exiting += (s, e) => EngineShutdown?.Invoke(null, new ShutdownEventArgs() { }); }
/// <summary> /// Prepares the engine for use by creating a window. This must be the first method you call on the engine. /// </summary> /// <param name="font">The font to load as the <see cref="DefaultFont"/>.</param> /// <param name="consoleWidth">The width of the default root console (and game window).</param> /// <param name="consoleHeight">The height of the default root console (and game window).</param> /// <param name="frameLimit">Defaults to 60 fps. Use 0 to indicate unlimited.</param> /// <returns>The default active console.</returns> public static Consoles.Console Initialize(string font, int consoleWidth, int consoleHeight, int frameLimit = 60) { SetupFontAndEffects(font); var window = new RenderWindow(new SFML.Window.VideoMode((uint)(DefaultFont.Size.X * consoleWidth), (uint)(DefaultFont.Size.Y * consoleHeight)), "SadConsole Game", SFML.Window.Styles.Titlebar | SFML.Window.Styles.Close); WindowWidth = (int)window.Size.X; WindowHeight = (int)window.Size.Y; window.Closed += (o, e) => { ShutdownEventArgs args = new ShutdownEventArgs(); EngineShutdown?.Invoke(null, args); if (!args.BlockShutdown) { ((SFML.Window.Window)o).Close(); } }; if (frameLimit != 0) { window.SetFramerateLimit((uint)frameLimit); } Device = window; SetupInputsAndTimers(); // Create the default console. return(SetupStartingConsole(consoleWidth, consoleHeight)); }