Ejemplo n.º 1
0
void PurchaseLayer::showListItems()
{
    for (int i = 0; i < CSCClass::CSC_IOSHelper::IAP_getProductsCount(); i++) {
        Node* itemNode = CSLoader::getInstance()->createNodeWithFlatBuffersFile("PurchaseItemNode.csb");
        Layout* layout = dynamic_cast<Layout*>(itemNode->getChildByName("Panel_PurchaseItem"));
        Text* itemName = dynamic_cast<Text*>(layout->getChildByName("Text_ItemName"));
        ScrollView* scrollView = dynamic_cast<ScrollView*>(layout->getChildByName("ScrollView_Desc"));
        Text* itemDesc = dynamic_cast<Text*>(scrollView->getChildByName("Text_Desc"));
        Button* button = dynamic_cast<Button*>(layout->getChildByName("Button_Buy"));
		const char* productID = CSCClass::CSC_IOSHelper::IAP_getProductID(i);
        button->addClickEventListener(CC_CALLBACK_1(PurchaseLayer::menuCallback_Buy, this, button, productID));
        
        itemName->setString(CSCClass::CSC_IOSHelper::IAP_getProductTitle(i));
        itemDesc->setString(CSCClass::CSC_IOSHelper::IAP_getProductDescription(i));
		CSCClass::setScrollViewTextAutoWrap(scrollView, itemDesc);

        button->setTitleText(CSCClass::CSC_IOSHelper::IAP_getProductPrice(i));
        
        layout->removeFromParentAndCleanup(false);
        m_pListView->pushBackCustomItem(layout);
        
        if (CSCClass::CSC_IOSHelper::IAP_isPurchased(productID)) {
			button->setEnabled(false);
        }
    }
}