Implement AppletModeState and block applet mode completely.

This commit is contained in:
J-D-K 2025-11-15 14:30:11 -05:00
parent 30ffa86b65
commit e58af5dbf7
22 changed files with 135 additions and 1 deletions

View File

@ -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"
],

View File

@ -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"
],

View File

@ -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"
],

View File

@ -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"
],

View File

@ -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"
],

View File

@ -1,4 +1,7 @@
{
"AppletMode": [
"0: JKSV ne prend plus en charge lexécution dans des applets comme lalbum.\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"
],

View File

@ -1,4 +1,7 @@
{
"AppletMode": [
"0: JKSV ne prend plus en charge lexécution dans des applets comme lalbum.\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"
],

View File

@ -1,4 +1,7 @@
{
"AppletMode": [
"0: JKSV non supporta più lesecuzione in applet come lalbum.\n\nAvvia di nuovo JKSV dopo aver avviato un gioco o un'applicazione tenendo premuto [R].\n\nPremi [+] per uscire."
],
"BackupMenu": [
"0: Nuovo backup"
],

View File

@ -1,4 +1,7 @@
{
"AppletMode": [
"0: JKSV はアルバムなどのアプレットでの実行をサポートしなくなりました。\n\n[R] を押しながらゲームまたはアプリケーションを起動した後、もう一度 JKSV を起動してください。\n\n終了するには [+] を押してください."
],
"BackupMenu": [
"0: 新しい バックアップ"
],

View File

@ -1,4 +1,7 @@
{
"AppletMode": [
"0: JKSV는 앨범과 같은 앱렛에서의 실행을 더 이상 지원하지 않습니다.\n\n[R]을 누른 상태로 게임 또는 애플리케이션을 실행한 후 JKSV를 다시 실행하세요.\n\n종료하려면 [+]를 누르세요."
],
"BackupMenu": [
"0: 새 백업"
],

View File

@ -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"
],

View File

@ -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"
],

View File

@ -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"
],

View File

@ -1,4 +1,7 @@
{
"AppletMode": [
"0: JKSV больше не поддерживает запуск в апплетах, таких как Альбом.\n\nЗапустите JKSV снова после запуска игры или приложения, удерживая [R].\n\nНажмите [+], чтобы выйти."
],
"BackupMenu": [
"0: Новый бэкап"
],

View File

@ -1,4 +1,7 @@
{
"AppletMode": [
"0: JKSV 不再支持在相册等小程序模式下运行。\n\n请在按住 [R] 启动游戏或应用后重新运行 JKSV。\n\n按 [+] 退出。"
],
"BackupMenu": [
"0: 新备份"
],

View File

@ -1,4 +1,7 @@
{
"AppletMode": [
"0: JKSV 不再支援在相簿等小程式中執行。\n\n請在按住 [R] 啟動遊戲或應用程式後重新啟動 JKSV。\n\n按下 [+] 以退出。"
],
"BackupMenu": [
"0: 新備份"
],

View File

@ -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();

View File

@ -0,0 +1,29 @@
#pragma once
#include "appstates/BaseState.hpp"
#include <memory>
/// @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<AppletModeState> create() { return std::make_shared<AppletModeState>(); }
/// @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;
};

View File

@ -9,7 +9,7 @@
#include <memory>
#include <string>
class MessageState final : public BaseState
class MessageState : public BaseState
{
public:
/// @brief Constructor.

View File

@ -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";

View File

@ -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);

View File

@ -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);
}