44
55#include < Geode/modify/CreatorLayer.hpp>
66#include < Geode/modify/CCSprite.hpp>
7- #include < Geode/modify/CCScale9Sprite.hpp>
7+ // #include <Geode/modify/CCScale9Sprite.hpp>
88#include < Geode/modify/MenuLayer.hpp>
99#include < Geode/loader/Log.hpp>
1010#include < Geode/utils/web.hpp>
@@ -558,7 +558,7 @@ class EventHandler : public CCObject {
558558};
559559
560560// Backgrounds
561- class $modify(CCSprite) {
561+ class $modify(UtilCCSprite, CCSprite) {
562562 static CCSprite* create (char const * name) {
563563 auto ret = CCSprite::create (name);
564564 if (ret == nullptr ) return ret;
@@ -582,9 +582,9 @@ class $modify(CCSprite) {
582582 return ret;
583583 }
584584};
585-
585+ /*
586586// Child background
587- class $modify(cocos2d::extension::CCScale9Sprite) {
587+ class $modify(UtilCCScale9, cocos2d::extension::CCScale9Sprite) {
588588 static cocos2d::extension::CCScale9Sprite* create(char const* name, CCRect rect) {
589589 auto ret = cocos2d::extension::CCScale9Sprite::create(name, rect);
590590 if (ret == nullptr) return ret;
@@ -667,6 +667,7 @@ class $modify(cocos2d::extension::CCScale9Sprite) {
667667 return ret;
668668 }
669669};
670+ */
670671// bool is_dailychest_ready = false;
671672bool is_socketserver_started = false ;
672673class $modify(MenuLayer) {
@@ -700,6 +701,18 @@ class $modify(MenuLayer) {
700701 }
701702};
702703
704+ void toggleSpriteHooks (bool value) {
705+ for (auto & hook : geode::Mod::get ()->getHooks ()) {
706+ if (hook->getDisplayName () == " cocos2d::CCSprite::create" || hook->getDisplayName () == " cocos2d::extension::CCScale9Sprite::create" ) {
707+ if (value) {
708+ (void )hook->enable ();
709+ } else {
710+ (void )hook->disable ();
711+ }
712+ }
713+ }
714+ }
715+
703716$execute {
704717 (void )Mod::get ()->registerCustomSettingType (" credit-buttons" , &SettingCreditsValue::parse);
705718 // (void)Mod::get()->registerCustomSettingType("notificationPlacement", &SettingPosValue::parse);
@@ -711,12 +724,19 @@ class $modify(MenuLayer) {
711724 CCScheduler::get ()->scheduleSelector (schedule_selector (EventHandler::check), EventHandler::create (), 1 .0F , false );
712725 // CCScheduler::get()->scheduleUpdateForTarget(EventHandler::create(), Priority::Last, false);
713726 });
727+ listenForSettingChanges (" activate-background" , [](bool value) {
728+ log::info (" Activate Background changed to {}" , value);
729+ toggleSpriteHooks (value);
730+ });
714731}
715732
716733// When the socket connection is made
717734$on_mod(Loaded) {
718735 log::info (" GDUtils Mod Loaded" );
719736
737+ if (!Mod::get ()->getSettingValue <bool >(" activate-background" )) {
738+ toggleSpriteHooks (false );
739+ }
720740 chestQueue.push (1 );
721741
722742 // Discord::init(); for next update ;)
0 commit comments