diff --git a/loader/include/Geode/ui/BasedButtonSprite.hpp b/loader/include/Geode/ui/BasedButtonSprite.hpp index 6c741d5e..9600f4ca 100644 --- a/loader/include/Geode/ui/BasedButtonSprite.hpp +++ b/loader/include/Geode/ui/BasedButtonSprite.hpp @@ -28,7 +28,6 @@ namespace geode { Gray = 2, Blue = 3, Cyan = 4, - Geode = 5, }; GEODE_DLL const char* baseEnumToString(CircleBaseColor); @@ -148,6 +147,8 @@ namespace geode { int m_size; int m_color; cocos2d::CCNode* m_onTop = nullptr; + float m_onTopRelativeScale = 1.f; + cocos2d::CCPoint m_topOffset = cocos2d::CCPointZero; bool init(cocos2d::CCNode* ontop, BaseType type, int size, int color); bool initWithSprite( @@ -157,7 +158,6 @@ namespace geode { const char* sprName, float sprScale, BaseType type, int size, int color ); - cocos2d::CCPoint getTopOffset() const; virtual cocos2d::CCSize getMaxTopSize() const; virtual ~BasedButtonSprite(); @@ -180,6 +180,12 @@ namespace geode { cocos2d::CCNode* ontop, BaseType type, int size, int color ); + /** + * Set an offset to the top sprite + */ + void setTopOffset(cocos2d::CCPoint const& offset); + void setTopRelativeScale(float scale); + cocos2d::CCNode* getTopNode() const; }; diff --git a/loader/src/hooks/MenuLayer.cpp b/loader/src/hooks/MenuLayer.cpp index b3af97a6..d9653165 100644 --- a/loader/src/hooks/MenuLayer.cpp +++ b/loader/src/hooks/MenuLayer.cpp @@ -72,7 +72,7 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> { if (!m_fields->m_menuDisabled) { m_fields->m_geodeButton = CircleButtonSprite::createWithSpriteFrameName( "geode-logo-outline-gold.png"_spr, - 1.0f, + .95f, CircleBaseColor::Green, CircleBaseSize::MediumAlt ); diff --git a/loader/src/ui/nodes/BasedButtonSprite.cpp b/loader/src/ui/nodes/BasedButtonSprite.cpp index 96d22ed8..59684534 100644 --- a/loader/src/ui/nodes/BasedButtonSprite.cpp +++ b/loader/src/ui/nodes/BasedButtonSprite.cpp @@ -25,7 +25,6 @@ const char* geode::baseEnumToString(CircleBaseColor value) { case CircleBaseColor::Gray: return "Gray"; case CircleBaseColor::Blue: return "Blue"; case CircleBaseColor::Cyan: return "Cyan"; - case CircleBaseColor::Geode: return "Geode"; } return "Unknown"; } @@ -190,8 +189,9 @@ bool BasedButtonSprite::init(CCNode* ontop, BaseType type, int size, int color) if (ontop) { m_onTop = ontop; - m_onTop->setPosition(this->getContentSize() / 2 + this->getTopOffset()); - limitNodeSize(m_onTop, this->getMaxTopSize(), m_onTop->getScale(), .1f); + m_onTop->setPosition(this->getContentSize() / 2 + m_topOffset); + limitNodeSize(m_onTop, this->getMaxTopSize(), 999.f, .1f); + m_onTop->setScale(m_onTop->getScale() * m_onTopRelativeScale); this->addChild(m_onTop); } @@ -202,8 +202,18 @@ CCSize BasedButtonSprite::getMaxTopSize() const { return m_obContentSize - CCSize(18.f, 18.f); } -CCPoint BasedButtonSprite::getTopOffset() const { - return { 0, 0 }; +void BasedButtonSprite::setTopOffset(CCPoint const& offset) { + m_topOffset = offset; + if (m_onTop) { + m_onTop->setPosition(this->getContentSize() / 2 + offset); + } +} +void BasedButtonSprite::setTopRelativeScale(float scale) { + m_onTopRelativeScale = scale; + if (m_onTop) { + limitNodeSize(m_onTop, this->getMaxTopSize(), 999.f, .1f); + m_onTop->setScale(m_onTop->getScale() * m_onTopRelativeScale); + } } bool BasedButtonSprite::initWithSprite( @@ -211,7 +221,7 @@ bool BasedButtonSprite::initWithSprite( ) { auto spr = CCSprite::create(sprName); if (!spr) return false; - spr->setScale(sprScale); + m_onTopRelativeScale = sprScale; return this->init(spr, type, size, color); } @@ -220,7 +230,7 @@ bool BasedButtonSprite::initWithSpriteFrameName( ) { auto spr = CCSprite::createWithSpriteFrameName(sprName); if (!spr) return false; - spr->setScale(sprScale); + m_onTopRelativeScale = sprScale; return this->init(spr, type, size, color); }