From 3081164600532274b12537d63d85fed9d964409c Mon Sep 17 00:00:00 2001 From: matcool <26722564+matcool@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:45:06 -0300 Subject: [PATCH] only send delegate update on closing ColorPickPopup --- loader/include/Geode/ui/ColorPickPopup.hpp | 1 + loader/src/ui/nodes/ColorPickPopup.cpp | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/loader/include/Geode/ui/ColorPickPopup.hpp b/loader/include/Geode/ui/ColorPickPopup.hpp index 66ffd22f..5a1b298d 100644 --- a/loader/include/Geode/ui/ColorPickPopup.hpp +++ b/loader/include/Geode/ui/ColorPickPopup.hpp @@ -39,6 +39,7 @@ namespace geode { void onOpacitySlider(cocos2d::CCObject* sender); void onReset(cocos2d::CCObject* sender); + void onClose(cocos2d::CCObject* sender) override; void textChanged(CCTextInputNode* input) override; void colorValueChanged(cocos2d::ccColor3B color) override; diff --git a/loader/src/ui/nodes/ColorPickPopup.cpp b/loader/src/ui/nodes/ColorPickPopup.cpp index b076533d..117f9ddf 100644 --- a/loader/src/ui/nodes/ColorPickPopup.cpp +++ b/loader/src/ui/nodes/ColorPickPopup.cpp @@ -335,10 +335,10 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) { } void ColorPickPopup::updateState(CCNode* except) { -#define IF_NOT_EXCEPT(inp, value) \ - if (inp->getInputNode() != except) { \ - inp->setString(value, false); \ - } + #define IF_NOT_EXCEPT(inp, value) \ + if (inp->getInputNode() != except) { \ + inp->setString(value, false); \ + } IF_NOT_EXCEPT(m_impl->m_rInput, numToString(m_impl->m_color.r)); IF_NOT_EXCEPT(m_impl->m_gInput, numToString(m_impl->m_color.g)); @@ -357,9 +357,6 @@ void ColorPickPopup::updateState(CCNode* except) { } m_impl->m_resetBtn->setVisible(m_impl->m_originalColor != m_impl->m_color); m_impl->m_newColorSpr->setColor(to3B(m_impl->m_color)); - if (m_impl->m_delegate) { - m_impl->m_delegate->updateColor(m_impl->m_color); - } } void ColorPickPopup::onOpacitySlider(CCObject* sender) { @@ -372,6 +369,13 @@ void ColorPickPopup::onReset(CCObject*) { this->updateState(); } +void ColorPickPopup::onClose(CCObject* sender) { + if (m_impl->m_delegate) { + m_impl->m_delegate->updateColor(m_impl->m_color); + } + Popup::onClose(sender); +} + void ColorPickPopup::textChanged(CCTextInputNode* input) { if (input->getString().size()) { switch (input->getTag()) {