From 9f95c8e68ebd5f9f2b87ba2a186858265a7b189b Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Fri, 15 Dec 2023 21:39:41 +0100 Subject: [PATCH] Hero Menu via Skills in the Tween Menu --- SKSE/Plugins/EnderalSE.dll | 4 +- interface/tweenmenu.swf | 4 +- scripts/_00e_heromenu.pex | Bin 0 -> 851 bytes source/Enderal DLL/src/DialogueMenuPatch.h | 4 +- source/Enderal DLL/src/EventListener.cpp | 5 +-- source/Enderal DLL/src/EventListener.h | 4 ++ source/Enderal DLL/src/Main.cpp | 2 + .../Enderal DLL/src/Patches/TweenMenuPatch.h | 39 ++++++++++++++++++ source/Enderal DLL/src/Util.h | 9 ++++ source/scripts/_00e_heromenu.psc | 5 +++ 10 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 scripts/_00e_heromenu.pex create mode 100644 source/Enderal DLL/src/Patches/TweenMenuPatch.h create mode 100644 source/scripts/_00e_heromenu.psc diff --git a/SKSE/Plugins/EnderalSE.dll b/SKSE/Plugins/EnderalSE.dll index a7135c07..ab30b698 100644 --- a/SKSE/Plugins/EnderalSE.dll +++ b/SKSE/Plugins/EnderalSE.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bfeeb196e7eab311b69046d73815f780c10366623d693900b043c3916e059db9 -size 733696 +oid sha256:f3a662001bd6dadd6d5b1786b9f1e95e014a12c8cca16a936aa4931047024683 +size 735232 diff --git a/interface/tweenmenu.swf b/interface/tweenmenu.swf index 0aa95770..d2c7fd21 100644 --- a/interface/tweenmenu.swf +++ b/interface/tweenmenu.swf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:349d4dca40f13efd8c4dbcca15943c2c1e711ee498bc359a82aff251630880c6 -size 22014 +oid sha256:91f04e8ed77fe1ebbd9e0791a2ed5466df49cb34fa9b37d7d307a9365dbb8f30 +size 24283 diff --git a/scripts/_00e_heromenu.pex b/scripts/_00e_heromenu.pex new file mode 100644 index 0000000000000000000000000000000000000000..7671f0ffa450ae768db635f4ae6ea22fc025b6d7 GIT binary patch literal 851 zcmb7C%Wl&^6g`vJNs}g~EtJyos251AsKR4Ib|9r?11uuJGBWl}JmAa(dt3{NuL1EN zdGbI+Wy=l8oGKf4_$@Src>?_+;4namb1DYvi4lxLeF#&DJ- zw#Tu>O7c}~WKMSXCN+#Kua>{8gAV$zqCgjGt?tczx0D4^0VPFahp=ySN_&xnWr z(d8_j{Tpj*D7o0)zW+e63!SZF78{E7QuA(2&>cfnlhi9HTW+txw-i4ANQI7E3jy60 zcwou<`-mn>c_{Q`>Y&e8KyfMK7tey)T4w1V)NK9oF~lxL7$d+n>|q}VEc?d_*A;Fk z3}tWCg&KYh6h=%ODIC@)*h;*Br9Fj!rJFT6XcBjDgj+0chdNO>=9~kZw3N&~6SuDt fT_)}{gu-3+P<5y-+xHaiaaG%o*^PB({VVJrkao5; literal 0 HcmV?d00001 diff --git a/source/Enderal DLL/src/DialogueMenuPatch.h b/source/Enderal DLL/src/DialogueMenuPatch.h index f9d38e9f..cc309ef2 100644 --- a/source/Enderal DLL/src/DialogueMenuPatch.h +++ b/source/Enderal DLL/src/DialogueMenuPatch.h @@ -1,5 +1,7 @@ #pragma once +#include "Util.h" + inline bool bTabBlocked = false; class DialogueMenuPatch final : public RE::DialogueMenu @@ -7,8 +9,6 @@ class DialogueMenuPatch final : public RE::DialogueMenu public: static void Install() { - REL::Relocation OpenJournalMenuFunc{ 0x0092412C }; - REL::Relocation vtbl(RE::VTABLE_DialogueMenu[0]); _ProcessMessageFn = vtbl.write_vfunc(0x4, &ProcessMessageEx); } diff --git a/source/Enderal DLL/src/EventListener.cpp b/source/Enderal DLL/src/EventListener.cpp index ac27aabd..e44cfade 100644 --- a/source/Enderal DLL/src/EventListener.cpp +++ b/source/Enderal DLL/src/EventListener.cpp @@ -1,7 +1,4 @@ #include "EventListener.h" -#include "Util.h" -#include "DialogueMenuPatch.h" -#include auto EventListener::GetSingleton() -> EventListener* { @@ -52,6 +49,8 @@ auto EventListener::ProcessEvent( if (a_event->menuName == RE::DialogueMenu::MENU_NAME) { // Make sure Tab is not blocked. If it should be, a Papyrus script will block it a few frames later. DialogueMenuPatch::BlockTab(false); + } else if (a_event->menuName == "CustomMenu") { + CloseTweenMenu(); } } else { if (a_event->menuName == RE::DialogueMenu::MENU_NAME) { diff --git a/source/Enderal DLL/src/EventListener.h b/source/Enderal DLL/src/EventListener.h index a6fd6c75..6c170628 100644 --- a/source/Enderal DLL/src/EventListener.h +++ b/source/Enderal DLL/src/EventListener.h @@ -1,5 +1,9 @@ #pragma once +#include "DialogueMenuPatch.h" +#include "Util.h" +#include + class EventListener : public RE::BSTEventSink, public RE::BSTEventSink, diff --git a/source/Enderal DLL/src/Main.cpp b/source/Enderal DLL/src/Main.cpp index c27a4c0c..3d22c370 100644 --- a/source/Enderal DLL/src/Main.cpp +++ b/source/Enderal DLL/src/Main.cpp @@ -7,6 +7,7 @@ #include "AchievementFix.h" #include "BinkInterruptPatch.h" #include "DialogueMenuPatch.h" +#include "Patches/TweenMenuPatch.h" using namespace SKSE; @@ -169,6 +170,7 @@ SKSEPluginLoad(const LoadInterface* skse) { GetPapyrusInterface()->Register(Papyrus::Bind); DialogueMenuPatch::Install(); + TweenMenuPatch::Install(); if (g_settings.at("VideoInterruptPatch")) { logger::info("Making videos interruptible..."); diff --git a/source/Enderal DLL/src/Patches/TweenMenuPatch.h b/source/Enderal DLL/src/Patches/TweenMenuPatch.h new file mode 100644 index 00000000..0cdefccf --- /dev/null +++ b/source/Enderal DLL/src/Patches/TweenMenuPatch.h @@ -0,0 +1,39 @@ +#pragma once + +inline void OpenMenu(RE::IMenu* tweenMenu, std::int32_t index) +{ + using func_t = decltype(&OpenMenu); + REL::Relocation func{ REL::RelocationID(51845, 51845) }; + return func(tweenMenu, index); +} + +class TweenMenuPatch final : public RE::TweenMenu +{ +public: + static void Install() + { + REL::Relocation vtbl(RE::VTABLE_TweenMenu[0]); + _AcceptFn = vtbl.write_vfunc(0x1, &AcceptEx); + } + +private: + + 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) { + RE::BSTSmartPointer stackCallback; + RE::BSScript::Internal::VirtualMachine::GetSingleton()->DispatchStaticCall("_00E_HeroMenu", "Show", RE::MakeFunctionArguments(), stackCallback); + } else if (index <= 4) { + OpenMenu(RE::UI::GetSingleton()->GetMenu(MENU_NAME).get(), index); + } + }); + } + + using AcceptFn = decltype(&Accept); + inline static REL::Relocation _AcceptFn; +}; diff --git a/source/Enderal DLL/src/Util.h b/source/Enderal DLL/src/Util.h index b95dcac1..9e7aaaf3 100644 --- a/source/Enderal DLL/src/Util.h +++ b/source/Enderal DLL/src/Util.h @@ -172,3 +172,12 @@ inline void OpenJournal(bool a_bool) REL::Relocation func{ REL::RelocationID(52428, 53327) }; return func(a_bool); } + +inline void CloseTweenMenu() +{ + if (RE::UI::GetSingleton()->IsMenuOpen(RE::TweenMenu::MENU_NAME)) { + using func_t = decltype(&CloseTweenMenu); + REL::Relocation func{ REL::RelocationID(51839, 52711) }; + return func(); + } +} diff --git a/source/scripts/_00e_heromenu.psc b/source/scripts/_00e_heromenu.psc new file mode 100644 index 00000000..df603385 --- /dev/null +++ b/source/scripts/_00e_heromenu.psc @@ -0,0 +1,5 @@ +Scriptname _00E_HeroMenu Hidden + +function Show() Global + ((Game.GetForm(0x10AA2) as Quest).GetAlias(0) as _00E_Game_SkillmenuSC).OpenSkillmenu() +endfunction