UGantrySettingsRegistry
One local player's settings: pages, values, changes, saving.
Every local player gets a registry as soon as they exist, including each split-screen player. It holds the pages listed in Project Settings > Plugins > Gantry Settings, plus any pages that active experiences add. Pages come from page assets (each player gets their own copies of the settings) or from settings providers, which build each player's pages in code.
Gantry draws no menu. Your game builds its settings screen, in UMG or Slate, on top of this.
Building a settings screen
- Author a Gantry Settings Page asset for each tab ("Video", "Audio", "Controls"), and add settings to its Settings list.
- List the pages under Pages in
Project Settings > Plugins > Gantry Settings. - In your menu widget, get the player's registry and draw its pages and settings.
- Give the menu Apply and Revert buttons that call Apply Changes and Revert Changes.
Setting a value takes effect at once, so the player sees the change straight away. Apply Changes keeps the new values, applies the engine's user settings when a changed setting needs it, and saves. Revert Changes puts back the values from the last apply.
A change to the window mode or resolution must then be confirmed. Show a "Keep these settings?" prompt while Is Awaiting Video Confirm is true, and call Confirm Video Changes or Revert Video Changes. If the player does nothing for Video Confirm Seconds, the change reverts by itself.
In Blueprint
In a widget, call Get Gantry Settings with Get Owning Player to reach the registry. Call Get Pages for the tabs, and Get Settings on a page for its rows. Cast each setting to its shape (Number Setting, Choice Setting, Toggle Setting, Action Setting, Key Binding Setting) to pick a row widget, and call Get Edit State to hide or grey out the row. Bind On Pages Changed to rebuild the tabs when an experience adds or removes a page, and On Setting Changed to refresh a row.
In C++
Call UGantrySettingsSubsystem::GetRegistry with the local player, or UGantrySettingsLibrary::GetSettingsRegistry with a player controller. A Slate screen can listen to OnSettingChangedNative.
- Inherits
UObject
Properties
| Property | Type | Default | Description |
|---|---|---|---|
OnSettingChanged | FGantryOnSettingChanged | () | Fired when any setting's value changes. |
OnSettingAction | FGantryOnSettingAction | () | Fired when an action setting is used. |
OnPagesChanged | FGantryOnSettingsPagesChanged | () | Fired when pages are added or removed. |
OnVideoConfirmChanged | FGantryOnVideoConfirmChanged | () | Fired when a display change starts or stops waiting to be confirmed. |
LocalPlayer | TObjectPtr<ULocalPlayer> | None | |
Pages | TArray<FGantrySettingsPageEntry> | ||
Providers | TArray<FGantrySettingsProviderEntry> | ||
Save | TObjectPtr<UGantrySettingsSave> | None | |
VideoSettings | TArray<TObjectPtr<UGantrySetting> > | Settings applied in the change awaiting confirmation, re-read if it reverts. |
Functions
AddPage
Adds a page for this player.
The settings on a page asset are copied for this player. A page a settings provider built for this player is used as it is. Keep In Save values are written back. A setting whose Id is already in the registry is left out, with a warning in the log. Adding the same page again only counts it; it is not added twice.
| Pin | Type | Direction | Description |
|---|---|---|---|
Page | UGantrySettingsPage* | in |
AddProvider
Adds a settings provider: makes one of the class and adds the pages it builds.
Adding the same class again only counts it; the provider is made once.
| Pin | Type | Direction | Description |
|---|---|---|---|
ProviderClass | TSubclassOf<UGantrySettingsProvider> | in |
ApplyChanges
Keeps every changed value.
Applies each changed setting, applies the engine's user settings when any of them needs it, and saves the player's values in the background. A display change then waits for Confirm Video Changes.
ConfirmVideoChanges
Keeps the display change waiting to be confirmed, and saves the engine's user settings.
FindSetting
| Pin | Type | Direction | Description |
|---|---|---|---|
Id | FName | in | |
| Return Value | UGantrySetting* | out | The setting with an id, or null. |
GetLocalPlayer
| Pin | Type | Direction | Description |
|---|---|---|---|
| Return Value | ULocalPlayer* | out | The local player, or null. |
GetPages
| Pin | Type | Direction | Description |
|---|---|---|---|
| Return Value | TArray<UGantrySettingsPage*> | out | This player's pages, by Sort Order and then by Title: one per tab of a settings screen. |
GetSavedValue
A value from the player's save, by setting Id.
Settings keep their values here by default, and Keep In Save settings remember theirs here.
| Pin | Type | Direction | Description |
|---|---|---|---|
Id | FName | in | The setting's id. |
DefaultValue | FString | in | Returned when nothing is saved. |
| Return Value | FString | out | The saved value, as text, or DefaultValue. |
GetSettings
| Pin | Type | Direction | Description |
|---|---|---|---|
Page | UGantrySettingsPage* | in | |
| Return Value | TArray<UGantrySetting*> | out | This player's settings on a page, in page order; empty for a page the registry does not have. |
GetVideoConfirmSecondsLeft
| Pin | Type | Direction | Description |
|---|---|---|---|
| Return Value | float | out | Seconds until an unconfirmed display change reverts; 0 when none is waiting. |
HasUnappliedChanges
| Pin | Type | Direction | Description |
|---|---|---|---|
| Return Value | bool | out | Whether any setting differs from when changes were last applied. |
IsAwaitingVideoConfirm
| Pin | Type | Direction | Description |
|---|---|---|---|
| Return Value | bool | out | Whether a display change is waiting to be kept. |
RemovePage
Removes a page once it has been removed as many times as it was added.
Changes on it that were not applied are reverted first.
| Pin | Type | Direction | Description |
|---|---|---|---|
Page | UGantrySettingsPage* | in |
RemoveProvider
Removes a provider and its pages once the class has been removed as many times as it was added.
| Pin | Type | Direction | Description |
|---|---|---|---|
ProviderClass | TSubclassOf<UGantrySettingsProvider> | in |
ResetToDefaults
Sets every resettable setting that has a default back to that default.
The change is not kept until Apply Changes.
| Pin | Type | Direction | Description |
|---|---|---|---|
Page | UGantrySettingsPage* | in | Only this page's settings; null for every page. |
RevertChanges
Puts every changed value back to what it was when changes were last applied.
RevertVideoChanges
Goes back to the display mode and resolution before the change.
SetSavedValue
Writes a value to the player's save, by setting Id.
It reaches the disk at the next Apply Changes.
| Pin | Type | Direction | Description |
|---|---|---|---|
Id | FName | in | |
Value | FString | in |
C++
Public C++ members that Blueprint does not see.
OnSettingChangedNative
FGantryOnSettingChangedNative
Fired when any setting's value changes, for C++; right after OnSettingChanged.
Initialize
void
Gets the registry ready: remembers the player and loads their save.
The settings subsystem calls it; you do not need to.
InLocalPlayer:The player; null for a registry without one (tests).
SaveSlot:The save slot, without the player's index; empty saves nothing.
UserIndex:Appended to the slot, and the user index the save is made for.
Shutdown
void
Reverts a display change still waiting to be confirmed.
Values not yet applied are not saved.
HandleSettingChanged
void
Called by a setting when its value changes: fires On Setting Changed, then tells the settings that depend on it.
HandleSettingAction
void
Called by an action setting when it is used.