11#pragma once
22
33#include < Geode/Geode.hpp>
4+ #include < Geode/binding/GJGameLevel.hpp>
45#include < Geode/modify/CCObject.hpp>
56#include < Geode/modify/CCPoolManager.hpp>
67#include < Geode/modify/CCDictionary.hpp>
910#include < alphalaneous.alphas_geode_utils/include/Fields.h>
1011#include " Macros.hpp"
1112#include " LateQueue.hpp"
13+ #include " Utils.hpp"
1214
1315using namespace geode ::prelude;
1416
@@ -28,55 +30,22 @@ class $modify(CCDictionary) {
2830 }
2931};
3032
31- static std::unordered_map<CCObject*, uintptr_t > s_nodeVTables;
32-
33- static bool checkNodeValidity (CCObject* node) {
34- auto ret = *(uintptr_t *)node == s_nodeVTables[node];
35- s_nodeVTables.erase (node);
36- return ret;
37- }
38-
39- static void setNodeVTable (CCNode* node) {
40- s_nodeVTables[node] = *(uintptr_t *)node;
41- }
42-
43- static std::unordered_map<const std::type_info*, bool > s_isNodeCache;
44-
45- static bool isNode (CCObject* obj) {
46- const std::type_info* ti = &typeid (*obj);
47-
48- auto it = s_isNodeCache.find (ti);
49- if (it != s_isNodeCache.end ()) {
50- return it->second ;
51- }
52-
53- bool isNode = typeinfo_cast<CCNode*>(obj) != nullptr ;
54- s_isNodeCache.emplace (ti, isNode);
55-
56- return isNode;
57- }
5833
5934class $modify(HTCCObject, CCObject) {
6035
61- static std::string_view extract (std::string_view s) {
62- if (auto pos = s.rfind (" ::" ); pos != std::string_view::npos)
63- return s.substr (pos + 2 );
64- return s;
65- }
66-
6736 CCObject* autorelease () {
6837 auto modding = UIModding::get ();
6938 if (!modding->doModify ) return CCObject::autorelease ();
7039
71- if (isNode (this )) {
40+ if (modding-> isNode (this )) {
7241 MyCCNode* node = reinterpret_cast <MyCCNode*>(this );
7342
7443 auto fields = node->m_fields .self ();
7544 if (!fields->m_modified ) {
76- setNodeVTable (node);
45+ modding-> setNodeVTable (node);
7746 LateQueue::get ()->queue (node, [modding, node = Ref (node), fields] {
78- if (!checkNodeValidity (node)) return ;
79- modding->doUICheckForType (extract (cocos::getObjectName (node)), node);
47+ if (!modding-> checkNodeValidity (node)) return ;
48+ modding->doUICheckForType (Utils:: extract (cocos::getObjectName (node)), node);
8049 fields->m_modified = true ;
8150 });
8251 }
0 commit comments