Skip to content

Commit a3f6806

Browse files
authored
Merge pull request #19 from Alphalaneous/fixes-and-improvements
Use Alpha's Geode Utils and make fixes and improvements
2 parents e157a9d + 4095a21 commit a3f6806

File tree

30 files changed

+171
-328
lines changed

30 files changed

+171
-328
lines changed

CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ endif()
2424

2525
include("cmake/CPM.cmake")
2626

27-
CPMAddPackage(
28-
NAME external-hook-api
29-
GIT_REPOSITORY https://github.com/OmgRod/External-Hook-API.git
30-
GIT_TAG master
31-
)
32-
target_link_libraries(${PROJECT_NAME} external-hook-api)
33-
3427
add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode)
3528

3629
setup_geode_mod(${PROJECT_NAME})

mod.json

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"geode": "4.2.0",
3-
"gd": {
4-
"android": "2.2074",
5-
"win": "2.2074",
2+
"geode": "4.2.0",
3+
"gd": {
4+
"android": "2.2074",
5+
"win": "2.2074",
66
"mac": "2.2074"
7-
},
8-
"version": "v2.0.0",
9-
"id": "omgrod.geodify",
10-
"name": "Geodify",
11-
"developers": ["OmgRod", "Viper"],
12-
"description": "Converts most menus' backgrounds to the Geode one (SwelvyBG).",
13-
"early-load": true,
14-
"resources": {
7+
},
8+
"version": "v2.0.0",
9+
"id": "omgrod.geodify",
10+
"name": "Geodify",
11+
"developers": ["OmgRod", "Viper"],
12+
"description": "Converts most menus' backgrounds to the Geode one (SwelvyBG).",
13+
"early-load": true,
14+
"resources": {
1515
"spritesheets": {
1616
"previewSheet": [
1717
"res/previews/*.png"
@@ -23,8 +23,8 @@
2323
"sprites": [
2424
"res/*.png"
2525
]
26-
},
27-
"settings": {
26+
},
27+
"settings": {
2828
"color-title": {
2929
"type": "title",
3030
"name": "Color Offset Settings"
@@ -355,19 +355,24 @@
355355
"type": "bool",
356356
"default": false
357357
}
358-
},
359-
"dependencies": [
360-
{
361-
"id": "geode.node-ids",
362-
"importance": "required",
363-
"version": ">=v1.12.0"
364-
},
365-
{
366-
"id": "alphalaneous.happy_textures",
367-
"importance": "recommended",
368-
"version": ">=1.3.18"
369-
}
370-
],
358+
},
359+
"dependencies": [
360+
{
361+
"id": "geode.node-ids",
362+
"importance": "required",
363+
"version": ">=v1.12.0"
364+
},
365+
{
366+
"id": "alphalaneous.happy_textures",
367+
"importance": "recommended",
368+
"version": ">=1.3.18"
369+
},
370+
{
371+
"id": "alphalaneous.alphas_geode_utils",
372+
"importance": "required",
373+
"version": ">=1.0.3"
374+
}
375+
],
371376
"incompatibilities": [
372377
{
373378
"id": "undefined0.icon_ninja",

src/SwelvyBG.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,8 @@ bool SwelvyBG::init(float widthmult, float hightmult, float minspeed, float maxs
3232
auto colorSetting = Mod::get()->getSettingValue<std::string>(settingKey);
3333

3434
if (!colorSetting.empty()) {
35-
unsigned int r, g, b;
36-
if (sscanf(colorSetting.c_str(), "%u,%u,%u", &r, &g, &b) == 3) {
37-
adjustedColor = {
38-
static_cast<GLubyte>(std::min(255u, r)),
39-
static_cast<GLubyte>(std::min(255u, g)),
40-
static_cast<GLubyte>(std::min(255u, b))
41-
};
42-
}
35+
auto res = cc3bFromHexString(colorSetting);
36+
if (res.isOk()) adjustedColor = res.unwrap();
4337
}
4438
}
4539

src/SwelvyBG.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@
44

55
using namespace geode::prelude;
66

7+
#define SET_SWELVY(layer, setting, backgroundID)\
8+
class $nodeModify(my##layer, layer) {\
9+
void modify() {\
10+
if (Mod::get()->getSettingValue<bool>(setting)) {\
11+
if (auto bg = getChildByID(backgroundID)) {\
12+
bg->setVisible(false);\
13+
SwelvyBG* swelvyBG = SwelvyBG::create();\
14+
swelvyBG->setZOrder(-999);\
15+
addChild(swelvyBG);\
16+
}\
17+
}\
18+
}\
19+
}
20+
21+
#define SET_SWELVY_SPRITE(layer, setting)\
22+
class $nodeModify(my##layer, layer) {\
23+
void modify() {\
24+
if (Mod::get()->getSettingValue<bool>(setting)) {\
25+
if (auto bg = getChildByType<CCSprite>(0)) {\
26+
bg->setVisible(false);\
27+
SwelvyBG* swelvyBG = SwelvyBG::create();\
28+
swelvyBG->setZOrder(-999);\
29+
addChild(swelvyBG);\
30+
}\
31+
}\
32+
}\
33+
}
34+
735
class SwelvyBG : public CCNode {
836
protected:
937
bool init(float widthmult, float heightmul, float minspeed, float maxspeed);

src/layers/GYModTile.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void GYModTile::viewMod(CCObject* sender) {
1212
GYModSettingsPopup::create(this->m_modName, this->m_modAuthor, this->m_modID)->show();
1313
}
1414

15-
GYModTile* GYModTile::create(const char *modName, const char *modAuthor, const char *modID) {
15+
GYModTile* GYModTile::create(std::string modName, std::string modAuthor, std::string modID) {
1616
GYModTile* ret = new GYModTile();
1717
if (ret && ret->init(modName, modAuthor, modID)) {
1818
ret->autorelease();
@@ -22,7 +22,7 @@ GYModTile* GYModTile::create(const char *modName, const char *modAuthor, const c
2222
return nullptr;
2323
}
2424

25-
bool GYModTile::init(const char *modName, const char *modAuthor, const char *modID) {
25+
bool GYModTile::init(std::string modName, std::string modAuthor, std::string modID) {
2626
if (!CCLayer::init())
2727
return false;
2828

@@ -42,7 +42,7 @@ bool GYModTile::init(const char *modName, const char *modAuthor, const char *mod
4242
bg->setAnchorPoint({ 0.f, 0.f});
4343
this->addChild(bg);
4444

45-
auto modNameText = CCLabelBMFont::create(modName, "bigFont.fnt");
45+
auto modNameText = CCLabelBMFont::create(modName.c_str(), "bigFont.fnt");
4646
modNameText->setPosition({ this->getContentSize().width / 2, this->getContentSize().height - winSize.height * 0.05f });
4747
modNameText->setScale(0.5f);
4848
bg->addChild(modNameText);

src/layers/GYModTile.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ using namespace geode::prelude;
77
class GYModTile : public CCLayer {
88
public:
99
void viewMod(CCObject* sender);
10-
static GYModTile* create(const char *modName, const char *modAuthor, const char *modID);
11-
bool init(const char *modName, const char *modAuthor, const char *modID);
10+
static GYModTile* create(std::string modName, std::string modAuthor, std::string modID);
11+
bool init(std::string modName, std::string modAuthor, std::string modID);
1212

1313
std::string m_modID;
1414
std::string m_modName;
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
#include <Geode/Geode.hpp>
22
#include "../../SwelvyBG.hpp"
3-
#include <HookClass.hpp>
3+
#include <alphalaneous.alphas_geode_utils/include/NodeModding.h>
4+
45
using namespace geode::prelude;
56

6-
HookClass_Scene(cvolton_betterinfo_CustomCreatorLayer,"cvolton.betterinfo/CustomCreatorLayer") {
7-
if (Mod::get()->getSettingValue<bool>("cvolton.betterinfo/CustomCreatorLayer")) {
8-
if (auto bg = _This->getChildByID("cvolton.betterinfo/background")) {
9-
bg->setVisible(false);
10-
SwelvyBG* swelvyBG = SwelvyBG::create();
11-
swelvyBG->setZOrder(-1);
12-
13-
_This->addChild(swelvyBG);
14-
}
15-
}
16-
}
7+
SET_SWELVY(CustomCreatorLayer, "cvolton.betterinfo/CustomCreatorLayer", "cvolton.betterinfo/background");
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
#include <Geode/Geode.hpp>
22
#include "../../SwelvyBG.hpp"
3-
#include <HookClass.hpp>
3+
#include <alphalaneous.alphas_geode_utils/include/NodeModding.h>
4+
45
using namespace geode::prelude;
5-
HookClass(DailyViewLayer) {
6-
if (Mod::get()->getSettingValue<bool>("cvolton.betterinfo/DailyViewLayer")) {
7-
if (auto bg = this->getChildByID("cvolton.betterinfo/background")) {
8-
bg->setVisible(false);
9-
}
10-
SwelvyBG* swelvyBG = SwelvyBG::create();
11-
swelvyBG->setZOrder(-1);
12-
13-
this->addChild(swelvyBG);
14-
}
15-
}
6+
7+
SET_SWELVY(DailyViewLayer, "cvolton.betterinfo/DailyViewLayer", "cvolton.betterinfo/background");
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
#include <Geode/Geode.hpp>
22
#include "../../SwelvyBG.hpp"
3-
#include <HookClass.hpp>
3+
#include <alphalaneous.alphas_geode_utils/include/NodeModding.h>
44

55
using namespace geode::prelude;
6-
HookClass_Scene(cvolton_betterinfo_LevelSearchViewLayer,"cvolton.betterinfo/LevelSearchViewLayer") {
7-
if (Mod::get()->getSettingValue<bool>("cvolton.betterinfo/LevelSearchViewLayer")) {
8-
if (auto bg = _This->getChildByID("cvolton.betterinfo/background")) {
9-
bg->setVisible(false);
10-
}
11-
SwelvyBG* swelvyBG = SwelvyBG::create();
12-
swelvyBG->setZOrder(-1);
13-
14-
_This->addChild(swelvyBG);
15-
}
16-
}
6+
7+
SET_SWELVY(LevelSearchViewLayer, "cvolton.betterinfo/LevelSearchViewLayer", "cvolton.betterinfo/background");
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
#include <Geode/Geode.hpp>
22
#include "../../SwelvyBG.hpp"
3-
#include <HookClass.hpp>
3+
#include <alphalaneous.alphas_geode_utils/include/NodeModding.h>
4+
45
using namespace geode::prelude;
5-
HookClass(RewardGroupLayer) {
6-
if (Mod::get()->getSettingValue<bool>("cvolton.betterinfo/RewardGroupLayer")) {
7-
if (auto bg = this->getChildByID("cvolton.betterinfo/background")) {
8-
bg->setVisible(false);
9-
}
10-
SwelvyBG* swelvyBG = SwelvyBG::create();
11-
swelvyBG->setZOrder(-1);
12-
13-
this->addChild(swelvyBG);
14-
}
15-
}
6+
7+
SET_SWELVY(RewardGroupLayer, "cvolton.betterinfo/RewardGroupLayer", "cvolton.betterinfo/background");

0 commit comments

Comments
 (0)