diff --git a/Assets/Text/DE.json b/Assets/Text/DE.json index d720d94..c0e5749 100644 --- a/Assets/Text/DE.json +++ b/Assets/Text/DE.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV unterstützt das Ausführen in Applets wie dem Album nicht mehr.\n\nStarte JKSV erneut, nachdem du ein Spiel oder eine Anwendung mit gedrückter [R]-Taste gestartet hast.\n\nDrücke [+], um zu beenden." + ], "BackupMenu": [ "0: Neues Backup" ], diff --git a/Assets/Text/ENGB.json b/Assets/Text/ENGB.json index dc0a961..63a122c 100644 --- a/Assets/Text/ENGB.json +++ b/Assets/Text/ENGB.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV no longer supports running under applets such as the album.\n\nRun JKSV again after starting a game or application while holding [R].\n\nPress [+] to exit." + ], "BackupMenu": [ "0: New Backup" ], diff --git a/Assets/Text/ENUS.json b/Assets/Text/ENUS.json index 0009594..3a4f47b 100644 --- a/Assets/Text/ENUS.json +++ b/Assets/Text/ENUS.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV no longer supports running under applets such as the album.\n\nRun JKSV again after starting a game or application while holding [R].\n\nPress [+] to exit." + ], "BackupMenu": [ "0: New Backup" ], diff --git a/Assets/Text/ES.json b/Assets/Text/ES.json index 40a998a..99b129f 100644 --- a/Assets/Text/ES.json +++ b/Assets/Text/ES.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV ya no es compatible con la ejecución en applets como el álbum.\n\nEjecuta JKSV nuevamente después de iniciar un juego o aplicación mientras mantienes presionado [R].\n\nPulsa [+] para salir." + ], "BackupMenu": [ "0: Nueva copia de seguridad" ], diff --git a/Assets/Text/ES419.json b/Assets/Text/ES419.json index 935e42c..ca6380b 100644 --- a/Assets/Text/ES419.json +++ b/Assets/Text/ES419.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV ya no es compatible con ejecutarse en applets como el álbum.\n\nInicia JKSV de nuevo después de abrir un juego o aplicación manteniendo presionado [R].\n\nPresiona [+] para salir." + ], "BackupMenu": [ "0: Nueva copia de seguridad" ], diff --git a/Assets/Text/FR.json b/Assets/Text/FR.json index 36527be..ffd2dbf 100644 --- a/Assets/Text/FR.json +++ b/Assets/Text/FR.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV ne prend plus en charge l’exécution dans des applets comme l’album.\n\nRelancez JKSV après avoir démarré un jeu ou une application en maintenant [R].\n\nAppuyez sur [+] pour quitter." + ], "BackupMenu": [ "0: Nouvelle sauvegarde" ], diff --git a/Assets/Text/FRCA.json b/Assets/Text/FRCA.json index 187e920..617affe 100644 --- a/Assets/Text/FRCA.json +++ b/Assets/Text/FRCA.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV ne prend plus en charge l’exécution dans des applets comme l’album.\n\nRelancez JKSV après avoir démarré un jeu ou une application en maintenant [R].\n\nAppuyez sur [+] pour quitter." + ], "BackupMenu": [ "0: Nouvelle sauvegarde" ], diff --git a/Assets/Text/IT.json b/Assets/Text/IT.json index 60ec58a..ee86b9c 100644 --- a/Assets/Text/IT.json +++ b/Assets/Text/IT.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV non supporta più l’esecuzione in applet come l’album.\n\nAvvia di nuovo JKSV dopo aver avviato un gioco o un'applicazione tenendo premuto [R].\n\nPremi [+] per uscire." + ], "BackupMenu": [ "0: Nuovo backup" ], diff --git a/Assets/Text/JA.json b/Assets/Text/JA.json index 0dd9b99..4423b4f 100644 --- a/Assets/Text/JA.json +++ b/Assets/Text/JA.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV はアルバムなどのアプレットでの実行をサポートしなくなりました。\n\n[R] を押しながらゲームまたはアプリケーションを起動した後、もう一度 JKSV を起動してください。\n\n終了するには [+] を押してください." + ], "BackupMenu": [ "0: 新しい バックアップ" ], diff --git a/Assets/Text/KO.json b/Assets/Text/KO.json index 471b9c6..72914ea 100644 --- a/Assets/Text/KO.json +++ b/Assets/Text/KO.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV는 앨범과 같은 앱렛에서의 실행을 더 이상 지원하지 않습니다.\n\n[R]을 누른 상태로 게임 또는 애플리케이션을 실행한 후 JKSV를 다시 실행하세요.\n\n종료하려면 [+]를 누르세요." + ], "BackupMenu": [ "0: 새 백업" ], diff --git a/Assets/Text/NL.json b/Assets/Text/NL.json index 8db46f7..829a7d5 100644 --- a/Assets/Text/NL.json +++ b/Assets/Text/NL.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV ondersteunt het uitvoeren onder applets zoals het album niet meer.\n\nStart JKSV opnieuw nadat je een spel of applicatie hebt gestart terwijl je [R] ingedrukt houdt.\n\nDruk op [+] om af te sluiten." + ], "BackupMenu": [ "0: Nieuwe back-up" ], diff --git a/Assets/Text/PT.json b/Assets/Text/PT.json index b980bf5..31aff04 100644 --- a/Assets/Text/PT.json +++ b/Assets/Text/PT.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: O JKSV já não suporta ser executado em applets como o álbum.\n\nExecute novamente o JKSV depois de iniciar um jogo ou aplicação enquanto mantém [R] pressionado.\n\nPrima [+] para sair." + ], "BackupMenu": [ "0: Novo Backup" ], diff --git a/Assets/Text/PTBR.json b/Assets/Text/PTBR.json index f96f230..dcb1b31 100644 --- a/Assets/Text/PTBR.json +++ b/Assets/Text/PTBR.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: O JKSV não oferece mais suporte para execução em applets como o álbum.\n\nExecute o JKSV novamente após iniciar um jogo ou aplicativo enquanto mantém [R] pressionado.\n\nPressione [+] para sair." + ], "BackupMenu": [ "0: Novo Backup" ], diff --git a/Assets/Text/RU.json b/Assets/Text/RU.json index 099add6..3802ac1 100644 --- a/Assets/Text/RU.json +++ b/Assets/Text/RU.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV больше не поддерживает запуск в апплетах, таких как Альбом.\n\nЗапустите JKSV снова после запуска игры или приложения, удерживая [R].\n\nНажмите [+], чтобы выйти." + ], "BackupMenu": [ "0: Новый бэкап" ], diff --git a/Assets/Text/ZHCN.json b/Assets/Text/ZHCN.json index 28499a2..f4ac723 100644 --- a/Assets/Text/ZHCN.json +++ b/Assets/Text/ZHCN.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV 不再支持在相册等小程序模式下运行。\n\n请在按住 [R] 启动游戏或应用后重新运行 JKSV。\n\n按 [+] 退出。" + ], "BackupMenu": [ "0: 新备份" ], diff --git a/Assets/Text/ZHTW.json b/Assets/Text/ZHTW.json index 738c828..f318dc1 100644 --- a/Assets/Text/ZHTW.json +++ b/Assets/Text/ZHTW.json @@ -1,4 +1,7 @@ { + "AppletMode": [ + "0: JKSV 不再支援在相簿等小程式中執行。\n\n請在按住 [R] 啟動遊戲或應用程式後重新啟動 JKSV。\n\n按下 [+] 以退出。" + ], "BackupMenu": [ "0: 新備份" ], diff --git a/include/JKSV.hpp b/include/JKSV.hpp index 24ddc45..fd4b7e2 100644 --- a/include/JKSV.hpp +++ b/include/JKSV.hpp @@ -60,6 +60,9 @@ class JKSV // Creates the needed directories on SD. bool create_directories(); + /// @brief Checks for and pushes the applet mode state. Returns true if applet type is applet. + bool applet_mode_check() noexcept; + /// @brief Adds the text color changing characters. void add_color_chars(); diff --git a/include/appstates/AppletModeState.hpp b/include/appstates/AppletModeState.hpp new file mode 100644 index 0000000..6b67fea --- /dev/null +++ b/include/appstates/AppletModeState.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "appstates/BaseState.hpp" + +#include + +/// @brief This is the state that's pushed when applet mode is detected because I'm tired of people complaining. +class AppletModeState final : public BaseState +{ + public: + /// @brief Constructor. + AppletModeState(); + + /// @brief Inline factory function. + static inline std::shared_ptr create() { return std::make_shared(); } + + /// @brief Runs the update routine. Basically does nothing. + void update() override; + + /// @brief Renders the message to the screen. + void render() override; + + private: + /// @brief Pointer to the string rendered to the screen. + const char *m_appletModeString{}; + + /// @brief Fetches the string to render to the screen. + void get_applet_mode_string() noexcept; +}; \ No newline at end of file diff --git a/include/appstates/MessageState.hpp b/include/appstates/MessageState.hpp index 7958fc7..94957a3 100644 --- a/include/appstates/MessageState.hpp +++ b/include/appstates/MessageState.hpp @@ -9,7 +9,7 @@ #include #include -class MessageState final : public BaseState +class MessageState : public BaseState { public: /// @brief Constructor. diff --git a/include/strings/names.hpp b/include/strings/names.hpp index de91b5d..e2192f0 100644 --- a/include/strings/names.hpp +++ b/include/strings/names.hpp @@ -3,6 +3,7 @@ namespace strings::names { + inline constexpr std::string_view APPLET_MODE = "AppletMode"; inline constexpr std::string_view BACKUPMENU_MENU = "BackupMenu"; inline constexpr std::string_view BACKUPMENU_CONFS = "BackupMenuConfirmations"; inline constexpr std::string_view BACKUPMENU_POPS = "BackupMenuPops"; diff --git a/source/JKSV.cpp b/source/JKSV.cpp index 2feb045..ef2aee3 100644 --- a/source/JKSV.cpp +++ b/source/JKSV.cpp @@ -1,6 +1,7 @@ #include "JKSV.hpp" #include "StateManager.hpp" +#include "appstates/AppletModeState.hpp" #include "appstates/FileModeState.hpp" #include "appstates/MainMenuState.hpp" #include "appstates/TaskState.hpp" @@ -90,6 +91,9 @@ JKSV::JKSV() JKSV::create_directories(); sys::threadpool::initialize(); // This is the thread pool so JKSV isn't constantly creating and destroying threads. + // To do: Rearrange init so JKSV doesn't init so much. + if (JKSV::applet_mode_check()) { return; } + // Push the remote init. sys::threadpool::push_job(remote::initialize, nullptr); @@ -217,6 +221,21 @@ bool JKSV::create_directories() return true; } +bool JKSV::applet_mode_check() noexcept +{ + // Determine whether or not we're running as and application. If we are, return false. + const bool appletMode = appletGetAppletType() != AppletType_Application; + if (!appletMode) { return false; } + + // We are running as an applet. Push the state. + StateManager::push_state(AppletModeState::create()); + + // Set this to running. + sm_isRunning = true; + + return true; +} + void JKSV::add_color_chars() { sdl::text::add_color_character(L'#', colors::BLUE); diff --git a/source/appstates/AppletModeState.cpp b/source/appstates/AppletModeState.cpp new file mode 100644 index 0000000..772843b --- /dev/null +++ b/source/appstates/AppletModeState.cpp @@ -0,0 +1,34 @@ +#include "appstates/AppletModeState.hpp" + +#include "graphics/colors.hpp" +#include "sdl.hpp" +#include "strings/strings.hpp" + +// ---- Construction ---- + +AppletModeState::AppletModeState() { AppletModeState::get_applet_mode_string(); } + +// ---- Public functions / overrides ---- + +void AppletModeState::update() +{ + // This serves no purpose other that to allow the user to exit. +} + +void AppletModeState::render() +{ + // Coordinates for rendering. + static constexpr int RENDER_X = 48; + static constexpr int RENDER_Y = 112; + static constexpr int FONT_SIZE = 24; + static constexpr int WRAP_WIDTH = 1154; + + sdl::text::render(sdl::Texture::Null, RENDER_X, RENDER_Y, FONT_SIZE, WRAP_WIDTH, colors::WHITE, m_appletModeString); +} + +// ---- Private functions ---- + +void AppletModeState::get_applet_mode_string() noexcept +{ + m_appletModeString = strings::get_by_name(strings::names::APPLET_MODE, 0); +} \ No newline at end of file