コード例 #1
0
void GameWeekRewardLayer::BindingUIItems(CCObject *p)
{
    CCString str;
    str.initWithFormat("%d%d",eNetMsgTypeMissionSys, eNetMsgMissionSysWeekRewardKind);
    CSJson::Value root = XQDate::sharedInstance().GetDate(str.getCString());
    
    bool isShowBtn = false;
    
    for (int i = 0; i < root.size(); i ++) {
        CSJson::Value & val = root[i];
        if (val["iscomplete"].asInt() == 1) {
            isShowBtn = true;
        }
    }
    
    ul = UILayer::create();
    addChild(ul, 1);
    auto myLayout = static_cast<Layout*>(GUIReader::shareReader() -> widgetFromJsonFile("./CocoStudioResources/WeekRewardLayer.json"));
    ul -> addWidget(myLayout);
    
    UIPanel *myPanel = dynamic_cast<UIPanel*>(ul -> getWidgetByName("Panel_2"));
    myPanel -> addReleaseEvent(this, coco_releaseselector(GameWeekRewardLayer::touchWindow));
    // bind ui images
    
    UIButton *btn = dynamic_cast<UIButton*>(ul -> getWidgetByName("LotteryBtn"));
    if (isShowBtn) {
        btn->disable();
        btn->setVisible(false);
    }
    else {
        btn -> addReleaseEvent(this, coco_releaseselector(GameWeekRewardLayer::getWeekRewardBtnClick));
    }

	//设置字体不被选中;
}
コード例 #2
0
ファイル: ShopMediator.cpp プロジェクト: Dream-Hat/mdsj
bool ShopLayer::init()
{
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(!CCLayer::init());
		m_Mediator = NULL;
		m_buyNum = 1;
		m_onePri = 5000;
		m_curTapMenu = SHOP_LAYOUT_TAG_TEJIA;

		m_pUILayer = UILayer::create();
		m_pUILayer->setTouchPriority(-200);
		m_pUILayer->scheduleUpdate();
		addChild(m_pUILayer);

		Layout* lay;
		lay = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile("ui/ShopUI/ShopUI.json"));
		m_pUILayer->addWidget(lay);

		m_layerLayout = dynamic_cast<Layout*>(lay->getChildByName("layerPanel"));
		m_buyLayout = dynamic_cast<Layout*>(lay->getChildByName("buyRootPanel"));


		UIButton* returnBtn1 = dynamic_cast<UIButton*>(m_buyLayout->getChildByName("returnBtn"));
		returnBtn1->addReleaseEvent(this, coco_releaseselector(ShopLayer::closeBtnDlgCallBack));

		UIScrollView* scroV = dynamic_cast<UIScrollView*>(m_layerLayout->getChildByName("ScrollView"));
// 		UIScrollViewP* scroV = dynamic_cast<UIScrollViewP*>(m_layerLayout->getChildByName("ScrollView"));
// 		UIImageView* spr = dynamic_cast<UIImageView*>(m_layerLayout->getChildByName("slideImge"));
// 		CCSize a  = scroV->getInnerContainerSize();
// 		CCSize b  =scroV->getSize();
// 		float scale = b.height/a.height;
// 		spr->setScaleY(scale);
// 		scroV->setSlideSprite(spr,scale);

		for (int i = 0; i < 8; i++)
		{
			UIButton* scroPanel = dynamic_cast<UIButton*>(scroV->getChildByName(CCString::createWithFormat("Panel_%d", i)->getCString()));
			scroPanel->addReleaseEvent(this, coco_releaseselector(ShopLayer::scroCallBack));
		}


		UIButton* returnBtn = dynamic_cast<UIButton*>(m_layerLayout->getChildByName("returnBtn"));
		returnBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::closeBtnCallBack));

		UIButton* payBtn = dynamic_cast<UIButton*>(m_layerLayout->getChildByName("payBtn"));
		payBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::payBtnCallBack));

		UIButton* subBtn = dynamic_cast<UIButton*>(m_buyLayout->getChildByName("subBtn"));
		subBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::subBtnCallBack));

		UIButton* addBtn = dynamic_cast<UIButton*>(m_buyLayout->getChildByName("addBtn"));
		addBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::addBtnCallBack));

		Layout* buyNumPanel = dynamic_cast<Layout*>(m_buyLayout->getChildByName("buyNumPanel"));
		buyNumPanel->addReleaseEvent(this,coco_releaseselector(ShopLayer::callForNumInput));

		m_buyNumLabel = dynamic_cast<UILabel*>(buyNumPanel->getChildByName("Label"));
		m_totalPriLabel = dynamic_cast<UILabel*>(m_buyLayout->getChildByName("totalPriLabel"));
		m_onePriLabel = dynamic_cast<UILabel*>(m_buyLayout->getChildByName("onePriLabel"));

		UITextButton* buyBtn = dynamic_cast<UITextButton*>(m_buyLayout->getChildByName("buyBtn"));
		buyBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::buyBtnCallBack));

		Layout* tapbtn_panel = dynamic_cast<Layout*>(m_layerLayout->getChildByName("tapbtn_Panel"));
		tapbtn_panel->setWidgetTag(SHOP_LAYOUT_TAG_ROOT);

		UIButton* equipBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("equipBtn"));
		equipBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack));
		equipBtn->setWidgetTag(SHOP_LAYOUT_TAG_EQUIP);

		UIButton* tejiaBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("tejiaBtn"));
		tejiaBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack));
		tejiaBtn->setWidgetTag(SHOP_LAYOUT_TAG_TEJIA);
		tejiaBtn->disable();

		UIButton* diamondBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("diamondBtn"));
		diamondBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack));
		diamondBtn->setWidgetTag(SHOP_LAYOUT_TAG_DIAMOND);

		UIButton* yaoshuiBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("yaoshuiBtn"));
		yaoshuiBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack));
		yaoshuiBtn->setWidgetTag(SHOP_LAYOUT_TAG_YAOSHUI);

		UIButton* otherBtn = dynamic_cast<UIButton*>(tapbtn_panel->getChildByName("otherBtn"));
		otherBtn->addReleaseEvent(this, coco_releaseselector(ShopLayer::tapMenuCallBack));
		otherBtn->setWidgetTag(SHOP_LAYOUT_TAG_OTHER);


		bRet = true;

	} while (0);

	return bRet;
}
コード例 #3
0
ファイル: ShopMediator.cpp プロジェクト: Dream-Hat/mdsj
void ShopLayer::tapMenuCallBack( CCObject* pSender )
{
	 UIButton* button = dynamic_cast<UIButton*>(pSender);

	 Layout* root = dynamic_cast<Layout*>(m_pUILayer->getWidgetByTag(SHOP_LAYOUT_TAG_ROOT));

	 UIButton* equipBtn = dynamic_cast<UIButton*>(root->getChildByTag(SHOP_LAYOUT_TAG_EQUIP));

	 UIButton* tejiaBtn = dynamic_cast<UIButton*>(root->getChildByTag(SHOP_LAYOUT_TAG_TEJIA));

	 UIButton* diamondBtn = dynamic_cast<UIButton*>(root->getChildByTag(SHOP_LAYOUT_TAG_DIAMOND));

	 UIButton* yaoshuiBtn = dynamic_cast<UIButton*>(root->getChildByTag(SHOP_LAYOUT_TAG_YAOSHUI));

	 UIButton* otherBtn = dynamic_cast<UIButton*>(root->getChildByTag(SHOP_LAYOUT_TAG_OTHER));

	 equipBtn->active();
	 tejiaBtn->active();
	 diamondBtn->active();
	 yaoshuiBtn->active();
	 otherBtn->active();

	 switch (button->getWidgetTag())
	 {
	 case SHOP_LAYOUT_TAG_EQUIP:
		 {
			 m_curTapMenu = SHOP_LAYOUT_TAG_EQUIP;
			 equipBtn->disable();
			 updateScroV(false);
		 }break;
	 case SHOP_LAYOUT_TAG_TEJIA:
		 {
			 m_curTapMenu = SHOP_LAYOUT_TAG_TEJIA;
			 tejiaBtn->disable();
			 updateScroV(true);
		 }break;
	 case SHOP_LAYOUT_TAG_DIAMOND:
		 {
			 m_curTapMenu = SHOP_LAYOUT_TAG_DIAMOND;
			 diamondBtn->disable();
			 updateScroV(false);
		 }break;
	 case SHOP_LAYOUT_TAG_YAOSHUI:
		 {
			 m_curTapMenu = SHOP_LAYOUT_TAG_YAOSHUI;
			 yaoshuiBtn->disable();
			 updateScroV(false);
		 }break;
	 case SHOP_LAYOUT_TAG_OTHER:
		 {
			 m_curTapMenu = SHOP_LAYOUT_TAG_OTHER;
			 otherBtn->disable();
			 updateScroV(false);
		 }break;
	 }
// 	 UIScrollView* scroV = dynamic_cast<UIScrollView*>(m_layerLayout->getChildByName("ScrollView"));
// 	 Layout* scroPanel[6];
// 	 for (int i = 0; i < 6; i++)
// 	 {
// 		 scroPanel[i] = dynamic_cast<UIButton*>(scroV->getChildByName(CCString::createWithFormat("Panel_%d", i)->getCString()));
// 		 scroPanel[i]->setBackGroundColor(ccc3(150,200,255));
// 	 }
}