Skip to content

Commit

Permalink
Disable border fix if wanted by mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphalaneous committed Aug 31, 2024
1 parent fb1d492 commit 53a7b3b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"android": "2.206",
"mac": "2.206"
},
"version": "v1.4.1",
"version": "v1.4.2",
"id": "alphalaneous.happy_textures",
"name": "Happy Textures :3",
"developer": "Alphalaneous",
Expand Down
50 changes: 43 additions & 7 deletions src/nodes/GJCommentListLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ using namespace geode::prelude;
class $modify(MyGJCommentListLayer, GJCommentListLayer) {

struct Fields {
SEL_SCHEDULE schedule;
SEL_SCHEDULE parentSchedule;
SEL_SCHEDULE revertSchedule;
SEL_SCHEDULE posSchedule;
bool hasBorder = false;
CCPoint lastPos;
};
Expand All @@ -20,6 +22,7 @@ class $modify(MyGJCommentListLayer, GJCommentListLayer) {

static GJCommentListLayer* create(BoomListView* p0, char const* p1, cocos2d::ccColor4B p2, float p3, float p4, bool p5) {
auto ret = GJCommentListLayer::create(p0, p1, p2, p3, p4, p5);

if(UIModding::get()->doModify){
if(ret->getColor() == ccColor3B{191,114,62}){
std::optional<ColorData> dataOpt = UIModding::get()->getColors("comment-list-layer-bg");
Expand Down Expand Up @@ -50,9 +53,12 @@ class $modify(MyGJCommentListLayer, GJCommentListLayer) {
}

MyGJCommentListLayer* myRet = static_cast<MyGJCommentListLayer*>(ret);
myRet->m_fields->schedule = schedule_selector(MyGJCommentListLayer::checkForParent);
myRet->schedule(myRet->m_fields->schedule);
myRet->schedule(schedule_selector(MyGJCommentListLayer::listenForPosition));
myRet->m_fields->parentSchedule = schedule_selector(MyGJCommentListLayer::checkForParent);
myRet->m_fields->posSchedule = schedule_selector(MyGJCommentListLayer::listenForPosition);
myRet->m_fields->revertSchedule = schedule_selector(MyGJCommentListLayer::listenForDisable);
myRet->schedule(myRet->m_fields->parentSchedule);
myRet->schedule(myRet->m_fields->posSchedule);
myRet->schedule(myRet->m_fields->revertSchedule);

CCPoint pos = {p3/2, p4/2};

Expand All @@ -62,15 +68,15 @@ class $modify(MyGJCommentListLayer, GJCommentListLayer) {
outlineSprite->setZOrder(20);
outlineSprite->setID("outline");

if(!p5){
if (!p5){
outlineSprite->setColor({130, 64, 32});
std::optional<ColorData> dataOpt = UIModding::get()->getColors("comment-list-outline-brown");
if(dataOpt.has_value()){
ColorData data = dataOpt.value();
outlineSprite->setColor(data.color);
}
}
else{
else {
outlineSprite->setColor({32, 49, 130});
std::optional<ColorData> dataOpt = UIModding::get()->getColors("comment-list-outline-blue");
if(dataOpt.has_value()){
Expand All @@ -87,6 +93,36 @@ class $modify(MyGJCommentListLayer, GJCommentListLayer) {

#ifndef GEODE_IS_MACOS

void listenForDisable(float dt) {
if (getUserObject("dont-correct-borders")){
revert();
}
}

void revert() {

unschedule(m_fields->parentSchedule);
unschedule(m_fields->posSchedule);

if(CCNode* node = getChildByID("left-border")) {
node->setVisible(true);
}
if(CCNode* node = getChildByID("right-border")) {
node->setVisible(true);
}
if(CCNode* node = getChildByID("top-border")) {
node->setVisible(true);
}
if(CCNode* node = getChildByID("bottom-border")) {
node->setVisible(true);
}

removeChildByID("outline");
removeChildByID("special-border");

unschedule(m_fields->revertSchedule);
}

void listenForPosition(float dt){
if(m_fields->hasBorder && m_fields->lastPos != getPosition()){
if(CCNode* parent = getParent()){
Expand All @@ -99,7 +135,7 @@ class $modify(MyGJCommentListLayer, GJCommentListLayer) {
void checkForParent(float dt){
if(CCNode* parent = getParent()){
updateBordersWithParent(parent);
unschedule(m_fields->schedule);
unschedule(m_fields->parentSchedule);
}
}

Expand Down

0 comments on commit 53a7b3b

Please sign in to comment.