From 53a7b3b5a34e1df5c6887f9f8920651b49dce311 Mon Sep 17 00:00:00 2001 From: Alphalaneous <38200084+Alphalaneous@users.noreply.github.com> Date: Sat, 31 Aug 2024 12:04:00 -0400 Subject: [PATCH] Disable border fix if wanted by mods --- mod.json | 2 +- src/nodes/GJCommentListLayer.h | 50 +++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/mod.json b/mod.json index 87d8fec..0534dc8 100644 --- a/mod.json +++ b/mod.json @@ -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", diff --git a/src/nodes/GJCommentListLayer.h b/src/nodes/GJCommentListLayer.h index f6761db..50a21c9 100644 --- a/src/nodes/GJCommentListLayer.h +++ b/src/nodes/GJCommentListLayer.h @@ -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; }; @@ -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 dataOpt = UIModding::get()->getColors("comment-list-layer-bg"); @@ -50,9 +53,12 @@ class $modify(MyGJCommentListLayer, GJCommentListLayer) { } MyGJCommentListLayer* myRet = static_cast(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}; @@ -62,7 +68,7 @@ class $modify(MyGJCommentListLayer, GJCommentListLayer) { outlineSprite->setZOrder(20); outlineSprite->setID("outline"); - if(!p5){ + if (!p5){ outlineSprite->setColor({130, 64, 32}); std::optional dataOpt = UIModding::get()->getColors("comment-list-outline-brown"); if(dataOpt.has_value()){ @@ -70,7 +76,7 @@ class $modify(MyGJCommentListLayer, GJCommentListLayer) { outlineSprite->setColor(data.color); } } - else{ + else { outlineSprite->setColor({32, 49, 130}); std::optional dataOpt = UIModding::get()->getColors("comment-list-outline-blue"); if(dataOpt.has_value()){ @@ -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()){ @@ -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); } }