#include "settings.h"

typedef struct settings_s
{
    Uint8  volume;
    bool   fullscreen;
} settings_t;

static settings_t settings;

void Settings_Init(void)
{
    settings.volume     = MIX_MAX_VOLUME / 2;
    settings.fullscreen = false;
}

void Settings_Load(void)
{
    FILE *file = NULL;

    file = fopen(SETTINGS_FILENAME, "rb");

    if (file != NULL)
        fread(&settings, sizeof(settings), 1, file);

    fclose(file);
}

void Settings_Save(void)
{
    FILE *file = NULL;

    file = fopen(SETTINGS_FILENAME, "wb");

    if (file != NULL)
        fwrite(&settings, sizeof(settings), 1, file);

    fclose(file);
}

void Settings_SetVolume(Uint8 volume)
{
    settings.volume = volume;
}

void Settings_SetFullscreen(bool fullscreen)
{
    settings.fullscreen = fullscreen;
}

Uint8 Settings_GetVolume(void)
{
    return settings.volume;
}

bool Settings_GetFullscreen(void)
{
    return settings.fullscreen;
}
