IAPCtlShopUI.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // IAPCtlShopUI.hpp
  3. // TileManor
  4. //
  5. // Created by 徐炼新 on 2024/1/16.
  6. //
  7. #ifndef IAPCtlShopUI_hpp
  8. #define IAPCtlShopUI_hpp
  9. #include <stdio.h>
  10. #include "cocos2d.h"
  11. #include "RUReboltLayer.h"
  12. #include "RUTableView.h"
  13. #include "IAPDefine.hpp"
  14. class IAPCtlShopItem;
  15. class MapIGCoin;
  16. class IAPConf;
  17. class IAPCtlShopUI : public cocos2d::Ref
  18. {
  19. public:
  20. static IAPCtlShopUI* getInstance();
  21. // 在指定节点内创建
  22. bool create(cocos2d::Node* pNode, IAPConf* cfg, iapshop::ShopRequirement& requirement,int placementId = 1);
  23. // 添加一个商店版位
  24. // id 卡片id(添加版位时的id)
  25. bool addAPlacement(const iapshop::IAPPlacement& plInfo);
  26. // 删除一个商店版位
  27. // id 卡片id(添加版位时的id)
  28. void removePlacement(const std::string& id);
  29. // 给某个商店版位添加卡片
  30. bool addCardToPlacement(const std::string& id, iapshop::IAPCard* card);
  31. // 给某个商店版位添加卡片
  32. bool removeCardToPlacement(const std::string id, int cardIndex = -1);
  33. // 清空活动
  34. void clearPlacement();
  35. // 获取活动礼包总数
  36. size_t getPlacementCount();
  37. // 设置退出时的回调
  38. void setCBWhileQuit(std::function<void()> cb) { _cb = cb; }
  39. // 当前是否正在显示
  40. bool isShowing();
  41. // 退出当前界面
  42. void quit();
  43. private:
  44. IAPCtlShopUI();
  45. ~IAPCtlShopUI();
  46. void clear();
  47. void _onNotifyDevelopment(const redutils::ReboltNotifyData& data);
  48. void constructShopItem(bool bShowAll , iapshop::ShopRequirement& requirement);
  49. Node* createPlacementUI(const iapshop::IAPPlacement& placement);
  50. // 根据所需要的金币进行过滤筛选
  51. void filterGoods(iapshop::ShopRequirement& requirement);
  52. // 对Goods列表价格进行排序 true : 从小到大 false: 从大到小
  53. void sortGoods(bool flag);
  54. private:
  55. static IAPCtlShopUI* _instance;
  56. IAPConf* _cfg = nullptr;
  57. redutils::RUReboltLayer* _layer = nullptr;
  58. cocos2d::Node* _ndScrollArea = nullptr;
  59. redutils::RUTableView* _tableView = nullptr;
  60. redutils::RUTableDataModel _tableData;
  61. std::vector<GoodsInfo> _goodsInfo;
  62. std::vector<IAPCtlShopItem*> _goodsItems;
  63. std::vector<IAPCtlShopItem*> _failItems;
  64. std::vector<Node*> _placementItems;
  65. redutils::RUReboltLayer* _btnShowAll = nullptr;
  66. std::vector<cocos2d::Size> _allSizes;
  67. MapIGCoin* _igCoin = nullptr;
  68. bool _bUIShowing = false;
  69. std::function<void()> _cb = nullptr;
  70. int _placementId = 0;
  71. std::map<std::string, iapshop::IAPPlacement> _placements;
  72. std::map<std::string, std::vector<Node*> > _indicators;
  73. };
  74. #endif /* IAPCtlShopUI_hpp */