Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
WinFormsGameHostBase.cs
1using System.Windows.Forms;
4
6
10public abstract class WinFormsGameHostBase : GameHostBase
11{
12 private readonly Control _renderSurface;
13 private readonly Action<Scene, bool> _bindScene;
14
21 protected WinFormsGameHostBase(Control renderSurface, Action<Scene, bool> bindScene)
22 {
23 _renderSurface = renderSurface ?? throw new ArgumentNullException(nameof(renderSurface));
24 _bindScene = bindScene ?? throw new ArgumentNullException(nameof(bindScene));
25 }
26
30 protected sealed override void ConfigurePlatform()
31 {
32 Engine.Instance.InitializeWinFormsAudioFormats();
34 }
35
39 protected sealed override void ConfigureKeyboard()
40 {
41 Engine.Instance.InitializeWinFormsKeyboardAdapter(_renderSurface);
43 }
44
48 protected sealed override void ConfigureMouse()
49 {
50 Engine.Instance.InitializeWinFormsMouseAdapter(_renderSurface);
52 }
53
58 protected override void ConfigureGamepads()
59 {
60 Engine.InitializeXInputGamepadManager();
62 }
63
68 protected override void ConfigureTouch()
69 {
71 }
72
77 protected sealed override void BindScene()
78 {
79 if (Scene is null)
80 throw new InvalidOperationException($"{nameof(BindScene)} cannot be called before {nameof(Scene)} has been created.");
81
82 _bindScene(Scene, false);
83 }
84
88 protected override void OnSceneBound()
89 {
90 // Method intentionally left empty.
91 }
92
96 protected virtual void OnConfigurePlatform() { }
97
101 protected virtual void OnKeyboardAdapterInitialized() { }
102
106 protected virtual void OnMouseAdapterInitialized() { }
107
111 protected virtual void OnGamepadManagerInitialized() { }
112
117 protected virtual void OnTouchAdapterInitialized() { }
118}
Provides a base class for hosting and managing the lifecycle of a Gondwana game application.
Scene? Scene
Gets the current active scene.
Engine Engine
Gets the singleton instance of the Gondwana engine.
virtual void OnConfigurePlatform()
Provides a hook for configuring platform-specific settings during initialization.
override void ConfigurePlatform()
Configures Windows Forms-specific platform features, including audio format support.
virtual void OnMouseAdapterInitialized()
Called after the mouse adapter has been initialized. Override to perform additional mouse setup.
override void ConfigureGamepads()
Configures gamepad support. By default, this method initializes the XInput gamepad manager,...
override void ConfigureMouse()
Configures the mouse adapter for the Windows Forms render surface.
virtual void OnGamepadManagerInitialized()
Called after the gamepad manager has been initialized. Override to perform additional gamepad setup.
virtual void OnTouchAdapterInitialized()
Called after the touch adapter has been initialized. Override to perform additional touch setup,...
override void BindScene()
Binds the current scene to the render surface host.
virtual void OnKeyboardAdapterInitialized()
Called after the keyboard adapter has been initialized. Override to perform additional keyboard setup...
override void ConfigureKeyboard()
Configures the keyboard adapter for the Windows Forms render surface.
override void OnSceneBound()
Called after the current scene has been bound to the Windows Forms render surface host.
override void ConfigureTouch()
Configures touch input. By default, this method does not perform any actions, but it can be overridde...
WinFormsGameHostBase(Control renderSurface, Action< Scene, bool > bindScene)
Initializes a new instance of the WinFormsGameHostBase class.