123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- #include <QSettings>
- #include "settings.h"
- namespace Settings {
- 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", false},
- // Backup
- {"Backup/installed", false},
- {"Backup/path", "/backup/"},
- {"Backup/creation_time", "none"},
- // Databases download settings (true means component is enabled)
- {"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
- {"DatabaseDownload/micro", false}, // MicroPatch
- // Network settings
- {"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"}
- };
- void setDefaultSettings()
- {
- QSettings settings;
- foreach (QString key, defaults.keys()) {
- settings.setValue(key, defaults[key]);
- }
- }
- QVariant getValue(QString key) {
- QSettings settings;
- return settings.value(key, defaults.value(key, QVariant()));
- }
- void setValue(QString key, QVariant value) {
- QSettings settings;
- settings.setValue(key, value);
- }
- SettingsBackup createSettingsBackup() {
- QSettings settings;
- QMap<QString, QVariant> keysValuesPairs;
- QStringList keys = settings.allKeys();
- QStringListIterator it(keys);
- while (it.hasNext()) {
- QString currentKey = it.next();
- keysValuesPairs.insert(currentKey, settings.value(currentKey));
- }
- return keysValuesPairs;
- }
- void restoreFromSettingsBackup(const SettingsBackup& backup) {
- QSettings settings;
- settings.clear();
- for (auto i = backup.begin(); i != backup.end(); ++i) {
- settings.setValue(i.key(), i.value());
- }
- }
- void updatePatchComponentsDependencies() {
- QSettings settings;
- auto isComponentActive = [&settings](const QString& component) -> bool {
- return settings.value("Components/" + component).toBool();
- };
- if (isComponentActive("texts_main") || isComponentActive("texts_items")
- || isComponentActive("texts_emotes") || isComponentActive("videos")) {
- // Videos also need text database, because it contains videos path references
- settings.setValue("DatabaseDownload/text", true);
- } else {
- settings.setValue("DatabaseDownload/text", false);
- }
- if (isComponentActive("texts_main") || isComponentActive("texts_items")
- || isComponentActive("texts_emotes")) {
- settings.setValue("DatabaseDownload/font", true);
- } else {
- settings.setValue("DatabaseDownload/font", false);
- }
- settings.setValue("DatabaseDownload/image", isComponentActive("maps"));
- settings.setValue("DatabaseDownload/loadscreen", isComponentActive("loadscreens"));
- settings.setValue("DatabaseDownload/texture", isComponentActive("textures"));
- settings.setValue("DatabaseDownload/sound", isComponentActive("sounds"));
- settings.setValue("DatabaseDownload/video", isComponentActive("videos"));
- settings.setValue("DatabaseDownload/micro", isComponentActive("micropatch"));
- }
- } /* namespace Settings */
|