IAPCtlShopUI.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. // pParent 父节点
  25. // stillNeedCoins 距离所需要的金币数还差多少金币
  26. void showSlideCardsByCoinsIn(cocos2d::Node* pNode, int stillNeedCoins);
  27. // 添加一个商店版位
  28. // id 卡片id(添加版位时的id)
  29. bool addAPlacement(const iapshop::IAPPlacement& plInfo);
  30. // 删除一个商店版位
  31. // id 卡片id(添加版位时的id)
  32. void removePlacement(const std::string& id);
  33. // 给某个商店版位添加卡片
  34. bool addCardToPlacement(const std::string& id, iapshop::IAPCard* card);
  35. // 给某个商店版位添加卡片
  36. bool removeCardToPlacement(const std::string id, int cardIndex = -1);
  37. // 清空活动
  38. void clearPlacement();
  39. // 获取活动礼包总数
  40. size_t getPlacementCount();
  41. // 设置退出时的回调
  42. void setCBWhileQuit(std::function<void()> cb) { _cb = cb; }
  43. // 当前是否正在显示
  44. bool isShowing();
  45. // 退出当前界面
  46. void quit();
  47. private:
  48. IAPCtlShopUI();
  49. ~IAPCtlShopUI();
  50. void clear();
  51. void _onNotifyDevelopment(const redutils::ReboltNotifyData& data);
  52. void constructShopItem(bool bShowAll , iapshop::ShopRequirement& requirement);
  53. Node* createPlacementUI(const iapshop::IAPPlacement& placement);
  54. // 根据所需要的金币进行过滤筛选
  55. void filterGoods(iapshop::ShopRequirement& requirement);
  56. // 对Goods列表价格进行排序 true : 从小到大 false: 从大到小
  57. void sortGoods(bool flag);
  58. private:
  59. static IAPCtlShopUI* _instance;
  60. IAPConf* _cfg = nullptr;
  61. redutils::RUReboltLayer* _layer = nullptr;
  62. cocos2d::Node* _ndScrollArea = nullptr;
  63. redutils::RUTableView* _tableView = nullptr;
  64. redutils::RUTableDataModel _tableData;
  65. std::vector<GoodsInfo> _goodsInfo;
  66. std::vector<IAPCtlShopItem*> _goodsItems;
  67. std::vector<IAPCtlShopItem*> _failItems;
  68. std::vector<Node*> _placementItems;
  69. redutils::RUReboltLayer* _btnShowAll = nullptr;
  70. std::vector<cocos2d::Size> _allSizes;
  71. MapIGCoin* _igCoin = nullptr;
  72. bool _bUIShowing = false;
  73. std::function<void()> _cb = nullptr;
  74. int _placementId = 0;
  75. std::map<std::string, iapshop::IAPPlacement> _placements;
  76. std::map<std::string, std::vector<Node*> > _indicators;
  77. };
  78. #endif /* IAPCtlShopUI_hpp */