Skip to content

Commit 95feeb6

Browse files
committed
move some stuff
1 parent 0ca19d3 commit 95feeb6

24 files changed

Lines changed: 147 additions & 148 deletions

src/Utils.hpp

Lines changed: 10 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
#include <Horrible.hpp>
44

5-
#include <classes/Jumpscares.hpp>
6-
#include <classes/Menu.hpp>
7-
#include <classes/Options.hpp>
8-
#include <classes/Randng.hpp>
5+
#include <util/Jumpscares.hpp>
6+
#include <util/Menu.hpp>
7+
#include <util/Options.hpp>
8+
#include <util/Randng.hpp>
9+
#include <util/Themes.hpp>
910

10-
#include <classes/ui/MathQuiz.hpp>
11-
#include <classes/ui/RandomAd.hpp>
12-
#include <classes/ui/SpamChallenge.hpp>
11+
#include <util/ui/MathQuiz.hpp>
12+
#include <util/ui/RandomAd.hpp>
13+
#include <util/ui/SpamChallenge.hpp>
1314

1415
#include <cocos2d.h>
1516

@@ -27,7 +28,7 @@ namespace horrible {
2728
*
2829
* @param chance The chance setting number
2930
*/
30-
inline float chanceToDelayPct(int chance) {
31+
inline float chanceToDelayPct(int chance) noexcept {
3132
if (chance <= 0) chance = 1;
3233
if (chance > 100) chance = 100;
3334

@@ -40,66 +41,7 @@ namespace horrible {
4041
* @param name Name of the audio file
4142
*/
4243
inline void playSfx(const char* file) {
43-
if (auto fmod = FMODAudioEngine::sharedEngine()) fmod->playEffectAsync(file);
44-
};
45-
46-
// Get the current theme's sprites and colors
47-
namespace theme {
48-
inline constexpr auto square = "square02_001.png";
49-
50-
// Theme options
51-
namespace enums {
52-
inline constexpr auto Blue = "Blue";
53-
inline constexpr auto Green = "Green";
54-
inline constexpr auto Dark = "Dark";
55-
inline constexpr auto Light = "Light";
56-
inline constexpr auto Dim = "Dim";
57-
inline constexpr auto Girlypop = "Girlypop";
58-
inline constexpr auto Aqua = "Aqua";
59-
inline constexpr auto Geode = "Geode";
60-
};
61-
62-
// Get the current theme's background sprite name
63-
inline const char* getBackgroundSprite(std::string_view theme) {
64-
if (theme == enums::Blue) return "GJ_square02.png";
65-
if (theme == enums::Green) return "GJ_square03.png";
66-
if (theme == enums::Dark) return "geode.loader/GE_square02.png";
67-
if (theme == enums::Light) return "geode.loader/white-square.png";
68-
if (theme == enums::Dim) return "GJ_square05.png";
69-
if (theme == enums::Girlypop) return "GJ_square04.png";
70-
if (theme == enums::Aqua) return "geode.loader/GE_square03.png";
71-
if (theme == enums::Geode) return "geode.loader/GE_square01.png";
72-
73-
return "GJ_square01.png";
74-
};
75-
76-
// Get the current theme's circle base color enum
77-
inline geode::CircleBaseColor getCircleBaseColor(std::string_view theme) {
78-
if (theme == enums::Blue) return geode::CircleBaseColor::Blue;
79-
if (theme == enums::Green) return geode::CircleBaseColor::Green;
80-
if (theme == enums::Dark) return geode::CircleBaseColor::Gray;
81-
if (theme == enums::Light) return geode::CircleBaseColor::Gray;
82-
if (theme == enums::Dim) return geode::CircleBaseColor::Gray;
83-
if (theme == enums::Girlypop) return geode::CircleBaseColor::Pink;
84-
if (theme == enums::Aqua) return geode::CircleBaseColor::DarkAqua;
85-
if (theme == enums::Geode) return geode::CircleBaseColor::DarkPurple;
86-
87-
return geode::CircleBaseColor::Green;
88-
};
89-
90-
// Get the current theme's square button sprite name
91-
inline const char* getButtonSquareSprite(std::string_view theme) {
92-
if (theme == enums::Blue) return "GJ_button_02.png";
93-
if (theme == enums::Green) return "GJ_button_01.png";
94-
if (theme == enums::Dark) return "GJ_button_05.png";
95-
if (theme == enums::Light) return "GJ_button_04.png";
96-
if (theme == enums::Dim) return "GJ_button_04.png";
97-
if (theme == enums::Girlypop) return "GJ_button_03.png";
98-
if (theme == enums::Aqua) return "geode.loader/GE_button_05.png";
99-
if (theme == enums::Geode) return "geode.loader/GE_button_05.png";
100-
101-
return "GJ_button_01.png";
102-
};
44+
if (auto fmod = FMODAudioEngine::sharedEngine()) (void)fmod->playEffectAsync(file);
10345
};
10446

10547
namespace str = geode::utils::string; // Shortcut for geode::utils::string

src/hooks/PlayLayer/BlackScreen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class $modify(BlackScreenPlayLayer, PlayLayer) {
3636

3737
auto const winSize = CCDirector::sharedDirector()->getWinSize();
3838

39-
auto blackScreen = NineSlice::create(theme::square);
39+
auto blackScreen = NineSlice::create(themes::square);
4040
blackScreen->setID("blink"_spr);
4141
blackScreen->setContentSize({ winSize.width + 10.f, winSize.height + 10.f });
4242
blackScreen->setPosition(winSize / 2.f);

src/hooks/PlayLayer/Math.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,19 @@ class $modify(MathPlayLayer, PlayLayer) {
4747
log::info("Showing math quiz");
4848

4949
if (auto quiz = MathQuiz::create()) {
50-
f->m_currentQuiz = quiz;
51-
5250
// clear pointer on close / handle correct/wrong answer
53-
f->m_currentQuiz->setCallback([this, f](bool correct) {
51+
quiz->setCallback([this, quiz](bool correct) {
5452
nextQuiz();
5553

5654
if (!correct) resetLevelFromStart();
57-
if (f->m_currentQuiz) f->m_currentQuiz->removeMeAndCleanup();
58-
});
55+
if (quiz) quiz->removeMeAndCleanup();
56+
});
5957

6058
#ifdef GEODE_IS_WINDOWS
6159
CCEGLView::sharedOpenGLView()->showCursor(true);
6260
#endif
63-
m_uiLayer->addChild(f->m_currentQuiz, 99);
61+
m_uiLayer->addChild(quiz, 99);
62+
f->m_currentQuiz = quiz;
6463
};
6564
};
6665
};

src/hooks/PlayLayer/Spam.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,19 @@ class $modify(SpamPlayLayer, PlayLayer) {
4444
log::info("Showing spam challenge");
4545

4646
if (auto spam = SpamChallenge::create()) {
47-
f->m_currentSpam = spam;
48-
4947
// clear pointer on close / handle correct/wrong answer
50-
f->m_currentSpam->setCallback([this, f](bool success) {
48+
spam->setCallback([this, spam](bool success) {
5149
nextSpam();
5250

5351
if (!success) resetLevelFromStart();
54-
if (f->m_currentSpam) f->m_currentSpam->removeMeAndCleanup();
55-
});
52+
if (spam) spam->removeMeAndCleanup();
53+
});
5654

5755
#ifdef GEODE_IS_WINDOWS
5856
CCEGLView::sharedOpenGLView()->showCursor(true);
5957
#endif
60-
m_uiLayer->addChild(f->m_currentSpam, 99);
58+
m_uiLayer->addChild(spam, 99);
59+
f->m_currentSpam = spam;
6160
};
6261
};
6362
};

src/menu/src/OptionCategoryItem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bool OptionCategoryItem::init(CCSize const& size, std::string category) {
2626
setContentSize(size);
2727
setAnchorPoint({ 0.5, 1 });
2828

29-
auto bg = NineSlice::create(theme::square);
29+
auto bg = NineSlice::create(themes::square);
3030
bg->setID("background");
3131
bg->setAnchorPoint({ 0, 0 });
3232
bg->setContentSize(getScaledContentSize());

src/menu/src/OptionItem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bool OptionItem::init(CCSize const& size, Option option) {
5252
setContentSize(size);
5353
setAnchorPoint({ 0.5, 1 });
5454

55-
auto bg = NineSlice::create(theme::square);
55+
auto bg = NineSlice::create(themes::square);
5656
bg->setID("background");
5757
bg->setAnchorPoint({ 0, 0 });
5858
bg->setContentSize(getScaledContentSize());

src/menu/src/OptionMenu.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,17 @@ OptionMenu::OptionMenu() : m_impl(std::make_unique<Impl>()) {};
8585
OptionMenu::~OptionMenu() {};
8686

8787
bool OptionMenu::init() {
88-
auto btns = theme::getCircleBaseColor(m_impl->theme);
88+
auto btns = themes::getCircleBaseColor(m_impl->theme);
8989

90-
if (!Popup::init(450.f, 280.f, theme::getBackgroundSprite(m_impl->theme))) return false;
90+
if (!Popup::init(450.f, 280.f, themes::getBackgroundSprite(m_impl->theme))) return false;
9191

9292
setID("options"_spr);
9393
setTitle("Horrible Options");
9494
setCloseButtonSpr(CircleButtonSprite::createWithSpriteFrameName("geode.loader/close.png", 0.875f, btns, CircleBaseSize::Small));
9595

9696
auto mainLayerSize = m_mainLayer->getScaledContentSize();
9797

98-
auto categoryListBg = NineSlice::create(theme::square);
98+
auto categoryListBg = NineSlice::create(themes::square);
9999
categoryListBg->setAnchorPoint({ 0.5, 0.5 });
100100
categoryListBg->setPosition({ mainLayerSize.width - 82.5f, 75.f });
101101
categoryListBg->setContentSize({ (mainLayerSize.width / 3.f) - 10.f, 95.f });
@@ -146,7 +146,7 @@ bool OptionMenu::init() {
146146
m_mainLayer->addChild(m_impl->categoryList, 1);
147147

148148
// Add a background sprite to the popup
149-
auto optionListBg = NineSlice::create(theme::square);
149+
auto optionListBg = NineSlice::create(themes::square);
150150
optionListBg->setAnchorPoint({ 0.5, 0.5 });
151151
optionListBg->setPosition({ (mainLayerSize.width / 2.f) - 77.5f, (mainLayerSize.height / 2.f) - 32.5f });
152152
optionListBg->setContentSize({ (mainLayerSize.width / 1.5f) - 20.f, mainLayerSize.height - 85.f });
@@ -187,7 +187,7 @@ bool OptionMenu::init() {
187187
m_mainLayer->addChild(m_impl->searchInput);
188188

189189
// add a list button background
190-
auto filterContainerBg = NineSlice::create(theme::square);
190+
auto filterContainerBg = NineSlice::create(themes::square);
191191
filterContainerBg->setAnchorPoint({ 0.5, 0.5 });
192192
filterContainerBg->setPosition({ mainLayerSize.width - 82.5f, (mainLayerSize.height / 2.f) - 12.5f });
193193
filterContainerBg->setContentSize({ (mainLayerSize.width / 3.f), mainLayerSize.height - 45.f });
@@ -225,7 +225,7 @@ bool OptionMenu::init() {
225225
};
226226

227227
for (auto const& filterBtn : filterBtns) {
228-
if (auto btnSprite = ButtonSprite::create(filterBtn.label, 155, true, "bigFont.fnt", theme::getButtonSquareSprite(m_impl->theme), 0.f, 0.8f)) {
228+
if (auto btnSprite = ButtonSprite::create(filterBtn.label, 155, true, "bigFont.fnt", themes::getButtonSquareSprite(m_impl->theme), 0.f, 0.8f)) {
229229
btnSprite->m_label->setColor(filterBtn.color);
230230
btnSprite->setScale(0.8f);
231231

src/menu/src/OptionMenuButton.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void OptionMenuButton::setupSprite() {
3434
m_impl->sprite = CircleButtonSprite::createWithSprite(
3535
"icon.png"_spr,
3636
0.925f,
37-
theme::getCircleBaseColor(m_impl->theme)
37+
themes::getCircleBaseColor(m_impl->theme)
3838
);
3939
m_impl->sprite->setAnchorPoint({ 0.5, 0.5 });
4040

src/menu/src/SettingV3.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bool HorribleSettingNodeV3::init(std::shared_ptr<HorribleSettingV3> setting, flo
5656
auto buttonSprite = ButtonSprite::create(
5757
"Horrible Options Menu",
5858
"bigFont.fnt",
59-
theme::getButtonSquareSprite(m_impl->theme),
59+
themes::getButtonSquareSprite(m_impl->theme),
6060
0.875f
6161
);
6262
buttonSprite->setScale(0.5f);
@@ -88,7 +88,7 @@ bool HorribleSettingNodeV3::init(std::shared_ptr<HorribleSettingV3> setting, flo
8888
auto buttonSprite = ButtonSprite::create(
8989
"Horrible Options Menu",
9090
"bigFont.fnt",
91-
theme::getButtonSquareSprite(m_impl->theme),
91+
themes::getButtonSquareSprite(m_impl->theme),
9292
0.875f
9393
);
9494
buttonSprite->setScale(0.5f);

0 commit comments

Comments
 (0)