Files
onionHEN/source/shellui/include/shellui_state.hpp
T
Hexwell 9fb270c06e fix: scope settings hooks to toolbox pages
SettingPage hooks are process-wide, so stock pages such as PkgInstaller were being consumed by toolbox handlers. Track the active XML page, dispatch handlers by toolbox domain, pass stock pages through unchanged, and add host regression coverage.
2026-07-20 16:17:47 +08:00

75 lines
2.0 KiB
C++

/* Copyright (C) 2025 OnionHEN / LightningMods
*
* Toolbox / settings UI runtime state. All ShellUI session state lives on g_ui.
*/
#pragma once
#include "shellui_types.hpp"
#include "toolbox_route.hpp"
#include <cstring>
#include <string>
#include <string_view>
#include <vector>
/** Settings page / resource-stream context for ShellUI hooks. */
struct ToolboxUiState {
toolbox::Page active_page = toolbox::Page::None;
bool cheats_shortcut_activated = false;
bool cheats_shortcut_activated_not_open = false;
std::string running_tid;
bool is_game_open = true;
bool is_current_game_open = true;
std::string current_menu_tid;
std::string current_cheat_tid;
int cheat_enabled_map[toolbox::kCheatMapSize]{};
std::vector<PayloadEntry> payloads_list;
std::vector<PayloadEntry> auto_payloads_list;
std::vector<Payloads_Apps> payloads_apps_list;
std::vector<GameEntry> games_list;
std::string remote_play_info;
void set_active_page(toolbox::Page page) {
active_page = page;
}
bool is_active_page(toolbox::Page page) const {
return active_page == page;
}
void leave_page(toolbox::Page page) {
if (active_page == page)
active_page = toolbox::Page::None;
}
void clear_cheat_shortcuts() {
cheats_shortcut_activated = false;
cheats_shortcut_activated_not_open = false;
}
bool any_cheat_shortcut() const {
return cheats_shortcut_activated || cheats_shortcut_activated_not_open;
}
bool reset_cheats_if_tid_changed(std::string_view new_tid) {
return toolbox::reset_cheat_map_if_tid_changed(
current_cheat_tid, cheat_enabled_map, toolbox::kCheatMapSize, new_tid);
}
void set_cheat_enabled(int cheat_id, bool enabled) {
toolbox::set_cheat_enabled(cheat_enabled_map, toolbox::kCheatMapSize,
cheat_id, enabled);
}
bool get_cheat_enabled(int cheat_id) const {
return toolbox::get_cheat_enabled(cheat_enabled_map, toolbox::kCheatMapSize,
cheat_id);
}
};
extern ToolboxUiState g_ui;