Skip to content

Commit 4c6f84e

Browse files
committed
migrate some hooks to delegate macro
1 parent 6478b48 commit 4c6f84e

19 files changed

Lines changed: 281 additions & 324 deletions

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ class $modify(MyPlayLayer, PlayLayer) {
8383
8484
---
8585
86+
### Thanks
87+
88+
- **[Geode SDK](https://www.geode-sdk.org/)**: Created an incredible SDK to make this mod possible!
89+
- **[RobTop Games](https://www.robtopgames.com/)**: Made [Geometry Dash](https://youtu.be/k90y6PIzIaE)...
90+
91+
- **You!**: For being there and keeping us motivated to continue this big ole' project.
92+
93+
---
94+
8695
![preview](previews/preview-1.png)
8796
![preview](previews/preview-2.png)
8897
![preview](previews/preview-3.png)

about.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,13 @@ class $modify(MyPlayLayer, PlayLayer) {
7878
7979
---
8080
81+
### Thanks
82+
83+
- **[Geode SDK](mod:geode.loader)**: Created an incredible SDK to make this mod possible!
84+
- **[RobTop Games](user:71)**: Made [Geometry Dash](https://youtu.be/k90y6PIzIaE)...
85+
86+
- **You!**: For being there and keeping us motivated to continue this big ole' project.
87+
88+
---
89+
8190
**![YT](frame:gj_ytIcon_001.png?scale=0.375) Watch the [Horrible Mods](https://www.youtube.com/watch?v=Ssl49pNmW_0&list=PL0dsSu2pR5cERnq7gojZTKVRvUwWo2Ohu) series out now on YouTube!**

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# v1.0.0
1+
# v1.0.0
22
- Initial release

src/hooks/PlayLayer/BlackScreen.cpp

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,43 @@ inline static Option const o = {
1717
HORRIBLE_REGISTER_OPTION(o);
1818

1919
class $modify(BlackScreenPlayLayer, PlayLayer) {
20-
struct Fields {
21-
bool enabled = options::get(o.id);
22-
};
20+
HORRIBLE_DELEGATE_HOOKS(o.id);
2321

2422
void setupHasCompleted() {
2523
PlayLayer::setupHasCompleted();
2624

27-
if (m_fields->enabled) {
28-
// random delay between 0 and 5 seconds
29-
auto delay = randng::get(5.f);
30-
log::debug("Black screen will appear after {} seconds", delay);
25+
// random delay between 0 and 5 seconds
26+
auto delay = randng::get(5.f);
27+
log::debug("Black screen will appear after {} seconds", delay);
3128

32-
scheduleOnce(schedule_selector(BlackScreenPlayLayer::showBlackScreen), delay);
33-
};
29+
scheduleOnce(schedule_selector(BlackScreenPlayLayer::showBlackScreen), delay);
3430
};
3531

3632
void showBlackScreen(float) {
37-
if (m_fields->enabled) {
38-
log::debug("Showing black screen after delay");
33+
log::debug("Showing black screen after delay");
3934

40-
auto const winSize = CCDirector::sharedDirector()->getWinSize();
35+
auto const winSize = CCDirector::sharedDirector()->getWinSize();
4136

42-
auto blackScreen = CCScale9Sprite::create("square02_001.png");
43-
blackScreen->setID("blink"_spr);
44-
blackScreen->setContentSize({ winSize.width + 10.f, winSize.height + 10.f });
45-
blackScreen->setPosition(winSize / 2.f);
37+
auto blackScreen = CCScale9Sprite::create("square02_001.png");
38+
blackScreen->setID("blink"_spr);
39+
blackScreen->setContentSize({ winSize.width + 10.f, winSize.height + 10.f });
40+
blackScreen->setPosition(winSize / 2.f);
4641

47-
m_uiLayer->addChild(blackScreen, 99);
42+
m_uiLayer->addChild(blackScreen, 99);
4843

49-
// Schedule removal after 0.5 seconds, then schedule to show again after a random delay
50-
blackScreen->runAction(CCSequence::createWithTwoActions(
51-
CCDelayTime::create(0.25f),
52-
CCCallFuncN::create(this, callfuncN_selector(BlackScreenPlayLayer::removeBlackScreen))
53-
));
54-
};
44+
// Schedule removal after 0.5 seconds, then schedule to show again after a random delay
45+
blackScreen->runAction(CCSequence::createWithTwoActions(
46+
CCDelayTime::create(0.25f),
47+
CCCallFuncN::create(this, callfuncN_selector(BlackScreenPlayLayer::removeBlackScreen))
48+
));
5549
};
5650

5751
void removeBlackScreen(CCNode * sender) {
5852
if (sender) sender->removeMeAndCleanup();
5953

60-
if (m_fields->enabled) {
61-
float delay = randng::get(3.f); // random delay between 0 and 3 seconds
62-
log::debug("Black screen will appear again after {} seconds", delay);
54+
float delay = randng::get(3.f); // random delay between 0 and 3 seconds
55+
log::debug("Black screen will appear again after {} seconds", delay);
6356

64-
scheduleOnce(schedule_selector(BlackScreenPlayLayer::showBlackScreen), delay);
65-
};
57+
scheduleOnce(schedule_selector(BlackScreenPlayLayer::showBlackScreen), delay);
6658
};
6759
};

src/hooks/PlayLayer/BlinkingIcon.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,25 @@ inline static Option const o = {
1717
HORRIBLE_REGISTER_OPTION(o);
1818

1919
class $modify(BlinkingIconPlayLayer, PlayLayer) {
20-
struct Fields {
21-
bool enabled = options::get(o.id);
22-
};
20+
HORRIBLE_DELEGATE_HOOKS(o.id);
2321

2422
void setupHasCompleted() {
2523
PlayLayer::setupHasCompleted();
26-
if (m_fields->enabled) nextBlink();
24+
nextBlink();
2725
};
2826

2927
void nextBlink() {
3028
auto delay = randng::get(2.f, 1.f);
3129
log::debug("scheduling blink in {}s", delay);
3230

33-
if (m_fields->enabled) scheduleOnce(schedule_selector(BlinkingIconPlayLayer::blink), delay);
31+
scheduleOnce(schedule_selector(BlinkingIconPlayLayer::blink), delay);
3432
};
3533

3634
void blink(float) {
37-
if (m_fields->enabled) {
38-
log::debug("Blink!");
35+
log::debug("Blink!");
3936

40-
if (m_player1) m_player1->playSpawnEffect();
41-
if (m_player2) m_player2->playSpawnEffect();
42-
};
37+
if (m_player1) m_player1->playSpawnEffect();
38+
if (m_player2) m_player2->playSpawnEffect();
4339

4440
nextBlink();
4541
};

src/hooks/PlayLayer/CrashGame.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,26 @@ inline static Option const o = {
1717
HORRIBLE_REGISTER_OPTION(o);
1818

1919
class $modify(CrashGamePlayLayer, PlayLayer) {
20+
HORRIBLE_DELEGATE_HOOKS(o.id);
21+
2022
struct Fields {
21-
bool enabled = options::get(o.id);
2223
int chance = options::getChance(o.id);
2324
};
2425

2526
void destroyPlayer(PlayerObject * p0, GameObject * p1) {
2627
auto f = m_fields.self();
2728

28-
if (f->enabled) {
29-
// ignore the anti-cheat spike lmao
30-
if (p1 == m_anticheatSpike && p0 && !p0->m_isDead) return;
29+
// ignore the anti-cheat spike lmao
30+
if (p1 == m_anticheatSpike && p0 && !p0->m_isDead) return;
3131

32-
int rnd = randng::fast();
33-
log::debug("crash destroy chance {}", rnd);
32+
int rnd = randng::fast();
33+
log::debug("crash destroy chance {}", rnd);
3434

35-
if (rnd <= f->chance) {
36-
log::warn("ur game crash hehehehehehehe");
35+
if (rnd <= f->chance) {
36+
log::warn("ur game crash hehehehehehehe");
3737

38-
PlayLayer::destroyPlayer(p0, p1);
39-
game::exit(true); // saves data
40-
};
38+
PlayLayer::destroyPlayer(p0, p1);
39+
game::exit(true); // saves data
4140
};
4241

4342
PlayLayer::destroyPlayer(p0, p1);

src/hooks/PlayLayer/Earthquake.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,25 @@ inline static Option const o = {
1717
HORRIBLE_REGISTER_OPTION(o);
1818

1919
class $modify(EarthquakePlayLayer, PlayLayer) {
20-
struct Fields {
21-
bool enabled = options::get(o.id);
22-
};
20+
HORRIBLE_DELEGATE_HOOKS(o.id);
2321

2422
void setupHasCompleted() {
25-
if (m_fields->enabled) scheduleOnce(schedule_selector(EarthquakePlayLayer::nextQuake), 0.125f);
23+
scheduleOnce(schedule_selector(EarthquakePlayLayer::nextQuake), 0.125f);
2624
PlayLayer::setupHasCompleted();
2725
};
2826

2927
void nextQuake(float) {
3028
auto delay = randng::get(3.f, 1.f);
3129
log::debug("scheduling quake in {}s", delay);
3230

33-
if (m_fields->enabled) scheduleOnce(schedule_selector(EarthquakePlayLayer::quake), delay);
31+
scheduleOnce(schedule_selector(EarthquakePlayLayer::quake), delay);
3432
};
3533

3634
void quake(float) {
37-
if (m_fields->enabled) {
38-
// shake the camera randomly based on intensity
39-
int rnd = randng::fast();
35+
// shake the camera randomly based on intensity
36+
int rnd = randng::fast();
4037

41-
shakeCamera(randng::get(5.f, 1.f), randng::get(10.f, 1.f), 0.00875F);
42-
};
38+
shakeCamera(randng::get(5.f, 1.f), randng::get(10.f, 1.f), 0.00875F);
4339

4440
scheduleOnce(schedule_selector(EarthquakePlayLayer::nextQuake), 0.125f);
4541
};

src/hooks/PlayLayer/FakeDeath.cpp

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ inline static Option const o = {
1717
HORRIBLE_REGISTER_OPTION(o);
1818

1919
class $modify(FakeDeathPlayLayer, PlayLayer) {
20-
struct Fields {
21-
bool enabled = options::get(o.id);
20+
HORRIBLE_DELEGATE_HOOKS(o.id);
2221

22+
struct Fields {
2323
bool m_dontCreateObjects = false;
2424
GameObject* m_destroyingObject;
2525
};
@@ -28,34 +28,29 @@ class $modify(FakeDeathPlayLayer, PlayLayer) {
2828
auto f = m_fields.self();
2929

3030
// Show explosion visual effect but do not kill the player
31-
if (f->enabled) {
32-
// ignore the anti-cheat spike lmao
33-
if (game == m_anticheatSpike && player && !player->m_isDead) return PlayLayer::destroyPlayer(player, game);
34-
if (!f->m_destroyingObject) f->m_destroyingObject = game;
3531

36-
// @geode-ignore(unknown-resource)
37-
FMODAudioEngine::sharedEngine()->playEffectAsync("explode_11.ogg");
38-
GJBaseGameLayer::shakeCamera(1.f, 2.f, 1.f);
32+
// ignore the anti-cheat spike lmao
33+
if (game == m_anticheatSpike && player && !player->m_isDead) return PlayLayer::destroyPlayer(player, game);
34+
if (!f->m_destroyingObject) f->m_destroyingObject = game;
3935

40-
if (m_player1) {
41-
log::debug("fake death");
42-
m_player1->playDeathEffect();
43-
m_player1->resetPlayerIcon();
36+
// @geode-ignore(unknown-resource)
37+
FMODAudioEngine::sharedEngine()->playEffectAsync("explode_11.ogg");
38+
GJBaseGameLayer::shakeCamera(1.f, 2.f, 1.f);
4439

45-
m_player1->m_isDead = false;
46-
};
40+
if (m_player1) {
41+
log::debug("fake death");
42+
m_player1->playDeathEffect();
43+
m_player1->resetPlayerIcon();
4744

48-
if (m_player2) {
49-
log::debug("fake death");
50-
m_player2->playDeathEffect();
51-
m_player2->resetPlayerIcon();
45+
m_player1->m_isDead = false;
46+
};
5247

53-
m_player2->m_isDead = false;
54-
};
48+
if (m_player2) {
49+
log::debug("fake death");
50+
m_player2->playDeathEffect();
51+
m_player2->resetPlayerIcon();
5552

56-
return;
53+
m_player2->m_isDead = false;
5754
};
58-
59-
PlayLayer::destroyPlayer(player, game);
6055
};
6156
};

src/hooks/PlayLayer/Flipped.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ inline static Option const o = {
1717
HORRIBLE_REGISTER_OPTION(o);
1818

1919
class $modify(FlippedPlayLayer, PlayLayer) {
20+
HORRIBLE_DELEGATE_HOOKS(o.id);
21+
2022
struct Fields {
21-
bool enabled = options::get(o.id);
2223
int chance = options::getChance(o.id);
2324

2425
bool flipping = false;
2526
};
2627

2728
void setupHasCompleted() {
2829
PlayLayer::setupHasCompleted();
29-
if (m_fields->enabled) schedule(schedule_selector(FlippedPlayLayer::flip), 0.125f);
30+
schedule(schedule_selector(FlippedPlayLayer::flip), 0.125f);
3031
};
3132

3233
void flippingEnded() {
@@ -37,7 +38,7 @@ class $modify(FlippedPlayLayer, PlayLayer) {
3738
void flip(float) {
3839
auto f = m_fields.self();
3940

40-
if (f->enabled && !f->flipping) {
41+
if (!f->flipping) {
4142
if (randng::tiny() > f->chance) return;
4243

4344
f->flipping = true;

src/hooks/PlayLayer/Freeze.cpp

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ inline static Option const o = {
1717
HORRIBLE_REGISTER_OPTION(o);
1818

1919
class $modify(FreezePlayLayer, PlayLayer) {
20+
HORRIBLE_DELEGATE_HOOKS(o.id);
21+
2022
struct Fields {
21-
bool enabled = options::get(o.id);
2223
int chance = options::getChance(o.id);
2324
};
2425

@@ -27,13 +28,9 @@ class $modify(FreezePlayLayer, PlayLayer) {
2728

2829
auto f = m_fields.self();
2930

30-
if (f->enabled) {
31-
if (auto gm = GameManager::sharedState()) {
32-
int rnd = randng::fast();
33-
if (rnd % 100 < f->chance) capFPS(1.f);
34-
};
35-
} else {
36-
log::warn("Random freezing at 90% is disabled");
31+
if (auto gm = GameManager::sharedState()) {
32+
int rnd = randng::fast();
33+
if (rnd % 100 < f->chance) capFPS(1.f);
3734
};
3835
};
3936

@@ -77,38 +74,36 @@ class $modify(FreezePlayLayer, PlayLayer) {
7774
};
7875

7976
void updateProgressbar() {
80-
if (m_fields->enabled) {
81-
// check if current percentage is less than or equal to 90
82-
if (getCurrentPercentInt() >= 90) {
83-
auto gm = GameManager::get();
77+
// check if current percentage is less than or equal to 90
78+
if (getCurrentPercentInt() >= 90) {
79+
auto gm = GameManager::get();
8480

85-
gm->setGameVariable("0116", true);
81+
gm->setGameVariable("0116", true);
8682

87-
// Randomize FPS between 1 and 45
88-
int rndFps = randng::get(45, 1); // 1 to 45 inclusive
83+
// Randomize FPS between 1 and 45
84+
int rndFps = randng::get(45, 1); // 1 to 45 inclusive
8985

90-
auto interval = 1.f / static_cast<float>(rndFps);
91-
if (interval <= 0.f || interval > 1.f) interval = 1.f / 60.f; // fallback to 60 FPS if invalid
86+
auto interval = 1.f / static_cast<float>(rndFps);
87+
if (interval <= 0.f || interval > 1.f) interval = 1.f / 60.f; // fallback to 60 FPS if invalid
9288

93-
CCDirector::sharedDirector()->setAnimationInterval(interval);
89+
CCDirector::sharedDirector()->setAnimationInterval(interval);
9490

95-
// log::debug("cap fps to {} (interval {})", rndFps, interval);
96-
} else {
97-
// default to user old fps
98-
auto gm = GameManager::get();
91+
// log::debug("cap fps to {} (interval {})", rndFps, interval);
92+
} else {
93+
// default to user old fps
94+
auto gm = GameManager::get();
9995

100-
gm->setGameVariable("0116", true);
96+
gm->setGameVariable("0116", true);
10197

102-
auto oldFPS = horribleMod->getSavedValue<float>("fps");
98+
auto oldFPS = horribleMod->getSavedValue<float>("fps");
10399

104-
// Use seconds per frame, not raw FPS
105-
auto interval = (oldFPS > 10.f) ? (1.f / oldFPS) : (1.f / 60.f); // minimum 10 FPS
106-
if (interval <= 0.f || interval > 1.f) interval = 1.f / 60.f; // fallback to 60 FPS if invalid
100+
// Use seconds per frame, not raw FPS
101+
auto interval = (oldFPS > 10.f) ? (1.f / oldFPS) : (1.f / 60.f); // minimum 10 FPS
102+
if (interval <= 0.f || interval > 1.f) interval = 1.f / 60.f; // fallback to 60 FPS if invalid
107103

108-
CCDirector::sharedDirector()->setAnimationInterval(interval);
104+
CCDirector::sharedDirector()->setAnimationInterval(interval);
109105

110-
// log::debug("reset fps to {} (interval {})", oldFPS, interval);
111-
};
106+
// log::debug("reset fps to {} (interval {})", oldFPS, interval);
112107
};
113108

114109
PlayLayer::updateProgressbar();

0 commit comments

Comments
 (0)