// // IAPCtlShopUI.hpp // TileManor // // Created by 徐炼新 on 2024/1/16. // #ifndef IAPCtlShopUI_hpp #define IAPCtlShopUI_hpp #include #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, iap::ShopRequirement& requirement,int placementId = 1); // 以滑动卡片的形式在某个节点中显示某些版位(适用于失败时的场景) // pParent 父节点 // plIds 需要的版位id void showPlacementsInNode(cocos2d::Node* pNode, const vector& plIds); // 添加一个商店版位 // id 卡片id(添加版位时的id) bool addAPlacement(const iap::IAPPlacement& plInfo); // 删除一个商店版位 // id 卡片id(添加版位时的id) void removePlacement(const std::string& id); // 给某个商店版位添加卡片 bool addCardToPlacement(const std::string& id, iap::IAPCard* card); // 给某个商店版位添加卡片 bool removeCardToPlacement(const std::string id, int cardIndex = -1); // 清空活动 void clearPlacement(); // 获取活动礼包总数 size_t getPlacementCount(); // 设置退出时的回调 void setCBWhileQuit(std::function cb) { _cb = cb; } // 当前是否正在显示 bool isShowing(); // 退出当前界面 void quit(); private: IAPCtlShopUI(); ~IAPCtlShopUI(); void clear(); void _onNotifyDevelopment(const redutils::ReboltNotifyData& data); void constructShopItem(bool bShowAll , iap::ShopRequirement& requirement); Node* createPlacementUI(const iap::IAPPlacement& placement); // 根据所需要的金币进行过滤筛选 void filterGoods(iap::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; std::vector _goodsItems; std::vector _placementItems; redutils::RUReboltLayer* _btnShowAll = nullptr; std::vector _allSizes; MapIGCoin* _igCoin = nullptr; bool _bUIShowing = false; std::function _cb = nullptr; int _placementId = 0; std::map _placements; std::map > _indicators; }; #endif /* IAPCtlShopUI_hpp */