Table of Contents

Class SettingsManager

Namespace
AshesOfVelsingrad.Managers
Assembly
Ashes of Velsingrad.dll

Manages game settings and provides centralized access to configuration options. Follows the Manager Pattern from your architecture.

[ScriptPath("res://scripts/managers/SettingsManager.cs")]
public class SettingsManager : BaseManager, IDisposable
Inheritance
GodotObject
Node
SettingsManager
Implements
Inherited Members
Node.NotificationEnterTree
Node.NotificationExitTree
Node.NotificationMovedInParent
Node.NotificationReady
Node.NotificationPaused
Node.NotificationUnpaused
Node.NotificationPhysicsProcess
Node.NotificationProcess
Node.NotificationParented
Node.NotificationUnparented
Node.NotificationSceneInstantiated
Node.NotificationDragBegin
Node.NotificationDragEnd
Node.NotificationPathRenamed
Node.NotificationChildOrderChanged
Node.NotificationInternalProcess
Node.NotificationInternalPhysicsProcess
Node.NotificationPostEnterTree
Node.NotificationDisabled
Node.NotificationEnabled
Node.NotificationResetPhysicsInterpolation
Node.NotificationEditorPreSave
Node.NotificationEditorPostSave
Node.NotificationWMMouseEnter
Node.NotificationWMMouseExit
Node.NotificationWMWindowFocusIn
Node.NotificationWMWindowFocusOut
Node.NotificationWMCloseRequest
Node.NotificationWMGoBackRequest
Node.NotificationWMSizeChanged
Node.NotificationWMDpiChange
Node.NotificationVpMouseEnter
Node.NotificationVpMouseExit
Node.NotificationWMPositionChanged
Node.NotificationOsMemoryWarning
Node.NotificationTranslationChanged
Node.NotificationWMAbout
Node.NotificationCrash
Node.NotificationOsImeUpdate
Node.NotificationApplicationResumed
Node.NotificationApplicationPaused
Node.NotificationApplicationFocusIn
Node.NotificationApplicationFocusOut
Node.NotificationTextServerChanged
Node.NotificationAccessibilityUpdate
Node.NotificationAccessibilityInvalidate
Node.GetNode<T>(NodePath)
Node.GetNodeOrNull<T>(NodePath)
Node.GetOwner<T>()
Node.GetOwnerOrNull<T>()
Node.GetParent<T>()
Node.GetParentOrNull<T>()
Node._EnterTree()
Node._GetAccessibilityConfigurationWarnings()
Node._GetConfigurationWarnings()
Node._GetFocusedAccessibilityElement()
Node._Input(InputEvent)
Node._ShortcutInput(InputEvent)
Node._UnhandledInput(InputEvent)
Node._UnhandledKeyInput(InputEvent)
Node.PrintOrphanNodes()
Node.GetOrphanNodeIds()
Node.RemoveChild(Node)
Node.HasNode(NodePath)
Node.GetNode(NodePath)
Node.GetNodeOrNull(NodePath)
Node.GetParent()
Node.HasNodeAndResource(NodePath)
Node.GetNodeAndResource(NodePath)
Node.IsInsideTree()
Node.IsPartOfEditedScene()
Node.IsAncestorOf(Node)
Node.IsGreaterThan(Node)
Node.GetPath()
Node.RemoveFromGroup(StringName)
Node.IsInGroup(StringName)
Node.GetGroups()
Node.PrintTree()
Node.PrintTreePretty()
Node.GetTreeString()
Node.GetTreeStringPretty()
Node.GetPhysicsProcessDeltaTime()
Node.IsPhysicsProcessing()
Node.GetProcessDeltaTime()
Node.IsProcessing()
Node.IsProcessingInput()
Node.IsProcessingShortcutInput()
Node.IsProcessingUnhandledInput()
Node.IsProcessingUnhandledKeyInput()
Node.CanProcess()
Node.QueueAccessibilityUpdate()
Node.GetAccessibilityElement()
Node.IsDisplayedFolded()
Node.IsProcessingInternal()
Node.IsPhysicsProcessingInternal()
Node.IsPhysicsInterpolated()
Node.IsPhysicsInterpolatedAndEnabled()
Node.ResetPhysicsInterpolation()
Node.CanAutoTranslate()
Node.SetTranslationDomainInherited()
Node.GetWindow()
Node.GetLastExclusiveWindow()
Node.GetTree()
Node.CreateTween()
Node.GetSceneInstanceLoadPlaceholder()
Node.IsEditableInstance(Node)
Node.GetViewport()
Node.QueueFree()
Node.RequestReady()
Node.IsNodeReady()
Node.GetMultiplayerAuthority()
Node.IsMultiplayerAuthority()
Node.RpcConfig(StringName, Variant)
Node.GetNodeRpcConfig()
Node.Rpc(StringName, params Variant[])
Node.UpdateConfigurationWarnings()
Node.CallDeferredThreadGroup(StringName, params Variant[])
Node.SetDeferredThreadGroup(StringName, Variant)
Node.CallThreadSafe(StringName, params Variant[])
Node.SetThreadSafe(StringName, Variant)
Node.EmitSignalReady()
Node.EmitSignalRenamed()
Node.EmitSignalTreeEntered()
Node.EmitSignalTreeExiting()
Node.EmitSignalTreeExited()
Node.EmitSignalChildEnteredTree(Node)
Node.EmitSignalChildExitingTree(Node)
Node.EmitSignalChildOrderChanged()
Node.EmitSignalReplacingBy(Node)
Node.EmitSignalEditorDescriptionChanged(Node)
Node.EmitSignalEditorStateChanged()
Node.InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Node.HasGodotClassMethod(in godot_string_name)
Node.HasGodotClassSignal(in godot_string_name)
Node.Name
Node.UniqueNameInOwner
Node.SceneFilePath
Node.Owner
Node.Multiplayer
Node.ProcessMode
Node.ProcessPriority
Node.ProcessPhysicsPriority
Node.ProcessThreadGroup
Node.ProcessThreadGroupOrder
Node.ProcessThreadMessages
Node.PhysicsInterpolationMode
Node.AutoTranslateMode
Node.EditorDescription
Node.Ready
Node.Renamed
Node.TreeEntered
Node.TreeExiting
Node.TreeExited
Node.ChildEnteredTree
Node.ChildExitingTree
Node.ChildOrderChanged
Node.ReplacingBy
Node.EditorDescriptionChanged
Node.EditorStateChanged
GodotObject.NotificationPostinitialize
GodotObject.NotificationPredelete
GodotObject.NotificationExtensionReloaded
GodotObject.IsInstanceValid(GodotObject)
GodotObject.WeakRef(GodotObject)
GodotObject.Dispose()
GodotObject.ToString()
GodotObject.ToSignal(GodotObject, StringName)
GodotObject._Get(StringName)
GodotObject._GetPropertyList()
GodotObject._IterGet(Variant)
GodotObject._IterInit(Array)
GodotObject._IterNext(Array)
GodotObject._PropertyCanRevert(StringName)
GodotObject._PropertyGetRevert(StringName)
GodotObject._Set(StringName, Variant)
GodotObject._ValidateProperty(Dictionary)
GodotObject.Free()
GodotObject.GetClass()
GodotObject.Set(StringName, Variant)
GodotObject.Get(StringName)
GodotObject.SetIndexed(NodePath, Variant)
GodotObject.GetIndexed(NodePath)
GodotObject.GetPropertyList()
GodotObject.GetMethodList()
GodotObject.PropertyCanRevert(StringName)
GodotObject.PropertyGetRevert(StringName)
GodotObject.GetInstanceId()
GodotObject.SetScript(Variant)
GodotObject.GetScript()
GodotObject.SetMeta(StringName, Variant)
GodotObject.RemoveMeta(StringName)
GodotObject.GetMeta(StringName, Variant)
GodotObject.HasMeta(StringName)
GodotObject.GetMetaList()
GodotObject.HasUserSignal(StringName)
GodotObject.RemoveUserSignal(StringName)
GodotObject.EmitSignal(StringName, params Variant[])
GodotObject.Call(StringName, params Variant[])
GodotObject.CallDeferred(StringName, params Variant[])
GodotObject.SetDeferred(StringName, Variant)
GodotObject.Callv(StringName, Array)
GodotObject.HasMethod(StringName)
GodotObject.GetMethodArgumentCount(StringName)
GodotObject.HasSignal(StringName)
GodotObject.GetSignalList()
GodotObject.GetSignalConnectionList(StringName)
GodotObject.GetIncomingConnections()
GodotObject.Disconnect(StringName, Callable)
GodotObject.IsConnected(StringName, Callable)
GodotObject.HasConnections(StringName)
GodotObject.IsBlockingSignals()
GodotObject.NotifyPropertyListChanged()
GodotObject.CanTranslateMessages()
GodotObject.Tr(StringName, StringName)
GodotObject.GetTranslationDomain()
GodotObject.SetTranslationDomain(StringName)
GodotObject.IsQueuedForDeletion()
GodotObject.CancelFree()
GodotObject.EmitSignalScriptChanged()
GodotObject.EmitSignalPropertyListChanged()
GodotObject.NativeInstance
GodotObject.ScriptChanged
GodotObject.PropertyListChanged

Properties

Instance

public static SettingsManager? Instance { get; }

Property Value

SettingsManager

Methods

EmitSignalDialogueSizeChanged(float)

protected void EmitSignalDialogueSizeChanged(float newSize)

Parameters

newSize float

EmitSignalInputBindingChanged(string)

protected void EmitSignalInputBindingChanged(string action)

Parameters

action string

EmitSignalSettingsChanged(string, Variant)

protected void EmitSignalSettingsChanged(string settingKey, Variant newValue)

Parameters

settingKey string
newValue Variant

GetDialogueSize()

Gets the current dialogue size setting.

public float GetDialogueSize()

Returns

float

The dialogue size as a float, defaulting to 1.0f if not set.

Remarks

This method retrieves the dialogue size from the settings data. If the dialogue size is not set, it returns a default value of 1.0f.

GetInputBinding(string)

Gets the current input binding for an action.

public InputEvent? GetInputBinding(string action)

Parameters

action string

The action name to retrieve the binding for.

Returns

InputEvent

The InputEvent bound to the action, or null if not found.

GetSetting<T>(string, T?)

Gets a custom setting by key, with an optional default value.

public T? GetSetting<T>(string key, T? defaultValue = default)

Parameters

key string

The key of the setting to retrieve.

defaultValue T

The default value to return if the setting is not found.

Returns

T

The setting value if found, otherwise the default value.

Type Parameters

T

The type of the setting value.

Remarks

This method retrieves a custom setting from the settings data. If the setting is not found, it returns the provided default value. It uses JSON serialization to convert the setting value to the specified type.

Initialize()

Initializes the SettingsManager singleton instance. Loads settings from the JSON file or creates a new default settings object.

protected override void Initialize()

Remarks

This method is called automatically by Godot when the node is ready. It ensures that only one instance of SettingsManager exists and initializes the settings data. If the settings file does not exist, it creates a new default settings object and saves it.

LoadSettings()

Loads settings from the JSON file. If the file does not exist, creates a new default settings object.

public virtual void LoadSettings()

Remarks

This method reads the settings from a JSON file located at user://settings.json. If the file is not found, it initializes a new SettingsData object with default values and saves it to create the settings file.

ResetToDefaults()

Resets all settings to their default values.

public void ResetToDefaults()

Remarks

This method clears the current settings and initializes a new SettingsData object with default values. It saves the new settings to the JSON file and emits a SettingsChanged signal to notify other components.

SaveSettings()

Saves the current settings to the JSON file.

public virtual void SaveSettings()

Remarks

This method serializes the current settings data to a JSON string and writes it to the user://settings.json file. It handles any exceptions that may occur during the file operations.

SetDialogueSize(float)

Sets the dialogue size and saves the settings. Emits a signal to notify other components of the change.

public void SetDialogueSize(float size)

Parameters

size float

The new dialogue size to set.

Remarks

This method updates the dialogue size in the settings data and saves it to the JSON file. It also emits a SettingsChanged signal to notify other components of the change. The size is clamped between 0.5f and 2.0f to ensure it remains within a reasonable range.

SetInputBinding(string, InputEvent?)

Sets a new input binding for an action and saves the settings. Emits a signal to notify other components of the change.

public void SetInputBinding(string action, InputEvent? inputEvent)

Parameters

action string

The action name to set the binding for.

inputEvent InputEvent

The InputEvent to bind to the action.

SetSetting<T>(string, T)

Sets a custom setting by key and saves the settings. Emits a signal to notify other components of the change.

public void SetSetting<T>(string key, T value)

Parameters

key string

The key of the setting to set.

value T

The value to set for the setting.

Type Parameters

T

The type of the setting value.

Remarks

This method updates a custom setting in the settings data and saves it to the JSON file. It also emits a SettingsChanged signal to notify other components of the change. The value is serialized to JSON format before being stored.

Events

DialogueSizeChanged

public event SettingsManager.DialogueSizeChangedEventHandler DialogueSizeChanged

Event Type

SettingsManager.DialogueSizeChangedEventHandler

InputBindingChanged

public event SettingsManager.InputBindingChangedEventHandler InputBindingChanged

Event Type

SettingsManager.InputBindingChangedEventHandler

SettingsChanged

public event SettingsManager.SettingsChangedEventHandler SettingsChanged

Event Type

SettingsManager.SettingsChangedEventHandler