Skip to content

Commit 13dac0c

Browse files
committed
hmm.....
1 parent 51df643 commit 13dac0c

9 files changed

Lines changed: 54 additions & 46 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# v1.2.4
22
- Sound effect for *Charged Leap* option will now only play when leaping at full charge
3+
- Internal tweaks
34

45
# v1.2.3
56
- Rework game modification internals to allow safer option toggling mid-level

src/Utils.h

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,8 @@
33
#include <horrible/API.h>
44
#include <horrible/OptionalAPI.hpp>
55

6-
#include <util/Cursor.hpp>
7-
#include <util/Jumpscares.hpp>
8-
#include <util/Options.hpp>
9-
#include <util/Random.hpp>
10-
#include <util/Themes.hpp>
11-
12-
#include <util/ui/Captcha.hpp>
13-
#include <util/ui/MathQuiz.hpp>
14-
#include <util/ui/RandomAd.hpp>
15-
#include <util/ui/SpamChallenge.hpp>
16-
#include <util/ui/TermsAndConditions.hpp>
17-
#include <util/ui/WhackButton.hpp>
6+
#include <util/Include.h>
7+
#include <util/Macros.h>
188

199
#include <cue/Util.hpp>
2010
#include <cue/DropdownNode.hpp>
@@ -30,22 +20,6 @@
3020

3121
#include <Geode/binding/FMODAudioEngine.hpp>
3222

33-
#define HIGHEST_Z cocos2d::CCScene::get()->getHighestChildZ() + 1
34-
35-
#define HORRIBLE_MODIFY_EVENT_HANDLER(Base, Derived) \
36-
listenForHorribleOptionChanges( \
37-
THIS_ID, \
38-
[](HorribleOptionSave data) { \
39-
if (auto b = Base::get()) modify_cast<Derived*>(b)->setupHorribleInterface(data.enabled); \
40-
})
41-
42-
#define HORRIBLE_TOGGLE_MODIFY(Base, Derived) \
43-
$on_mod(Loaded) { \
44-
HORRIBLE_MODIFY_EVENT_HANDLER(Base, Derived); \
45-
}
46-
47-
#define HORRIBLE_SETUP_INTERFACE_FUNC void setupHorribleInterface(bool on = true)
48-
4923
// Additional utility methods for Horrible Menu
5024
namespace horrible {
5125
// Pointer to this Geode mod

src/hooks/jumpscares/ForceLevels.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ static std::vector<std::weak_ptr<Hook>> g_jsHookVector;
4444

4545
namespace js_internal {
4646
static constexpr auto getLevelInfo(std::string_view id) noexcept {
47-
if (id == THIS_ID_GRIEF) return jumpscares::level::grief;
48-
if (id == THIS_ID_CONGREG) return jumpscares::level::congregation;
49-
if (id == THIS_ID_TIDAL) return jumpscares::level::tidal;
47+
if (id == THIS_ID_GRIEF) return HORRIBLE_JUMPSCARES_GRIEF;
48+
if (id == THIS_ID_CONGREG) return HORRIBLE_JUMPSCARES_CONGREG;
49+
if (id == THIS_ID_TIDAL) return HORRIBLE_JUMPSCARES_TIDAL;
5050

51-
return jumpscares::level::grief;
51+
return HORRIBLE_JUMPSCARES_GRIEF;
5252
};
5353

5454
static void toggleHooks(bool on) {
@@ -104,7 +104,7 @@ static void tryJumpscare(bool useReplay) {
104104

105105
log::debug("jumpscare for {} triggered!", level);
106106
return jumpscares::switchLevel(level, false, useReplay, [level]() {
107-
if (level == jumpscares::level::tidal) Notification::create("Wait, this isn't Tidal Wave...")->show();
107+
if (level == HORRIBLE_JUMPSCARES_TIDAL) Notification::create("Wait, this isn't Tidal Wave...")->show();
108108
});
109109
};
110110
};

src/hooks/jumpscares/TrollLevel.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ static auto const o = Option::create(THIS_ID)
1818
->autoRegister();
1919

2020
namespace js_internal {
21-
static constexpr auto id = 57436521;
22-
2321
static void saveTrollLevel() {
24-
jumpscares::coro::getLevel(id, [](Result<GJGameLevel*> result) {
22+
jumpscares::coro::getLevel(HORRIBLE_JUMPSCARES_TROLL, [](Result<GJGameLevel*> result) {
2523
if (result.isOk()) {
2624
if (auto jm = jumpscares::JumpscareLevelManager::get()) jm->saveLevel(std::move(result).unwrap());
2725
} else if (result.isErr()) {
28-
log::error("Failed to get level {}: {}", id, result.unwrapErr());
26+
log::error("Failed to get level {}: {}", HORRIBLE_JUMPSCARES_TROLL, result.unwrapErr());
2927
};
3028
});
3129
};
@@ -58,7 +56,7 @@ class $modify(TrollLevelPlayLayer, PlayLayer) {
5856
bool init(GJGameLevel* level, bool useReplay, bool dontCreateObjects) {
5957
if (auto jm = jumpscares::JumpscareLevelManager::get()) {
6058
if (rng::chance(m_fields->chance)) {
61-
if (auto lvl = jm->getLevel(js_internal::id)) return PlayLayer::init(lvl, useReplay, dontCreateObjects);
59+
if (auto lvl = jm->getLevel(HORRIBLE_JUMPSCARES_TROLL)) return PlayLayer::init(lvl, useReplay, dontCreateObjects);
6260
};
6361
};
6462

src/util/Include.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include "Cursor.hpp"
4+
#include "Jumpscares.hpp"
5+
#include "Options.hpp"
6+
#include "Random.hpp"
7+
#include "Themes.hpp"
8+
9+
#include "ui/Include.h"

src/util/Jumpscares.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ namespace horrible {
66
namespace util {
77
// Jumpscare level manager
88
namespace jumpscares {
9-
namespace level {
10-
inline constexpr auto grief = 129066933;
11-
inline constexpr auto congregation = 129066879;
12-
inline constexpr auto tidal = 93733469;
13-
};
14-
159
void switchLevel(int level, bool dontCreateObjects, bool useReplay, geode::CopyableFunction<void()>&& callback = nullptr);
1610

1711
namespace coro {

src/util/Macros.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#define HIGHEST_Z cocos2d::CCScene::get()->getHighestChildZ() + 1
4+
5+
#define HORRIBLE_SETUP_INTERFACE_FUNC_NAME setupHorribleInterface
6+
7+
#define HORRIBLE_SETUP_INTERFACE_FUNC void HORRIBLE_SETUP_INTERFACE_FUNC_NAME(bool on = true)
8+
9+
#define HORRIBLE_MODIFY_EVENT_HANDLER(Base, Derived) \
10+
horrible::listenForHorribleOptionChanges( \
11+
THIS_ID, \
12+
[](HorribleOptionSave data) { \
13+
if (auto b = Base::get()) geode::cast::modify_cast<Derived*>(b)->HORRIBLE_SETUP_INTERFACE_FUNC_NAME(data.enabled); \
14+
})
15+
16+
#define HORRIBLE_TOGGLE_MODIFY(Base, Derived) \
17+
$on_mod(Loaded) { \
18+
HORRIBLE_MODIFY_EVENT_HANDLER(Base, Derived); \
19+
}
20+
21+
#define HORRIBLE_JUMPSCARES_GRIEF 129066933
22+
#define HORRIBLE_JUMPSCARES_CONGREG 129066879
23+
#define HORRIBLE_JUMPSCARES_TIDAL 93733469
24+
#define HORRIBLE_JUMPSCARES_TROLL 57436521

src/util/ui/Include.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include "Captcha.hpp"
4+
#include "MathQuiz.hpp"
5+
#include "RandomAd.hpp"
6+
#include "SpamChallenge.hpp"
7+
#include "TermsAndConditions.hpp"
8+
#include "WhackButton.hpp"

src/util/ui/src/RandomAd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ bool RandomAd::init() {
5656
if (auto load = loading.lock()) load->setVisible(true);
5757

5858
if (auto pl = PlayLayer::get()) {
59-
if (pl->m_level->m_levelID == jumpscares::level::congregation) return removeFromParent();
59+
if (pl->m_level->m_levelID == HORRIBLE_JUMPSCARES_CONGREG) return removeFromParent();
6060

6161
log::info("Switching from ad to Congregation jumpscare");
62-
jumpscares::switchLevel(jumpscares::level::congregation, false, false);
62+
jumpscares::switchLevel(HORRIBLE_JUMPSCARES_CONGREG, false, false);
6363
} else {
6464
log::error("Player not in a level");
6565
};

0 commit comments

Comments
 (0)