fix: Properly save achievements in web version
This commit is contained in:
parent
42c1f5601a
commit
248acd5e26
@ -215,7 +215,16 @@ namespace hex {
|
||||
}
|
||||
|
||||
try {
|
||||
auto json = nlohmann::json::parse(file.readString());
|
||||
#if defined(OS_WEB)
|
||||
auto data = (char *) MAIN_THREAD_EM_ASM_INT({
|
||||
let data = localStorage.getItem("achievements");
|
||||
return data ? stringToNewUTF8(data) : null;
|
||||
});
|
||||
#else
|
||||
auto data = file.readString();
|
||||
#endif
|
||||
|
||||
auto json = nlohmann::json::parse(data);
|
||||
|
||||
for (const auto &[categoryName, achievements] : getAchievements()) {
|
||||
for (const auto &[achievementName, achievement] : achievements) {
|
||||
@ -254,6 +263,12 @@ namespace hex {
|
||||
if (json.empty())
|
||||
return;
|
||||
|
||||
#if defined(OS_WEB)
|
||||
auto data = json.dump();
|
||||
MAIN_THREAD_EM_ASM({
|
||||
localStorage.setItem("config", UTF8ToString($0));
|
||||
}, data.c_str());
|
||||
#else
|
||||
for (const auto &directory : paths::Config.write()) {
|
||||
auto path = directory / AchievementsFile;
|
||||
|
||||
@ -264,6 +279,7 @@ namespace hex {
|
||||
file.writeString(json.dump(4));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
@ -30,7 +30,14 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
// Load settings
|
||||
m_showPopup = ContentRegistry::Settings::read<bool>("hex.builtin.setting.interface", "hex.builtin.setting.interface.achievement_popup", true);
|
||||
{
|
||||
bool defaultValue = true;
|
||||
#if defined(OS_WEB)
|
||||
defaultValue = false;
|
||||
#endif
|
||||
|
||||
m_showPopup = ContentRegistry::Settings::read<bool>("hex.builtin.setting.interface", "hex.builtin.setting.interface.achievement_popup", defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
ViewAchievements::~ViewAchievements() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user