Skip to content

Commit 549ad93

Browse files
committed
me when i manage ur memory
1 parent 5dc98bd commit 549ad93

10 files changed

Lines changed: 24 additions & 29 deletions

File tree

include/horrible/API.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ namespace horrible {
2727
class BRKD_HORRIBLE_API_DLL OptionManager final {
2828
friend class Option;
2929

30+
// Type alias for `geode::Function<void(bool)>`, used in hook delegation
31+
using Callback = geode::Function<void(bool)>;
32+
3033
private:
3134
geode::utils::StringMap<std::shared_ptr<Option>> m_options; // Map of registered options
3235
std::vector<std::string> m_categories; // Array of auto-registered categories
3336

3437
geode::utils::StringMap<const geode::Mod* const> m_integrations; // Map of auto-registered external mods using this API
3538

36-
// Type alias for `geode::Function<void(bool)>`, used in hook delegation
37-
using Callback = geode::Function<void(bool)>;
38-
3939
std::unordered_map<std::string_view, std::vector<Callback>> m_delegates; // Map of option ID to array of delegates to call when that option is toggled
4040

4141
protected:

src/hooks/GJBaseGameLayer/TOS.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class $modify(TOSGJBaseGameLayer, GJBaseGameLayer) {
2020
HORRIBLE_DELEGATE_HOOKS(THIS_ID);
2121

2222
struct Fields {
23-
TermsAndConditions* currentTos = nullptr;
23+
Ref<TermsAndConditions> currentTos = nullptr;
2424
};
2525

2626
void handleButton(bool down, int button, bool isPlayer1) {
@@ -29,8 +29,8 @@ class $modify(TOSGJBaseGameLayer, GJBaseGameLayer) {
2929
if (down) {
3030
auto f = m_fields.self();
3131

32-
if (auto popup = WeakRef(f->currentTos).lock()) {
33-
popup.take()->removeFromParent();
32+
if (f->currentTos) {
33+
f->currentTos.take()->removeFromParent();
3434
f->currentTos = nullptr;
3535
} else if (auto popup = TermsAndConditions::create(
3636
[this](bool accepted) {

src/hooks/PlayLayer/WhackAFace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class $modify(WhackAFacePlayLayer, PlayLayer) {
107107
auto f = m_fields.self();
108108

109109
for (auto& whackBtn : f->active) {
110-
if (auto btn = whackBtn.lock()) btn->removeFromParent();
110+
if (auto btn = whackBtn.lock()) btn.take()->removeFromParent();
111111
};
112112

113113
f->active.clear();

src/ui/MenuOption.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
namespace horrible {
88
class MenuOption final : public cocos2d::CCMenu {
9+
using Callback = Function<void()>;
10+
911
private:
1012
class Impl;
1113
std::unique_ptr<Impl> m_impl;
1214

13-
using Callback = Function<void()>;
14-
1515
protected:
1616
MenuOption();
1717
~MenuOption();

src/ui/MenuOptionCategory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace horrible {
66
class MenuOptionCategory final : public cocos2d::CCMenu {
7+
using Callback = geode::Function<void(std::string_view, bool)>;
8+
79
private:
810
class Impl;
911
std::unique_ptr<Impl> m_impl;
1012

11-
using Callback = geode::Function<void(std::string_view, bool)>;
12-
1313
protected:
1414
MenuOptionCategory();
1515
~MenuOptionCategory();

src/util/ui/MathQuiz.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ using namespace geode::prelude;
77
namespace horrible {
88
namespace ui {
99
class MathQuiz final : public CCBlockLayer {
10-
private:
11-
class Impl;
12-
std::unique_ptr<Impl> m_impl;
10+
using Callback = Function<void(bool)>;
1311

1412
enum class MathOperation : unsigned int {
1513
Addition = 0,
@@ -18,7 +16,9 @@ namespace horrible {
1816
Geometry = 3
1917
};
2018

21-
using Callback = Function<void(bool)>;
19+
private:
20+
class Impl;
21+
std::unique_ptr<Impl> m_impl;
2222

2323
protected:
2424
MathQuiz();

src/util/ui/SpamChallenge.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
#include <Geode/Geode.hpp>
44

5-
using namespace geode::prelude;
6-
75
namespace horrible {
86
namespace ui {
97
class SpamChallenge final : public CCBlockLayer {
8+
using Callback = geode::Function<void(bool)>;
9+
1010
private:
1111
class Impl;
1212
std::unique_ptr<Impl> m_impl;
1313

14-
using Callback = Function<void(bool)>;
15-
1614
protected:
1715
SpamChallenge();
1816
~SpamChallenge();
@@ -27,7 +25,7 @@ namespace horrible {
2725
public:
2826
static SpamChallenge* create();
2927

30-
bool ccTouchBegan(CCTouch* touch, CCEvent* event) override;
28+
bool ccTouchBegan(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) override;
3129

3230
void setCallback(Callback&& cb) &;
3331
};

src/util/ui/TermsAndConditions.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
#include <Geode/Geode.hpp>
44

5-
using namespace geode::prelude;
6-
75
namespace horrible {
86
namespace ui {
9-
class TermsAndConditions final : public Popup {
10-
private:
11-
using Callback = CopyableFunction<void(bool)>;
7+
class TermsAndConditions final : public geode::Popup {
8+
using Callback = geode::CopyableFunction<void(bool)>;
129

1310
protected:
1411
bool init(Callback&& cb);

src/util/ui/WhackButton.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ using namespace geode::prelude;
77
namespace horrible {
88
namespace ui {
99
class WhackButton final : public CCNode {
10+
using Callback = Function<void(bool)>;
11+
1012
private:
1113
class Impl;
1214
std::unique_ptr<Impl> m_impl;
1315

14-
using Callback = Function<void(bool)>;
15-
1616
void reload();
1717

1818
protected:

src/util/ui/src/TermsAndConditions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bool TermsAndConditions::init(Callback&& cb) {
5252
"bigFont.fnt",
5353
themes::getButtonSquareSprite(theme)),
5454
[this, cb](auto) {
55-
cb(true);
55+
if (cb) cb(true);
5656
removeFromParent();
5757
});
5858
acceptButton->setScale(0.75f);
@@ -63,7 +63,7 @@ bool TermsAndConditions::init(Callback&& cb) {
6363
"goldFont.fnt",
6464
themes::getButtonSquareSprite(theme)),
6565
[this, cb](auto) {
66-
cb(false);
66+
if (cb) cb(false);
6767
removeFromParent();
6868
});
6969
declineButton->setScale(0.75f);

0 commit comments

Comments
 (0)