1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // 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);
-
- // 添加一个商店版位
- // 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 */
|