From cd2ad8bbf61d20f8f9cce1304f1846d40c264f00 Mon Sep 17 00:00:00 2001 From: DudeMcDude Date: Wed, 20 Apr 2016 08:19:21 +0300 Subject: [PATCH] Fix for radial menu not checking if there's an active menu when left clicking with charmed PCs --- TemplePlus/radialmenu.cpp | 22 ++++++++++++++++++++++ TemplePlus/radialmenu.h | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/TemplePlus/radialmenu.cpp b/TemplePlus/radialmenu.cpp index beb4794df..0668fa989 100644 --- a/TemplePlus/radialmenu.cpp +++ b/TemplePlus/radialmenu.cpp @@ -160,6 +160,11 @@ class RadialMenuReplacements : public TempleFix }); + replaceFunction(0x100F0850, [](int activeNodeIdx)->int + { + return radialMenus.GetActiveMenuChildrenCount(activeNodeIdx); + }); + } }; @@ -494,6 +499,23 @@ void RadialMenus::GetRadialMenuXY(float& radX, float& radY) const radY = temple::GetRef(0x10BD0228); } +RadialMenu* RadialMenus::GetActiveRadialMenu() const +{ + return (*addresses.activeRadialMenu); +} + +int RadialMenus::GetActiveMenuChildrenCount(int nodeidx) const +{ + auto activeMenu = GetActiveRadialMenu(); + if (!activeMenu) + return 0; + if (temple::GetRef(0x10BD0234) && activeMenu && activeMenu->nodes[nodeidx].morphsTo != -1) + { + nodeidx = activeMenu->nodes[nodeidx].morphsTo; + } + return activeMenu->nodes[nodeidx].childCount; +} + RadialMenuEntry::RadialMenuEntry(){ SetDefaults(); } diff --git a/TemplePlus/radialmenu.h b/TemplePlus/radialmenu.h index 2c1cb84d9..d9dc7a4a4 100644 --- a/TemplePlus/radialmenu.h +++ b/TemplePlus/radialmenu.h @@ -180,7 +180,9 @@ class RadialMenus { /* gets the radial menu coordinates in absolute worldspace coords */ - void GetRadialMenuXY(float& radX, float& radY) const; + void GetRadialMenuXY(float& radX, float& radY) const; + RadialMenu* GetActiveRadialMenu() const; + int GetActiveMenuChildrenCount(int activeNodeIdx) const; }; extern RadialMenus radialMenus;