RUReboltPopupLayer.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // RUReboltPopupLayer.cpp
  3. // building_ui
  4. //
  5. // Created by ZhengSong on 2023/6/14.
  6. //
  7. #include "RUReboltPopupLayer.h"
  8. #include "RUPopupMgr.h"
  9. NS_RU_BEGIN
  10. ReboltPopupLayer::ReboltPopupLayer()
  11. {
  12. }
  13. ReboltPopupLayer::~ReboltPopupLayer() {
  14. }
  15. ReboltPopupLayer* ReboltPopupLayer::create(const std::string& windowName,
  16. const std::string& redreamName,
  17. const std::function<void(void)>& closeCb,
  18. std::function<void (const redutils::ReboltNotifyData&)> notifyCallback)
  19. {
  20. ReboltPopupLayer * ret = new (std::nothrow) ReboltPopupLayer();
  21. ret->_windowName = windowName;
  22. ret->_redreamName = redreamName;
  23. ret->_closeCb = closeCb;
  24. ret->_notifyCallback = notifyCallback;
  25. ret->autorelease();
  26. return ret;
  27. }
  28. void ReboltPopupLayer::_open() {
  29. if (_reboltLayer == nullptr) {
  30. _reboltLayer = redutils::RUReboltLayer::createReboltLayer(_redreamName);
  31. this->addChild(_reboltLayer);
  32. _reboltLayer->registerOnNotify([this](const redutils::ReboltNotifyData& data){
  33. _onNotifyDevelopment(data);
  34. });
  35. }
  36. _reboltLayer->runBehaviacWhitFunName("初始化面板");
  37. }
  38. void ReboltPopupLayer::_close() {
  39. CCASSERT(_reboltLayer, "");
  40. if(_reboltLayer) {
  41. _reboltLayer->runBehaviacWhitFunName("关闭面板");
  42. }
  43. }
  44. void ReboltPopupLayer::_onNotifyDevelopment(const redutils::ReboltNotifyData& data) {
  45. std::string notify = data.notify;
  46. if(notify == "成功关闭面板") {
  47. redutils::PopupMgr::getInstance()->popupLayerClosed(_windowName);
  48. this->runAction(RemoveSelf::create());
  49. }else if( _notifyCallback ){
  50. _notifyCallback(data);
  51. }
  52. }
  53. NS_RU_END