2023-12-15 20:39:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class TweenMenuPatch final : public RE::TweenMenu
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void Install()
|
|
|
|
{
|
|
|
|
REL::Relocation<uintptr_t> vtbl(RE::VTABLE_TweenMenu[0]);
|
|
|
|
_AcceptFn = vtbl.write_vfunc(0x1, &AcceptEx);
|
2023-12-18 13:04:00 +00:00
|
|
|
|
|
|
|
REL::Relocation<std::uintptr_t> target{ REL::RelocationID(51400, 52249), REL::Relocate(0x409, 0x421) };
|
|
|
|
REL::safe_fill(target.address(), REL::NOP, 45);
|
|
|
|
|
|
|
|
auto& trampoline = SKSE::GetTrampoline();
|
|
|
|
SKSE::AllocTrampoline(14);
|
|
|
|
_OpenStats = trampoline.write_call<5>(target.address(), OpenStats);
|
|
|
|
|
|
|
|
REL::Relocation<std::uintptr_t> target2{ REL::RelocationID(51400, 52249), REL::Relocate(0x409, 0x439) };
|
|
|
|
std::uint8_t code[] = { 0x40, 0xB5, 0x01 };
|
|
|
|
REL::safe_write(target2.address(), code, sizeof(code));
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t OpenStats(uint32_t arg_1, uint32_t arg_2, uint32_t arg_3, uint32_t arg_4, uint32_t arg_5)
|
|
|
|
{
|
|
|
|
SKSE::ModCallbackEvent modEvent{ "Enderal_OpenHeroMenu", "", 0.0f, nullptr };
|
|
|
|
SKSE::GetModCallbackEventSource()->SendEvent(&modEvent);
|
|
|
|
return 0;
|
2023-12-15 20:39:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2023-12-18 13:04:00 +00:00
|
|
|
static void OpenMenu(RE::IMenu* tweenMenu, std::int32_t index)
|
|
|
|
{
|
|
|
|
using func_t = decltype(&OpenMenu);
|
|
|
|
REL::Relocation<func_t> func{ REL::RelocationID(51845, 52718) };
|
|
|
|
return func(tweenMenu, index);
|
|
|
|
}
|
|
|
|
|
2023-12-15 20:39:41 +00:00
|
|
|
void AcceptEx(CallbackProcessor* a_cbReg)
|
|
|
|
{
|
|
|
|
_AcceptFn(this, a_cbReg);
|
|
|
|
|
|
|
|
fxDelegate->callbacks.Remove("OpenHighlightedMenu");
|
|
|
|
a_cbReg->Process("OpenHighlightedMenu", [](const RE::FxDelegateArgs& args) {
|
|
|
|
auto index = args[0].GetSInt();
|
|
|
|
if (index <= 1) {
|
2023-12-18 13:04:00 +00:00
|
|
|
SKSE::ModCallbackEvent modEvent{ "Enderal_OpenHeroMenu", "", 0.0f, nullptr };
|
|
|
|
SKSE::GetModCallbackEventSource()->SendEvent(&modEvent);
|
2023-12-15 20:39:41 +00:00
|
|
|
} else if (index <= 4) {
|
|
|
|
OpenMenu(RE::UI::GetSingleton()->GetMenu(MENU_NAME).get(), index);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-12-18 13:04:00 +00:00
|
|
|
inline static REL::Relocation<decltype(&Accept)> _AcceptFn;
|
|
|
|
inline static REL::Relocation<decltype(OpenStats)> _OpenStats;
|
2023-12-15 20:39:41 +00:00
|
|
|
};
|