123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // IAPCtlShopUI.hpp
- // TileManor
- //
- // Created by 徐炼新 on 2024/1/16.
- //
- #ifndef IAPCtlShopUI_hpp
- #define IAPCtlShopUI_hpp
- #include <stdio.h>
- #include "cocos2d.h"
- #include "RUReboltLayer.h"
- #include "RUTableView.h"
- #include "IAPDefine.hpp"
- class IAPCtlShopItem;
- class MapIGCoin;
- class IAPConf;
- class IAPCtlShopUI : public cocos2d::Ref
- {
- public:
- static IAPCtlShopUI* getInstance();
-
- // 在指定节点内创建
- bool create(cocos2d::Node* pNode, IAPConf* cfg, iapshop::ShopRequirement& requirement,int placementId = 1);
-
- // 以滑动卡片的形式在某个节点中显示满足金币条件的所有商店卡片
- // pParent 父节点
- // stillNeedCoins 距离所需要的金币数还差多少金币
- void showSlideCardsByCoinsIn(cocos2d::Node* pNode, int stillNeedCoins);
-
- // 添加一个商店版位
- // id 卡片id(添加版位时的id)
- bool addAPlacement(const iapshop::IAPPlacement& plInfo);
-
- // 删除一个商店版位
- // id 卡片id(添加版位时的id)
- void removePlacement(const std::string& id);
-
- // 给某个商店版位添加卡片
- bool addCardToPlacement(const std::string& id, iapshop::IAPCard* card);
-
- // 给某个商店版位添加卡片
- bool removeCardToPlacement(const std::string id, int cardIndex = -1);
-
- // 清空活动
- void clearPlacement();
-
- // 获取活动礼包总数
- size_t getPlacementCount();
-
- // 设置退出时的回调
- void setCBWhileQuit(std::function<void()> cb) { _cb = cb; }
-
- // 当前是否正在显示
- bool isShowing();
-
- // 退出当前界面
- void quit();
- private:
- IAPCtlShopUI();
- ~IAPCtlShopUI();
-
- void clear();
- void _onNotifyDevelopment(const redutils::ReboltNotifyData& data);
-
- void constructShopItem(bool bShowAll , iapshop::ShopRequirement& requirement);
-
- Node* createPlacementUI(const iapshop::IAPPlacement& placement);
-
- // 根据所需要的金币进行过滤筛选
- void filterGoods(iapshop::ShopRequirement& requirement);
-
- // 对Goods列表价格进行排序 true : 从小到大 false: 从大到小
- void sortGoods(bool flag);
- private:
- static IAPCtlShopUI* _instance;
- IAPConf* _cfg = nullptr;
- redutils::RUReboltLayer* _layer = nullptr;
- cocos2d::Node* _ndScrollArea = nullptr;
- redutils::RUTableView* _tableView = nullptr;
- redutils::RUTableDataModel _tableData;
- std::vector<GoodsInfo> _goodsInfo;
- std::vector<IAPCtlShopItem*> _goodsItems;
- std::vector<IAPCtlShopItem*> _failItems;
- std::vector<Node*> _placementItems;
- redutils::RUReboltLayer* _btnShowAll = nullptr;
- std::vector<cocos2d::Size> _allSizes;
- MapIGCoin* _igCoin = nullptr;
- bool _bUIShowing = false;
- std::function<void()> _cb = nullptr;
- int _placementId = 0;
-
- std::map<std::string, iapshop::IAPPlacement> _placements;
- std::map<std::string, std::vector<Node*> > _indicators;
- };
- #endif /* IAPCtlShopUI_hpp */
|