mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Ask the users if they want to check for updates (#803)
* ask the users for updates * Only treat 1 as enabled * Fix formatting * update locales * comment to document value
This commit is contained in:
@@ -35,6 +35,22 @@ namespace hex::plugin::builtin {
|
||||
|
||||
/* General */
|
||||
|
||||
/* Values of this setting :
|
||||
0 - do not check for updates on startup
|
||||
1 - check for updates on startup
|
||||
2 - default value - ask the user if he wants to check for updates. This value should only be encountered on the first startup.
|
||||
*/
|
||||
ContentRegistry::Settings::add("hex.builtin.setting.general", "hex.builtin.setting.general.check_for_updates", 2, [](auto name, nlohmann::json &setting) {
|
||||
static bool enabled = static_cast<int>(setting) == 1;
|
||||
|
||||
if (ImGui::Checkbox(name.data(), &enabled)) {
|
||||
setting = static_cast<int>(enabled);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
ContentRegistry::Settings::add("hex.builtin.setting.general", "hex.builtin.setting.general.show_tips", 1, [](auto name, nlohmann::json &setting) {
|
||||
static bool enabled = static_cast<int>(setting);
|
||||
|
||||
|
||||
@@ -517,6 +517,21 @@ namespace hex::plugin::builtin {
|
||||
loadDefaultLayout();
|
||||
});
|
||||
|
||||
EventManager::subscribe<EventWindowInitialized>([] {
|
||||
// documentation of the value above the setting definition
|
||||
int showCheckForUpdates = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.check_for_updates", 2);
|
||||
if (showCheckForUpdates == 2) {
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.check_for_updates", 0);
|
||||
View::showYesNoQuestionPopup("hex.builtin.welcome.check_for_updates_text"_lang,
|
||||
[] { // yes
|
||||
ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.check_for_updates", 1);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}, [] { // no
|
||||
ImGui::CloseCurrentPopup();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1075, [&] {
|
||||
if (ImGui::BeginMenu("hex.builtin.menu.file.open_recent"_lang, !s_recentProvidersUpdating && !s_recentProviders.empty())) {
|
||||
// Copy to avoid changing list while iteration
|
||||
|
||||
Reference in New Issue
Block a user