コード例 #1
0
void ZItemCountDlg::Open(ZITEMCOUNTDLG_MODE mode, const char* szItemName, CCBitmap* pIcon, int price, int nMin, int nMax, IItemCountDlgDoneHandler* pHandler )
{
	m_mode = mode;
	m_strItemName = szItemName;
	m_pItemIcon = pIcon;
	m_nPrice = price;
	m_nMin = nMin;
	m_nMax = nMax;
	m_pDoneHandler = pHandler;

	if (m_nMin > m_nMax || m_nMin < 0 || m_nMax < 0)
	{
		_ASSERT(0);
		m_nMin = m_nMax = 0;
	}

	m_nCurrCount = 1;

	CCFrame* pFrame = (CCFrame*)GetIDLResource()->FindWidget("TradeCountableItemFrame");
	CCLabel* pLabel1 = (CCLabel*)GetIDLResource()->FindWidget("TradeCountableItem_Message");
	CCLabel* pLabel2 = (CCLabel*)GetIDLResource()->FindWidget("TradeCountableItem_NullLabel");
	CCButton* pBtn = (CCButton*)GetIDLResource()->FindWidget("TradeCountableItem_Ok");

	switch (m_mode) {
		case ZICD_SELL:
			if (pFrame) pFrame->SetText(ZMsg(MSG_SHOPEQUIP_SELL_ITEM));
			if (pLabel1) pLabel1->SetText(ZMsg(MSG_SHOPEQUIP_SELL_COUNT_ASK));
			if (pLabel2) pLabel2->SetText(ZMsg(MSG_SHOPEQUIP_SELL_COUNT));
			if (pBtn) pBtn->SetText(ZMsg(MSG_SHOPEQUIP_SELL_BUTTON));
			break;
		case ZICD_BUY:
			if (pFrame) pFrame->SetText(ZMsg(MSG_SHOPEQUIP_BUY_ITEM));
			if (pLabel1) pLabel1->SetText(ZMsg(MSG_SHOPEQUIP_BUY_COUNT_ASK));
			if (pLabel2) pLabel2->SetText(ZMsg(MSG_SHOPEQUIP_BUY_COUNT));
			if (pBtn) pBtn->SetText(ZMsg(MSG_SHOPEQUIP_BUY_BUTTON));
			break;
		case ZICD_SENDACCOUNT:
			if (pFrame) pFrame->SetText(ZMsg(MSG_SHOPEQUIP_SEND_ITEM));
			if (pLabel1) pLabel1->SetText(ZMsg(MSG_SHOPEQUIP_SEND_COUNT_ASK));
			if (pLabel2) pLabel2->SetText(ZMsg(MSG_SHOPEQUIP_SEND_COUNT));
			if (pBtn) pBtn->SetText(ZMsg(MSG_SHOPEQUIP_SEND_BUTTON));
			break;
		case ZICD_BRINGACCOUNT:
			if (pFrame) pFrame->SetText(ZMsg(MSG_SHOPEQUIP_BRING_ITEM));
			if (pLabel1) pLabel1->SetText(ZMsg(MSG_SHOPEQUIP_BRING_COUNT_ASK));
			if (pLabel2) pLabel2->SetText(ZMsg(MSG_SHOPEQUIP_BRING_COUNT));
			if (pBtn) pBtn->SetText(ZMsg(MSG_SHOPEQUIP_BRING_BUTTON));
			break;
	}

	UpdateDlg();

	CCWidget* pWidget = GetIDLResource()->FindWidget( "TradeCountableItemFrame");
	if ( pWidget)
		pWidget->Show( true, true);

	pWidget = GetIDLResource()->FindWidget( "TradeCountableItem_CountNum");
	if ( pWidget)
		pWidget->SetFocus();
}
コード例 #2
0
ファイル: LevelSelectScene.cpp プロジェクト: rapito/CrossPath
void LevelSelectScene::ccTouchesBegan(CCSet* touches, CCEvent* touchEvent)
{
	CCTouch* touch = (CCTouch*)touches->anyObject();
	CCButton *touchedBut = 0;
	if(_btnBack.collidesWith(&touch->getLocation()))
	{
		touchedBut = &_btnBack;
	}
	else
	{
		for(int i = 0 ; i<(int)_btnLevelsVector.size();i++)
		{
			CCButton* but = _btnLevelsVector[i];
			if (but->collidesWith(&touch->getLocation()))
			{
				touchedBut = but;
				i = (int)_btnLevelsVector.size()+1;
			}
		}
	}
	if(touchedBut)
	{
		touchedBut->onTriggered();
	}

}
コード例 #3
0
void BWCombatLayer::initUILayer()
{
    Size contentSize = getContentSize();

    CCButton*  pBtnBack = CCButton::create("back",COMMON_FONT,50);
    pBtnBack->setPosition(Point(50,contentSize.height-50));
    pBtnBack->addTargetWithActionForControlEvents(this, cccontrol_selector(BWCombatLayer::clickBack), Control::EventType::TOUCH_UP_INSIDE);
    _pBgLayerUI->addChild(pBtnBack);

}
コード例 #4
0
 CCButton * CCButton::buttonWithFiles(CCObject* target, SEL_MenuHandler selector,const char * mNormal,const char * mSelected,const char * mDisabled)
{
    CCButton *pRet = new CCButton();
    if (pRet)
    {
        pRet->initWithFile(target, selector,mNormal,mSelected,mDisabled);
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet)
    return NULL;
}
コード例 #5
0
ファイル: LevelSelectScene.cpp プロジェクト: rapito/CrossPath
bool LevelSelectScene::setLevelButtons()
{
	_btnLevelsVector = vector<CCLevelButton*>();
	LevelManager::getInstance()->initLevelsButtons(&_btnLevelsVector,"LevelArchive.CPLA");
	
	for(int i = 0 ; i<(int)_btnLevelsVector.size();i++)
	{
		CCButton* but = _btnLevelsVector[i];
		but->addToScene(this,2);
	}
	return true;
}
コード例 #6
0
ファイル: CCButtonTest.cpp プロジェクト: kkkkiven/CocosWidget
bool CCButtonBasicTest::init()
{
	CCButtonTestSceneBase::init();
	setTitle("CCButtonBasicTest");
	setDescription("button by create");

	CCButton* pButton = CCButton::create("btn1_1.png", "btn1_2.png", "btn1_3.png");
	pButton->setPosition(ccp(480, 320));
	m_pLayout->addChild(pButton);

	return true;
}
コード例 #7
0
bool CCTableGridBackPackTest::onItemLongClick(CCObject* pSender)
{
	CCButton* pIconButton = (CCButton*) pSender;
	pIconButton->setVisible(false);

	CCPoint tPoint = pIconButton->getParent()->convertToWorldSpace(pIconButton->getPosition());

	m_pSelectedSprite->setVisible(true);
	m_pSelectedSprite->setPosition(tPoint);

	return true;
}
コード例 #8
0
void ZSellCashItemConfirmDlg::Update()
{
	if (!m_bWaitActivatingOkBtn) return;

	DWORD currTime = timeGetTime();
	if (currTime - m_nWaitActivatingOkBtnBeginTime > 3000)
	{
		m_bWaitActivatingOkBtn = false;

		CCButton* pButton = (CCButton*)GetIDLResource()->FindWidget("SellCashItemConfirmFrame_Sell");
		if (pButton)
			pButton->Enable(true);
	}
}
コード例 #9
0
CCButton *CCBar::addButton(const QPixmap &pix)
{
	m_buttonCount++;
	
	m_mask = QPixmap( (m_buttonCount+1)*m_radio+m_offset*3, m_radio+10);
	m_mask.fill(Qt::transparent);
	
	CCButton *but = new CCButton(m_radio,true, this);
	
	
	m_layout->addWidget(but);
	but->setIcon(pix);
	
	return but;
}
コード例 #10
0
//=============================================================
//=============================================================
CCButton* CC3DCircleListLayer::getSelectedButton()
{
    CCButton* pSelButton = NULL;
    int nSelZOrder = 0;
    for(int i=0;i<m_pButtonArray->count();i++)
    {
        CCButton* pButton = (CCButton*)m_pButtonArray->objectAtIndex(i);
        int nZOrder = pButton->getZOrder();
        if(nZOrder > nSelZOrder)
        {
            pSelButton = pButton;
        }
        nSelZOrder = pSelButton->getZOrder();
    }
    return pSelButton;
}
コード例 #11
0
void CCTableGridBackPackTest::onLayoutTouchEndedAfterLongClick(CCObject* pSender, CCTouch* pTouch, float fDuration)
{
	CCButton* pIconButton = (CCButton*) pSender;
	
	m_pSelectedSprite->setPosition(pTouch->getLocation());

	CCPoint tLayoutPoint = m_pLayout->convertTouchToNodeSpace(pTouch);
	if( m_pToggleImage->boundingBox().containsPoint(tLayoutPoint) )
	{
		m_vData.erase(m_vData.begin() + pIconButton->getUserTag());
		pTable->setCountOfCell(m_vData.size());
		pTable->reloadData();
	}

	pIconButton->setVisible(true); //back to the same as before drag
	m_pSelectedSprite->setVisible(false);
	m_pToggleImage->setChecked(false);
}
コード例 #12
0
CCTableGridCell* CCTableGridBackPackTest::tableviewDataSource(CCTableGrid* pTable, CCTableGridCell* pCell, unsigned int idx)
{
	CCButton* pIconButton = NULL;

	if(!pCell)
	{
		pCell = new CCTableGridCell();
		pCell->autorelease();

		CC9Sprite* pBg = CC9Sprite::create("sprite9_btn1.png");
		pBg->setContentSize(CCSize(70, 70));
		pBg->setPosition(ccp(320 / 4 / 2, 390 / 5 / 2));
		pCell->addChild(pBg);

		pIconButton = CCButton::create("icon.png");
		pIconButton->setLongClickSelector(this, longclick_selector(CCTableGridBackPackTest::onItemLongClick));
		pIconButton->getTextTTF()->setFontSize(25);
		pIconButton->setPosition(ccp(320 / 4 / 2, 390 / 5 / 2));
		pIconButton->setTextOffset(ccp(-15, -15));
		pIconButton->setTag(1);
		pCell->addChild(pIconButton);
	}
	else
	{
		pIconButton = (CCButton*) pCell->getChildByTag(1);
	}

	if( idx != CC_INVALID_INDEX )
	{
		pIconButton->setVisible(true);

		pIconButton->getTextTTF()->setString(m_vData[idx].c_str());
		pIconButton->setUserTag(idx);
	}
	else
	{
		pIconButton->setVisible(false);
	}

	return pCell;
}
コード例 #13
0
ファイル: CCButtonTest.cpp プロジェクト: kkkkiven/CocosWidget
bool CCButton9SpriteTest::init()
{
	CCButtonTestSceneBase::init();
	setTitle("CCButtonAttributeTest");
	setDescription("9PatchSprite by create");

	CCButton* pButton = CCButton::createWith9Sprite(CCSize(196, 68),"sprite9_btn1.png", "sprite9_btn2.png");
	pButton->getTextTTF()->initWithString("one", "", 30.0f);
	pButton->setPosition(ccp(480, 370));
	m_pLayout->addChild(pButton);

	CCButton* pButton2 = CCButton::create();
	pButton2->setContentSize(CCSize(196, 68));
	pButton2->set9SpriteEnabled(true);
	pButton2->setNormalImage("sprite9_btn1.png");
	pButton2->setSelectedImage("sprite9_btn2.png");
	pButton2->getTextTTF()->initWithString("two", "", 30.0f);
	pButton2->setPosition(ccp(480, 270));
	m_pLayout->addChild(pButton2);

	return true;
}
コード例 #14
0
void ZSellCashItemConfirmDlg::Open(const char* szItemName, CCBitmap* pIcon, int price, int count, ISellCashItemConfirmDlgDoneHandler* pHandler)
{
	CCPicture* pPicture = (CCPicture*)GetIDLResource()->FindWidget("SellCashItemConfirmFrame_Thumbnail");
	if (pPicture)
		pPicture->SetBitmap(pIcon);

	CCLabel* pLabel = (CCLabel*)GetIDLResource()->FindWidget("SellCashItemConfirmFrame_ItemName");
	if (pLabel)
		pLabel->SetText(szItemName);

	char szPrice[256];
	sprintf(szPrice, "%d %s", price, ZMsg(MSG_CHARINFO_BOUNTY));
	pLabel = (CCLabel*)GetIDLResource()->FindWidget("SellCashItemConfirmFrame_Bounty");
	if (pLabel)
		pLabel->SetText(szPrice);

	CCTextArea* pTextArea = (CCTextArea*)GetIDLResource()->FindWidget("SellCashItemConfirmFrame_Warning");
	if (pTextArea)
		pTextArea->SetText( ZMsg(MSG_SHOPEQUIP_SELL_CASHITEM_CONFIRM));

	CCFrame* pFrame = (CCFrame*)GetIDLResource()->FindWidget("SellCashItemConfirmFrame");
	if (pFrame)
	{
		pFrame->Show(true, true);
	}

	m_pDoneHandler = pHandler;

	// 유저가 지금 팔고자 하는 캐쉬아이템을 확실히 인지할수 있는 시간을 주기 위해 OK 버튼을 몇초후 활성화시킨다
	CCButton* pButton = (CCButton*)GetIDLResource()->FindWidget("SellCashItemConfirmFrame_Sell");
	if (pButton)
	{
		pButton->Enable(false);
		m_bWaitActivatingOkBtn = true;
		m_nWaitActivatingOkBtnBeginTime = timeGetTime();
	}
}
コード例 #15
0
ファイル: BWHomeLayer.cpp プロジェクト: bingwan/PlaneClasses
void BWHomeLayer::initUI()
{
    Size cntentSize = getContentSize();
    CCButton*  pBtnCloseGuide = CCButton::create("level",COMMON_FONT,50);
    pBtnCloseGuide->setPosition(Point(cntentSize.width*0.5,cntentSize.height*0.5));
    pBtnCloseGuide->addTargetWithActionForControlEvents(this, cccontrol_selector(BWHomeLayer::clickLevel), Control::EventType::TOUCH_UP_INSIDE);
    addChild(pBtnCloseGuide);
    
    CCButton*  pBtnEdit = CCButton::create("edit",COMMON_FONT,50);
    pBtnEdit->setPosition(Point(cntentSize.width*0.5,cntentSize.height*0.2));
    pBtnEdit->addTargetWithActionForControlEvents(this, cccontrol_selector(BWHomeLayer::clickEdit), Control::EventType::TOUCH_UP_INSIDE);
    addChild(pBtnEdit);
    
}
コード例 #16
0
CCTableGridCell* CCTableGridBasicTest::tableviewDataSource(CCTableGrid* pTable, CCTableGridCell* pCell, unsigned int idx)
{
	CCButton* pButton = NULL;

	if(!pCell)
	{
		pCell = new CCTableGridCell();
		pCell->autorelease();

		pButton = CCButton::createWith9Sprite(CCSizeMake(70, 70), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setPosition(ccp(320 / 4 / 2, 390 / 5 / 2));
		pButton->getTextTTF()->setFontSize(25.0f);
		pButton->setTag(1);
		pCell->addChild(pButton);
	}
	else
	{
		pButton = (CCButton*) pCell->getChildByTag(1);
	}

	if( idx != CC_INVALID_INDEX )
	{
		pButton->setVisible(true);

		char buff[64];
		sprintf(buff, "%u", idx);
		pButton->getTextTTF()->setString(buff);
		pButton->setUserTag(idx);
	}
	else
	{
		pButton->setVisible(false);
	}

	return pCell;
}
コード例 #17
0
//=============================================================
//=============================================================
void CC3DCircleListLayer::refreshItemWithMoveDegree(float fMoveDegree)
{
    float fMoveX = getContentSize().width*0.5;
    float fMoveY = getContentSize().height*0.5;
    
    float fScaleMax = 1;
    float fScaleMin = 0.5;
    
    int zOrderMax = 1000;
    
    //    float fCameraDegreeMax = 45;
    //    float fCameraDegreeMin = 0;
    
    for(int i=0;i<m_pButtonArray->count();i++)
    {
        CCButton* pButton = (CCButton*)m_pButtonArray->objectAtIndex(i);
        CCString* pFOldDegree = (CCString*)pButton->getUserData();
        float fOldDegree  = pFOldDegree->floatValue();
        
        fOldDegree = fabsf(fOldDegree);
        float fCurDegree = fOldDegree + fMoveDegree;
        if(fCurDegree < 0)
        {
            fCurDegree = 2*M_PI - fabsf(fCurDegree);
        }
        int nCircleCount = (int)fCurDegree/(2*M_PI);
        fCurDegree = fCurDegree - nCircleCount*(2*M_PI);
        //=============================================================
        //=============================================================
        delete pFOldDegree;
        CCString* pString = new CCString();
        pString->initWithFormat("%f",fabs(fCurDegree));
        pButton->setUserData(pString);
        //=============================================================
        //=============================================================
        //
        //
        //
        //=============================================================
        //=============================================================
        float fCircleX = m_fEllipseA * cosf(fCurDegree);
        float fCircleY = m_fEllipseB * sinf(fCurDegree);
        fCircleX += fMoveX;
        fCircleY += fMoveY;
        CCPoint buttonPos = ccp(fCircleX,fCircleY);
        pButton->setPosition(buttonPos);
        //=============================================================
        //=============================================================
        //
        //
        //
        //=============================================================
        //=============================================================
        float fScaleDegree = fCurDegree - M_PI_2;
        float fScalePercent = (1-cosf(fScaleDegree))/2.0;
        float fScale = fScaleMin + (fScaleMax - fScaleMin)*fScalePercent;
        pButton->setScale(fScale);
        int nOrder = zOrderMax * fScalePercent + 1;
        pButton->setZOrder(nOrder);
        //=============================================================
        //=============================================================
        
        m_pSelectedButton =  getSelectedButton();
        if(m_pSelectedButton)
        {
            if(m_pDelegate)
            {
                int nIndex = m_pSelectedButton->getTag();
                m_pDelegate->onCC3DCircleListLayerSelectIndex(nIndex);
            }
        }
        
        //        //=============================================================
        //        //camera
        //        //=============================================================
        //        int flagMove = 1;
        //        if(buttonPos.x > getContentSize().width*0.5)
        //        {
        //            flagMove = 1;
        //        }
        //        else
        //        {
        //            flagMove = -1;
        //        }
        //        float fCameraDegree = fCameraDegreeMin + (fCameraDegreeMax - fCameraDegreeMin)*(1-fScalePercent);
        //        fCameraDegree *= -flagMove;
        //        float radians = (float)CC_DEGREES_TO_RADIANS(fCameraDegree);
        //        float fSin = sinf(radians) * CCCamera::getZEye();
        //        CCCamera* pCamera = pButton->getCamera();
        //        pCamera->setCenterXYZ(fSin, 0, 0);
        //        //=============================================================
        //        //=============================================================
    }
}
コード例 #18
0
//=============================================================
//=============================================================
void CC3DCircleListLayer::initDataCircle(float fEllipseA,float fEllipseB,CCSize itemSize,CCArray* pArray,bool bFlipY)
{
    if(!pArray)
        return;
    m_itemSize = itemSize;
    m_fEllipseA = fEllipseA;
    m_fEllipseB = fEllipseB;
    
    int     nAllItemCount = pArray->count();
    float   fCircleStepDegree = (2*M_PI)/nAllItemCount;
    
    float fMoveX = getContentSize().width*0.5;
    float fMoveY = getContentSize().height*0.5;
    
    m_pButtonArray->removeAllObjects();
    for(int i=0;i<nAllItemCount;i++)
    {
        float fCurDegree = fCircleStepDegree * (i+1);
        float fCircleX = m_fEllipseA * cosf(fCurDegree);
        float fCircleY = m_fEllipseB * sinf(fCurDegree);
        
        fCircleX += fMoveX;
        fCircleY += fMoveY;
        
        CCSprite* pSprite = (CCSprite*)pArray->objectAtIndex(i);
        
        CCScale9Sprite* pScaleSprite = CCScale9Sprite::createWithSpriteFrame(pSprite->displayFrame());
        CCButton* pButton = CCButton::create( pScaleSprite);
        pButton->setTag(i);
        pButton->setZoomOnTouchDown(false);
        
        CCPoint point = ccp(fCircleX,fCircleY);
        pButton->setPosition(point);
        
        CCString* pString = new CCString();
        pString->initWithFormat("%f",fCurDegree);
        pButton->setUserData(pString);
        pButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CC3DCircleListLayer::clickButton), CCControlEventTouchUpInside);
        addChild(pButton);
        m_pButtonArray->addObject(pButton);
        
        if(bFlipY)
        {
            CCSize buttonSize = pButton->getContentSize();
            CCSprite* pFlipYSprite = CCSprite::createWithTexture(pSprite->getTexture());
            CCRect oldRect = pSprite->getTextureRect();
            pFlipYSprite->setFlipY(true);
            pFlipYSprite->setOpacity(255*0.5);
            pFlipYSprite->setAnchorPoint(ccp(0.5,1));
            pFlipYSprite->setPosition(ccp(buttonSize.width*0.5,0));
            pButton->addChild(pFlipYSprite);
        }
        
//        CCSize buttonSize = pButton->getContentSize();
//        char testChr[32];
//        sprintf(testChr, "%d",i);
//        CCLabelTTF* pTestLabel = CCLabelTTF::create(testChr, "Arial", 52);
//        pTestLabel->setColor(ccRED);
//        pTestLabel->setPosition(ccp(buttonSize.width*0.5,buttonSize.height*0.5));
//        pButton->addChild(pTestLabel);
        
    }
    refreshItemWithMoveDegree(0);
}