bool UIImageViewTest_Scale9::init()
{
    if (UIScene::init())
    {
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        
        UILabel *alert = UILabel::create();
        alert->setText("ImageView scale9 render");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(ccc3(159, 168, 176));
//        alert->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getRect().size.height * 1.75));
        m_pUiLayer->addWidget(alert);
        
        // Create the ui layer
        UILayer *ul = UILayer::create();
        ul->scheduleUpdate();
        addChild(ul);
        
        // Create the imageview
        UIImageView *imageView = UIImageView::create();
        imageView->setScale9Enabled(true);
        imageView->loadTexture("cocosgui/buttonHighlighted.png");
//        imageView->setScale9Size(CCSizeMake(200, 85));
//        imageView->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f + imageView->getRect().size.height / 4.0f));
        ul->addWidget(imageView);
        
        return true;
    }
    return false;
}
bool UILoadingBarTest::init()
{
    if (UIScene::init())
    {
        scheduleUpdate();
        
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        
        // Add the alert
        UILabel *alert = UILabel::create();
        alert->setText("LoadingBar");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(ccc3(159, 168, 176));
//        alert->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getRect().size.height * 1.75));
        m_pUiLayer->addWidget(alert);
        
        // Create the loading bar
        UILoadingBar* loadingBar = UILoadingBar::create();
        loadingBar->setName("LoadingBar");
        loadingBar->loadTexture("cocosgui/sliderProgress.png");
//        loadingBar->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f + loadingBar->getRect().size.height / 4.0f));
        m_pUiLayer->addWidget(loadingBar);
        
        return true;
    }
    return false;
}
PolycodeProjectBrowser::PolycodeProjectBrowser(PolycodeProject *project) : UIElement() {

    this->project = project;
    headerBg = new UIRect(10,10);
    addChild(headerBg);
    headerBg->setAnchorPoint(-1.0, -1.0, 0.0);
    headerBg->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiHeaderBgColor"));

    UILabel *label = new UILabel("PROJECT BROWSER", 18, "section", Label::ANTIALIAS_FULL);
    label->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiHeaderFontColor"));

    addChild(label);
    label->setPosition(10, 3);


    treeContainer = new UITreeContainer("boxIcon.png", project->getProjectName(), 200, 555);
    treeContainer->getRootNode()->toggleCollapsed();
    treeContainer->getRootNode()->addEventListener(this, UITreeEvent::SELECTED_EVENT);
    treeContainer->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
    treeContainer->setPosition(0, 30);

    BrowserUserData *data = new BrowserUserData();
    data->type = 0;
    data->parentProject = project;
    treeContainer->getRootNode()->setUserData((void*) data)	;

    addChild(treeContainer);
    selectedData = NULL;

    parseFolderIntoNode(treeContainer->getRootNode(), project->getRootFolder());
}
void Scene_GameItem::itemBtnCallBack(cocos2d::CCObject *object)
{
    UIButton* btn = (UIButton*)object;
    UIImageView* img;
    
    //通过游戏的道具信息获取道具价钱.
    sItemData* itemData = CGameInfoMan::sharedInstance().getItemDate(GameShare_Global::shareGlobal()->gameType, btn->getTag());

    UILabel* itemInfo = dynamic_cast<UILabel*>(ul->getWidgetByName("Label_591"));
    
    
    switch (btn->getTag()) {
        case Btn_1:
            img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_1"));
            break;
        case Btn_2:
            img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_2"));
            break;
        case Btn_3:
            img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_3"));
            break;
        case Btn_4:
            img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_4"));
            break;
        default:
            break;
    }
    
    if (img->isVisible()) {
        
        img->setVisible(false);

        if (itemData) {
            CCString infoStr;
            infoStr.initWithFormat("%s:%s",itemData->ItemName.c_str(),itemData->ItemDetail.c_str());
            itemInfo->setText(infoStr.getCString());
            needGold -= itemData->CurrencyValue;
        }
    }else{
        img->setVisible(true);
        if (itemData) {
            CCString infoStr;
            infoStr.initWithFormat("%s:%s",itemData->ItemName.c_str(),itemData->ItemDetail.c_str());
            itemInfo->setText(infoStr.getCString());
            needGold += itemData->CurrencyValue;
            if (CPlayerInfoMan::sharedInstance().getPlayerInfo().nMoney < needGold) {
                GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure);
                needGold -= itemData->CurrencyValue;
                alertUl->setText(GET_STRING_CSV(1010000021));
                this->addChild(alertUl,1);
                img->setVisible(false);
            }
        }
        
    }
    this->setItemByTag(btn->getTag());
}
Beispiel #5
0
UILabel* UI::addLabel(int id, int x, int y, int width, int height, const char* text)
{
    UILabel* label = new UILabel(mRootNode);
    label->nodeID = id;
    label->setPos(x, y);
    label->setText(text);
    label->setSize(width, height);
    nodeList.push_back(label);
    return label;
}
UILabel* UILabel::create()
{
    UILabel* widget = new UILabel();
    if (widget && widget->init())
    {
        return widget;
    }
    CC_SAFE_DELETE(widget);
    return NULL;
}
bool UILabelTest::init()
{
    if (UIScene::init())
    {
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        
        UILabel *alert = UILabel::create();
        alert->setText("Label");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(ccc3(159, 168, 176));
//        alert->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getRect().size.height * 1.75));
        m_pUiLayer->addWidget(alert);
        
        // Create the label
        UILabel* label = UILabel::create();
        label->setText("Label");
        label->setFontName("AmericanTypewriter");
        label->setFontSize(30);
//        label->setPosition(ccp(screenSize.width / 2, screenSize.height / 2 + label->getRect().size.height / 4));
        m_pUiLayer->addWidget(label);
        
        return true;
    }
    return false;
}
void EquipmentUpgradeUILayer::showSecondNextLevelAttributionLabel(const char* text)
{
	if(m_equipmentLayout)
	{
		UILabel* label = m_equipmentLayout->FindChildObjectByName<UILabel>("equipUpgradeChoosedAddNextLevel2");
		if(label)
		{
			label->setString(text);
		}
	}
}
void EquipmentUpgradeUILayer::showCurrentAttributeLabel(const char* text)
{
	if(m_equipmentLayout)
	{
		UILabel* label = m_equipmentLayout->FindChildObjectByName<UILabel>("equipUpgradeChoosedAddSkill");
		if(label)
		{
			label->setString(text);
		}
	}
}
Beispiel #10
0
UILabel* UILabel::create()
{
	UILabel *node = new UILabel();
	if (node)
	{
		node->autorelease();
		return node;
	}
	CC_SAFE_DELETE(node);
	return NULL;
}
Beispiel #11
0
void UILabel::copySpecialProperties(UIWidget *widget)
{
    UILabel* label = dynamic_cast<UILabel*>(widget);
    if (label)
    {
        setFontName(label->_fontName.c_str());
        setFontSize(label->_labelRenderer->getFontSize());
        setText(label->getStringValue());
        setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled);
    }
}
Beispiel #12
0
UILabel* UILabel::create()
{
    UILabel* widget = new UILabel();
    if (widget && widget->init())
    {
        widget->autorelease();
        return widget;
    }
    CC_SAFE_DELETE(widget);
    return nullptr;
}
void EquipmentUpgradeUILayer::showCurrentName(const char* name,const ccColor3B& color)
{
	if(m_equipmentLayout)
	{
		UILabel* label = m_equipmentLayout->FindChildObjectByName<UILabel>("equipUpgradeChoosedName");
		if(label)
		{
			label->setString(name);
			label->setColor(color);
		}
	}
}
void GameLayer_Menu::setInfoNum()
{
    UIImageView* img = dynamic_cast<UIImageView*>(gameMenu->getWidgetByName("Email_RemindImg"));
    if (CPlayerInfoMan::sharedInstance().getPlayerInfo().sysInfoNum <= 0) {
        img->setVisible(false);
    }else{
        img->setVisible(true);
        UILabel* label = dynamic_cast<UILabel*>(gameMenu->getWidgetByName("InfoLabel"));
        CCString str;
        str.initWithFormat("%d",CPlayerInfoMan::sharedInstance().getPlayerInfo().sysInfoNum);
        label->setText(str.getCString());
    }
}
Beispiel #15
0
void UICanvas::showMessageBox(const String& message)
{
	Widget* modalBackground = new Widget();
	
	UIWindow* surface = addSurface("modal");
	surface->attach(modalBackground);
	modalBackground->setRect(surface->getRect());

	UILabel* label = new UILabel(message);
	label->setSize(700,50);
	//label->setCenter(modalBackground->getMiddlePosition());
	modalBackground->attach(label);
};
Beispiel #16
0
void ShopLayer::updateBuyLayout(CCObject* pSender,bool isVis)
{
	UIButton* btn = dynamic_cast<UIButton*>(pSender);
	UILabel* nameLab = dynamic_cast<UILabel*>(m_buyLayout->getChildByName("propNameLabel"));
	nameLab->setText(dynamic_cast<UILabel*>(btn->getChildByName("nameLabel"))->getStringValue());

	UIImageView* discountImg = dynamic_cast<UIImageView*>(m_buyLayout->getChildByName("discountImg"));
	discountImg->setVisible(isVis);
	m_onePri = atoi(dynamic_cast<UILabel*>(btn->getChildByName("priLabel"))->getStringValue());
	m_onePriLabel->setText(CCString::createWithFormat("%d",m_onePri)->getCString());
	m_buyNum = 1;
	m_totalPriLabel->setText(CCString::createWithFormat("%d",m_onePri*m_buyNum)->getCString());
}
Beispiel #17
0
EditorGridSettingsWindow::EditorGridSettingsWindow(EditorGrid *grid) : UIWindow("Grid Settings", 100, 190) {
    
    visible = false;
    enabled = false;
    
    this->grid = grid;
    
    visibleCheck = new UICheckBox("Enabled", grid->visible);
    addChild(visibleCheck);
    visibleCheck->setPosition(10, 40);
    visibleCheck->addEventListener(this, UIEvent::CHANGE_EVENT);
    
    UILabel *label = new UILabel("Size:", 12);
    label->setColor(1.0, 1.0 ,1.0, 1.0);
    addChild(label);
    label->setPosition(10, 70);
    
    sizeInput = new UITextInput(false, 50, 10);
    addChild(sizeInput);
    sizeInput->setPosition(60, 68);
    sizeInput->setNumberOnly(true);
    sizeInput->setText(String::NumberToString(grid->getGridSize()));
    sizeInput->addEventListener(this, UIEvent::CHANGE_EVENT);
    
    label = new UILabel("Count:", 12);
    label->setColor(1.0, 1.0 ,1.0, 1.0);
    addChild(label);
    label->setPosition(10, 100);

    countInput = new UITextInput(false, 50, 10);
    addChild(countInput);
    countInput->setPosition(60, 98);
    countInput->setNumberOnly(true);
    countInput->setText(String::IntToString(grid->getGridLen()));
    countInput->addEventListener(this, UIEvent::CHANGE_EVENT);
    
    xAxisBox = new UICheckBox("X Axis", grid->isXAxisEnabled());
    addChild(xAxisBox);
    xAxisBox->setPosition(10, 130);
    xAxisBox->addEventListener(this, UIEvent::CHANGE_EVENT);
    
    yAxisBox = new UICheckBox("Y Axis", grid->isYAxisEnabled());
    addChild(yAxisBox);
    yAxisBox->setPosition(10, 155);
    yAxisBox->addEventListener(this, UIEvent::CHANGE_EVENT);
    
    zAxisBox = new UICheckBox("Z Axis", grid->isZAxisEnabled());
    addChild(zAxisBox);
    zAxisBox->setPosition(10, 180);
    zAxisBox->addEventListener(this, UIEvent::CHANGE_EVENT);
}
Beispiel #18
0
bool QiangHuaLayer::init(HeroType hero)
{
    if(!CCLayer::init())
    {
        return false;
    }
    m_hero=hero;
    bUpgrade=false;
    m_pUiLayer=UILayer::create();

    this->addChild(m_pUiLayer);
    CCSize winSize =CCDirector::sharedDirector()->getWinSize();
    UIImageView* imageView = UIImageView::create();
    imageView->setTexture("herolistbg.png");
    imageView->setPosition(ccp(winSize.width/2,winSize.height/2));
    m_pUiLayer->addWidget(imageView);
    
    UIImageView* heroImage = UIImageView::create();
    heroImage->setTexture(hero.textureName.c_str());
    heroImage->setPosition(ccp(winSize.width/2,winSize.height/2));
    m_pUiLayer->addWidget(heroImage);
    
    UIImageView* coinImage = UIImageView::create();
    coinImage->setTexture("coins.png");
    coinImage->setPosition(ccp(coinImage->getContentSize().width/2+30,winSize.height/2));
    coinImage->setTag(111);
    m_pUiLayer->addWidget(coinImage);
    
    
    UILabel *label = UILabel::create();
    char str[32];
    sprintf(str,"%d",hero.level);
    label->setText(str);
    m_pUiLayer->addWidget(label);
    
    UIButton *btn=UIButton::create();
    btn->setTouchEnabled(true);
    btn->setTextures("qianghua1.png","qianghua2.png","");
    btn->setPosition(ccp(winSize.width/2,winSize.height/2-250));
    btn->addReleaseEvent(this, coco_releaseselector(QiangHuaLayer::qianghua));
    m_pUiLayer->addWidget(btn);
    
    UIButton *btnclose=UIButton::create();
    btnclose->setTouchEnabled(true);
    btnclose->setTextures("close1.png","close2.png","close2.png");
    btnclose->setPosition(ccp(winSize.width-60, winSize.height/2+300));
    btnclose->addReleaseEvent(this, coco_releaseselector(QiangHuaLayer::close));
    m_pUiLayer->addWidget(btnclose);
    getHeros();
    return true;
}
void EquipmentUpgradeUILayer::showEquipName(unsigned int index,const char* name,const ccColor3B& color)
{
	if(m_equipmentLayout)
	{
		char lableName[30];
		sprintf(lableName,"equipUpgradeLabel%d",index);
		UILabel* label = m_equipmentLayout->FindChildObjectByName<UILabel>(lableName);
		if(label)
		{
			label->setString(name);
			label->setColor(color);
		}
	}
}
Beispiel #20
0
void UIMenu::addMenuBreak() {
	UILabel* label = new UILabel(gfx);
	label->setColor(MENU_TEXT_COLOR);
	label->setText("...", 0, text_size);
	label->setPosition(vector2());
	label->setActive(false);
//	label->fadeIn();
	
	//size[0] = 18;
	size[1] = (labels_n+1)*text_size;
	
	gfx->addSceneNode(label, this);
	labels.push_back(label);
	labels_n++;	
}
void EquipmentUpgradeUILayer::showEquipLevel(unsigned int index,unsigned int level)
{
	if(m_equipmentLayout)
	{
		char lableName[30];
		sprintf(lableName,"equipUpgradeLevelLabel%d",index);
		UILabel* label = m_equipmentLayout->FindChildObjectByName<UILabel>(lableName);
		if(label)
		{
			char text[10];
			sprintf(text,"lv %d",level);
			label->setString(text);
		}
	}
}
Beispiel #22
0
NS_CC_BEGIN
UILabel* UILabel::create(const char *content,float fontSize)
{
	UILabel *node = new UILabel();
	if (node)
	{
		if (node->initWithContent(content,fontSize))
		{
			node->autorelease();
			return node;
		}
	}
	CC_SAFE_DELETE(node);
	return NULL;
}
void FrontCoverLayer::setLastServerLabel()
{
	if(m_layout)
	{
		UILabel* label = m_layout->FindChildObjectByName<UILabel>("serverLabel");
		if(label)
		{
			const char* name = UserData::GetLastServerName();
			if(*name != '\0')
			{
				label->setString(name);
			}
		}
	}
}
void EquipmentUpgradeUILayer::updateBottomCoinLabel()
{
	if(m_equipmentLayout)
	{
		UILabel* label = m_equipmentLayout->FindChildObjectByName<UILabel>("bottomCoinLable");
		if(label)
		{
			unsigned int coin = UserData::GetGold();
			const char* str = MainMenuLayer::GetNumByFormat(coin);
			if(str)
			{
				label->setString(str);
			}
		}
	}
}
Beispiel #25
0
	virtual void callback(UIBase *base)
	{
		if (dialog && window)
		{
			// 创建图片
			UIPanel *panel = window->getNowTouchPanel();
			if (panel)
			{
				UILabel * label = (UILabel*)panel->createLabel(ccp(0,0),CCSizeMake(0,0),"default",32,panel);
				if (label)
				{
					label->setEditable(true);
					label->bind(UIBase::EVENT_EDIT_DOWN,new stShowProp());
				}
			}
		}
	}
Beispiel #26
0
void TartarLayer::TextFieldInserted( CCObject* pSender )
{
    UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_Warning"));
    pUILabel->setVisible(false);

    UITextField* pUITextField = DynamicCast<UITextField*>(pSender);
    std::string str = pUITextField->getStringValue();
    if (str.size() > 0)
    {
        char lastLetter = str[str.size()-1];
        if (lastLetter < '0' || lastLetter > '9')
        {
            str.pop_back();
            pUITextField->setText(str.c_str());
        }
    }
}
void EquipmentUpgradeUILayer::showSecondNextLevelAttribution(unsigned int key,unsigned int strenghValue)
{
	const char* text = ItemManager::Get()->getAttributionText(key,strenghValue);
	if(text)
	{
		if(m_equipmentLayout)
		{
			UILabel* label = m_equipmentLayout->FindChildObjectByName<UILabel>("equipUpgradeChoosedAddNextLevel2");
			if(label)
			{
				char nextAttr[80];
				sprintf(nextAttr,"%s%s",Localizatioin::getLocalization("M_NEXTLEVEL"),text);
				label->setString(nextAttr);
			}
		}
	}
}
bool UIWidgetAddNodeTest::init()
{
    if (UIScene::init())
    {
        CCSize widgetSize = m_pWidget->getSize();
        
        // Add the alert
        UILabel *alert = UILabel::create();
        alert->setText("Widget Add Node");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(ccc3(159, 168, 176));
        alert->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75));
        m_pUiLayer->addWidget(alert);
        
        // Create the ui node container
        UIWidget* widget = UIWidget::create();
        widget->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
        m_pUiLayer->addWidget(widget);
        
        CCSprite* sprite = CCSprite::create("cocosui/ccicon.png");
        sprite->setPosition(ccp(0, sprite->boundingBox().size.height / 4));
        widget->addNode(sprite);
        
        return true;
    }
    return false;
}
void CocosGUIExamplesPageScene::onEnter()
{
    CCScene::onEnter();
    
    m_pUILayer = UILayer::create();
    m_pUILayer->scheduleUpdate();
    addChild(m_pUILayer);
    
    PageInit();
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    UILabel* label = UILabel::create();
    label->setText("Move by horizontal direction");
    label->setFontName("Marker Felt");
    label->setFontSize(32);
    label->setAnchorPoint(ccp(0.5f, -1));
    label->setPosition(ccp(winSize.width / 2.0f, winSize.height / 2.0f + label->getContentSize().height * 1.5));
    m_pUILayer->addWidget(label);
    
    // left button
    UIButton* left_button = UIButton::create();
    left_button->setTouchEnable(true);
    left_button->loadTextures("cocosgui/UITest/b1.png", "cocosgui/UITest/b2.png", "");
    float left_button_width = left_button->getContentSize().width;
    left_button->setPosition(ccp(left_button_width - left_button_width / 2, m_pUILayer->getContentSize().height / 2));
    left_button->addReleaseEvent(this, coco_releaseselector(CocosGUIExamplesPageScene::toCocosGUIExamplesMapScene));
    m_pUILayer->addWidget(left_button);
}
bool UILoadingBarTest_Left_Scale9::init()
{
    if (UIScene::init())
    {
        scheduleUpdate();
        
        CCSize widgetSize = m_pWidget->getSize();
        
        // Add the alert
        UILabel *alert = UILabel::create();
        alert->setText("LoadingBar left scale9 render");
        alert->setFontName("Marker Felt");
        alert->setFontSize(20);
        alert->setColor(ccc3(159, 168, 176));
        alert->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7));
        m_pUiLayer->addWidget(alert);
        
        // Create the loading bar
        UILoadingBar* loadingBar = UILoadingBar::create();
        loadingBar->setName("LoadingBar");
        loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png");
        loadingBar->setScale9Enabled(true);
        loadingBar->setCapInsets(CCRectMake(0, 0, 0, 0));
        /*===*/
        loadingBar->setSize(CCSizeMake(300, loadingBar->getContentSize().height));
        /*=*/
        loadingBar->setPercent(0);
        
        loadingBar->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
        m_pUiLayer->addWidget(loadingBar);
        
        return true;
    }
    return false;
}