mirror of
https://github.com/aydencharles/onionHEN.git
synced 2026-10-23 04:12:37 -05:00
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.
78 lines
2.2 KiB
C++
78 lines
2.2 KiB
C++
/* Copyright (C) 2025 OnionHEN / LightningMods
|
|
*
|
|
* Table-driven OnPress dispatch for ShellUI toolbox items.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "shellui_types.hpp"
|
|
#include "hooked_funcs.hpp"
|
|
#include "ipc.hpp"
|
|
#include <onion/platform.h>
|
|
#include <onion/proc_query.h>
|
|
#include <cstddef>
|
|
#include <string>
|
|
|
|
/** Per-press context shared by domain handlers. */
|
|
struct OnPressContext {
|
|
MonoObject *instance = nullptr;
|
|
MonoObject *element = nullptr;
|
|
MonoObject *event = nullptr;
|
|
std::string id;
|
|
std::string value;
|
|
std::string title;
|
|
|
|
/** Request settings_commit after successful handling. */
|
|
bool reload_main = false;
|
|
bool reload_util = false;
|
|
bool dirty = true; // SaveSettings by default when handled
|
|
};
|
|
|
|
/**
|
|
* Handler result:
|
|
* - Handled: domain handled the id; dispatcher will settings_commit (if dirty) then oOnPress.
|
|
* - Consumed: fully handled custom/dynamic id; optional commit if dirty, do NOT call oOnPress.
|
|
* Use for ids outside the stock Settings model (e.g. id_cheat_*), where original
|
|
* SettingPage.OnPressed may null-deref on unknown elements.
|
|
* - EarlyReturn: stop now; call oOnPress without commit (no-op / validation fail).
|
|
* - NotMine: try next matcher / fall through.
|
|
*/
|
|
enum class OnPressResult {
|
|
Handled,
|
|
Consumed,
|
|
EarlyReturn,
|
|
NotMine,
|
|
};
|
|
|
|
using OnPressHandler = OnPressResult (*)(OnPressContext &ctx);
|
|
|
|
struct OnPressExactEntry {
|
|
const char *id;
|
|
OnPressHandler handler;
|
|
};
|
|
|
|
struct OnPressPrefixEntry {
|
|
const char *prefix;
|
|
OnPressHandler handler;
|
|
};
|
|
|
|
/* Domain tables (defined in onpress_*.cpp). */
|
|
const OnPressExactEntry *onpress_overlay_exact(size_t *count);
|
|
const OnPressExactEntry *onpress_network_exact(size_t *count);
|
|
const OnPressExactEntry *onpress_system_exact(size_t *count);
|
|
const OnPressExactEntry *onpress_misc_root_exact(size_t *count);
|
|
const OnPressExactEntry *onpress_remote_play_exact(size_t *count);
|
|
|
|
const OnPressPrefixEntry *onpress_payloads_prefix(size_t *count);
|
|
const OnPressPrefixEntry *onpress_cheats_prefix(size_t *count);
|
|
const OnPressPrefixEntry *onpress_packages_prefix(size_t *count);
|
|
|
|
/** Shared toggle helpers. */
|
|
inline bool value_as_int(const OnPressContext &ctx) {
|
|
return atoi(ctx.value.c_str());
|
|
}
|
|
|
|
inline bool value_as_long(const OnPressContext &ctx) {
|
|
return atol(ctx.value.c_str());
|
|
}
|