1
0
mirror of synced 2024-09-24 11:38:26 +02:00

impr: Store settings and achievements immediately

This commit is contained in:
WerWolv 2024-05-15 18:25:33 +02:00
parent 6a9e07729f
commit ca17054a1e
3 changed files with 3 additions and 12 deletions

View File

@ -340,6 +340,8 @@ namespace hex {
void write(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const std::common_type_t<T> &value) {
impl::getSetting(unlocalizedCategory, unlocalizedName, value) = value;
impl::runOnChangeHandlers(unlocalizedCategory, unlocalizedName, value);
impl::store();
}
using OnChangeCallback = std::function<void(const SettingsValue &)>;

View File

@ -234,17 +234,6 @@ namespace hex::init {
return true;
}
bool storeSettings() {
try {
ContentRegistry::Settings::impl::store();
AchievementManager::storeProgress();
} catch (std::exception &e) {
log::error("Failed to store configuration! {}", e.what());
return false;
}
return true;
}
// Run all exit tasks, and print to console
void runExitTasks() {
for (const auto &[name, task, async] : init::getExitTasks()) {
@ -264,7 +253,6 @@ namespace hex::init {
std::vector<Task> getExitTasks() {
return {
{ "Saving settings", storeSettings, false },
{ "Prepare exit", prepareExit, false },
{ "Unloading plugins", unloadPlugins, false },
{ "Deleting old files", deleteOldFiles, false },

View File

@ -18,6 +18,7 @@ namespace hex::plugin::builtin {
// Add newly unlocked achievements to the display queue
EventAchievementUnlocked::subscribe(this, [this](const Achievement &achievement) {
m_achievementUnlockQueue.push_back(&achievement);
AchievementManager::storeProgress();
});
RequestOpenWindow::subscribe(this, [this](const std::string &name) {