// // RUReboltPopupLayer.cpp // building_ui // // Created by ZhengSong on 2023/6/14. // #include "RUReboltPopupLayer.h" #include "RUPopupMgr.h" NS_RU_BEGIN ReboltPopupLayer::ReboltPopupLayer() { } ReboltPopupLayer::~ReboltPopupLayer() { } ReboltPopupLayer* ReboltPopupLayer::create(const std::string& windowName, const std::string& redreamName, const std::function& closeCb, std::function notifyCallback) { ReboltPopupLayer * ret = new (std::nothrow) ReboltPopupLayer(); ret->_windowName = windowName; ret->_redreamName = redreamName; ret->_closeCb = closeCb; ret->_notifyCallback = notifyCallback; ret->autorelease(); return ret; } void ReboltPopupLayer::_open() { if (_reboltLayer == nullptr) { _reboltLayer = redutils::RUReboltLayer::createReboltLayer(_redreamName); this->addChild(_reboltLayer); _reboltLayer->registerOnNotify([this](const redutils::ReboltNotifyData& data){ _onNotifyDevelopment(data); }); } _reboltLayer->runBehaviacWhitFunName("初始化面板"); } void ReboltPopupLayer::_close() { CCASSERT(_reboltLayer, ""); if(_reboltLayer) { _reboltLayer->runBehaviacWhitFunName("关闭面板"); } } void ReboltPopupLayer::_onNotifyDevelopment(const redutils::ReboltNotifyData& data) { std::string notify = data.notify; if(notify == "成功关闭面板") { redutils::PopupMgr::getInstance()->popupLayerClosed(_windowName); this->runAction(RemoveSelf::create()); }else if( _notifyCallback ){ _notifyCallback(data); } } NS_RU_END