Panel
namespace Griff.Scenes;
public sealed class Panel : ComponentA menu that opens over the game and closes again: a pause menu, an options panel, a shop, a map. It’s open while its entity is showing; while it is, the mouse, keyboard and gamepad only reach controls on it (not the HUD or a panel underneath, except buttons marked OverPanels), its top control is picked straight away, and Esc or the gamepad’s B closes it. The press that opens or closes it is used up: the game’s scripts don’t see it that frame. Closing it gives the keyboard back to whatever was picked before. Open one with a OpenPanel button, with OpenOn (a pause menu opens on “Pause”), with OpenMessage (a puzzle’s “Solved” screen), or from scripts with Game.OpenPanel (or by showing its entity).
Panels are hidden when the game starts unless Open is ticked, so they can be laid out in the Scene view.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”CloseOnBack
Section titled “CloseOnBack”public bool CloseOnBack { get; set; }Whether Esc and the gamepad’s B close it. If it has a button whose Shortcut is Esc, they click that instead; while a running script claims Back (a builder’s tool in hand), they’re the script’s. Untick it for a panel the player has to choose their way out of.
public string? First { get; set; }The name of the control to pick as it opens, e.g. “Resume”. Empty picks its top one.
public bool IsTop { get; }True while it’s the open panel on top, the one the player’s input goes to.
NeedsFlag
Section titled “NeedsFlag”public string? NeedsFlag { get; set; }A flag that has to be set before it opens, e.g. “FoundMap” (set by a trigger’s Set Flag, a dialogue’s “[set FoundMap]” or a script’s Game.SetFlag), or “not FoundMap” for while it isn’t: until then its OpenOn action, OpenMessage and buttons that open it do nothing. Its Open action and scripts still open it.
public bool Open { get; set; }Whether it’s open. Tick it to have the panel open when the scene starts; while the game runs it follows the panel, so rewinding puts it back as it was.
OpenMessage
Section titled “OpenMessage”public string? OpenMessage { get; set; }A message that opens it, with no code: “Solved” (a puzzle’s goals all covered), “GameOver”, or anything a pickup, switch or script sends. Empty opens it only from a button, its OpenOn action or a script.
OpenOn
Section titled “OpenOn”public string? OpenOn { get; set; }An input action that opens it when no other panel is open, and closes it again: “Pause” for a pause menu (Esc, P or Start), or one of your own, like “Map”. It waits while a script or system claims Back (Esc and B) for something under way, like a tool in hand. Empty opens it only from a button or a script.
PauseGame
Section titled “PauseGame”public bool PauseGame { get; set; }Stop the game while it’s open: game time stands still and only scripts on open panels run. Untick it for a panel that the game goes on behind, like a game over screen during a slow-motion death.
Pauses
Section titled “Pauses”public string? Pauses { get; set; }What it stops while it’s open: empty stops the whole game; an entity’s name (one inside this panel first) stops only it and everything inside it, as a PauseGroup does, while the rest of the game runs on behind the panel: the minigame a pause menu is for, the world behind a shop while the music and the HUD go on.
public bool Popup { get; set; }Whether it’s a pop-up, like a tool palette’s fly-out, a dropdown or a context menu: a mouse press anywhere off it closes it and does nothing else (no button there clicks, scripts don’t see the press and Game.MouseOnUi is true for it), and clicking one of its buttons closes it once the button has done what it does, so an Open Panel button on it opens its window in its place. Untick Pause Game for one the game goes on behind.
public string? Sound { get; set; }A sound played as it opens, e.g. “Sounds/open.wav”.
Events
Section titled “Events”Closed
Section titled “Closed”public event Action<Panel>? ClosedRaised as it closes.
Opened
Section titled “Opened”public event Action<Panel>? OpenedRaised as it opens.