11#include < Utils.hpp>
22
3+ #include < ranges>
4+
35#include < menu/OptionMenuButton.hpp>
46#include < menu/SettingV3.hpp>
57
6- #include < ranges>
7-
88#include < Geode/modify/PlayLayer.hpp>
99#include < Geode/modify/PauseLayer.hpp>
1010#include < Geode/modify/GJGameLevel.hpp>
1414using namespace horrible ::prelude;
1515
1616inline static std::vector<Hook*> safeModeHooks;
17- inline static std::vector<Hook* > floatingBtnHooks;
17+ inline static std::vector<std::weak_ptr< Hook> > floatingBtnHooks;
1818
1919#define HORRIBLE_HOOK_SAFEMODE (hookName ) \
2020 static void onModify (auto & self) { \
@@ -39,7 +39,7 @@ inline static std::vector<Hook*> floatingBtnHooks;
3939 hook->setAutoEnable (enable); \
4040 (void )hook->toggle (enable); \
4141 \
42- floatingBtnHooks.push_back (hook. get ()); \
42+ floatingBtnHooks.push_back (hook); \
4343 }; \
4444 }
4545
@@ -68,8 +68,10 @@ inline static std::vector<Hook*> floatingBtnHooks;
6868 if (auto fb = OptionMenuButton::get ()) fb->setVisible (value);
6969
7070 for (auto & hook : floatingBtnHooks) {
71- log::trace (" Toggling floating button hook '{}' {}..." , hook->getDisplayName (), value ? " ON" : " OFF" );
72- (void )hook->toggle (value);
71+ if (auto h = hook.lock ()) {
72+ log::trace (" Toggling floating button hook '{}' {}..." , h->getDisplayName (), value ? " ON" : " OFF" );
73+ (void )h->toggle (value);
74+ };
7375 };
7476 });
7577
0 commit comments