Skip to content

Commit ed7ba5b

Browse files
committed
nerf some stuff
1 parent 96a153e commit ed7ba5b

22 files changed

Lines changed: 79 additions & 75 deletions

src/Utils.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// Additional utility methods for Horrible Menu
3131
namespace horrible {
3232
// Pointer to this Geode mod
33-
inline static Mod* thisMod = geode::Mod::get();
33+
inline static Mod* mod = geode::Mod::get();
3434

3535
/**
3636
* Convert a chance setting number to a cooldown percentage decimal
@@ -87,6 +87,11 @@ namespace horrible {
8787
inline constexpr auto misc = "Misc";
8888
};
8989

90+
// got tired of typing {0.5, 0.5} a billion times
91+
namespace anchor {
92+
inline constexpr cocos2d::CCPoint center = {0.5f, 0.5f};
93+
};
94+
9095
// All namespace includes
9196
namespace prelude {
9297
using namespace ::horrible;

src/hooks/Mock.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class $modify(MockMenuLayer, MenuLayer) {
3636
log::trace("mock chance {}", rnd);
3737

3838
if (rnd <= f->chance) {
39-
auto const mockConfigPath = fmt::format("{}\\mock.json", thisMod->getSaveDir());
39+
auto const mockConfigPath = fmt::format("{}\\mock.json", mod->getSaveDir());
4040
auto const mockConfig = file::readJson(fs::path(mockConfigPath));
4141

4242
log::trace("Reading path {}...", mockConfigPath);
@@ -55,14 +55,14 @@ class $modify(MockMenuLayer, MenuLayer) {
5555
if (!id.empty()) {
5656
log::trace("ID {} with percentage {} is valid", id, percent);
5757

58-
auto const pngPath = fmt::format("{}\\{}.png", thisMod->getSaveDir(), id);
58+
auto const pngPath = fmt::format("{}\\{}.png", mod->getSaveDir(), id);
5959

6060
log::info("Displaying {}", pngPath);
6161

6262
auto ss = LazySprite::create({192.f, 108.f});
6363
ss->setID("mocked"_spr);
6464
ss->setScale(0.25);
65-
ss->setAnchorPoint({0.5, 0.5});
65+
ss->setAnchorPoint(anchor::center);
6666
ss->setPosition({-192.f, getScaledContentHeight() / 2.f});
6767

6868
ss->setLoadCallback([self = WeakRef(this), screenshot = WeakRef(ss), percent, rnd](Result<> res) {
@@ -150,10 +150,10 @@ class $modify(MockPlayLayer, PlayLayer) {
150150
renderTexture->end();
151151

152152
if (auto image = renderTexture->newCCImage()) {
153-
auto const path = fmt::format("{}\\{}.png", thisMod->getSaveDir(), id);
153+
auto const path = fmt::format("{}\\{}.png", mod->getSaveDir(), id);
154154

155155
if (image->saveToFile(path.c_str(), false)) {
156-
auto const mockConfigPath = fmt::format("{}\\mock.json", thisMod->getSaveDir());
156+
auto const mockConfigPath = fmt::format("{}\\mock.json", mod->getSaveDir());
157157
auto const mockConfig = file::readJson(fs::path(mockConfigPath)); // get the saved fails to mock the player with :)
158158

159159
auto toWrite = matjson::Value(); // what we're gonna write in the mock.json file
@@ -198,7 +198,7 @@ class $modify(MockPlayLayer, PlayLayer) {
198198
int id = m_level->m_levelID;
199199
int percentage = m_level->m_normalPercent;
200200

201-
auto const mockConfigPath = fmt::format("{}\\mock.json", thisMod->getSaveDir());
201+
auto const mockConfigPath = fmt::format("{}\\mock.json", mod->getSaveDir());
202202
auto const mockConfig = file::readJson(fs::path(mockConfigPath)); // get the saved levels to mock the player :)
203203

204204
if (mockConfig.isOk()) {

src/hooks/obstructive/BlackScreen.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,25 @@ class $modify(BlackScreenPlayLayer, PlayLayer) {
3434

3535
auto const winSize = CCDirector::sharedDirector()->getWinSize();
3636

37-
auto blackScreen = NineSlice::create("square02_001.png");
37+
auto blackScreen = CCLayerColor::create();
3838
blackScreen->setID("blink"_spr);
39-
blackScreen->setContentSize({winSize.width + 10.f, winSize.height + 10.f});
39+
blackScreen->setColor(colors::black);
40+
blackScreen->setAnchorPoint(anchor::center);
41+
blackScreen->setContentSize(winSize);
4042
blackScreen->setPosition(winSize / 2.f);
4143

4244
m_uiLayer->addChild(blackScreen, 99);
4345

4446
// Schedule removal after 0.5 seconds, then schedule to show again after a random delay
4547
blackScreen->runAction(CCSequence::createWithTwoActions(
46-
CCDelayTime::create(0.25f),
48+
CCDelayTime::create(randng::get(0.25f, 0.125f)),
4749
CCCallFuncN::create(this, callfuncN_selector(BlackScreenPlayLayer::removeBlackScreen))));
4850
};
4951

5052
void removeBlackScreen(CCNode* sender) {
5153
cue::resetNode(sender);
5254

53-
float delay = randng::get(3.f); // random delay between 0 and 3 seconds
55+
auto delay = randng::get(3.75f);
5456
log::debug("Black screen will appear again after {} seconds", delay);
5557

5658
scheduleOnce(schedule_selector(BlackScreenPlayLayer::showBlackScreen), delay);

src/hooks/obstructive/Confetti.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ class $modify(ConfettiPlayLayer, PlayLayer) {
3939

4040
void setupHasCompleted() {
4141
PlayLayer::setupHasCompleted();
42-
4342
scheduleOnce(schedule_selector(ConfettiPlayLayer::nextConfetti), randng::get(0.125f));
4443
};
4544

4645
void nextConfetti(float) {
47-
auto delay = randng::get(10.f, 1.f);
46+
auto delay = randng::get(8.75f, 1.25f);
4847
log::trace("scheduling confetti in {}s", delay);
4948

5049
scheduleOnce(schedule_selector(ConfettiPlayLayer::confetti), delay);

src/hooks/obstructive/Earthquake.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class $modify(EarthquakePlayLayer, PlayLayer) {
2525
};
2626

2727
void nextQuake(float) {
28-
auto delay = randng::get(5.f, 1.f);
28+
auto delay = randng::get(3.75f, 1.25f);
2929
log::trace("scheduling quake in {}s", delay);
3030

3131
scheduleOnce(schedule_selector(EarthquakePlayLayer::quake), delay);
@@ -35,7 +35,7 @@ class $modify(EarthquakePlayLayer, PlayLayer) {
3535
// shake the camera randomly based on intensity
3636
auto rnd = randng::fast();
3737

38-
shakeCamera(randng::get(5.f, 1.f), randng::get(10.f, 1.f), 0.00125f);
38+
shakeCamera(randng::get(2.5f, 1.f), randng::get(5.f, 1.f), 0.00125f);
3939

4040
scheduleOnce(schedule_selector(EarthquakePlayLayer::nextQuake), 0.125f);
4141
};

src/hooks/obstructive/Friends.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ class $modify(FriendsPlayLayer, PlayLayer) {
5757
auto rA = randng::pc();
5858
auto rB = randng::pc();
5959

60-
log::trace("friend starts at height percent {} and ends at {}", rA, rB);
61-
6260
auto yA = uiSize.height * rA; // starting height pos
6361
auto yB = uiSize.height * rB; // ending height pos
6462

src/hooks/playerlife/Health.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class $modify(HealthPlayLayer, PlayLayer) {
3737
f->m_healthBar = ProgressBar::create();
3838
f->m_healthBar->setID("health-bar"_spr);
3939
f->m_healthBar->setFillColor(colors::red);
40-
f->m_healthBar->setAnchorPoint({0.5f, 0.5f});
40+
f->m_healthBar->setAnchorPoint(anchor::center);
4141
f->m_healthBar->setPosition({10.f, getScaledContentHeight() / 2.f});
4242
f->m_healthBar->setRotation(-90.f);
4343

src/hooks/playerlife/Oxygen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class $modify(OxygenPlayLayer, PlayLayer) {
4343
f->m_oxygenBar = ProgressBar::create();
4444
f->m_oxygenBar->setID("oxygen-bar"_spr);
4545
f->m_oxygenBar->setFillColor(colors::cyan);
46-
f->m_oxygenBar->setAnchorPoint({0.5f, 0.5f});
46+
f->m_oxygenBar->setAnchorPoint(anchor::center);
4747
f->m_oxygenBar->setPosition({10.f, getScaledContentHeight() / 2.f});
4848
f->m_oxygenBar->setRotation(-90.f);
4949

src/hooks/randoms/Freeze.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class $modify(FreezeMenuLayer, MenuLayer) {
2626
if (auto gm = GameManager::sharedState()) {
2727
// get and store user current fps
2828
float currentFPS = gm->m_customFPSTarget;
29-
(void)thisMod->setSavedValue<float>("fps", currentFPS);
29+
(void)mod->setSavedValue<float>("fps", currentFPS);
3030

3131
log::debug("Stored current FPS: {}", currentFPS);
3232
};
@@ -62,7 +62,7 @@ class $modify(FreezePlayLayer, PlayLayer) {
6262
// default to user old fps
6363
auto gm = GameManager::sharedState();
6464

65-
float oldFPS = thisMod->getSavedValue<float>("fps");
65+
float oldFPS = mod->getSavedValue<float>("fps");
6666

6767
gm->setGameVariable("0116", true);
6868

@@ -114,7 +114,7 @@ class $modify(FreezePlayLayer, PlayLayer) {
114114

115115
gm->setGameVariable("0116", true);
116116

117-
auto oldFPS = thisMod->getSavedValue<float>("fps");
117+
auto oldFPS = mod->getSavedValue<float>("fps");
118118

119119
// Use seconds per frame, not raw FPS
120120
auto interval = (oldFPS > 10.f) ? (1.f / oldFPS) : (1.f / 60.f); // minimum 10 FPS

src/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static std::vector<std::weak_ptr<Hook>> s_floatingBtnHooks;
2020
#define HORRIBLE_HOOK_INTERNAL(hookVector, settingId) \
2121
static void onModify(auto& self) { \
2222
utils::StringMap<std::shared_ptr<Hook>>& hooks = self.m_hooks; \
23-
auto enable = thisMod->getSettingValue<bool>(settingId); \
23+
auto enable = mod->getSettingValue<bool>(settingId); \
2424
\
2525
for (auto& hook : hooks | std::views::values) { \
2626
hook->setAutoEnable(enable); \
@@ -33,7 +33,7 @@ static std::vector<std::weak_ptr<Hook>> s_floatingBtnHooks;
3333
}
3434

3535
$on_game(Loaded) {
36-
(void)thisMod->registerCustomSettingType("menu", &HorribleSettingV3::parse);
36+
(void)mod->registerCustomSettingType("menu", &HorribleSettingV3::parse);
3737

3838
if (auto om = OverlayManager::get()) {
3939
if (auto fb = MenuButton::get()) om->addChild(fb);
@@ -139,7 +139,7 @@ class $modify(HIFloatBtnPauseLayer, PauseLayer) {
139139
HORRIBLE_HOOK_INTERNAL(s_floatingBtnHooks, setting::FloatingBtn);
140140

141141
void customSetup() {
142-
auto toggle = thisMod->getSettingValue<bool>(setting::FloatingBtn);
142+
auto toggle = mod->getSettingValue<bool>(setting::FloatingBtn);
143143

144144
log::trace("{} floating button", toggle ? "Showing" : "Hiding");
145145
if (auto fb = MenuButton::get()) {
@@ -183,7 +183,7 @@ class $modify(HIFloatBtnPlayLayer, PlayLayer) {
183183
log::trace("{} floating button", toggle ? "Showing" : "Hiding");
184184

185185
if (auto fb = MenuButton::get()) {
186-
auto toggleTo = thisMod->getSettingValue<bool>(setting::FloatingBtn) && (fb->showInLevel() || toggle);
186+
auto toggleTo = mod->getSettingValue<bool>(setting::FloatingBtn) && (fb->showInLevel() || toggle);
187187

188188
fb->setVisible(toggleTo);
189189
fb->setTouchEnabled(toggleTo);

0 commit comments

Comments
 (0)