59 lines
1.5 KiB
C
59 lines
1.5 KiB
C
|
#pragma once
|
||
|
|
||
|
// Based on Ryan McKenzie's Stay at the System Page
|
||
|
class JournalMenuEx :
|
||
|
public RE::JournalMenu
|
||
|
{
|
||
|
public:
|
||
|
enum class Tab : std::uint32_t
|
||
|
{
|
||
|
kQuest,
|
||
|
kStats,
|
||
|
kSystem
|
||
|
};
|
||
|
|
||
|
void Hook_Accept(RE::FxDelegateHandler::CallbackProcessor* a_cbProc)
|
||
|
{
|
||
|
_Accept(this, a_cbProc);
|
||
|
fxDelegate->callbacks.Remove("RememberCurrentTabIndex");
|
||
|
a_cbProc->Process("RememberCurrentTabIndex", RememberCurrentTabIndex);
|
||
|
}
|
||
|
|
||
|
RE::UI_MESSAGE_RESULTS Hook_ProcessMessage(RE::UIMessage& a_message)
|
||
|
{
|
||
|
switch (a_message.type.get()) {
|
||
|
case RE::UI_MESSAGE_TYPE::kShow:
|
||
|
{
|
||
|
auto UI = RE::UI::GetSingleton();
|
||
|
auto InterfaceStrings = RE::InterfaceStrings::GetSingleton();
|
||
|
if (UI && InterfaceStrings && UI->IsMenuOpen(InterfaceStrings->mapMenu)) {
|
||
|
*_savedTabIdx = Tab::kQuest;
|
||
|
} else {
|
||
|
*_savedTabIdx = Tab::kSystem;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return _ProcessMessage(this, a_message);
|
||
|
}
|
||
|
|
||
|
static void RememberCurrentTabIndex([[maybe_unused]] const RE::FxDelegateArgs& a_params)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
static void InstallHooks()
|
||
|
{
|
||
|
REL::Relocation<uintptr_t> vtbl(RE::VTABLE_JournalMenu[0]);
|
||
|
_Accept = vtbl.write_vfunc(0x01, &JournalMenuEx::Hook_Accept);
|
||
|
_ProcessMessage = vtbl.write_vfunc(0x04, &JournalMenuEx::Hook_ProcessMessage);
|
||
|
}
|
||
|
|
||
|
static inline REL::Relocation<decltype(&Hook_Accept)> _Accept;
|
||
|
static inline REL::Relocation<decltype(&Hook_ProcessMessage)> _ProcessMessage;
|
||
|
static inline REL::Relocation<Tab*> _savedTabIdx{ RELOCATION_ID(520167, 406697) };
|
||
|
};
|