Skip to content

Commit 8c6a482

Browse files
committed
fixes + betterinfo LevelSearchViewLayer
1 parent 7a847dc commit 8c6a482

File tree

4 files changed

+79
-40
lines changed

4 files changed

+79
-40
lines changed

src/modify/EditLevelLayer.cpp

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,39 @@
55
using namespace geode::prelude;
66

77
class $modify(MyEditLevelLayer, EditLevelLayer) {
8-
bool init(GJGameLevel* p0) {
9-
if (!EditLevelLayer::init(p0)) {
10-
return false;
11-
}
12-
if (Mod::get()->getSettingValue<bool>("show-edit-level")){
13-
if (auto bg = this->getChildByID("background")){
14-
bg->setVisible(false);
15-
}
8+
bool init(GJGameLevel* p0) {
9+
if (!EditLevelLayer::init(p0)) {
10+
return false;
11+
}
12+
if (Mod::get()->getSettingValue<bool>("show-edit-level")) {
13+
// Hide the existing background
14+
if (auto bg = this->getChildByID("background")) {
15+
bg->setVisible(false);
16+
}
1617

17-
CCScale9Sprite* levelNameBG = dynamic_cast<CCScale9Sprite*>(this->getChildByID("level-name-background"));
18-
if (levelNameBG) {
19-
levelNameBG->setColor(ccColor3B(0, 0, 0));
20-
levelNameBG->setOpacity(60);
21-
} else {
22-
log::debug("Failed to cast level-name-background to CCSprite");
23-
}
18+
// Adjust level name background
19+
if (auto levelNameBG = static_cast<CCScale9Sprite*>(this->getChildByID("level-name-background"))) {
20+
levelNameBG->setColor(ccColor3B(0, 0, 0));
21+
levelNameBG->setOpacity(60);
22+
} else {
23+
log::debug("level-name-background not found or wrong type");
24+
}
2425

25-
CCScale9Sprite* descriptionBG = dynamic_cast<CCScale9Sprite*>(this->getChildByID("description-background"));
26-
if (descriptionBG) {
27-
descriptionBG->setColor(ccColor3B(0, 0, 0));
28-
descriptionBG->setOpacity(60);
29-
} else {
30-
log::debug("Failed to cast description-background to CCSprite");
31-
}
26+
// Adjust description background
27+
if (auto descriptionBG = static_cast<CCScale9Sprite*>(this->getChildByID("description-background"))) {
28+
descriptionBG->setColor(ccColor3B(0, 0, 0));
29+
descriptionBG->setOpacity(60);
30+
} else {
31+
log::debug("description-background not found or wrong type");
32+
}
3233

33-
auto swelvyBG = SwelvyBG::create();
34-
swelvyBG->setZOrder(-2);
35-
swelvyBG->setID("swelvy-background");
34+
// Add SwelvyBG
35+
auto swelvyBG = SwelvyBG::create();
36+
swelvyBG->setZOrder(-2);
37+
swelvyBG->setID("swelvy-background");
3638

37-
this->addChild(swelvyBG);
38-
}
39-
return true;
40-
}
41-
};
39+
this->addChild(swelvyBG);
40+
}
41+
return true;
42+
}
43+
};

src/modify/cvolton.betterinfo/CustomCreatorLayer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ class CustomCreatorLayer : public Betterhook::HookBetter {
55
void init(CCNode* _This) override {
66
if (auto bg = _This->getChildByID("cvolton.betterinfo/background")) {
77
bg->setVisible(false);
8-
SwelvyBG* swelvyBG = SwelvyBG::create();
9-
swelvyBG->setZOrder(-1);
10-
swelvyBG->setID("swelvy-background");
11-
_This->addChild(swelvyBG);
8+
SwelvyBG* swelvyBG = SwelvyBG::create();
9+
swelvyBG->setZOrder(-1);
10+
swelvyBG->setID("swelvy-background");
11+
_This->addChild(swelvyBG);
1212
}
1313
}
1414

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <Geode/Geode.hpp>
2+
#include "../../SwelvyBG.hpp"
3+
#include "../../Hooks/Hooker.hpp"
4+
class LevelSearchViewLayer : public Betterhook::HookBetter {
5+
void init(CCNode* _This) override {
6+
if (auto bg = _This->getChildByID("cvolton.betterinfo/background")) {
7+
bg->setVisible(false);
8+
}
9+
SwelvyBG* swelvyBG = SwelvyBG::create();
10+
swelvyBG->setZOrder(-1);
11+
swelvyBG->setID("swelvy-background");
12+
_This->addChild(swelvyBG);
13+
}
14+
15+
const char* PutLayer() const override { return "LevelSearchViewLayer"; }
16+
};
17+
18+
19+
REGISTER_HookBetter(LevelSearchViewLayer);
20+

src/modify/geode.texture-loader/PackSelectLayer.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#include <Geode/Geode.hpp>
22
#include "../../SwelvyBG.hpp"
3-
#include "../../Hooks/Hooker.hpp"
4-
class PackSelectLayer : public Betterhook::HookBetter {
3+
#include "../../Hooks/Hooker.hpp"
4+
5+
class PackSelectLayer : public Betterhook::HookBetter {
6+
public:
57
void init(CCNode* _This) override {
6-
if (auto bg = _This->getChildByID("background")) {
8+
if (auto bg = _This->getChildByID("background")) {
79
bg->setVisible(false);
810
}
911

@@ -13,9 +15,24 @@ class PackSelectLayer : public Betterhook::HookBetter {
1315
_This->addChild(swelvyBG);
1416
}
1517

16-
const char* PutLayer() const override { return "PackSelectLayer"; }
17-
};
18+
void onApply(CCObject* sender) {
19+
if (auto _This = dynamic_cast<CCNode*>(sender)) {
20+
if (auto bg = _This->getChildByID("background")) {
21+
bg->setVisible(false);
22+
}
23+
24+
SwelvyBG* swelvyBG = SwelvyBG::create();
25+
swelvyBG->setZOrder(-1);
26+
swelvyBG->setID("swelvy-background");
27+
_This->addChild(swelvyBG);
28+
} else {
29+
log::debug("Failed to apply SwelvyBG: sender is not a CCNode.");
30+
}
31+
}
1832

33+
const char* PutLayer() const override {
34+
return "PackSelectLayer";
35+
}
36+
};
1937

2038
REGISTER_HookBetter(PackSelectLayer);
21-

0 commit comments

Comments
 (0)