Ejemplo n.º 1
0
Node* LHGameChat::waitView(){
    Size vs = Director::getInstance()->getVisibleSize();
    Vec2 vo = Director::getInstance()->getVisibleOrigin();
    
    auto lo = ui::Layout::create();
    Size sz = Size(vs.width/2,vs.height/4);
    lo->setSize(sz);
    lo->setPosition(Vec2(vs.width/2 - sz.width/2, vs.height/2 - sz.height/2));
    lo->setBackGroundColorType(cocos2d::ui::Layout::BackGroundColorType::SOLID);
    lo->setBackGroundColor(Color3B::GRAY);
    lo->setBackGroundColorOpacity(200);
    
    auto load = ui::Text::create("Loading...", Common_Font, 30);
    load->setColor(Color3B::GREEN);
    load->setPosition(Vec2(sz.width/2, lo->getSize().height/2));
    auto cancel = ui::Button::create("close.png");
    cancel->setPosition(Vec2(sz.width/2, lo->getSize().height/2 - load->getContentSize().height - 20));
    cancel->addTouchEventListener([](Ref *ps,ui::Widget::TouchEventType type){
        if (type == ui::Widget::TouchEventType::ENDED) {
            if (_chatManager) {
                _chatManager->disconnect();
                delete _chatManager;
                _chatManager = nullptr;
                
                LHDialog::disMissDialog();
            }
        }
    });
    
    lo->addChild(load);
    lo->addChild(cancel);
    return lo;
}
Ejemplo n.º 2
0
bool LHDialog::init(){
    Size vs = Director::getInstance()->getVisibleSize();
    Vec2 vo = Director::getInstance()->getVisibleOrigin();
    setPosition(vo);
    setSize(vs);
    
    auto rs = Director::getInstance()->getRunningScene();
    rs->addChild(this);
    
    setBackGroundColorType(cocos2d::ui::Layout::BackGroundColorType::SOLID);
    setBackGroundColor(Color3B::BLACK);
    setBackGroundColorOpacity(200);
    
    return true;
}
Ejemplo n.º 3
0
void UILayout::copySpecialProperties(UIWidget *widget)
{
    UILayout* layout = dynamic_cast<UILayout*>(widget);
    if (layout)
    {
        setBackGroundImageScale9Enabled(layout->m_bBackGroundScale9Enabled);
        setBackGroundImage(layout->m_strBackGroundImageFileName.c_str(),layout->m_eBGImageTexType);
        setBackGroundImageCapInsets(layout->m_backGroundImageCapInsets);
        setBackGroundColorType(layout->m_colorType);
        setBackGroundColor(layout->m_cColor);
        setBackGroundColor(layout->m_gStartColor, layout->m_gEndColor);
        setBackGroundColorOpacity(layout->m_nCOpacity);
        setBackGroundColorVector(layout->m_AlongVector);
        setLayoutType(layout->m_eLayoutType);
        setClippingEnabled(layout->m_bClippingEnabled);
    }
}
Ejemplo n.º 4
0
void Layout::copySpecialProperties(Widget *widget)
{
    Layout* layout = dynamic_cast<Layout*>(widget);
    if (layout)
    {
        setBackGroundImageScale9Enabled(layout->_backGroundScale9Enabled);
        setBackGroundImage(layout->_backGroundImageFileName,layout->_bgImageTexType);
        setBackGroundImageCapInsets(layout->_backGroundImageCapInsets);
        setBackGroundColorType(layout->_colorType);
        setBackGroundColor(layout->_cColor);
        setBackGroundColor(layout->_gStartColor, layout->_gEndColor);
        setBackGroundColorOpacity(layout->_cOpacity);
        setBackGroundColorVector(layout->_alongVector);
        setLayoutType(layout->_layoutType);
        setClippingEnabled(layout->_clippingEnabled);
        setClippingType(layout->_clippingType);
        _loopFocus = layout->_loopFocus;
        _passFocusToChild = layout->_passFocusToChild;
        _isInterceptTouch = layout->_isInterceptTouch;
    }
}
Ejemplo n.º 5
0
Layout * Mx::createDialog(Node* child, Node * parent, Size innerSize, DialogBtn buttonStyle, string background){
    auto layout = Layout::create();
    auto size = parent->getContentSize();
    auto dialogSize = Size(innerSize.width + 30, innerSize.height + 30);
    parent->addChild(layout, 999);
    layout->setContentSize(size);
    layout->setBackGroundColorType(cocos2d::ui::Layout::BackGroundColorType::SOLID);
    layout->setBackGroundColor(Color3B::BLACK);
    layout->setBackGroundColorOpacity(150);
    layout->setTouchEnabled(true);

    auto diaLayout = Layout::create();
    layout->addChild(diaLayout);
    diaLayout->setContentSize(innerSize);
    diaLayout->setClippingEnabled(false);
    diaLayout->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
    diaLayout->setPosition(Vec2(dialogSize.width/2, dialogSize.height/2));
    diaLayout->setScale(0);
    diaLayout->setBackGroundImageScale9Enabled(true);
    if (background == "") {
        diaLayout->setBackGroundImage("sys_toast_b.png");
    }else{
        diaLayout->setBackGroundImage(background);
    }
    
    diaLayout->setPosition(size/2);
    
    if (child != nullptr) {
        diaLayout->addChild(child);
    }
    
    // set button;
    {
        if (buttonStyle.buttonNum != 0) {
        
            if (buttonStyle.closeText == "") {
                buttonStyle.closeText = this->getStrValue("close");
            }
            auto buttonConfirm = this->createDialogButton(buttonStyle, buttonStyle.confirmText);
            auto buttonClose = this->createDialogButton(buttonStyle, buttonStyle.closeText);

            if (buttonStyle.buttonNum == 1) {
                buttonConfirm->setPosition(Vec2((dialogSize/2).width, 0));
                diaLayout->addChild(buttonConfirm);
            }else{
            
                Size size = buttonConfirm->getContentSize()/2;
                Size center = dialogSize/2;
                buttonConfirm->setPosition(Vec2(center.width - size.width, 0));
                buttonClose->setPosition(Vec2(center.width + size.width, 0));
                diaLayout->addChild(buttonConfirm);
                diaLayout->addChild(buttonClose);
            }
        }
        if (buttonStyle.isVisibleClose) {
            auto buttonClose = this->createDialogCloseButton(buttonStyle, buttonStyle.closeText, layout, diaLayout);
            diaLayout->addChild(buttonClose);
            buttonClose->setPosition(diaLayout->getContentSize() - buttonClose->getContentSize()/2 + Size(25, 25));
        }
    }
    auto action = EaseBackOut::create(ScaleTo::create(.3, 1));
    diaLayout->runAction(action);
    return layout;
}