//------------------------------------------------------------------
//
// ScrollBar2
//
//------------------------------------------------------------------
void CommonScrollBar2::onEnter()
{
    CommonDemo::onEnter();
	
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	
	CCSize size = CCSizeMake(visibleSize.width * 4 / 5, visibleSize.height * 3 / 5);
	CCScrollView* scroll = CCScrollView::create(size);
    scroll->ignoreAnchorPointForPosition(false);
    scroll->setAnchorPoint(ccp(0.5f, 0.5f));
    scroll->setPosition(ccp(origin.x + visibleSize.width / 2,
							origin.y + visibleSize.height / 2));
    scroll->setDirection(kCCScrollViewDirectionVertical);
    addChild(scroll);
	
	CCLayer* content = createScrollContent(size);
    scroll->addChild(content);
    scroll->setContentSize(content->getContentSize());
    scroll->setContentOffset(scroll->minContainerOffset());
    
    // vertical bar
	CCScale9Sprite* track = CCScale9Sprite::create("Images/track.png");
	CCSprite* thumb = CCSprite::create("Images/thumb.png");
	CCScrollBar* vsb = CCScrollBar::create(track, thumb);
	vsb->setAutoFade(true);
	vsb->attachToCCScrollView(scroll, cci(5, 5, 5, 5));
}
Beispiel #2
0
bool BanTimeView::init(int type ,const char *content,const char * buttonName, int timeJson){
    m_type = type;
//    this->setIsHDPanel(true);
    CCNode* _rootNode = _rootNode = CCBLoadFile("YesNoDialog.ccbi", this, this);
//    auto bg = CCBLoadFile("GoldExchangeView_NEW", this, this,true);
//    CCSize winsize = CCDirector::sharedDirector()->getWinSize();
//    this->setContentSize(winsize);
    bool bRet=false;
    if (_rootNode) {
//        mContents.clear();
        CCSize size=CCDirector::sharedDirector()->getWinSize();
        setContentSize(size);
        //label可滑动,放在scrollview上
        m_contentLabel = CCLabelTTF::create();
        m_contentLabel->setDimensions(CCSize(360, 0));
        m_contentLabel->setString(content);
        m_contentLabel->setColor(ccWHITE);
        m_contentLabel->setFontSize(24);
        m_contentLabel->setVerticalAlignment(kCCVerticalTextAlignmentTop);
        m_contentLabel->setHorizontalAlignment(kCCTextAlignmentLeft);
        m_contentLabel->setPosition(ccp(0, -10));
        int totalHeight = m_contentLabel->getContentSize().height ;/** m_contentLabel->getOriginScaleY();*/
        if(totalHeight > m_subLayer->getContentSize().height + 5){
            
            CCScrollView* scroll = CCScrollView::create(CCSize(360, 200));
            scroll->setContentSize(CCSize(360, m_contentLabel->getContentSize().height/**m_contentLabel->getOriginScaleY()*/));
            m_contentLabel->setAnchorPoint(Point(0,0));
            scroll->addChild(m_contentLabel);
            m_subLayer->addChild(scroll);
            float gapWidth = 360-m_contentLabel->getContentSize().width/**m_contentLabel->getOriginScaleX()*/;
            scroll->setPosition(ccp(gapWidth/2, 5));
            scroll->setDirection(kCCScrollViewDirectionVertical);
            scroll->setAnchorPoint(ccp(0, 0));
            scroll->setContentOffset(ccp(0, 200-m_contentLabel->getContentSize().height/**m_contentLabel->getOriginScaleY()*/));
            //            }
        }else{
            m_subNode->addChild(m_contentLabel);
            m_contentLabel->setAnchorPoint(ccp(0, 1));
            float gapWidth = 360-m_contentLabel->getContentSize().width/**m_contentLabel->getOriginScaleX()*/;
            m_contentLabel->setPosition(ccp(gapWidth/2, 0));
        }
        CCCommonUtils::setButtonTitle(m_btnOk, buttonName);
        
        this->m_btnText->setString(buttonName);
        
        CCCommonUtils::setButtonTitle(m_btnCancel, _lang("cancel_btn_label").c_str());
        this->m_goldIcon->setVisible(false);
        this->m_goldNum->setVisible(false);
        this->m_btnText->setVisible(false);
        this->m_btnCancel->setVisible(false);
        this->m_muteTimeNode->setVisible(false);
        bRet=true;
        
        // change btn priority to prevent touch swallowed by others (CCControl class must change it's DefaultTouchPriority)
        m_btnOk->setTouchPriority(-1);
        m_btnCancel->setTouchPriority(-1);
        
        m_noticeNode->setVisible(false);
        m_noticeLabel->setString(_lang("102109"));
        m_timeLabel->setString("");
        m_timeLabel->setColor(ccYELLOW);
        
//        m_time=-1;
//        m_isBuild=true;
        m_isAlliance = false;
        m_closeAll = false;
        serverUpdateInfo(content, timeJson);
    }
    return bRet;
}
Beispiel #3
0
void PropSpeedupView::refreshView(CCObject* ccObj){
    if(m_clickIndex > -1 && m_clickIndex<m_Tools.size()){
        
        m_isSendingCMD=false;
        m_sprSelect->removeFromParent();
        m_sprSelect=NULL;
        CCPoint offset = m_scrollView->getContentOffset();
        CCSize nodeSize = m_nodeProp1->getContentSize();
        CCScrollView *scroll = CCScrollView::create(nodeSize);
        scroll->setDirection(kCCScrollViewDirectionHorizontal);
        scroll->setTouchEnabled(false);
        m_nodeProp1->addChild(scroll);
        std::vector<int>::iterator iter = m_Tools.begin();
        int index =0;
        while (iter!=m_Tools.end()) {
            auto &info = ToolController::getInstance()->getToolInfoById((*iter));
            if(info.getCNT()>0){
                PropSpeedupCell* cell = PropSpeedupCell::create(info.itemId);
                scroll->addChild(cell);
                cell->setPosition(ccp(PROP_SPEEDUP_CELL_W * (index + .5), PROP_SPEEDUP_CELL_W * 1.1));
                ++index;
                ++iter;
            }else{
                m_Tools.erase(iter);
            }
        }
        if(m_clickIndex >= m_Tools.size()){
            m_clickIndex = m_Tools.size() - 1;
        }
        scroll->setContentOffset(offset);
        m_scrollView->removeFromParent();
        m_scrollView = scroll;
        m_sprSelect=CCLoadSprite::createScale9Sprite("sel_general.png");
        m_sprSelect->setInsetBottom(10);
        m_sprSelect->setInsetTop(10);
        m_sprSelect->setInsetLeft(10);
        m_sprSelect->setInsetRight(10);
        m_sprSelect->setPreferredSize(CCSize(PROP_SPEEDUP_CELL_W, PROP_SPEEDUP_CELL_W));
        m_partileNode = Node::create();
        m_sprSelect->addChild(m_partileNode);
        auto particle = ParticleController::createParticle("Speedupicon_1");
        particle->setPosition(m_sprSelect->getContentSize() / 2);
        m_partileNode->addChild(particle);
        m_scrollView->addChild(m_sprSelect);
        m_sprSelect->setZOrder(-1);
        setSelectSpritePosition();
        autoBoundsScroll();
        refreshEditBox();
        {
            this->unschedule(schedule_selector(PropSpeedupView::updateProgressBar));
            auto& qInfo = GlobalData::shared()->allQueuesInfo[m_qID];
            float sumTime = qInfo.totalTime;
            float curTime = qInfo.finishTime - GlobalData::shared()->getWorldTime();
            float scaleXDst = 1 - curTime * 1.0 / sumTime;
//            float scaleYNow = m_progressTime->getScaleX();
            float scaleY = m_progressTime->getScaleY();
            m_progressTime->stopAllActions();
            this->unschedule(CC_SCHEDULE_SELECTOR(PropSpeedupView::showProTxt));
            this->schedule(CC_SCHEDULE_SELECTOR(PropSpeedupView::showProTxt));
            ScaleTo* sc = ScaleTo::create(1.0, scaleXDst, scaleY);
            auto fun1 = [=](){
                this->unschedule(CC_SCHEDULE_SELECTOR(PropSpeedupView::showProTxt));
                this->unschedule(schedule_selector(PropSpeedupView::updateProgressBar));
                this->updateProgressBar(0);
                this->schedule(schedule_selector(PropSpeedupView::updateProgressBar), 1);
            };
            CallFunc* cfun1 = CallFunc::create(fun1);
            m_progressTime->runAction(Sequence::create(sc, cfun1, nullptr));
        }
    }
    
    if(m_Tools.size()==0){
        closeDialog();
    }else{
//        m_clickIndex = -1;
        m_isSendingCMD=false;
        if(m_waitInterface){
            m_waitInterface->removeFromParent();
            m_waitInterface=NULL;
        }
        CCSafeNotificationCenter::sharedNotificationCenter()->removeObserver(this,  MSG_QUEUE_TIME_UPDATE);
    }
}
Beispiel #4
0
bool MailWritePopUpView::initWithGift(int giftID,int propID) {
    if(!PopupBaseView::init()) {
        return false;
    }
    setIsHDPanel(true);
    mPropID = propID;
    mType = 1;
//    auto cf = CCLoadSprite::getSF("Mail_diban.png");
    auto cf = CCLoadSprite::getSF("Mail_BG1.png");
    if (cf==NULL) {
        CCLoadSprite::doResourceByCommonIndex(11, true);
        CCLoadSprite::doResourceByCommonIndex(6, true);
        setCleanFunction([]() {
            CCLoadSprite::doResourceByCommonIndex(11, false);
            CCLoadSprite::doResourceByCommonIndex(6, false);
        });
    }
    else {
        CCLoadSprite::doResourceByCommonIndex(11, true);
        setCleanFunction([]() {
            CCLoadSprite::doResourceByCommonIndex(11, false);
        });
    }

    auto bg = CCBLoadFile("NEWMailWriteView", this, this);
    if (CCCommonUtils::isIosAndroidPad()) {
        this->setContentSize(CCDirector::sharedDirector()->getWinSize());
    }
    else
        this->setContentSize(bg->getContentSize());
//    setTitleName(_lang("105513"));
    m_titleText->setString(_lang("105513"));
    if (CCCommonUtils::isIosAndroidPad()) {
        int extH = getExtendHeight();
        this->m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + extH));
        m_downNode->setPositionY(m_downNode->getPositionY() - extH);
        m_bgNode->setPositionY(m_bgNode->getPositionY() - extH);
//        m_nodeContent->setPositionY(m_nodeContent->getPositionY() - extH);
        auto tbg = CCLoadSprite::loadResource("Mail_diban.png");
        auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
        auto picBg1 = CCLoadSprite::createSprite("Mail_diban.png");
        picBg1->setAnchorPoint(ccp(0, 0));
        picBg1->setPosition(ccp(0, 0));
        picBg1->setScaleX(2.4);
        tBatchNode->addChild(picBg1);
        int maxHeight = CCDirector::sharedDirector()->getWinSize().height;
        int curHeight = picBg1->getContentSize().height;
        while(curHeight < maxHeight)
        {
            auto picBg2 = CCLoadSprite::createSprite("Mail_diban.png");
            picBg2->setAnchorPoint(ccp(0, 0));
            picBg2->setPosition(ccp(0, curHeight));
            picBg2->setScaleX(2.4);
            tBatchNode->addChild(picBg2);
            curHeight += picBg2->getContentSize().height;
        }
        m_bgNode->addChild(tBatchNode);
    }
    else {
        int extH = getExtendHeight();
        this->m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + extH));
        m_downNode->setPositionY(m_downNode->getPositionY() - extH);
        m_bgNode->setPositionY(m_bgNode->getPositionY() - extH);
//        m_nodeContent->setPositionY(m_nodeContent->getPositionY() - extH);
        auto tbg = CCLoadSprite::loadResource("Mail_diban.png");
        auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
        auto picBg1 = CCLoadSprite::createSprite("Mail_diban.png");
        picBg1->setAnchorPoint(ccp(0, 0));
        picBg1->setPosition(ccp(0, 0));
        tBatchNode->addChild(picBg1);
        int maxHeight = CCDirector::sharedDirector()->getWinSize().height;
        int curHeight = picBg1->getContentSize().height;
        while(curHeight < maxHeight)
        {
            auto picBg2 = CCLoadSprite::createSprite("Mail_diban.png");
            picBg2->setAnchorPoint(ccp(0, 0));
            picBg2->setPosition(ccp(0, curHeight));
            tBatchNode->addChild(picBg2);
            curHeight += picBg2->getContentSize().height;
        }
        m_bgNode->addChild(tBatchNode);
    }
//    CCSize wNodeSize = this->m_waitingNode->getContentSize();
//    m_waitingNode->setContentSize(CCSize(wNodeSize.width,wNodeSize.height + dh));
//    m_waitingNode->setPositionY(m_waitingNode->getPositionY() - dh*0.5);

//    this->m_nameText->setString(_lang("105505").c_str());
    //    this->m_titleText->setString(_lang("105503").c_str());
//    this->m_contentText->setString(_lang("105504").c_str());

    CCNode *searchnode = CCNode::create();
    auto spr1 = CCLoadSprite::createScale9Sprite("button_dark.png");
    CCControlButton *shareBtn = CCControlButton::create(spr1);
    searchnode->addChild(shareBtn);
    shareBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(MailWritePopUpView::onChooseName), CCControlEventTouchUpInside);
    CCSprite* sprIcon = CCLoadSprite::createSprite("search_icon.png");
    CCSize sprSize = sprIcon->getContentSize();
    searchnode->addChild(sprIcon);
    CCCommonUtils::setSpriteMaxSize(sprIcon, 40);
    shareBtn->setPreferredSize(CCSize(60, 60));
    this->m_nameContainer->addChild(searchnode);
    searchnode->setPosition(440, 0);

    CCScrollView *scrollView = CCScrollView::create(m_listNode->getContentSize());
    scrollView->setTouchPriority(Touch_Popup_Item);
    scrollView->setDirection(kCCScrollViewDirectionVertical);
    m_nodeContent->removeFromParentAndCleanup(false);
    scrollView->addChild(m_nodeContent);
    scrollView->setTag(10000);
    m_nameEditBox = InputFieldMultiLine::create(CCSizeMake(380,40),"Mail_write.png",24);
//    m_nameEditBox->setTouchPriority(Touch_Default);
    m_nameEditBox->setMaxChars(30);
    m_nameEditBox->setPosition(ccp(0, -20));
    m_nameEditBox->setLineNumber(1);
    m_nameEditBox->setFontColor({63,44,27});

    this->m_nameContainer->addChild(m_nameEditBox);
    m_nameEditBox->m_enabled = (mPropID == ITEM_SEND_GIFTALLIANCE || mPropID == ITEM_SEND_GIFT || mPropID == ITEM_SEND_GIFTMORE)?false:true;

    m_contentEditBox = InputFieldMultiLine::create(m_contentContainer->getContentSize(),"Mail_write.png",24);
    m_contentEditBox->setTouchPriority(Touch_Default);
    m_contentEditBox->setMaxChars(300);
    m_contentEditBox->setLineNumber(5);
    m_contentEditBox->setPosition(ccp(0, 0));
    m_contentEditBox->setFontColor({63,44,27});
    this->m_contentContainer->addChild(m_contentEditBox);
    m_contentEditBox->setText(_lang("101383"));
    CCSize liseNodeSize = this->m_listNode->getContentSize() * m_listNode->getScale();
    MailGiftCell *mailGiftCell = MailGiftCell::create(CCSize(liseNodeSize.width, liseNodeSize.height - 110),mPropID,giftID);
    scrollView->addChild(mailGiftCell);
    mailGiftCell->setTag(10000);
    CCSize cellSize = mailGiftCell->getContentSize();
    int needH = ceil(cellSize.height + 400);
    int nowH = m_listNode->getContentSize().height;
    m_nodeContent->setPosition(ccp(300,cellSize.height + 100));
    mailGiftCell->setPosition(ccp(0,0));
    m_listNode->addChild(scrollView);
    scrollView->setContentSize(CCSize(600,400 + cellSize.height));
    scrollView->setContentOffset(ccp(0, nowH - needH));

    if(needH>nowH) {
        scrollView->setTouchEnabled(true);
    } else {
        scrollView->setTouchEnabled(false);
    }

    if(!m_toName.empty()) {
        m_nameEditBox->setText(m_toName.c_str());
        m_nameEditBox->setEnabled(false);
    }
    updateBtnStatus();

    return true;
}