Implement data reinitialization/cache rebuilding.

This commit is contained in:
J-D-K
2025-06-19 17:31:15 -04:00
parent 025c778011
commit 53c9a4633f
3 changed files with 40 additions and 4 deletions

View File

@@ -1,13 +1,29 @@
#include "appstates/ExtrasMenuState.hpp"
#include "appstates/MainMenuState.hpp"
#include "colors.hpp"
#include "data/data.hpp"
#include "input.hpp"
#include "keyboard.hpp"
#include "strings.hpp"
#include "ui/PopMessageManager.hpp"
#include <string_view>
namespace
{
// This target is shared be a lot of states.
constexpr std::string_view SECONDARY_TARGET = "SecondaryTarget";
// Enum for switch case readability.
enum
{
REINIT_DATA,
SD_TO_SD_BROWSER,
BIS_PRODINFO_F,
BIS_SAFE,
BIS_SYSTEM,
BIS_USER,
TERMINATE_PROCESS
};
} // namespace
ExtrasMenuState::ExtrasMenuState(void)
@@ -29,7 +45,24 @@ void ExtrasMenuState::update(void)
{
m_extrasMenu.update(AppState::has_focus());
if (input::button_pressed(HidNpadButton_B))
if (input::button_pressed(HidNpadButton_A))
{
switch (m_extrasMenu.get_selected())
{
case REINIT_DATA:
{
// Reinitialize the data with the cache cleared.
data::initialize(true);
ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS,
strings::get_by_name(strings::names::EXTRAS_POP_MESSAGES, 0));
// This should be adequate for this...
MainMenuState::refresh_view_states();
}
break;
}
}
else if (input::button_pressed(HidNpadButton_B))
{
AppState::deactivate();
}