Skip to content

Commit 62cfa37

Browse files
committed
tweaks
1 parent bfe930f commit 62cfa37

10 files changed

Lines changed: 46 additions & 60 deletions

File tree

src/hooks/Freeze.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class $modify(FreezeMenuLayer, MenuLayer) {
2323
bool init() {
2424
if (!MenuLayer::init()) return false;
2525

26-
if (auto gm = GameManager::get()) {
26+
if (auto gm = GameManager::sharedState()) {
2727
// get and store user current fps
2828
float currentFPS = gm->m_customFPSTarget;
2929
(void)thisMod->setSavedValue<float>("fps", currentFPS);
@@ -60,7 +60,7 @@ class $modify(FreezePlayLayer, PlayLayer) {
6060

6161
void revertFPS() {
6262
// default to user old fps
63-
auto gm = GameManager::get();
63+
auto gm = GameManager::sharedState();
6464

6565
float oldFPS = thisMod->getSavedValue<float>("fps");
6666

@@ -75,7 +75,7 @@ class $modify(FreezePlayLayer, PlayLayer) {
7575
};
7676

7777
void capFPS(float value) {
78-
auto gm = GameManager::get();
78+
auto gm = GameManager::sharedState();
7979

8080
gm->setGameVariable("0116", true);
8181
gm->setGameVariable("0116", true);
@@ -95,7 +95,7 @@ class $modify(FreezePlayLayer, PlayLayer) {
9595
void updateProgressbar() {
9696
// check if current percentage is less than or equal to 90
9797
if (getCurrentPercentInt() >= 90) {
98-
auto gm = GameManager::get();
98+
auto gm = GameManager::sharedState();
9999

100100
gm->setGameVariable("0116", true);
101101

@@ -110,7 +110,7 @@ class $modify(FreezePlayLayer, PlayLayer) {
110110
// log::debug("cap fps to {} (interval {})", rndFps, interval);
111111
} else {
112112
// default to user old fps
113-
auto gm = GameManager::get();
113+
auto gm = GameManager::sharedState();
114114

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

src/ui/Menu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <Geode/Geode.hpp>
66

77
namespace horrible {
8-
class MenuNothingNode final : public CCNode {
8+
class MenuNothingNode final : public cocos2d::CCNode {
99
protected:
1010
bool init(cocos2d::CCSize const& size, cocos2d::CCPoint const& pos);
1111

src/ui/SettingV3.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ namespace horrible {
2424

2525
class HorribleSettingNodeV3 final : public geode::SettingNodeV3 {
2626
private:
27-
class Impl;
28-
std::unique_ptr<Impl> m_impl;
27+
CCMenuItemSpriteExtra* m_button = nullptr;
2928

3029
protected:
31-
HorribleSettingNodeV3();
32-
~HorribleSettingNodeV3();
33-
3430
void updateState(cocos2d::CCNode* invoker) override;
3531
void onCommit() override;
3632
void onResetToDefault() override;

src/ui/src/MenuCredits.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,17 @@ bool MenuPlayer::init(ZStringView name, int account, int icon, ccColor3B const&
2424

2525
addChild(playerIcon);
2626

27-
auto label = CCLabelBMFont::create(name.c_str(), "goldFont.fnt");
28-
label->setScale(0.375f);
29-
30-
if (label->getScaledContentWidth() > getScaledContentWidth()) setContentWidth(label->getScaledContentWidth());
31-
32-
auto labelBtn = Button::createWithNode(
33-
label,
27+
auto labelBtn = Button::createWithLabel(
28+
name.c_str(),
29+
"goldFont.fnt",
3430
[account](auto) {
3531
if (auto page = ProfilePage::create(account, false)) page->show();
3632
});
3733
labelBtn->setID("profile-btn");
38-
labelBtn->setPosition({getScaledContentWidth() / 2.f, getScaledContentHeight() + (label->getScaledContentHeight() * 0.875f)});
34+
labelBtn->setScale(0.375f);
35+
labelBtn->setPosition({getScaledContentWidth() / 2.f, getScaledContentHeight() + (labelBtn->getScaledContentHeight() * 0.875f)});
36+
37+
if (labelBtn->getScaledContentWidth() > getScaledContentWidth()) setContentWidth(labelBtn->getScaledContentWidth());
3938

4039
playerIcon->setPositionX(getScaledContentWidth() / 2.f);
4140

@@ -118,17 +117,14 @@ bool MenuCredits::init(ZStringView theme) {
118117
m_mainLayer->addChild(leadDevContainer);
119118
leadDevContainer->updateLayout();
120119

121-
constexpr auto creditsMdTxt =
120+
auto creditsMd = MDTextArea::create(
122121
"# ![🛠](frame:GJ_hammerIcon_001.png?scale=0.875) Resources\n"
123122
"**[alk1m123](user:11535118)**: '*[Sapphire SDK](https://www.x.com/GeodeSDK/status/2039225279353176398/)*' logo\n\n"
124123
"**[Uproxide](user:25397826)**: '*The Yellow One*' sprite from [More Difficulties](mod:uproxide.more_difficulties)\n\n<mod:uproxide.more_difficulties>\n\n"
125124
"**[Cheeseworks](user:6408873)**: [Mod Developer Branding](mod:cheeseworks.moddevbranding) image for this mod\n\n<mod:cheeseworks.moddevbranding>\n\n"
126125
"# ![💝](frame:GJ_diamondsIcon_001.png?scale=0.875) Special Thanks\n"
127126
"**[Team Avalanche](user:31079132)**: Supporting the project since its experimental days\n\n"
128-
"**[dankmeme](user:9735891)**: helped with pretty important programming decisions :D\n\n";
129-
130-
auto creditsMd = MDTextArea::create(
131-
creditsMdTxt,
127+
"**[dankmeme](user:9735891)**: helped with pretty important programming decisions :D\n\n",
132128
{m_mainLayer->getScaledContentWidth() - 55.f,
133129
140.f});
134130
creditsMd->setID("credits");

src/ui/src/MenuOption.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MenuOption::Impl final {
4949
if (auto label = WeakRef(newContainer).lock()) label->setVisible(false);
5050
};
5151

52-
constexpr const char* getTierDescString(SillyTier silly, bool compat) noexcept {
52+
constexpr auto getTierDescString(SillyTier silly, bool compat) noexcept {
5353
if (!compat) return "<cp>OPTION UNAVAILABLE</c>";
5454

5555
switch (silly) {

src/ui/src/SettingV3.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ SettingNodeV3* HorribleSettingV3::createNode(float width) {
4040
return HorribleSettingNodeV3::create(std::static_pointer_cast<HorribleSettingV3>(shared_from_this()), width);
4141
};
4242

43-
class HorribleSettingNodeV3::Impl final {
44-
public:
45-
CCMenuItemSpriteExtra* button = nullptr;
46-
};
47-
48-
HorribleSettingNodeV3::HorribleSettingNodeV3() : m_impl(std::make_unique<Impl>()) {};
49-
HorribleSettingNodeV3::~HorribleSettingNodeV3() {};
50-
5143
bool HorribleSettingNodeV3::init(std::shared_ptr<HorribleSettingV3> setting, float width) {
5244
if (!SettingNodeV3::init(setting, width)) return false;
5345

@@ -58,17 +50,19 @@ bool HorribleSettingNodeV3::init(std::shared_ptr<HorribleSettingV3> setting, flo
5850
0.875f);
5951
buttonSprite->setScale(0.5f);
6052

61-
m_impl->button = CCMenuItemExt::createSpriteExtra(
53+
m_button = CCMenuItemExt::createSpriteExtra(
6254
buttonSprite,
63-
[](auto) { menu::open(); });
64-
m_impl->button->setID("horrible-options-btn");
55+
[](auto) {
56+
menu::open();
57+
});
58+
m_button->setID("horrible-options-btn");
6559

6660
if (auto menu = getButtonMenu()) {
6761
menu->setAnchorPoint({0.5, 0.5});
6862
menu->setPosition(getScaledContentSize() / 2.f);
6963
menu->setContentSize({getScaledContentWidth(), 0.f});
7064

71-
menu->addChildAtPosition(m_impl->button, Anchor::Center);
65+
menu->addChildAtPosition(m_button, Anchor::Center);
7266
menu->updateLayout();
7367
} else {
7468
log::error("Couldn't find button menu in settings");
@@ -79,16 +73,16 @@ bool HorribleSettingNodeV3::init(std::shared_ptr<HorribleSettingV3> setting, flo
7973
[this](std::shared_ptr<SettingV3> setting) {
8074
auto strSetting = std::static_pointer_cast<StringSettingV3>(setting);
8175

82-
if (m_impl->button) {
76+
if (m_button) {
8377
auto buttonSprite = ButtonSprite::create(
8478
"Horrible Options Menu",
8579
"bigFont.fnt",
8680
themes::getButtonSquareSprite(strSetting->getValue()),
8781
0.875f);
8882
buttonSprite->setScale(0.5f);
8983

90-
m_impl->button->setNormalImage(buttonSprite);
91-
m_impl->button->updateSprite();
84+
m_button->setNormalImage(buttonSprite);
85+
m_button->updateSprite();
9286
} else {
9387
log::error("Setting button not found");
9488
};

src/util/Jumpscares.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace horrible {
66
namespace util {
77
// Jumpscare level manager
88
namespace jumpscares {
9-
class JumpscareDelegateBase {
9+
class JumpscareDelegateData {
1010
private:
1111
geode::WeakRef<PlayLayer> m_playLayer = nullptr;
1212

@@ -18,8 +18,8 @@ namespace horrible {
1818
bool m_useReplay = false;
1919

2020
protected:
21-
explicit JumpscareDelegateBase(PlayLayer* pl, int levelID, int songID, std::string levelName, bool dontCreateObjects, bool useReplay);
22-
virtual ~JumpscareDelegateBase() = default;
21+
explicit JumpscareDelegateData(PlayLayer* pl, int levelID, int songID, std::string levelName, bool dontCreateObjects, bool useReplay);
22+
virtual ~JumpscareDelegateData() = default;
2323

2424
public:
2525
geode::WeakRef<PlayLayer> const& getPlayLayer() const noexcept;
@@ -32,15 +32,15 @@ namespace horrible {
3232
bool getUseReplay() const noexcept;
3333
};
3434

35-
struct SearchDelegate final : public LevelManagerDelegate, public JumpscareDelegateBase {
35+
struct SearchDelegate final : public LevelManagerDelegate, public JumpscareDelegateData {
3636
public:
3737
SearchDelegate(PlayLayer* pl, int levelID, int songID, std::string levelName, bool dontCreateObjects, bool useReplay);
3838

3939
void loadLevelsFinished(cocos2d::CCArray* levels, char const* key) override;
4040
void loadLevelsFailed(char const* key) override;
4141
};
4242

43-
struct DownloadDelegate final : public LevelDownloadDelegate, public JumpscareDelegateBase {
43+
struct DownloadDelegate final : public LevelDownloadDelegate, public JumpscareDelegateData {
4444
public:
4545
DownloadDelegate(PlayLayer* pl, int levelID, int songID, std::string levelName, bool dontCreateObjects, bool useReplay);
4646

src/util/src/Jumpscares.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@
77
using namespace geode::prelude;
88
using namespace horrible::util;
99

10-
jumpscares::JumpscareDelegateBase::JumpscareDelegateBase(PlayLayer* pl, int levelID, int songID, std::string levelName, bool dontCreateObjects, bool useReplay) :
10+
jumpscares::JumpscareDelegateData::JumpscareDelegateData(PlayLayer* pl, int levelID, int songID, std::string levelName, bool dontCreateObjects, bool useReplay) :
1111
m_playLayer(pl), m_levelID(levelID), m_songID(songID), m_levelName(std::move(levelName)), m_dontCreateObjects(dontCreateObjects), m_useReplay(useReplay) {};
1212

13-
WeakRef<PlayLayer> const& jumpscares::JumpscareDelegateBase::getPlayLayer() const noexcept {
13+
WeakRef<PlayLayer> const& jumpscares::JumpscareDelegateData::getPlayLayer() const noexcept {
1414
return m_playLayer;
1515
};
1616

17-
int jumpscares::JumpscareDelegateBase::getLevelID() const noexcept {
17+
int jumpscares::JumpscareDelegateData::getLevelID() const noexcept {
1818
return m_levelID;
1919
};
2020

21-
int jumpscares::JumpscareDelegateBase::getSongID() const noexcept {
21+
int jumpscares::JumpscareDelegateData::getSongID() const noexcept {
2222
return m_songID;
2323
};
2424

25-
ZStringView jumpscares::JumpscareDelegateBase::getLevelName() const noexcept {
25+
ZStringView jumpscares::JumpscareDelegateData::getLevelName() const noexcept {
2626
return m_levelName;
2727
};
2828

29-
bool jumpscares::JumpscareDelegateBase::getDontCreateObjects() const noexcept {
29+
bool jumpscares::JumpscareDelegateData::getDontCreateObjects() const noexcept {
3030
return m_dontCreateObjects;
3131
};
3232

33-
bool jumpscares::JumpscareDelegateBase::getUseReplay() const noexcept {
33+
bool jumpscares::JumpscareDelegateData::getUseReplay() const noexcept {
3434
return m_useReplay;
3535
};
3636

3737
jumpscares::DownloadDelegate::DownloadDelegate(PlayLayer* pl, int levelID, int songID, std::string levelName, bool dontCreateObjects, bool useReplay) :
38-
JumpscareDelegateBase(pl, levelID, songID, std::move(levelName), dontCreateObjects, useReplay) {};
38+
JumpscareDelegateData(pl, levelID, songID, std::move(levelName), dontCreateObjects, useReplay) {};
3939

4040
void jumpscares::DownloadDelegate::levelDownloadFinished(GJGameLevel* level) {
4141
log::trace("Download finished for level {}", getLevelID());
@@ -74,7 +74,7 @@ void jumpscares::DownloadDelegate::levelDownloadFailed(int response) {
7474
};
7575

7676
jumpscares::SearchDelegate::SearchDelegate(PlayLayer* pl, int levelID, int songID, std::string levelName, bool dontCreateObjects, bool useReplay) :
77-
JumpscareDelegateBase(pl, levelID, songID, std::move(levelName), dontCreateObjects, useReplay) {};
77+
JumpscareDelegateData(pl, levelID, songID, std::move(levelName), dontCreateObjects, useReplay) {};
7878

7979
void jumpscares::SearchDelegate::loadLevelsFinished(CCArray* levels, char const* key) {
8080
log::trace("Search finished for level {}", getLevelName());

src/util/ui/TermsAndConditions.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ namespace horrible {
88
namespace ui {
99
class TermsAndConditions final : public Popup {
1010
private:
11-
using Callback = FunctionRef<void(bool)>;
11+
using Callback = CopyableFunction<void(bool)>;
1212

1313
protected:
14-
bool init(Callback cb);
14+
bool init(Callback&& cb);
1515

1616
public:
17-
static TermsAndConditions* create(Callback cb);
17+
static TermsAndConditions* create(Callback&& cb);
1818
};
1919
};
2020
};

src/util/ui/src/TermsAndConditions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using namespace geode::prelude;
88
using namespace horrible::prelude;
99

10-
bool TermsAndConditions::init(Callback cb) {
10+
bool TermsAndConditions::init(Callback&& cb) {
1111
auto const theme = thisMod->getSettingValue<std::string>("theme");
1212

1313
if (!Popup::init(420.f, 240.f, themes::getBackgroundSprite(theme))) return false;
@@ -74,9 +74,9 @@ bool TermsAndConditions::init(Callback cb) {
7474
return true;
7575
};
7676

77-
TermsAndConditions* TermsAndConditions::create(Callback cb) {
77+
TermsAndConditions* TermsAndConditions::create(Callback&& cb) {
7878
auto ret = new TermsAndConditions();
79-
if (ret && ret->init(cb)) {
79+
if (ret && ret->init(std::move(cb))) {
8080
ret->autorelease();
8181
return ret;
8282
};

0 commit comments

Comments
 (0)