From e02bcd04050ee82c887013f959ba067c14b7bece Mon Sep 17 00:00:00 2001 From: DudeMcDude Date: Tue, 19 Apr 2016 00:07:13 +0300 Subject: [PATCH] Fixes #194 --- TemplePlus/d20.cpp | 2 +- TemplePlus/hotkeys.cpp | 3 +- TemplePlus/radialmenu.cpp | 53 +++++++++++++++++++++++++++++- TemplePlus/radialmenu.h | 2 ++ TemplePlus/ui/ui_item_creation.cpp | 20 ++--------- 5 files changed, 59 insertions(+), 21 deletions(-) diff --git a/TemplePlus/d20.cpp b/TemplePlus/d20.cpp index faccaa418..561ccbc1d 100644 --- a/TemplePlus/d20.cpp +++ b/TemplePlus/d20.cpp @@ -1437,7 +1437,7 @@ ActionErrorCode D20ActionCallbacks::ActionFrameDisarm(D20Actn* d20a) } disarmedArgs; disarmedArgs.weapon = weapon; objects.floats->FloatCombatLine(d20a->d20APerformer, 200); // Counter Disarmed! - conds.AddTo(d20a->d20APerformer, "Disarmed", { ((int*)&disarmedArgs)[0], ((int*)&disarmedArgs)[1], 0,0,0,0 }); + conds.AddTo(d20a->d20APerformer, "Disarmed", { ((int*)&disarmedArgs)[0], ((int*)&disarmedArgs)[1], 0,0,0,0,0,0 }); return AEC_OK; } else if (!failedOnce) diff --git a/TemplePlus/hotkeys.cpp b/TemplePlus/hotkeys.cpp index ffca9b0cd..009bceb63 100644 --- a/TemplePlus/hotkeys.cpp +++ b/TemplePlus/hotkeys.cpp @@ -104,8 +104,9 @@ BOOL HotkeyReplacements::HotkeyActivate(objHndl obj) return FALSE; auto radMenuNodeCount = temple::GetRef(0x118676C0); - if (radMenuNodeCount > radMenuForHK->nodeCount) + if (radMenuNodeCount > radMenuForHK->nodeCount) { return FALSE; + } auto& activeRadialMenu = temple::GetRef(0x115B2048); activeRadialMenu = radialMenus.GetForObj(obj); diff --git a/TemplePlus/radialmenu.cpp b/TemplePlus/radialmenu.cpp index d6c4817c5..fcdc79ff2 100644 --- a/TemplePlus/radialmenu.cpp +++ b/TemplePlus/radialmenu.cpp @@ -20,6 +20,7 @@ //#include "temple_functions.h" RadialMenus radialMenus; +int RadialMenus::standardNodeIndices[120]; static_assert(temple::validate_size::value, "Structure has an incorrect size."); static_assert(temple::validate_size::value, "Structure has an incorrect size."); @@ -93,8 +94,20 @@ class RadialMenuReplacements : public TempleFix } static int RmbReleasedHandler(TigMsg* msg); + void ReplaceStandardRadialNodes(); + void apply() override { + + + // GetStandardNode + replaceFunction(0x100F12B0, [](int stdNode){ + return radialMenus.GetStandardNode(static_cast(stdNode)); + }); + + ReplaceStandardRadialNodes(); + + // RadialMenuUpdate replaceFunction(0x1004D1F0, [](objHndl objHnd){ auto obj = gameSystems->GetObj().GetObject(objHnd); @@ -170,6 +183,44 @@ int RadialMenuReplacements::RmbReleasedHandler(TigMsg* msg) return 1; } +void RadialMenuReplacements::ReplaceStandardRadialNodes() +{ + auto writeval = reinterpret_cast(RadialMenus::standardNodeIndices); + + // SetStandardNode + write(0x100F145F + 3, &writeval, sizeof(int*)); + write(0x100F1441 + 3, &writeval, sizeof(int*)); + + + write(0x100F15B9 + 3, &writeval, sizeof(int*)); + write(0x100F16E7 + 3, &writeval, sizeof(int*)); + write(0x100F1818 + 3, &writeval, sizeof(int*)); + write(0x100F1945 + 3, &writeval, sizeof(int*)); + write(0x100F1A77 + 3, &writeval, sizeof(int*)); + write(0x100F1BA8 + 3, &writeval, sizeof(int*)); + write(0x100F1D30 + 3, &writeval, sizeof(int*)); + write(0x100F1D70 + 3, &writeval, sizeof(int*)); + write(0x100F1E97 + 3, &writeval, sizeof(int*)); + write(0x100F1FD0 + 3, &writeval, sizeof(int*)); + write(0x100F2100 + 3, &writeval, sizeof(int*)); + write(0x100F2384 + 3, &writeval, sizeof(int*)); + + // BuildRadialMenuNormal + write(0x100F2674 + 2, &writeval, sizeof(int*)); + write(0x100F27EC + 3, &writeval, sizeof(int*)); + + writeval = reinterpret_cast(RadialMenus::standardNodeIndices) + 8; + write(0x100F2876 + 2, &writeval, sizeof(int*)); + write(0x100F28F4 + 1, &writeval, sizeof(int*)); + write(0x100F2969 + 2, &writeval, sizeof(int*)); + write(0x100F29E3 + 2, &writeval, sizeof(int*)); + write(0x100F2A62 + 1, &writeval, sizeof(int*)); + write(0x100F2AD0 + 2, &writeval, sizeof(int*)); + + writeval = reinterpret_cast(RadialMenus::standardNodeIndices) + 0x28; + write(0x100F2B71 + 2, &writeval, sizeof(int*)); +} + RadialMenuReplacements radMenuReplace; @@ -197,7 +248,7 @@ const RadialMenuEntry& RadialMenus::GetLastSelected() { } int RadialMenus::GetStandardNode(RadialMenuStandardNode node) { - return addresses.standardNodeIndices[(int)node]; + return standardNodeIndices[(int)node]; } int RadialMenus::Sub_100F0200(objHndl objHnd, RadialMenuEntry* radEntry) diff --git a/TemplePlus/radialmenu.h b/TemplePlus/radialmenu.h index af8f104a9..2c1cb84d9 100644 --- a/TemplePlus/radialmenu.h +++ b/TemplePlus/radialmenu.h @@ -136,6 +136,8 @@ struct D20RadialMenuDef class RadialMenus { public: + static int standardNodeIndices[120]; + /* Returns the radial menu for the given object or null if no radial menu exists. diff --git a/TemplePlus/ui/ui_item_creation.cpp b/TemplePlus/ui/ui_item_creation.cpp index 5b2324dd3..c7864f418 100644 --- a/TemplePlus/ui/ui_item_creation.cpp +++ b/TemplePlus/ui/ui_item_creation.cpp @@ -550,25 +550,9 @@ uint32_t ItemCreationBuildRadialMenuEntry(DispatcherCallbackArgs args, ItemCreat { if (combatSys.isCombatActive()) { return 0; } MesLine mesLine; - RadialMenuEntry radmenu; - mesLine.key = combatMesLine; - mesFuncs.GetLine_Safe(*combatSys.combatMesfileIdx, &mesLine); - //RadialMenuStructInit(&radmenu); - radmenu.text = (char*)mesLine.value; - //radmenu.field0 = (void*)mesLine.value; + RadialMenuEntryAction radEntry(combatMesLine, D20A_ITEM_CREATION, itemCreationType, helpSystemString); + radEntry.AddChildToStandard(args.objHndCaller, RadialMenuStandardNode::Feats); - radmenu.d20ActionType = D20A_ITEM_CREATION; - //radmenu.field20 = 37; - - radmenu.d20ActionData1 = itemCreationType; - //radmenu.field24 = itemCreationType; - - radmenu.helpId = templeFuncs.StringHash(helpSystemString); - //radmenu.field40 = templeFuncs.StringHash(helpSystemString); - - radialMenus.AddChildNode(args.objHndCaller, &radmenu, radialMenus.GetStandardNode(RadialMenuStandardNode::Feats)); - //radialFuncs.RadialMenuCreateEntry(args.objHndCaller, &radmenu , radialFuncs.RadialMenuArgMap_sub_100F12B0(3) ) ; - return 0; };