From 6f5437d7f518d5ff077997ea45f947059d761f0a Mon Sep 17 00:00:00 2001 From: mrdude2478 Date: Tue, 3 Oct 2023 10:27:58 +0100 Subject: [PATCH] add autoplay music option --- include/util/config.hpp | 1 + romfs/lang/de.json | 1 + romfs/lang/en.json | 1 + romfs/lang/es.json | 1 + romfs/lang/fr.json | 1 + romfs/lang/it.json | 1 + romfs/lang/jp.json | 1 + romfs/lang/ru.json | 1 + romfs/lang/tw.json | 1 + source/ui/mainPage.cpp | 2 +- source/ui/optionsPage.cpp | 40 ++++++++++++++++++++++++++------------- source/util/config.cpp | 4 ++++ 12 files changed, 41 insertions(+), 14 deletions(-) diff --git a/include/util/config.hpp b/include/util/config.hpp index e67abb1..81d8c25 100644 --- a/include/util/config.hpp +++ b/include/util/config.hpp @@ -22,6 +22,7 @@ namespace inst::config { extern bool usbAck; extern bool useTheme; extern bool useSound; + extern bool useMusic; extern bool fixticket; extern bool listoveride; extern bool httpkeyboard; diff --git a/romfs/lang/de.json b/romfs/lang/de.json index adee39d..4a296bb 100644 --- a/romfs/lang/de.json +++ b/romfs/lang/de.json @@ -175,6 +175,7 @@ "ask_delete": "Frage ob installierte Titel gelöscht werden sollen", "auto_update": "Suche automatisch nach Updates für TinWoo", "useSound": "Nutzen von Benachrichtungstönen während Installation", + "useMusic": "Musik automatisch abspielen, wenn Tinwoo startet", "fixticket": "Wandeln Sie temporäre Tickets in permanente Tickets um", "listoveride": "Deaktivieren Sie die URL-Listenwarnung und die Dateibeschränkung", "usehttpkeyboard": "Verwenden Sie die Tastatur während der Installation des HTTP-Servers", diff --git a/romfs/lang/en.json b/romfs/lang/en.json index af75174..5d394fe 100644 --- a/romfs/lang/en.json +++ b/romfs/lang/en.json @@ -175,6 +175,7 @@ "ask_delete": "Ask to delete original files after installation", "auto_update": "Check for updates to TinWoo Installer automatically", "useSound": "Use sound notifications during installs", + "useMusic": "Autoplay music when Tinwoo starts", "fixticket": "Convert temporary tickets to permanent", "listoveride": "Disable URL list warning and file limit", "usehttpkeyboard": "Use keyboard during http server installs", diff --git a/romfs/lang/es.json b/romfs/lang/es.json index 18c1ecc..6adc790 100644 --- a/romfs/lang/es.json +++ b/romfs/lang/es.json @@ -175,6 +175,7 @@ "ask_delete": "Solicitar eliminar los archivos originales después de la instalación", "auto_update": "Busca actualizaciones para TinWoo Installer automáticamente", "useSound": "Usar notificaciones de sonido durante las instalaciones", + "useMusic": "Reproducción automática de música cuando se inicia Tinwoo", "fixticket": "Convertir tiquetes temporales en permanentes", "listoveride": "Deshabilitar advertencia de limite de elementos en el listado de un URL", "usehttpkeyboard": "Utilizar teclado durante instalaciones vía servidor HTTP", diff --git a/romfs/lang/fr.json b/romfs/lang/fr.json index b0ceb1c..636ee73 100644 --- a/romfs/lang/fr.json +++ b/romfs/lang/fr.json @@ -175,6 +175,7 @@ "ask_delete": "Demande de suppression des fichiers originaux après l'installation", "auto_update": "Vérifier les mises à jour de l'installateur TinWoo automatiquement", "useSound": "Utiliser les notifications sonores lors des installations", + "useMusic": "Lecture automatique de la musique au démarrage de Tinwoo", "fixticket": "Convertir des billets temporaires en billets permanents", "listoveride": "Désactiver l'avertissement de liste d'URL et la limite de fichiers", "usehttpkeyboard": "Utiliser le clavier lors des installations du serveur http", diff --git a/romfs/lang/it.json b/romfs/lang/it.json index 79233d6..fc7bbf0 100644 --- a/romfs/lang/it.json +++ b/romfs/lang/it.json @@ -175,6 +175,7 @@ "ask_delete": "Chiedi di cancellare i file originale dopo l'installazione", "auto_update": "Controlla aggiornamenti di TinWoo Installer automaticamente", "useSound": "Utilizza notifiche sonore durante le installazioni", + "useMusic": "Riproduci automaticamente la musica all'avvio di Tinwoo", "fixticket": "Converti i biglietti temporanei in permanenti", "listoveride": "Disabilita l'avviso dell'elenco degli URL e il limite dei file", "usehttpkeyboard": "Utilizzare la tastiera durante le installazioni del server http", diff --git a/romfs/lang/jp.json b/romfs/lang/jp.json index 2ce3bec..0d85efe 100644 --- a/romfs/lang/jp.json +++ b/romfs/lang/jp.json @@ -175,6 +175,7 @@ "ask_delete": "インストール後に元のファイルを削除する", "auto_update": "TinWooのアップデートを自動的に確認する", "useSound": "インストール時にサウンドで通知する", + "useMusic": "Tinwoo の起動時に音楽を自動再生", "fixticket": "一時的なチケットを永続的なチケットに変換する", "listoveride": "URL リストの警告とファイル制限を無効にする", "usehttpkeyboard": "httpサーバーのインストール中にキーボードを使用する", diff --git a/romfs/lang/ru.json b/romfs/lang/ru.json index 9379461..9559489 100644 --- a/romfs/lang/ru.json +++ b/romfs/lang/ru.json @@ -175,6 +175,7 @@ "ask_delete": "Спрашивать разрешения удалить исходные файлы после установки", "auto_update": "Автоматически проверять наличие обновлений", "useSound": "Используйте звуковые уведомления во время установки", + "useMusic": "Автовоспроизведение музыки при запуске Tinwoo", "fixticket": "Превратить временные билеты в постоянные", "listoveride": "Отключить предупреждение списка URL-адресов и ограничение количества файлов", "usehttpkeyboard": "Используйте клавиатуру во время установки http-сервера", diff --git a/romfs/lang/tw.json b/romfs/lang/tw.json index 71f9500..a44ee21 100644 --- a/romfs/lang/tw.json +++ b/romfs/lang/tw.json @@ -175,6 +175,7 @@ "ask_delete": "在安裝完成後,詢問是否刪除原始檔案", "auto_update": "自動檢查Tinwoo Installer的更新版本", "useSound": "在安裝過程中使用音效提醒進度", + "useMusic": "Tinwoo 啟動時自動播放音樂", "fixticket": "將臨時門票轉換為永久門票", "listoveride": "禁用 URL 列表警告和文件限制", "usehttpkeyboard": "在 http 服務器安裝期間使用鍵盤", diff --git a/source/ui/mainPage.cpp b/source/ui/mainPage.cpp index c2ade19..9a27001 100644 --- a/source/ui/mainPage.cpp +++ b/source/ui/mainPage.cpp @@ -285,7 +285,7 @@ namespace inst::ui { } this->Add(this->optionMenu); this->AddRenderCallback(mainMenuThread); - playmusic(); + if (inst::config::useMusic) playmusic(); } void MainPage::installMenuItem_Click() { diff --git a/source/ui/optionsPage.cpp b/source/ui/optionsPage.cpp index 7e0659d..85eae38 100644 --- a/source/ui/optionsPage.cpp +++ b/source/ui/optionsPage.cpp @@ -191,6 +191,11 @@ namespace inst::ui { useSoundOption->SetColor(COLOR("#FFFFFFFF")); useSoundOption->SetIcon(this->getMenuOptionIcon(inst::config::useSound)); this->menu->AddItem(useSoundOption); + + auto useMusicOption = pu::ui::elm::MenuItem::New("options.menu_items.useMusic"_lang); + useMusicOption->SetColor(COLOR("#FFFFFFFF")); + useMusicOption->SetIcon(this->getMenuOptionIcon(inst::config::useMusic)); + this->menu->AddItem(useMusicOption); auto fixticket = pu::ui::elm::MenuItem::New("options.menu_items.fixticket"_lang); fixticket->SetColor(COLOR("#FFFFFFFF")); @@ -217,12 +222,10 @@ namespace inst::ui { ThemeMenuOption->SetIcon("romfs:/images/icons/thememenu.png"); this->menu->AddItem(ThemeMenuOption); - // auto ThemeUrlOption = pu::ui::elm::MenuItem::New("theme.theme_url"_lang + inst::util::shortenString(inst::config::httplastUrl2, 42, false)); ThemeUrlOption->SetColor(COLOR("#FFFFFFFF")); ThemeUrlOption->SetIcon("romfs:/images/icons/themeurl.png"); this->menu->AddItem(ThemeUrlOption); - // auto SigPatch = pu::ui::elm::MenuItem::New("main.menu.sig"_lang); SigPatch->SetColor(COLOR("#FFFFFFFF")); @@ -342,6 +345,17 @@ namespace inst::ui { inst::config::setConfig(); break; case 6: + if (inst::config::useMusic) { + inst::config::useMusic = false; + } + else { + inst::config::useMusic = true; + } + this->setMenuText(); + this->menu->SetSelectedIndex(index); + inst::config::setConfig(); + break; + case 7: if (inst::config::fixticket) { inst::config::fixticket = false; } @@ -352,7 +366,7 @@ namespace inst::ui { this->menu->SetSelectedIndex(index); inst::config::setConfig(); break; - case 7: + case 8: if (inst::config::listoveride) { inst::config::listoveride = false; } @@ -363,7 +377,7 @@ namespace inst::ui { this->menu->SetSelectedIndex(index); inst::config::setConfig(); break; - case 8: + case 9: if (inst::config::httpkeyboard) { inst::config::httpkeyboard = false; } @@ -374,20 +388,20 @@ namespace inst::ui { this->menu->SetSelectedIndex(index); inst::config::setConfig(); break; - case 9: + case 10: thememessage(); inst::config::setConfig(); this->setMenuText(); this->menu->SetSelectedIndex(index); break; - case 10: + case 11: if (inst::util::getIPAddress() == "1.0.0.127") { inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/information.png"); break; } mainApp->ThemeinstPage->startNetwork(); break; - case 11: + case 12: keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::httplastUrl2.c_str(), 500); if (keyboardResult.size() > 0) { inst::config::httplastUrl2 = keyboardResult; @@ -396,10 +410,10 @@ namespace inst::ui { this->menu->SetSelectedIndex(index); } break; - case 12: + case 13: sigPatchesMenuItem_Click(); break; - case 13: + case 14: keyboardResult = inst::util::softwareKeyboard("options.sig_hint"_lang, inst::config::sigPatchesUrl.c_str(), 500); if (keyboardResult.size() > 0) { inst::config::sigPatchesUrl = keyboardResult; @@ -408,7 +422,7 @@ namespace inst::ui { this->menu->SetSelectedIndex(index); } break; - case 14: + case 15: keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::httpIndexUrl.c_str(), 500); if (keyboardResult.size() > 0) { inst::config::httpIndexUrl = keyboardResult; @@ -417,7 +431,7 @@ namespace inst::ui { this->menu->SetSelectedIndex(index); } break; - case 15: + case 16: languageList = languageStrings; languageList[0] = "options.language.system_language"_lang; //replace "sys" with local language string rc = inst::ui::mainApp->CreateShowDialog("options.language.title"_lang, "options.language.desc"_lang, languageList, false, flag); @@ -457,7 +471,7 @@ namespace inst::ui { mainApp->FadeOut(); mainApp->Close(); break; - case 16: + case 17: if (inst::util::getIPAddress() == "1.0.0.127") { inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/update.png"); break; @@ -469,7 +483,7 @@ namespace inst::ui { } this->askToUpdate(downloadUrl); break; - case 17: + case 18: inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, { "common.close"_lang }, true, "romfs:/images/icons/credits.png"); break; default: diff --git a/source/util/config.cpp b/source/util/config.cpp index c4abb62..41e720f 100644 --- a/source/util/config.cpp +++ b/source/util/config.cpp @@ -17,6 +17,7 @@ namespace inst::config { bool overClock; bool useTheme; bool useSound; + bool useMusic; bool usbAck; bool validateNCAs; bool fixticket; @@ -30,6 +31,7 @@ namespace inst::config { {"gAuthKey", gAuthKey}, {"useTheme", useTheme}, {"useSound", useSound}, + {"useMusic", useMusic}, {"ignoreReqVers", ignoreReqVers}, {"languageSetting", languageSetting}, {"overClock", overClock}, @@ -60,6 +62,7 @@ namespace inst::config { gAuthKey = j["gAuthKey"].get(); useTheme = j["useTheme"].get(); useSound = j["useSound"].get(); + useMusic = j["useMusic"].get(); ignoreReqVers = j["ignoreReqVers"].get(); languageSetting = j["languageSetting"].get(); overClock = j["overClock"].get(); @@ -82,6 +85,7 @@ namespace inst::config { deletePrompt = true; useTheme = false; useSound = true; + useMusic = true; fixticket = true; listoveride = false; httpkeyboard = false;