#ifndef SETTINGS_H
#define SETTINGS_H

#include <QSettings>

namespace Settings
{

static QMap<QString, QVariant> defaults = {
    // General info
    {"General/UI_scale", "100"},
    {"General/CurrentInitStage", "0"},
    {"General/MicroUpdates", false},
    {"General/PatchDownloadDir", "data"},

    // Lotro Manager
    {"Lotro/game_path", "none"},
    {"Lotro/original_locale", "English"},
    {"Lotro/skip_raw_download", "True"},
    {"Lotro/no_splash_screen", "True"},

    // Databases download settings

    {"DatabaseDownload/text", false},          // TextsPatch
    {"DatabaseDownload/font", false},          // TextsPatch
    {"DatabaseDownload/image", false},         // GraphicsPatch
    {"DatabaseDownload/loadscreen", false},    // GraphicsPatch
    {"DatabaseDownload/texture", false},       // GraphicsPatch
    {"DatabaseDownload/sound", false},         // SoundsPatch
    {"DatabaseDownload/video", false},         // VideosPatch

    // Flags, meaning that database is fresh and needs to be installed

    {"DatabaseUpdated/text", false},           // TextsPatch
    {"DatabaseUpdated/font", false},           // TextsPatch
    {"DatabaseUpdated/image", false},          // GraphicsPatch
    {"DatabaseUpdated/loadscreen", false},     // GraphicsPatch
    {"DatabaseUpdated/texture", false},        // GraphicsPatch
    {"DatabaseUpdated/sound", false},          // SoundsPatch
    {"DatabaseUpdated/video", false},          // VideosPatch

    // Localisation components
    {"Components/fonts", false},               // TextsPatch
    {"Components/texts_main", false},          // TextsPatch
    {"Components/texts_items", false},         // TextsPatch
    {"Components/texts_emotes", false},        // TextsPatch
    {"Components/maps", false},                // ImagesPatch
    {"Components/loadscreens", false},         // ImagesPatch
    {"Components/textures", false},            // ImagesPatch
    {"Components/sounds", false},              // SoundsPatch
    {"Components/videos", false},              // VideosPatch

    // Network
    {"Network/site_url", "http://translate.lotros.ru/"},
    {"Network/forum_url", "http://lotros.ru/"},
    {"Network/discord_url", "https://discord.gg/j25MdKR"},
    {"Network/add_report_url", "http://translate.lotros.ru/bugs/add"},
    {"Network/donate_url", "http://translate.lotros.ru/donate"},
    {"Network/game_servers_status", "http://translate.lotros.ru/servers.txt"},
    {"Network/game_servers_message", "http://translate.lotros.ru/profmessage.txt"},
    {"Network/weekly_code_url", "http://translate.lotros.ru/coupon.txt"},
    {"Network/news_list_url", "http://translate.lotros.ru/groupware/launcher_news/30/1"},
    {"Network/patch_updates_url", "http://translate.lotros.ru/groupware/check_updates"}
};

static void setDefaultSettings()
{
    QSettings settings;
    foreach (QString key, defaults.keys()) {
        settings.setValue(key, defaults[key]);
    }
}

static QVariant getValue(QString key) {
    QSettings settings;
    return settings.value(key, defaults[key]);
}

static void setValue(QString key, QVariant value) {
    QSettings settings;
    settings.setValue(key, value);
}


}

#endif // SETTINGS_H
