Skip to content

Commit

Permalink
Many changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphalaneous committed Dec 24, 2024
1 parent 81b95ab commit 115944a
Show file tree
Hide file tree
Showing 30 changed files with 90 additions and 65 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.7.8
- list-cell-selected added to hardcoded color modifications for leaderboards
- changed hook prio logic
- Mac support for everything

## 1.7.7
- Zipped packs should work properly now
- Fixed issues with file listener
Expand Down
8 changes: 3 additions & 5 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"android": "2.2074",
"mac": "2.2074"
},
"version": "v1.7.7",
"version": "v1.7.8",
"id": "alphalaneous.happy_textures",
"name": "Happy Textures :3",
"developer": "Alphalaneous",
Expand Down Expand Up @@ -37,15 +37,13 @@
"name": "CCScale9Sprite Fix",
"description": "Fix sprite overlapping when you have transparent CCScale9Sprites (Such as on the level search page).",
"type": "bool",
"default": true,
"platforms": ["win", "android"]
"default": true
},
"pusab-fix": {
"name": "Pusab Fix",
"description": "Makes changing pusab in texture packs not affect the font within levels.",
"type": "bool",
"default": true,
"platforms": ["win", "android"]
"default": true
},
"comment-border-fix": {
"name": "Comment Border Fix",
Expand Down
6 changes: 3 additions & 3 deletions src/BackgroundColors.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void setBackground(CCNode* node) {
class $modify(CCDirector) {

static void onModify(auto& self) {
(void) self.setHookPriority("CCDirector::willSwitchToScene", INT_MIN);
HOOK_LATEST("cocos2d::CCDirector::willSwitchToScene");
}

void willSwitchToScene(CCScene* scene) {
Expand All @@ -33,7 +33,7 @@ class $modify(CCDirector) {
class $modify(LeaderboardsLayer) {

static void onModify(auto& self) {
(void) self.setHookPriority("LeaderboardsLayer::init", INT_MIN);
HOOK_LATEST("LeaderboardsLayer::init");
}

bool init(LeaderboardState p0) {
Expand All @@ -46,7 +46,7 @@ class $modify(LeaderboardsLayer) {
class $modify(LevelBrowserLayer) {

static void onModify(auto& self) {
(void) self.setHookPriority("LevelBrowserLayer::init", INT_MIN);
HOOK_LATEST("LevelBrowserLayer::init");
}

bool init(GJSearchObject* p0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Callbacks* Callbacks::instance = nullptr;

//do cursed UB stuff to simplify the code
//do cursed UB stuff, currently unused but may be useful in the future

template <typename T>
FakeNodeLayer<T> Callbacks::createUBDummyLayer() {
Expand Down
16 changes: 14 additions & 2 deletions src/Macros.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#define HOOK_LATEST(method) queueInMainThread([&self] {\
(void) self.setHookPriorityAfterPost(method, Utils::getHookPrioLatest(method));\
});

#define public_cast(value, member) [](auto* v) { \
class FriendClass__; \
using T = std::remove_pointer<decltype(v)>::type; \
Expand Down Expand Up @@ -73,7 +77,7 @@ if (eventVal.contains(#type)) {\
#define setCellColors(class, method, paramType) \
struct My##class : geode::Modify<My##class, class> { \
static void onModify(auto& self) {\
(void) self.setHookPriority(#class "::" #method, INT_MIN);\
HOOK_LATEST(#class "::" #method);\
}\
struct Fields {\
ccColor3B m_lastBG;\
Expand Down Expand Up @@ -105,6 +109,14 @@ struct My##class : geode::Modify<My##class, class> { \
child->setColor(data.color);\
child->setOpacity(data.alpha);\
}\
}\
else if (child->getColor() == ccColor3B{230,150,10}) {\
std::optional<ColorData> dataOpt = UIModding::get()->getColors("list-cell-selected");\
if (dataOpt.has_value()) {\
ColorData data = dataOpt.value();\
child->setColor(data.color);\
child->setOpacity(data.alpha);\
}\
}\
}\
}\
Expand All @@ -125,4 +137,4 @@ m_callbacks[#clazz] = callbacks
std::map<std::string, std::pair<CCNode*, cocos2d::SEL_MenuHandler>> callbacks; \
m_callbacks[#clazz] = callbacks

#define REGISTER_CALLBACK(clazz, method) m_callbacks[#clazz][#method] = std::pair<CCNode*, cocos2d::SEL_MenuHandler>(self, menu_selector(clazz::method))
#define REGISTER_CALLBACK(clazz, method) m_callbacks[#clazz][#method] = std::pair<CCNode*, cocos2d::SEL_MenuHandler>(self, menu_selector(clazz::method))
2 changes: 1 addition & 1 deletion src/NodeModding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace geode::prelude;
class $modify(MyCCObject, CCObject) {

static void onModify(auto& self) {
(void) self.setHookPriority("CCObject::autorelease", INT_MIN - 1);
HOOK_LATEST("cocos2d::CCObject::autorelease");
}

CCObject* autorelease() {
Expand Down
12 changes: 0 additions & 12 deletions src/UIModding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ void UIModding::recursiveModify(CCNode* node, matjson::Value elements) {

void UIModding::runAction(CCNode* node, matjson::Value attributes) {

#ifndef GEODE_IS_MACOS

if (attributes.contains("actions")) {
matjson::Value actionsValue = attributes["actions"];
if (actionsValue.isArray()) {
Expand All @@ -141,7 +139,6 @@ void UIModding::runAction(CCNode* node, matjson::Value attributes) {
}
}
}
#endif
}

void UIModding::runScrollToTop(CCNode* node, matjson::Value attributes) {
Expand Down Expand Up @@ -190,8 +187,6 @@ void UIModding::runCallback(CCNode* node, matjson::Value attributes) {
CCActionInterval* UIModding::createAction(CCNode* node, matjson::Value action) {
CCActionInterval* retAction = nullptr;

#ifndef GEODE_IS_MACOS

if (action.contains("type")) {

bool repeat = false;
Expand Down Expand Up @@ -327,7 +322,6 @@ CCActionInterval* UIModding::createAction(CCNode* node, matjson::Value action) {
}
}
}
#endif
return retAction;
}

Expand All @@ -339,8 +333,6 @@ CCActionInterval* UIModding::getEasingType(std::string name, CCActionInterval* a
easingType = action;
}

#ifndef GEODE_IS_MACOS

typeForEaseCC(EaseInOut);
typeForEaseCC(EaseIn);
typeForEaseCC(EaseOut);
Expand All @@ -360,8 +352,6 @@ CCActionInterval* UIModding::getEasingType(std::string name, CCActionInterval* a
typeForEase(BackIn);
typeForEase(BackOut);

#endif

return easingType;
}

Expand Down Expand Up @@ -1285,9 +1275,7 @@ void UIModding::handleModifications(CCNode* node, matjson::Value nodeObject) {
nodesFor(updateLayout);
nodesFor(runScrollToTop);
nodesFor(setLocked);
#ifndef GEODE_IS_MACOS
nodesFor(runAction);
#endif
nodesFor(playSound);
nodesFor(openLink);
nodesFor(runCallback);
Expand Down
19 changes: 19 additions & 0 deletions src/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,25 @@ namespace Utils {
return "";
}

static std::string getHookPrioLatest(const std::string& name) {
int minPriority = INT_MAX - 1;
const Mod* currentMod = Mod::get();
std::string latestModID = currentMod->getID();

for (const auto* mod : Loader::get()->getAllMods()) {
if (mod == currentMod) continue;

for (const auto* hook : mod->getHooks()) {
if (hook->getDisplayName() == name && hook->getPriority() < minPriority) {
minPriority = hook->getPriority();
latestModID = mod->getID();
}
}
}

return latestModID;
}

static int getRandomNumber(int lower, int upper) {
if (lower > upper) {
std::swap(lower, upper);
Expand Down
6 changes: 1 addition & 5 deletions src/fixes/FontFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

using namespace geode::prelude;

#ifndef GEODE_IS_MACOS

bool s_isInCreateTextLayers = false;

class $modify(GJBaseGameLayer) {
Expand Down Expand Up @@ -67,6 +65,4 @@ class $modify(CCTextureCache) {
}
return ret;
}
};

#endif
};
14 changes: 6 additions & 8 deletions src/nodes/CCLabelBMFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ using namespace geode::prelude;

class $modify(MyCCLabelBMFont, CCLabelBMFont) {

static void onModify(auto& self) {
HOOK_LATEST("cocos2d::CCLabelBMFont::setString");
HOOK_LATEST("cocos2d::CCLabelBMFont::limitLabelWidth");
HOOK_LATEST("cocos2d::CCLabelBMFont::create");
}

struct Fields {
float m_limitWidth = 1;
float m_limitDefaultScale = 1;
Expand Down Expand Up @@ -61,22 +67,16 @@ class $modify(MyCCLabelBMFont, CCLabelBMFont) {

auto myRet = static_cast<MyCCLabelBMFont*>(ret);

#ifndef GEODE_IS_MACOS

bool doFix = Mod::get()->getSettingValue<bool>("pusab-fix");

if (doFix) {
myRet->m_fields->m_schedule = schedule_selector(MyCCLabelBMFont::checkParent);
ret->schedule(myRet->m_fields->m_schedule);
}

#endif

return ret;
}

#ifndef GEODE_IS_MACOS

void checkParent(float dt) {

if (auto parent = this->getParent()) {
Expand All @@ -90,6 +90,4 @@ class $modify(MyCCLabelBMFont, CCLabelBMFont) {
this->unschedule(m_fields->m_schedule);
}
}

#endif
};
8 changes: 2 additions & 6 deletions src/nodes/CCMenu.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#ifndef GEODE_IS_MACOS

#include <Geode/Geode.hpp>
#include <Geode/modify/CCMenu.hpp>
#include "CCMenuItemSpriteExtra.h"
Expand All @@ -17,7 +15,7 @@ class EventsPush : CCNode {};
class $modify(EventCCMenu, CCMenu) {

static void onModify(auto& self) {
(void) self.setHookPriority("CCMenu::initWithArray", INT_MAX);
HOOK_LATEST("cocos2d::CCMenu::initWithArray");
}

struct Fields {
Expand Down Expand Up @@ -91,6 +89,4 @@ class $modify(EventCCMenu, CCMenu) {
m_fields->canExit = false;
}
}
};

#endif
};
6 changes: 3 additions & 3 deletions src/nodes/CCMenuItemSpriteExtra.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ using namespace geode::prelude;
class $modify(EventCCMenuItemSpriteExtra, CCMenuItemSpriteExtra) {

static void onModify(auto& self) {
(void) self.setHookPriority("CCMenuItemSpriteExtra::selected", INT_MAX-1);
(void) self.setHookPriority("CCMenuItemSpriteExtra::unselected", INT_MAX-1);
(void) self.setHookPriority("CCMenuItemSpriteExtra::activate", INT_MAX-1);
HOOK_LATEST("CCMenuItemSpriteExtra::selected");
HOOK_LATEST("CCMenuItemSpriteExtra::unselected");
HOOK_LATEST("CCMenuItemSpriteExtra::activate");
}

struct Fields {
Expand Down
5 changes: 5 additions & 0 deletions src/nodes/CCScale9Sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ using namespace geode::prelude;

class $modify(MyCCScale9Sprite, CCScale9Sprite) {

static void onModify(auto& self) {
HOOK_LATEST("cocos2d::CCScale9Sprite::initWithFile");
HOOK_LATEST("cocos2d::CCScale9Sprite::visit");
}

struct Fields {
std::string textureName;
CCRect rect;
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/CCScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace geode::prelude;
class $modify(MyCCScene, CCScene) {

static void onModify(auto& self) {
(void) self.setHookPriority("CCScene::create", INT_MIN);
HOOK_LATEST("cocos2d::CCScene::create");
}

struct Fields {
Expand Down
7 changes: 1 addition & 6 deletions src/nodes/CellColors.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ using namespace geode::prelude;
setCellColors(LevelCell, loadFromLevel, GJGameLevel);
setCellColors(LevelListCell, loadFromList, GJLevelList);
setCellColors(GJScoreCell, loadFromScore, GJUserScore);

#ifndef GEODE_IS_MACOS

setCellColors(GJUserCell, loadFromScore, GJUserScore);
setCellColors(AchievementCell, loadFromDict, CCDictionary);
setCellColors(StatsCell, loadFromObject, StatsObject);
setCellColors(GJMessageCell, loadFromMessage, GJUserMessage);
setCellColors(MapPackCell, loadFromMapPack, GJMapPack);
setCellColors(GJLevelScoreCell, loadFromScore, GJUserScore);

#endif
setCellColors(GJLevelScoreCell, loadFromScore, GJUserScore);
2 changes: 1 addition & 1 deletion src/nodes/CommentCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class $modify(MyCommentCell, CommentCell) {
};

static void onModify(auto& self) {
(void) self.setHookPriority("CommentCell::loadFromComment", INT_MIN);
HOOK_LATEST("CommentCell::loadFromComment");
}

void loadFromComment(GJComment* p0) {
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/CustomMusicCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace geode::prelude;
class $modify(MyCustomMusicCell, CustomMusicCell) {

static void onModify(auto& self) {
(void) self.setHookPriority("CustomMusicCell::loadFromObject", INT_MIN);
HOOK_LATEST("CustomMusicCell::loadFromObject");
}

struct Fields {
Expand Down
3 changes: 2 additions & 1 deletion src/nodes/EditLevelLayer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#pragma once

#include <Geode/Geode.hpp>
Expand All @@ -9,7 +10,7 @@ using namespace geode::prelude;
class $modify(MyEditLevelLayer, EditLevelLayer) {

static void onModify(auto& self) {
(void) self.setHookPriority("EditLevelLayer::init", INT_MIN);
HOOK_LATEST("EditLevelLayer::init");
}

bool init(GJGameLevel* p0) {
Expand Down
4 changes: 4 additions & 0 deletions src/nodes/FLAlertLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

class $modify(MyFLAlertLayer, FLAlertLayer) {

static void onModify(auto& self) {
HOOK_LATEST("FLAlertLayer::init");
}

struct Fields {
TextArea* m_contentTextArea = nullptr;
CCLabelBMFont* m_title = nullptr;
Expand Down
Loading

0 comments on commit 115944a

Please sign in to comment.