Repository navigation
Widgets DialogBox
DialogBox is the base class for Gondwana's draggable in-game dialogs. It supplies the common window behavior: panel, title bar, optional close button, dragging, Enter/Escape handling, result values, and close lifecycle.
DialogBox is abstract, so normal game code does not instantiate it directly. Use AboutBox for the built-in About dialog, or derive a small game-specific dialog when you need custom content.
These examples assume you already have a
RenderSurfaceHostBasenamedhostand, where appropriate, aViewnamedview, aSceneLayernamedsceneLayer, or aSpritenamedsprite.
A derived dialog automatically receives:
- a panel and title bar;
- an optional close button;
- dragging by the title bar;
-
AcceptKey(Enter by default); -
CancelKey(Escape by default); -
DialogResult; - a
Closedevent; - optional automatic disposal after closing;
- visual bring-to-front behavior when
Activate()is called, preserving the dialog's internal Z-order relationships.
using System.Drawing;
using Gondwana.Rendering;
using Gondwana.Rendering.Views;
using Gondwana.Widgets.Controls;
using Gondwana.Widgets.Dialogs;
public sealed class ConfirmDialog : DialogBox
{
public ButtonWidget YesButton { get; }
public ConfirmDialog(
RenderSurfaceHostBase host,
View view,
Rectangle bounds)
: base(host, view, bounds, "Confirm")
{
YesButton = new ButtonWidget(
host,
view,
new Rectangle(bounds.Left + 24, bounds.Bottom - 54, 100, 34),
"Yes");
Add(YesButton);
YesButton.Clicked += () => Close(DialogResult.OK);
}
}var confirm = new ConfirmDialog(
host,
view,
new Rectangle(140, 100, 360, 220));
confirm.Closed += result =>
{
if (result == DialogResult.OK)
DeleteSave();
};
confirm.Show();
confirm.Activate();confirm.Close(DialogResult.Cancel);By default, closing a dialog also disposes it. To keep the instance for reuse:
confirm.DisposeOnClose = false;confirm.AcceptKey = 13; // Enter
confirm.CancelKey = 27; // EscapeDerived dialogs can override OnAcceptRequested() when Enter should perform a custom action.
| Member | Purpose |
|---|---|
Closed |
Raised with the final DialogResult. |
Close() |
Closes the dialog with a chosen result. |
Result |
Result used when the dialog closed. |
IsClosed |
Whether it has already closed. |
DisposeOnClose |
Controls automatic disposal. |
Panel / TitleBar / TitleText
|
Built-in dialog visuals. |
CloseButton |
Optional built-in close button. |
- Home
- Make Your First Game in 30 Minutes
- Engine Architecture Overview
- Game Hosts and Application Startup
- Gondwana Engine Lifecycle
- Gondwana CLI Cheatsheet
- Using Gondwana with ChatGPT and Codex
Core Concepts
Systems
Rendering
Widgets
-
Controls
-
Dialogs
- AboutBox
- ConversationBox
- DialogBox — base class for custom dialogs
-
Hud
-
Layout
-
Menus
-
Overlays