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:
parent
2826e6f325
commit
bececff9e5
@ -25,6 +25,9 @@ namespace hex::init {
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
static bool checkForUpdates() {
|
||||
// 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 == 1){
|
||||
hex::Net net;
|
||||
|
||||
auto releases = net.getJson(GitHubApiURL + "/releases/latest"s, 2000).get();
|
||||
@ -42,6 +45,7 @@ namespace hex::init {
|
||||
if (latestVersion != currVersion)
|
||||
ImHexApi::System::impl::addInitArgument("update-available", latestVersion.data());
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -44,6 +44,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.welcome.learn.plugins.link", "https://github.com/WerWolv/ImHex/wiki/Plugins-Development-Guide" },
|
||||
{ "hex.builtin.welcome.header.various", "Verschiedenes" },
|
||||
{ "hex.builtin.welcome.tip_of_the_day", "Tipp des Tages" },
|
||||
// { "hex.builtin.welcome.check_for_updates_text", "Do you want to automatically check for updates on startup ?\n"
|
||||
// "Possible updates will be shown in the 'Update' tab of the welcome screen" },
|
||||
|
||||
{ "hex.builtin.welcome.safety_backup.title", "Verlorene Daten wiederherstellen" },
|
||||
{ "hex.builtin.welcome.safety_backup.desc", "Oh nein, ImHex ist letztes mal abgestürtzt.\nWillst du das verherige Projekt wiederherstellen?"},
|
||||
@ -779,6 +781,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "Kürzlich geöffnete Dateien" },
|
||||
{ "hex.builtin.setting.general", "Allgemein" },
|
||||
// { "hex.builtin.setting.general.check_for_updates", "Check for updates on startup" },
|
||||
{ "hex.builtin.setting.general.show_tips", "Tipps beim start anzeigen" },
|
||||
{ "hex.builtin.setting.general.auto_load_patterns", "Automatisches Pattern laden" },
|
||||
{ "hex.builtin.setting.general.sync_pattern_source", "Pattern Source Code zwischen Providern synchronisieren" },
|
||||
|
@ -45,6 +45,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.welcome.learn.plugins.link", "https://github.com/WerWolv/ImHex/wiki/Plugins-Development-Guide" },
|
||||
{ "hex.builtin.welcome.header.various", "Various" },
|
||||
{ "hex.builtin.welcome.tip_of_the_day", "Tip of the Day" },
|
||||
{ "hex.builtin.welcome.check_for_updates_text", "Do you want to automatically check for updates on startup ?\n"
|
||||
"Possible updates will be shown in the 'Update' tab of the welcome screen" },
|
||||
|
||||
{ "hex.builtin.welcome.safety_backup.title", "Restore lost data" },
|
||||
{ "hex.builtin.welcome.safety_backup.desc", "Oh no, ImHex crashed last time.\nDo you want to restore your past work?"},
|
||||
@ -784,6 +786,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "Recent Files" },
|
||||
{ "hex.builtin.setting.general", "General" },
|
||||
{ "hex.builtin.setting.general.check_for_updates", "Check for updates on startup" },
|
||||
{ "hex.builtin.setting.general.show_tips", "Show tips on startup" },
|
||||
{ "hex.builtin.setting.general.auto_load_patterns", "Auto-load supported pattern" },
|
||||
{ "hex.builtin.setting.general.sync_pattern_source", "Sync pattern source code between providers" },
|
||||
|
@ -44,6 +44,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.welcome.learn.plugins.link", "https://github.com/WerWolv/ImHex/wiki/Plugins-Development-Guide" },
|
||||
{ "hex.builtin.welcome.header.various", "Varie" },
|
||||
{ "hex.builtin.welcome.tip_of_the_day", "Consiglio del giorno" },
|
||||
// { "hex.builtin.welcome.check_for_updates_text", "Do you want to automatically check for updates on startup ?\n"
|
||||
// "Possible updates will be shown in the 'Update' tab of the welcome screen" },
|
||||
|
||||
{ "hex.builtin.welcome.safety_backup.title", "Ripristina i dati persi" },
|
||||
{ "hex.builtin.welcome.safety_backup.desc", "Oh no, l'ultima volta ImHex è crashato.\nVuoi ripristinare il tuo lavoro?"},
|
||||
@ -788,6 +790,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "File recenti" },
|
||||
{ "hex.builtin.setting.general", "Generali" },
|
||||
// { "hex.builtin.setting.general.check_for_updates", "Check for updates on startup" },
|
||||
{ "hex.builtin.setting.general.show_tips", "Mostra consigli all'avvio" },
|
||||
{ "hex.builtin.setting.general.auto_load_patterns", "Auto-caricamento del pattern supportato" },
|
||||
// { "hex.builtin.setting.general.sync_pattern_source", "Sync pattern source code between providers" },
|
||||
|
@ -44,6 +44,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.welcome.learn.plugins.link", "https://github.com/WerWolv/ImHex/wiki/Plugins-Development-Guide" },
|
||||
{ "hex.builtin.welcome.header.various", "Various" }, //?
|
||||
{ "hex.builtin.welcome.tip_of_the_day", "今日の豆知識" },
|
||||
// { "hex.builtin.welcome.check_for_updates_text", "Do you want to automatically check for updates on startup ?\n"
|
||||
// "Possible updates will be shown in the 'Update' tab of the welcome screen" },
|
||||
|
||||
{ "hex.builtin.welcome.safety_backup.title", "セッションの回復" },
|
||||
{ "hex.builtin.welcome.safety_backup.desc", "ImHexがクラッシュしました。\n前のデータを復元しますか?"},
|
||||
@ -786,6 +788,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "最近開いたファイル" },
|
||||
{ "hex.builtin.setting.general", "基本" },
|
||||
// { "hex.builtin.setting.general.check_for_updates", "Check for updates on startup" },
|
||||
{ "hex.builtin.setting.general.show_tips", "起動時に豆知識を表示" },
|
||||
{ "hex.builtin.setting.general.auto_load_patterns", "対応するパターンを自動で読み込む" },
|
||||
{ "hex.builtin.setting.general.sync_pattern_source", "プロバイダ間のパターンソースコードを同期" },
|
||||
|
@ -44,6 +44,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.welcome.learn.plugins.link", "https://github.com/WerWolv/ImHex/wiki/Plugins-Development-Guide" },
|
||||
{ "hex.builtin.welcome.header.various", "Various" },
|
||||
{ "hex.builtin.welcome.tip_of_the_day", "오늘의 팁" },
|
||||
// { "hex.builtin.welcome.check_for_updates_text", "Do you want to automatically check for updates on startup ?\n"
|
||||
// "Possible updates will be shown in the 'Update' tab of the welcome screen" },
|
||||
|
||||
{ "hex.builtin.welcome.safety_backup.title", "손상된 데이터 복구" },
|
||||
{ "hex.builtin.welcome.safety_backup.desc", "이전에 ImHex가 비 정상적으로 종료된 것 같습니다.\n이전의 작업을 복구할까요?"},
|
||||
@ -783,6 +785,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "최근 파일" },
|
||||
{ "hex.builtin.setting.general", "일반" },
|
||||
// { "hex.builtin.setting.general.check_for_updates", "Check for updates on startup" },
|
||||
{ "hex.builtin.setting.general.show_tips", "시작 시 팁 표시" },
|
||||
{ "hex.builtin.setting.general.auto_load_patterns", "지원하는 패턴 자동으로 로드" },
|
||||
{ "hex.builtin.setting.general.sync_pattern_source", "공급자 간 패턴 소스 코드 동기화" },
|
||||
|
@ -44,6 +44,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.welcome.learn.plugins.link", "https://github.com/WerWolv/ImHex/wiki/Plugins-Development-Guide" },
|
||||
{ "hex.builtin.welcome.header.various", "Vários" },
|
||||
{ "hex.builtin.welcome.tip_of_the_day", "Dica do Dia" },
|
||||
// { "hex.builtin.welcome.check_for_updates_text", "Do you want to automatically check for updates on startup ?\n"
|
||||
// "Possible updates will be shown in the 'Update' tab of the welcome screen" },
|
||||
|
||||
{ "hex.builtin.welcome.safety_backup.title", "Restaurar dados perdidos" },
|
||||
{ "hex.builtin.welcome.safety_backup.desc", "Ah não, ImHex crashou na ultima vez.\nDeseja restaurar seu trabalho anterior?"},
|
||||
@ -782,6 +784,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "Arquivos Recentes" },
|
||||
{ "hex.builtin.setting.general", "General" },
|
||||
// { "hex.builtin.setting.general.check_for_updates", "Check for updates on startup" },
|
||||
{ "hex.builtin.setting.general.show_tips", "Mostrar dicas na inicialização" },
|
||||
{ "hex.builtin.setting.general.auto_load_patterns", "Padrão compatível com carregamento automático" },
|
||||
// { "hex.builtin.setting.general.sync_pattern_source", "Sync pattern source code between providers" },
|
||||
|
@ -44,6 +44,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.welcome.learn.plugins.link", "https://github.com/WerWolv/ImHex/wiki/Plugins-Development-Guide" },
|
||||
{ "hex.builtin.welcome.header.various", "杂项" },
|
||||
{ "hex.builtin.welcome.tip_of_the_day", "每日提示" },
|
||||
// { "hex.builtin.welcome.check_for_updates_text", "Do you want to automatically check for updates on startup ?\n"
|
||||
// "Possible updates will be shown in the 'Update' tab of the welcome screen" },
|
||||
|
||||
{ "hex.builtin.welcome.safety_backup.title", "恢复崩溃数据" },
|
||||
{ "hex.builtin.welcome.safety_backup.desc", "糟糕,ImHex 上次崩溃了!\n您想从异常转储中恢复之前的数据吗?"},
|
||||
@ -784,6 +786,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "最近文件" },
|
||||
{ "hex.builtin.setting.general", "通用" },
|
||||
// { "hex.builtin.setting.general.check_for_updates", "Check for updates on startup" },
|
||||
{ "hex.builtin.setting.general.show_tips", "在启动时显示每日提示" },
|
||||
{ "hex.builtin.setting.general.auto_load_patterns", "自动加载支持的模式" },
|
||||
{ "hex.builtin.setting.general.sync_pattern_source", "在提供器间同步模式源码" },
|
||||
|
@ -44,6 +44,8 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.welcome.learn.plugins.link", "https://github.com/WerWolv/ImHex/wiki/Plugins-Development-Guide" },
|
||||
{ "hex.builtin.welcome.header.various", "多樣" },
|
||||
{ "hex.builtin.welcome.tip_of_the_day", "今日提示" },
|
||||
// { "hex.builtin.welcome.check_for_updates_text", "Do you want to automatically check for updates on startup ?\n"
|
||||
// "Possible updates will be shown in the 'Update' tab of the welcome screen" },
|
||||
|
||||
{ "hex.builtin.welcome.safety_backup.title", "復原遺失資料" },
|
||||
{ "hex.builtin.welcome.safety_backup.desc", "喔不,ImHex 上次崩潰了。\n您要復原您的工作階段嗎?"},
|
||||
@ -782,6 +784,7 @@ namespace hex::plugin::builtin {
|
||||
{ "hex.builtin.setting.imhex", "ImHex" },
|
||||
{ "hex.builtin.setting.imhex.recent_files", "近期檔案" },
|
||||
{ "hex.builtin.setting.general", "一般" },
|
||||
// { "hex.builtin.setting.general.check_for_updates", "Check for updates on startup" },
|
||||
{ "hex.builtin.setting.general.show_tips", "啟動時顯示提示" },
|
||||
{ "hex.builtin.setting.general.auto_load_patterns", "自動載入支援的模式" },
|
||||
{ "hex.builtin.setting.general.sync_pattern_source", "同步提供者之間的模式原始碼" },
|
||||
|
Loading…
Reference in New Issue
Block a user