# API

**Assembly:** `Spark.GameSettings` **Interface:** `IGameSettingsPlugin` **Implementation:** `GameSettingsPlugin`

## Interface

```csharp
public interface IGameSettingsPlugin
{
    // Video
    void SetResolution(int width, int height, FullScreenMode mode);
    int GetResolutionWidth();
    int GetResolutionHeight();
    void SetWindowMode(FullScreenMode mode);
    FullScreenMode GetWindowMode();
    void SetVSync(bool enabled);
    bool GetVSync();
    void SetFrameRateLimit(int limit);
    int GetFrameRateLimit();
    void SetQualityLevel(int level);
    int GetQualityLevel();
    void SetAntiAliasing(int level);
    int GetAntiAliasing();
    void SetTextureQuality(int quality);
    int GetTextureQuality();

    // Audio
    void SetVolume(AudioChannel channel, float volume);
    float GetVolume(AudioChannel channel);
    void SetAudioMixer(AudioMixer mixer);

    // Keybinds
    void RegisterInputActionAsset(InputActionAsset asset);
    void StartInteractiveRebind(string actionId, int bindingIndex,
        Action onComplete, Action onCancel);
    void CancelInteractiveRebind();
    void ResetBinding(string actionId, int bindingIndex);
    void ClearBinding(string actionId, int bindingIndex);
    void ResetAllBindings();
    string GetBindingDisplayString(string actionId, int bindingIndex);
    InputAction FindConflictingBinding(string bindingPath, string excludeActionId);

    // Persistence
    Task SaveSettingsAsync();
    void SaveSettings();
    Task LoadSettingsAsync();
    void ResetToDefaults();

    // Data access
    VideoSettingsData GetVideoSettings();
    AudioSettingsData GetAudioSettings();
    KeybindSettingsData GetKeybindSettings();
}
```

## AudioChannel Enum

```csharp
public enum AudioChannel
{
    Master,
    Music,
    SFX,
    UI
}
```

## Save Data Classes

### VideoSettingsData

Extends `SaveDataEntry`.

| Field              | Type           | Description                         |
| ------------------ | -------------- | ----------------------------------- |
| `resolutionWidth`  | int            | Screen width in pixels              |
| `resolutionHeight` | int            | Screen height in pixels             |
| `windowMode`       | FullScreenMode | Fullscreen, windowed, or borderless |
| `vSyncEnabled`     | bool           | Vertical sync toggle                |
| `frameRateLimit`   | int            | Max framerate (0 = unlimited)       |
| `qualityLevel`     | int            | Unity quality settings index        |
| `antiAliasing`     | int            | Anti-aliasing level                 |
| `textureQuality`   | int            | Texture resolution level            |

### AudioSettingsData

Extends `SaveDataEntry`.

| Field          | Type  | Description                    |
| -------------- | ----- | ------------------------------ |
| `masterVolume` | float | Master volume in dB (-80 to 0) |
| `musicVolume`  | float | Music volume in dB (-80 to 0)  |
| `sfxVolume`    | float | SFX volume in dB (-80 to 0)    |
| `uiVolume`     | float | UI volume in dB (-80 to 0)     |

### KeybindSettingsData

Extends `SaveDataEntry`.

| Field            | Type                            | Description                |
| ---------------- | ------------------------------- | -------------------------- |
| `assetOverrides` | List\<InputActionAssetOverride> | Per-asset rebind overrides |

Each `InputActionAssetOverride` contains:

| Field           | Type   | Description                  |
| --------------- | ------ | ---------------------------- |
| `assetGuid`     | string | GUID of the InputActionAsset |
| `assetName`     | string | Human-readable asset name    |
| `overridesJson` | string | Serialized rebind data       |

## Events

| Event                     | Description                                   |
| ------------------------- | --------------------------------------------- |
| `KeybindChangedEvent`     | Published when a keybind is rebound           |
| `GameSettingsLoadedEvent` | Published after settings are loaded from disk |

## Usage

```csharp
var settings = Spark.GetPlugin<IGameSettingsPlugin>();
if (settings != null)
{
    // Audio
    settings.SetVolume(AudioChannel.Master, -10f);
    float masterVol = settings.GetVolume(AudioChannel.Master);

    // Video
    settings.SetResolution(1920, 1080, FullScreenMode.FullScreenWindow);
    settings.SetVSync(true);

    // Keybinds
    settings.RegisterInputActionAsset(myInputActions);
    settings.StartInteractiveRebind("Jump", 0,
        onComplete: () => Debug.Log("Rebound!"),
        onCancel: () => Debug.Log("Cancelled"));

    // Save
    await settings.SaveSettingsAsync();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sparkframework.dev/documentation/developer-guide/core-systems/gamesettings/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
