add EventListener::getFilter

This commit is contained in:
HJfod 2023-03-27 21:22:18 +03:00
parent 704e6ba0db
commit 5cdfbc3e67
3 changed files with 19 additions and 4 deletions

View file

@ -408,12 +408,12 @@ class cocos2d::CCMenu {
virtual auto registerWithTouchDispatcher() = mac 0x438cd0, ios 0x131f8c;
virtual auto onExit() = mac 0x438bd0, ios 0x131ed4;
virtual auto removeChild(cocos2d::CCNode*, bool) = mac 0x438c20, ios 0x15e630;
auto initWithArray(cocos2d::CCArray*) = mac 0x4389f0, ios 0x131d04;
auto itemForTouch(cocos2d::CCTouch*) = mac 0x438dd0;
bool initWithArray(cocos2d::CCArray*) = mac 0x4389f0, ios 0x131d04;
cocos2d::CCMenuItem* itemForTouch(cocos2d::CCTouch*) = mac 0x438dd0;
}
class cocos2d::CCMenuItem {
auto initWithTarget(cocos2d::CCObject*, cocos2d::SEL_MenuHandler) = mac 0x1fb7f0;
bool initWithTarget(cocos2d::CCObject*, cocos2d::SEL_MenuHandler) = mac 0x1fb7f0;
virtual ~CCMenuItem() = mac 0x1fb8e0, ios 0x2cdf4;
virtual auto activate() = mac 0x1fba70, ios 0x2ceb0;
virtual auto selected() = mac 0x1fb9e0, ios 0x2ce2e;

View file

@ -990,13 +990,24 @@ public:
GEODE_DLL void swapChildIndices(CCNode* first, CCNode* second);
template <class Filter, class... Args>
geode::EventListenerProtocol* addEventListener(typename Filter::Callback callback, Args&&... args) {
geode::EventListenerProtocol* addEventListener(
geode::utils::MiniFunction<typename Filter::Callback> callback, Args&&... args
) {
auto listener = new geode::EventListener<Filter>(
callback, Filter(this, std::forward<Args>(args)...)
);
this->addEventListenerInternal(listener);
return listener;
}
template <class Ev, class... Args>
geode::EventListenerProtocol* addEventListener(
geode::utils::MiniFunction<geode::ListenerResult(Ev*)> callback,
Args&&... args
) {
return this->template addEventListener<typename Ev::Filter>(
callback, std::forward<Args>(args)...
);
}
GEODE_DLL void removeEventListener(geode::EventListenerProtocol* listener);
/// @{

View file

@ -120,6 +120,10 @@ namespace geode {
m_filter = filter;
}
T getFilter() const {
return m_filter;
}
protected:
utils::MiniFunction<Callback> m_callback = nullptr;
T m_filter;