From 4e2e2166c6e7377d3d8765351321d048dfe426c5 Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Mon, 18 Dec 2023 14:04:00 +0100 Subject: [PATCH] Patched the Quick Stats hotkey to open the hero menu --- SKSE/Plugins/EnderalSE.dll | 4 +- interface/controls/pc/controlmap.txt | 217 ------------------ source/Enderal DLL/src/AchievementFix.h | 2 +- source/Enderal DLL/src/EventListener.cpp | 2 +- source/Enderal DLL/src/MapMarkerPlacement.h | 6 +- .../Enderal DLL/src/Patches/TweenMenuPatch.h | 40 +++- 6 files changed, 35 insertions(+), 236 deletions(-) delete mode 100644 interface/controls/pc/controlmap.txt diff --git a/SKSE/Plugins/EnderalSE.dll b/SKSE/Plugins/EnderalSE.dll index ab30b698..55312395 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:f3a662001bd6dadd6d5b1786b9f1e95e014a12c8cca16a936aa4931047024683 -size 735232 +oid sha256:03258ca83dcb99414b79db25332a6a984d63495866f01638e15d18002c7f01ce +size 737280 diff --git a/interface/controls/pc/controlmap.txt b/interface/controls/pc/controlmap.txt deleted file mode 100644 index 863a5d29..00000000 --- a/interface/controls/pc/controlmap.txt +++ /dev/null @@ -1,217 +0,0 @@ -// 1st field: User event name. DO NOT ALTER! This field is used to ID events in the code -// 2nd: Keyboard key ID that will proc this event. A value of 0xff means the event is unmapped for this device. -// 3rd: Mouse button ID that will proc this event. -// 4th: Gamepad button ID that will proc this event. -// 5th: If set to 1, this event can be remapped to a keyboard key -// 6th: If set to 1, this event can be remapped to a mouse button -// 7th: If set to 1, this event can be remapped to a gamepad button -// 8th (Optional): User event binary flag. Used to group together related user events, like "Movement" or -// "Menu", so they can be toggled on and off together -// -// Blank lines signify the start of a new input context. -// See ControlMap.h for more details on input contexts. -// -// Main Gameplay -Forward 0x11 0xff 0xff 1 1 0 0x801 -Back 0x1f 0xff 0xff 1 1 0 0x801 -Strafe Left 0x1e 0xff 0xff 1 1 0 0x801 -Strafe Right 0x20 0xff 0xff 1 1 0 0x801 -Move 0xff 0xff 0x000b 0 0 0 0x801 -Look 0xff 0xa 0x000c 0 0 0 0x2 -Left Attack/Block 0xff 0x1 0x0009 1 1 1 0x841 -Right Attack/Block 0xff 0x0 0x000a 1 1 1 0x841 -Activate 0x12 0xff 0x1000 1 1 1 0x804 -Ready Weapon 0x13 0xff 0x4000 1 1 1 0x840 -Tween Menu 0x0f 0xff 0x2000 1 1 1 0x908 -Toggle POV 0x21 0xff 0x0080 1 1 1 0x820 -Zoom Out 0xff 0x9 0xff 0 0 0 0x220 -Zoom In 0xff 0x8 0xff 0 0 0 0x220 -Jump 0x39 0xff 0x8000 1 1 1 0xC01 -Sprint 0x38 0xff 0x0100 1 1 1 0x801 -Shout 0x2c 0xff 0x0200 1 1 1 0x840 -Sneak 0x1d 0xff 0x0040 1 1 1 0x881 -Run 0x2a 0xff 0xff 1 1 0 0x801 -Toggle Always Run 0x3a 0xff 0xff 1 1 0 0x801 -Auto-Move 0x2e 0xff 0xff 1 1 0 0x801 -Favorites 0x10 0xff 0x0001,0x0002 1 1 0 0x908 -Hotkey1 0x02,0x4f 0xff 0x0004 0 0 0 0x908 -Hotkey2 0x03,0x50 0xff 0x0008 0 0 0 0x908 -Hotkey3 0x04,0x51 0xff 0xff 0 0 0 0x908 -Hotkey4 0x05,0x4b 0xff 0xff 0 0 0 0x908 -Hotkey5 0x06,0x4c 0xff 0xff 0 0 0 0x908 -Hotkey6 0x07,0x4d 0xff 0xff 0 0 0 0x908 -Hotkey7 0x08,0x47 0xff 0xff 0 0 0 0x908 -Hotkey8 0x09,0x48 0xff 0xff 0 0 0 0x908 -Quicksave 0x3f 0xff 0xff 1 0 0 -Quickload 0x43 0xff 0xff 1 0 0 -Wait 0x14 0xff 0x0020 1 1 1 0x808 -Journal 0x24 0xff 0x0010 1 1 1 0x808 -Pause 0x1 0xff 0xff 1 1 0 0x8 -Screenshot 0xb7 0xff 0xff 0 0 0 -Multi-Screenshot 0x1d+0xb7,0x9d+0xb7 0xff 0xff 0 0 0 -Console 0x29,0x94 0xff 0xff 0 0 0 0x10 -CameraPath 0x58 0xff 0xff 0 0 0 -Quick Inventory 0x17 0xff 0xff 1 1 0 0x908 -Quick Magic 0x19 0xff 0xff 1 1 0 0x908 -Quick Stats 0xff 0xff 0xff 0 1 0 0x908 -Quick Map 0x32 0xff 0xff 1 1 0 0x908 - -// Menu Mode -Accept !0,Activate !0,Activate !0,Activate 0 0 0 0x8 -Cancel !0,Tween Menu,!0,Pause !0,Tween Menu,!0,Pause !0,Tween Menu 0 0 0 0x8 -Up !0,Forward !0,Forward 0x0001 0 0 0 0x8 -Down !0,Back !0,Back 0x0002 0 0 0 0x8 -Left !0,Strafe Left !0,Strafe Left 0x0004 0 0 0 0x8 -Right !0,Strafe Right !0,Strafe Right 0x0008 0 0 0 0x8 -Left Stick 0xff 0xff 0x000b 0 0 0 0x8 -Console 0x29 0xff 0xff 0 0 0 0x10 - -// Console -PickPrevious 0xff 0x8 0x0002 0 0 0 0x10 -PickNext 0xff 0x9 0x0001 0 0 0 0x10 -Up 0xc8 0xff 0xff 0 0 0 0x10 -Down 0xd0 0xff 0xff 0 0 0 0x10 -PageUp 0xc9 0xff 0xff 0 0 0 0x10 -PageDown 0xd1 0xff 0xff 0 0 0 0x10 -Console 0x29 0xff 0xff 0 0 0 0x10 -NextFocus 0x0f 0xff 0x0200 0 0 0 0x10 -PreviousFocus 0x2a+0x0f,0x36+0x0f 0xff 0x0100 0 0 0 0x10 - -// Item Menus -LeftEquip !0,Left Attack/Block !0,Left Attack/Block !0,Left Attack/Block 0 0 0 0x8 -RightEquip !0,Right Attack/Block !0,Right Attack/Block !0,Right Attack/Block 0 0 0 0x8 -Item Zoom 0x2e 0xff !0,Toggle POV 0 0 0 0x8 -Rotate 0xff 0xff 0x000c 0 0 0 0x8 -XButton !0,Ready Weapon !0,Ready Weapon !0,Ready Weapon 0 0 0 0x8 -YButton !0,Toggle POV !0,Toggle POV !0,Jump 0 0 0 0x8 -Cursor 0xff 0xa 0xff 0 0 0 0x8 - -// Inventory -ChargeItem !0,Wait !0,Wait !0,Shout 0 0 0 0x8 - -// Debug Text -PrevPage 0xc8 0xff 0xff 0 0 0 0x10 -NextPage 0xd0 0xff 0xff 0 0 0 0x10 -PrevSubPage 0xc9 0xff 0xff 0 0 0 0x10 -NextSubPage 0xd1 0xff 0xff 0 0 0 0x10 - -// Favorites menu -Up !0,Forward !0,Forward 0x0001 0 0 0 0x8 -Down !0,Back !0,Back 0x0002 0 0 0 0x8 -Accept !0,Activate !0,Activate !0,Activate 0 0 0 0x8 -Cancel !0,Favorites,!0,Tween Menu,!0,Pause !0,Favorites,!0,Tween Menu,!0,Pause !0,Tween Menu 0 0 0 0x8 -Left Stick 0xff 0xff 0x000b 0 0 0 0x8 -Cursor 0xff 0xa 0xff 0 0 0 0x8 - -// Map Menu -Cancel !0,Tween Menu,!0,Pause !0,Tween Menu,!0,Pause !0,Tween Menu 0 0 0 0x8 -Look 0xff 0xff 0x000c 0 0 0 0x8 -Zoom In 0xff 0x8 !0,Right Attack/Block 0 0 0 0x8 -Zoom Out 0xff 0x9 !0,Left Attack/Block 0 0 0 0x8 -MapLookMode 0xff 0x1 0xff 0 0 0 0x8 -Click 0xff 0xff 0x1000 0 0 0 0x8 -PlacePlayerMarker 0x19 0xff 0xff 0 0 0 0x8 -Cursor 0xff 0xa 0x000b 0 0 0 0x8 -PlayerPosition 0x12 0xff 0x8000 0 0 0 0x8 -LocalMap 0x26 0xff 0x4000 0 0 0 0x8 -LocalMapMoveMode 0xff 0x0 0xff 0 0 0 0x8 -Journal 0x24 0xff 0x0010 0 0 0 0x8 -Up !0,Forward !0,Forward 0xff 0 0 0 0x8 -Down !0,Back !0,Back 0xff 0 0 0 0x8 -Left !0,Strafe Left !0,Strafe Left 0xff 0 0 0 0x8 -Right !0,Strafe Right !0,Strafe Right 0xff 0 0 0 0x8 - -// Stats -Rotate 0xff 0xff 0x000b 0 0 0 0x8 -YButton !0,Toggle POV !0,Toggle POV !0,Jump 0 0 0 0x8 - -// Cursor -Cursor 0xff 0xa 0x000c 0 0 0 0x10 -Click 0xff 0x0 0x1000 0 0 0 0x10 - -// Book -PrevPage 0xcb,0x1e 0x0,0x9 0x0004 0 0 0 0x8 -NextPage 0xcd,0x20 0x1,0x8 0x0008 0 0 0 0x8 - -// Debug overlay -Console 0x29 0xff 0xff 0 0 0 0x10 -NextFocus 0x0f 0xff 0x0200 0 0 0 0x10 -PreviousFocus 0x2a+0x0f,0x36+0x0f 0xff 0x0100 0 0 0 0x10 -Up 0xc8 0xff 0x0001 0 0 0 0x10 -Down 0xd0 0xff 0x0002 0 0 0 0x10 -Left 0xcb 0xff 0x0004 0 0 0 0x10 -Right 0xcd 0xff 0x0008 0 0 0 0x10 -PageUp 0xc9 0xff 0xff 0 0 0 0x10 -PageDown 0xd1 0xff 0xff 0 0 0 0x10 -ToggleMinimize 0x3f 0xff 0x0020 0 0 0 0x10 -ToggleMove 0x3e 0xff 0x0080 0 0 0 0x10 -Close 0x40 0xff 0xff 0 0 0 0x10 -F1 0x3b 0xff 0xff 0 0 0 0x10 -F2 0x3c 0xff 0xff 0 0 0 0x10 -F3 0x3d 0xff 0xff 0 0 0 0x10 -F7 0x41 0xff 0xff 0 0 0 0x10 -F8 0x42 0xff 0xff 0 0 0 0x10 -F9 0x43 0xff 0xff 0 0 0 0x10 -F10 0x44 0xff 0xff 0 0 0 0x10 -F11 0x57 0xff 0xff 0 0 0 0x10 -F12 0x58 0xff 0xff 0 0 0 0x10 -LTrigger 0xff 0xff 0x0009 0 0 0 0x10 -RTrigger 0xff 0xff 0x000a 0 0 0 0x10 -Backspace 0x0e 0xff 0xff 0 0 0 0x10 -Enter 0x1c 0xff 0xff 0 0 0 0x10 -B 0xff 0xff 0x2000 0 0 0 0x10 -Y 0xff 0xff 0x8000 0 0 0 0x10 -X 0xff 0xff 0x4000 0 0 0 0x10 - -// Journal -Zoom In 0xff 0x8 0xff 0 0 0 0x8 -Zoom Out 0xff 0x9 0xff 0 0 0 0x8 -XButton 0x2d,0x32 0xff !0,Ready Weapon 0 0 0 0x8 -YButton 0x14 0xff !0,Jump 0 0 0 0x8 -TabSwitch 0xff 0xff !0,Left Attack/Block,!0,Right Attack/Block 0 0 0 0x8 - -// TFC mode -CameraZUp 0xff 0x8 0x000a 0 0 0 -CameraZDown 0xff 0x9 0x0009 0 0 0 -WorldZUp 0xff 0x0 0x0200 0 0 0 -WorldZDown 0xff 0x1 0x0100 0 0 0 -LockToZPlane 0xff 0xff 0x4000 0 0 0 - -// Debug Map Menu-like mode (but not the actual map menu) -Look 0xff 0xff 0x000c 0 0 0 0x8 -Zoom In 0xff 0x8 0x000a 0 0 0 0x8 -Zoom Out 0xff 0x9 0x0009 0 0 0 0x8 -Move 0xff 0xa 0x000b 0 0 0 0x8 - -// Lockpicking -RotatePick 0xff 0xa 0x000b 0 0 0 0x8 -RotateLock !0,Forward,!0,Back,!0,Strafe Left,!0,Strafe Right !0,Forward,!0,Back,!0,Strafe Left,!0,Strafe Right 0x000c 0 0 0 0x8 -DebugMode 0x35 0xff 0x4000 0 0 0 0x8 -Cancel !0,Tween Menu,!0,Pause !0,Tween Menu,!0,Pause !0,Tween Menu 0 0 0 0x8 - -// Creations Menu -Accept 0x12,0x1c 0xff 0x1000 0 0 0 0x8 -Cancel 0x0f,0x1 0xff 0x2000 0 0 0 0x8 -Up 0x11,0xc8 0xff 0x0001 0 0 0 0x8 -Down 0x1f,0xd0 0xff 0x0002 0 0 0 0x8 -Left 0x1e,0xcb 0xff 0x0004 0 0 0 0x8 -Right 0x20,0xcd 0xff 0x0008 0 0 0 0x8 -HomeKey 0xc7 0xff 0xff 0 0 0 0x8 -EndKey 0xcf 0xff 0xff 0 0 0 0x8 -DeleteKey 0xd3 0xff 0xff 0 0 0 0x8 -MouseClickAccept 0xff 0x0 0xff 0 0 0 0x8 -Options 0x18 0xff 0x0010 0 0 0 0x8 -Left Stick 0xff 0xff 0x000b 0 0 0 0x8 -Console 0x29 0xff 0xff 0 0 0 0x10 -MouseScrollDown 0xff 0x9 0xff 0 0 0 0x8 -MouseScrollUp 0xff 0x8 0xff 0 0 0 0x8 -LoadOrderAndDelete 0x14 0xff 0x8000 0 0 0 0x8 -CategorySideBar 0x2a 0xff 0x0009 0 0 0 0x8 -LikeUnlike 0x26 0xff 0x0200 0 0 0 0x8 -SearchEdit 0x2d 0xff 0x0100 0 0 0 0x8 -Filter 0x2f 0xff 0x000a 0 0 0 0x8 -F1 0x3b 0xff 0xff 0 0 0 0x8 -PurchaseCredits 0x19 0xff 0x4000 0 0 0 0x8 - -// Favor -Cancel !0,Tween Menu,!0,Pause !0,Tween Menu,!0,Pause !0,Tween Menu 0 0 0 0x108 diff --git a/source/Enderal DLL/src/AchievementFix.h b/source/Enderal DLL/src/AchievementFix.h index 09d20ce5..484fd338 100644 --- a/source/Enderal DLL/src/AchievementFix.h +++ b/source/Enderal DLL/src/AchievementFix.h @@ -15,6 +15,6 @@ namespace AchievementFix } std::uint8_t code[] = { 0xB0, 0x00, 0xC3, NOP }; - REL::safe_write(target.address(), code, 4); + REL::safe_write(target.address(), code, sizeof(code)); } } diff --git a/source/Enderal DLL/src/EventListener.cpp b/source/Enderal DLL/src/EventListener.cpp index e44cfade..45df00b6 100644 --- a/source/Enderal DLL/src/EventListener.cpp +++ b/source/Enderal DLL/src/EventListener.cpp @@ -49,7 +49,7 @@ 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") { + } else if (a_event->menuName == "CustomMenu" && RE::UI::GetSingleton()->IsMenuOpen(RE::TweenMenu::MENU_NAME)) { CloseTweenMenu(); } } else { diff --git a/source/Enderal DLL/src/MapMarkerPlacement.h b/source/Enderal DLL/src/MapMarkerPlacement.h index c45d5620..1bf9db0e 100644 --- a/source/Enderal DLL/src/MapMarkerPlacement.h +++ b/source/Enderal DLL/src/MapMarkerPlacement.h @@ -2,8 +2,6 @@ namespace MapMarkerPlacement { - constexpr std::uint8_t NOP{ 0x90 }; - struct IsFastTravelEnabled { static bool thunk(RE::PlayerCharacter* a_this, bool a_hideNotification) @@ -38,8 +36,8 @@ namespace MapMarkerPlacement // Place a marker without asking, if a location isn't discovered yet REL::Relocation target2{ REL::RelocationID(52208, 53095), REL::Relocate(0x17A, 0x183) }; - std::uint8_t code[] = { 0xB0, 0x01, NOP, NOP, NOP }; - REL::safe_write(target2.address(), code, 5); + std::uint8_t code[] = { 0xB0, 0x01, REL::NOP, REL::NOP, REL::NOP }; + REL::safe_write(target2.address(), code, sizeof(code)); logger::info("Applied undiscovered map marker placement fix"sv); } diff --git a/source/Enderal DLL/src/Patches/TweenMenuPatch.h b/source/Enderal DLL/src/Patches/TweenMenuPatch.h index 0cdefccf..6df2bf68 100644 --- a/source/Enderal DLL/src/Patches/TweenMenuPatch.h +++ b/source/Enderal DLL/src/Patches/TweenMenuPatch.h @@ -1,12 +1,5 @@ #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: @@ -14,10 +7,35 @@ public: { REL::Relocation vtbl(RE::VTABLE_TweenMenu[0]); _AcceptFn = vtbl.write_vfunc(0x1, &AcceptEx); + + REL::Relocation 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 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; } private: + static void OpenMenu(RE::IMenu* tweenMenu, std::int32_t index) + { + using func_t = decltype(&OpenMenu); + REL::Relocation func{ REL::RelocationID(51845, 52718) }; + return func(tweenMenu, index); + } + void AcceptEx(CallbackProcessor* a_cbReg) { _AcceptFn(this, a_cbReg); @@ -26,14 +44,14 @@ private: 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); + SKSE::ModCallbackEvent modEvent{ "Enderal_OpenHeroMenu", "", 0.0f, nullptr }; + SKSE::GetModCallbackEventSource()->SendEvent(&modEvent); } else if (index <= 4) { OpenMenu(RE::UI::GetSingleton()->GetMenu(MENU_NAME).get(), index); } }); } - using AcceptFn = decltype(&Accept); - inline static REL::Relocation _AcceptFn; + inline static REL::Relocation _AcceptFn; + inline static REL::Relocation _OpenStats; };