Skip to content

Commit d37309b

Browse files
committed
add optimization & dont build for nightly (yeah i cant hook ext funcs, wow!)
1 parent 1166d0b commit d37309b

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ jobs:
4747
bindings-ref: main
4848
combine: true
4949
target: ${{ matrix.config.target }}
50-
cli: nightly
51-
sdk: nightly
50+
#sdk: nightly
5251

5352
package:
5453
name: Package builds

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* <cg>Added</c> option to hide the connected notification.
44
* <cr>Removed</c> demon list warning if the level wasn't found on the demon list.
55
* <cy>Fixed</c> notifications sometimes not being received.
6-
* <cy>Fixed</c> notifications sometimes not being received.
76
* <cy>Fixed</c> reconnection times not being exponential.
7+
* <cg>Added</c> hook optimizations.
88

99
## <cj>v1.5.1</c> <cb>(2025-04-20)</c>
1010
* <cy>Temporarily removed</c> showing past notifications.

src/main.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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;
671672
bool is_socketserver_started = false;
672673
class $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

Comments
 (0)