Beispiel #1
0
void CHeroExpItem::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);

	const CEvolQuest &evol = m_evolInfo.questsList.at(uIdx);
	const TaskData *task = DataCenter::sharedData()->getTask(Evole_Task)->getCfg(evol.id);
	for (int i = 1; i <=4; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);

		if (i==1)
		{
			CImageView *bgView= (CImageView*)child;
			bgView->setTouchEnabled(true);
		    bgView->setUserData(&m_evolInfo.questsList.at(uIdx));
			bgView->setOnClickListener(this, ccw_click_selector(CHeroExpItem::onRecvTask));
		}
		else if (i==2)
		{
			CLabel *taskName = (CLabel*)child;
			taskName->setString(task->taskName.c_str());
		}
		else if (i==3)
		{
			CLabel *taskDesc = (CLabel*)child;
			taskDesc->setString(task->taskDesc.c_str());
		}
		else if (i==4)
		{
			child->setVisible(evol.pass);
		}
	}
}
Beispiel #2
0
LSERR WINAPI CEmbeddedDobj::QueryPointPcp(
                             PDOBJ pdobj,            // IN
                             PCPOINTUV pptuvQuery,   // IN
                             PCLSQIN plsqIn,         // IN
                             PLSQOUT plsqOut)        // OUT
{
    LSTRACE(EmbeddedQueryPointPcp);

    CLineServices* pLS = pdobj->GetPLS();
    CFlowLayout* pFlowLayout = pLS->_pFlowLayout;
    PLSRUN plsrun = PLSRUN(plsqIn->plsrun);
    CLayout* pLayout = plsrun->GetLayout(pFlowLayout);
    long xWidth;

    ZeroMemory(plsqOut, sizeof(LSQOUT));

    pFlowLayout->GetSiteWidth( pLayout, pLS->_pci, FALSE, 0, &xWidth);

    plsqOut->dupObj  = xWidth;
    plsqOut->plssubl = NULL;

    plsqOut->lstextcell.cpStartCell = pLayout->GetContentFirstCp();
    plsqOut->lstextcell.cpEndCell   = pLayout->GetContentLastCp();

    plsqOut->lstextcell.dupCell      = xWidth;
    plsqOut->lstextcell.pCellDetails = NULL;

    return lserrNone;
}
Beispiel #3
0
CLayout *TuiManager::createLayout(float tag,float x,float y,float w,float h,float rotation){
	CLayout *pLayout = CLayout::create(Size(w,h));
	pLayout->setPosition(Point(x,-y));
	pLayout->setRotation(rotation);
	pLayout->setTag(tag);
	return pLayout;
}
bool CExpandableListViewBasicTest::init()
{
	CExpandableListViewTestSceneBase::init();
	setTitle("CExpandableListViewBasicTest");
	setDescription("click item to expand");
	
	pListView = CExpandableListView::create(CCSize(320, 390));
	pListView->setBackgroundImage("background2.png");
	pListView->setPosition(CCPoint(480, 320));
	m_pWindow->addChild(pListView);

	for( int i = 0; i < 10; i++ )
	{
		CExpandableNode* pExpandableNode = CExpandableNode::create();
		pExpandableNode->setContentSize(CCSize(320, 50));
		pListView->insertExpandableNodeAtLast(pExpandableNode);

		CImageViewScale9* pExpandableNodeBg = CImageViewScale9::create(CCSize(320, 45), "expandnodebg.png");
		pExpandableNodeBg->setPosition(CCPoint(320/2, 50/2));
		pExpandableNode->addChild(pExpandableNodeBg);

		CButton* pColBtn = CButton::createWith9Sprite(CCSize(35, 35), "sprite9_btn1.png", "sprite9_btn2.png");
		pColBtn->setPosition(ccp(320 - 30, 50 / 2));
		pColBtn->setText("-");
		pColBtn->setUserTag(i);
		pColBtn->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick));
		pExpandableNode->addChild(pColBtn);

		char buff[64] = {0};
		sprintf(buff, "ExpandableNode : %d", i);
		CLabel* pTitleLabel = CLabel::create(buff, "", 28);
		pTitleLabel->setPosition(CCPoint(10, 50/2));
		pTitleLabel->setAnchorPoint(CCPoint(0, 0.5));
		pExpandableNode->addChild(pTitleLabel);


		sprintf(buff, "Label %d - 1", i);
		pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
		sprintf(buff, "Label %d - 2", i);
		pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
		sprintf(buff, "Label %d - 3", i);
		pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
		
		CButton* pButton = CButton::createWith9Sprite(CCSize(150, 38), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick));
		pButton->initText("collapse", "", 28);
		pButton->setUserTag(i);
		pButton->setPosition(CCPoint(100, 40/2));
		CLayout* pBtnLayout = CLayout::create(CCSize(320, 40));
		pBtnLayout->addChild(pButton);
		pExpandableNode->insertItemNodeAtLast(pBtnLayout);
	}

	pListView->reloadData();
	

	return true;
}
Beispiel #5
0
void CStrengthenItem::onSetFilter(const TMessage& tMsg)
{
	m_itemList.clear();

	vector<int> *filt = (vector<int> *)tMsg.lParam;

	m_filterVec = *filt;

	for (int i=0; i<m_itemData.itemList.size(); ++i)
	{
		CItem *item =(CItem*)(&m_itemData.itemList.at(i));

		bool isAdd = false;
		for (int j = 0; j < filt->size(); j++)
		{
			
			if (item->armor.armorType == filt->at(j))
			{
				if (tMsg.nMsg == 2)
				{
					isAdd = true;
				}
				else if (tMsg.nMsg == 0&&tMsg.nMsg==item->armor.hero)
				{
					isAdd = true;
				}
				else if (tMsg.nMsg == 1&& item->armor.hero>0)
				{  
					isAdd = true;
				}
				else
				{
					isAdd = false;
				}
				break;
			}
		}
		if (isAdd)
		{
			m_itemList.push_back(&m_itemData.itemList.at(i));
		}
	}

	//排序
	std::sort(m_itemList.begin(), m_itemList.end(), SortItem);
	m_tableView->setCountOfCell(m_itemList.size());
	m_tableView->reloadData();

	CLayout *attribute = (CLayout*)(m_ui->findWidgetById("attr"));
	attribute->setVisible(false);

	if (m_itemList.size()>0)
	{
		CTableViewCell *cell = (CTableViewCell*)m_tableView->getCells()->objectAtIndex(0);
		onTouchItem(cell->getChildByTag(1));
	}
}
Beispiel #6
0
void CSmeltArmor::initItemInfo( CCPoint posStart, CLayout* pLayout[], int iCount )
{
	for(int i=0; i<iCount; i++)
	{
		CLayout* pCopyLayout = UICloneMgr::cloneLayout(m_pCellInfo);
		pCopyLayout->setPosition(posStart+ccp(0, -i*50));
		m_attr->addChild(pCopyLayout, 911);
		pLayout[i] = pCopyLayout;
		pLayout[i]->setVisible(false);
	}
}
Beispiel #7
0
CLayout* CLayout::create()
{
	CLayout* pRet = new CLayout();
	if( pRet && pRet->init() )
	{
		pRet->autorelease();
		return pRet;
	}
	CC_SAFE_DELETE(pRet);
	return NULL;
}
Beispiel #8
0
CLayout* CLayout::create(const Size& tContentSize)
{
	CLayout* pRet = new CLayout();
	if( pRet && pRet->init() )
	{
		pRet->setContentSize(tContentSize);
		pRet->autorelease();
		return pRet;
	}
	CC_SAFE_DELETE(pRet);
	return NULL;
}
Beispiel #9
0
void CStrengthenItem::onTouchItem(CCObject* pSender)
{
	if(isVisible())
	{
		PlayEffectSound(SFX_Button);
	}

	CImageView * img = (CImageView*)pSender;
	m_item = (CItem*)img->getUserData();

	m_pItemTip->showItemProperty(m_item);

	CLayout *attribute = (CLayout*)(m_ui->findWidgetById("attr"));
	attribute->setVisible(true);

	m_selectCellImg->removeFromParent();
	img->addChild(m_selectCellImg);
	m_selectCellImg->setVisible(true);
	m_selectCellImg->setPosition(ccp(img->getContentSize().width/2,0/*img->getContentSize().height/2*/));

	CButton *select = (CButton*)(m_ui->findWidgetById("select")); //sel_font
	CLabel *selfont = (CLabel*)(m_ui->findWidgetById("sel_font"));
	if (m_toHero==m_item->armor.hero&&m_toHero>0)
	{
		select->setVisible(true);
		selfont->setVisible(false);
	}
	else if (m_toHero>0&&!m_item->canUse)
	{
		select->setVisible(false);
		selfont->setVisible(false);
	}
	else
	{
		select->setVisible(true);
		selfont->setVisible(true);
	}

	if (m_type==2)
	{
		if (m_toHero>0)
		{
			CImageView *uninstall = (CImageView*)(m_ui->findWidgetById("uninstall"));
			CImageView *change = (CImageView*)(m_ui->findWidgetById("change"));
			CImageView *selfont = (CImageView*)(m_ui->findWidgetById("sel_font"));
			uninstall->setVisible(m_toHero==m_item->armor.hero);
			change->setVisible(m_toHero!=m_item->armor.hero&&m_item->armor.hero>0&&m_item->canUse);
			selfont->setVisible(m_item->armor.hero==0&&m_item->canUse);
		}
	}
}
Beispiel #10
0
void CMainCityUI::imageLoadSuccessCallBack(string sTag, vector<char>* pBuffer)
{
	CCImage* img = new CCImage;
	img->initWithImageData((unsigned char*)pBuffer->data(), pBuffer->size());
	CCTexture2D* texture = new CCTexture2D();
    texture->initWithImage(img);
	CLayout* headPart = (CLayout*)m_ui->findWidgetById("head_part");

	CCSprite* head = (CCSprite*)headPart->getChildByTag(15);
//	head->removeFromParent();
	//head->setTexture(texture);

	string path = HttpLoadImage::getInstance()->getStoragePath("download/fbImg",sTag.c_str())+".jpg";
	string buff(pBuffer->begin(), pBuffer->end());
	CCLOG("path: %s", path.c_str());
	FILE *fp = fopen(path.c_str(), "wb+");
	fwrite(buff.c_str(), 1, pBuffer->size(),  fp);
	fclose(fp);

//	CCSprite *headbg = (CCSprite*)(m_ui->findWidgetById("headbg"));
// 	CCClippingNode *clip = CCClippingNode::create();	
// 	CCSprite *fbimg = CCSprite::createWithTexture(texture);
// 	clip->addChild(fbimg);
// 
// 	clip->setPosition(headbg->getPosition());
// 	clip->setContentSize(CCSizeMake(110,110));
// 
// 	static ccColor4F red ={1,0,1};
// 	float radius = 106;
// 	const int nCount = 200;
// 	const float angle = 2.0f* (float)M_PI/nCount;
// 	CCPoint circle[nCount];
// 	for(int i=0; i<nCount; i++)
// 	{
// 		float radian = i*angle;
// 		circle[i].x = radius * cosf(radian);
// 		circle[i].y = radius * sinf(radian); 
// 	}
// 	CCDrawNode *stencil= CCDrawNode::create();
// 	stencil->drawPolygon(circle,nCount,red,0,red);
// 	clip->setStencil(stencil);	
// 	m_ui->addChild(clip);
	CCSprite *headBg = (CCSprite *)(headPart->findWidgetById("headbg"));
	CCSprite *headSpr = MakeFaceBookHeadToCircle(CCSprite::createWithTexture(texture));
	headSpr->setTag(15);
	headSpr->setPosition(headBg->getPosition());
	headPart->addChild(headSpr);
	head->removeFromParent();
	img->release();
}
Beispiel #11
0
void CHandBookHeroLayer::initListCellIcon( AtlasIns *pAtlasIns, CCPoint startPos, int iGapX, CTableViewCell *pCell )
{
	int iSize = pAtlasIns->data_list_size();
	for(int i=0; i<iSize; i++)
	{
		//克隆元素
		CLayout *pIconCell = UICloneMgr::cloneLayout(m_pCell);
		pIconCell->setPosition(ccp(startPos.x+iGapX*i, startPos.y));
		pCell->addChild(pIconCell, 10);

		initCellIconByData( pAtlasIns->mutable_data_list()->Mutable(i),  pIconCell );
	}

}
Beispiel #12
0
bool Arguments::handleCommandLine() const
{
  if (!(mSaveLayout && haveFile() && haveOutputDir()))
    return false;

  CCopasiRootContainer::init(0, NULL, false);
  CCopasiDataModel& model = *CCopasiRootContainer::addDatamodel();

  try
    {
      if (!model.importSBML(mFilename, NULL))
        model.loadModel(mFilename, NULL);
    }
  catch (CCopasiException &ex)
    {
      std::cerr << ex.getMessage().getAllMessageText() << std::endl;
      return true;
    }

  for (size_t i = 0; i < model.getListOfLayouts()->size(); ++i)
    {
      CLayout* layout = (*model.getListOfLayouts())[i];
      CQLayoutScene scene(layout, &model);
      scene.recreate();
      scene.saveToFile(mOutputDir + "/" + QFileInfo(mFilename.c_str()).baseName().toStdString() + "_" + layout->getObjectName() + "." + mFileType, mFileType);
    }

  return true;
}
Beispiel #13
0
bool Circuit::insertLayout(CLayout& tmp){
	// map<string, CLayout>::iterator cells_it=layouts.find(tmp.getName());
	//	if(cells_it!=layouts.end())
	//		cout << "-> Cell layout " << tmp.getName() << " already exists. Overwriting..." << endl;
	layouts[tmp.getName()]=tmp;
	return true;
}
Beispiel #14
0
void CChangeHeadImg::addGridCell(unsigned int uIdx, CGridViewCell* pCell)
{
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);

	for (int i=1; i<=2; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);

		if (i==1)
		{
			if (m_headIconList.at(uIdx)>0)
			{
				CImageView* pHead = CImageView::create(CCString::createWithFormat("headImg/%d.png", m_headIconList.at(uIdx))->getCString());
				if(!pHead)
				{
					pHead = CImageView::create("headImg/null.png");
					CCLOG("ERROR_____CChangeHeadImg::addGridCell");
				}
				child->addChild(pHead);
				NodeFillParent(pHead);
			}
			else
			{
				UserData *data = DataCenter::sharedData()->getUser()->getUserData();
				string fbName = data->getFbId() +".jpg";
				string fullName = CCFileUtils::sharedFileUtils()->fullPathForFilename(fbName.c_str());
				bool isFileExist = CCFileUtils::sharedFileUtils()->isFileExist(fullName);
				if(isFileExist)
				{
					CCSprite* spr =CCSprite::create(fullName.c_str());
					child->addChild(spr);
					NodeFillParent(spr);
				}
			}
			
		}
		else if(i==2)
		{
			CImageView* pBtn = (CImageView*)child;
			pBtn->setTouchEnabled(true);
			pBtn->setUserData(&m_headIconList.at(uIdx));
			pBtn->setOnClickListener(this,ccw_click_selector(CChangeHeadImg::onChangHeadImg));
		}
	}
}
void CHeroEvolveEffectLayer::showDataFlyOutByType( int iType )
{
	for(int i=0; i<9; i++)
	{
		if( (iType==1 && i<4) || (iType==2 && i>=4))
		{
			CLayout *pLay = (CLayout *)m_pUI->findWidgetById(CCString::createWithFormat("data%d", i+1)->getCString());
			pLay->runAction(CCSequence::create(
				CCDelayTime::create(0.05f*i),
				CCMoveBy::create(0.15f, ccp(-600, 0)),
				CCHide::create(),
				CCMoveBy::create(0.0f, ccp(600, 0)),
				nullptr
				));
		}
	}
}
Beispiel #16
0
void CListViewBasicTest::onClick(Ref* pSender)
{
	if( !m_lDatas.empty() )
	{
		tagItem& tItem = m_lDatas.front();

		CLayout* pLayout = CLayout::create();
		pLayout->setContentSize(tItem.tSize);
		/*
		pLayout->setBackgroundColor(Color4B(tItem.tColor.r,
			tItem.tColor.g,
			tItem.tColor.b,
			255));
			*/
		pLayout->setBackgroundImage("icon.png");
		pLayout->ignoreAnchorPointForPosition(false);
		pLayout->setAnchorPoint(Vec2(0.5f, 0.5f));
		pLayout->setContentSize(Size(tItem.tSize.width - 4, tItem.tSize.height - 2));
		pLayout->setPosition(Vec2(tItem.tSize.width/2, tItem.tSize.height/2));

		m_pListView->insertNodeAtLast(pLayout);
		m_pListView->reloadData();
		m_lDatas.pop_front();
	}
}
Beispiel #17
0
void CLayout::SetName(CString name_) 
{
	if (name_ == "")
		return;

	// check it's not in use by other layouts
	CLayout* layout;
	POSITION position = application->layouts.GetHeadPosition();

	for (int i = 0; i < application->layouts.GetCount(); i++)
	{ 
		layout = application->layouts.GetNext(position);
		
		if (layout->GetName() == name_)
			return;
	}

	m_Name = name_;
	m_WndName = name_;

	HWND ClientWindow;
	ClientWindow = ::GetWindow(g_MainFrame->m_hWndMDIClient, GW_CHILD);

	// Now find any layouts within this application
	while (ClientWindow != NULL)
	{
		CChildFrame* pWnd = (CChildFrame*)CWnd::FromHandle(ClientWindow);
		if(pWnd->layout == this)
		{
			// Rename
			CString Title;
			Title.Format("%s : %s", pWnd->application->file_information.name, m_Name);
			pWnd->SetWindowText(Title);
		}

		ClientWindow = :: GetWindow(ClientWindow, GW_HWNDNEXT);
	}

	// update project bar
	g_MainFrame->project_bar.tree.SetItemText(tree, name_);

	// Update windows displaying this potentially
	g_MainFrame->tabs.RedrawWindow();

}
Beispiel #18
0
//+---------------------------------------------------------------------------
//
//  Member:     CRichtextLayout::DrawClient
//
//  Synopsis:   Draw client rect part of the controls
//
//  Arguments:  prcBounds       bounding rect of display leaf node
//              prcRedraw       rect to be redrawn
//              pSurface        surface to render into
//              pDispNode       pointer to display node
//              pClientData     client-dependent data for drawing pass
//              dwFlags         flags for optimization
//
//----------------------------------------------------------------------------
void CRichtextLayout::DrawClient(
            const RECT*     prcBounds,
            const RECT*     prcRedraw,
            CDispSurface*   pDispSurface,
            CDispNode*      pDispNode,
            void*           cookie,
            void*           pClientData,
            DWORD           dwFlags)
{
    Assert(pClientData);

    CFormDrawInfo* pDI = (CFormDrawInfo*)pClientData;

    {
        // we set draw surface information separately for Draw() and
        // the stuff below, because the Draw method of some subclasses
        // (like CFlowLayout) puts pDI into a special device coordinate
        // mode
        CSetDrawSurface sds(pDI, prcBounds, prcRedraw, pDispSurface);
        Draw(pDI);
    }

    {
        // see comment above
        CSetDrawSurface sds(pDI, prcBounds, prcRedraw, pDispSurface);

        // We only want to paint selection on the client rect in this part
        // In RTL the scrollbar is on the left and will leave extra highlighting
        // on the right side of the control if we do not adjust it here
        if(_fTextSelected)
        {
            DrawTextSelectionForRect(pDI->GetDC(), (CRect*)prcRedraw , &pDI->_rcClip, _fSwapColor);
        }

        if(GetView()->IsFlagSet(CView::VF_ZEROBORDER))
        {
            CLayout* pParentLayout = GetUpdatedParentLayout();
            if(pParentLayout && pParentLayout->ElementOwner()->IsEditable())
            {
                DrawZeroBorder(pDI);
            }
        }
    }
}
Beispiel #19
0
void CVipCard::onEnter()
{
	BaseLayer::onEnter();
	//确定
	CButton* pConfirm = (CButton*)m_ui->findWidgetById("confirm");
	pConfirm->setOnClickListener(this, ccw_click_selector(CVipCard::onConfirm));

	CButton* cancel = (CButton*)m_ui->findWidgetById("cancel");
	cancel->setOnClickListener(this, ccw_click_selector(CVipCard::onCancel));

	CButton* pClose = CButton::create("common/back.png", "common/back.png");
	pClose->getSelectedImage()->setScale(1.1f);
	pClose->setPosition(VLEFT+50, VTOP-50);
	pClose->setOnClickListener(this,ccw_click_selector(CVipCard::onClose));
	this->addChild(pClose, 999);
	
	CImageViewScale9* pRect1 = (CImageViewScale9*)m_ui->findWidgetById("rect1");
	m_cardText = CursorTextField::textFieldWithPlaceHolder("", FONT_NAME, 29, CCSize(690, 110), ccBLACK);
	m_cardText->setPriority(this->getTouchPriority());
	m_cardText->setLimitNum(17);
	m_cardText->setAnchorPoint(ccp(0, 0.5f));
	m_cardText->setPosition( ccp(pRect1->getPositionX()-440, pRect1->getPositionY()));
	m_ui->addChild(m_cardText, 999);

	//展示区图片
	CLayout *pShowInfo = CLayout::create();

	CScrollView *pScroll = (CScrollView*)m_ui->findWidgetById("scroll_info");
	pScroll->setDirection(eScrollViewDirectionVertical);
	pScroll->setBounceable(false);
	pScroll->getContainer()->addChild(pShowInfo);

	CCSize size = CCSize(957, 471);
	pShowInfo->setContentSize(size);
	pScroll->setContainerSize(size);
	pShowInfo->setPosition(ccp(pScroll->getContainerSize().width*0.5f, pScroll->getContainerSize().height*0.5f));
	pScroll->setContentOffsetToTop();

	//嫁接内容
	CLayout* pLayout = (CLayout*)findWidgetById("layer_info");
	pLayout->retain();
	pLayout->removeFromParent();
	pShowInfo->addChild(pLayout);
	pLayout->release();
	pLayout->setPosition(ccp(size.width/2, size.height/2+10));

}
Beispiel #20
0
void LoginLayerUC::addTableCell( unsigned int uIdx, CTableViewCell * pCell )
{
	CLayout *lay = UICloneMgr::cloneLayout(m_pCell);

	const Server& server = m_serverInfo.server_list().Get(uIdx);

	for (unsigned int i=1; i<=4; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		child->setTag(i);
		pCell->addChild(child);
		pCell->setTag(uIdx);

		switch (i)
		{
		case 1:
			{
				CImageView* pBoard = (CImageView*)child;
				pBoard->setTouchEnabled(true);
				pBoard->setOnClickListener(this, ccw_click_selector(LoginLayerUC::selectServer));
			}
			break;
		case 3:
			{
				CLabel* pLabel = (CLabel*)child;
				pLabel->setString(server.server_name().c_str());
			}
			break;
		case 4:
			{
				CLabel* pLabel = (CLabel*)child;
				int iShowText[5] = {2002, 1184, 1185, 1186, 1187};
				pLabel->setString(GETLANGSTR(iShowText[server.server_status()]));
			}
			break;
		default:
			break;
		}
	}
}
void CHeroEvolveEffectLayer::showDataFlyInByType( int iType )
{
	for(int i=0; i<9; i++)
	{
		if( (iType==1 && i<4) || (iType==2 && i>=4))
		{
			CLayout *pLay = (CLayout *)m_pUI->findWidgetById(CCString::createWithFormat("data%d", i+1)->getCString());
			pLay->setPositionX(pLay->getPositionX()-600);
			pLay->setVisible(false);
			pLay->setOpacity(0);
			pLay->runAction(CCSequence::create(
				CCDelayTime::create(0.05f*i),
				CCSpawn::createWithTwoActions(
				CCMoveBy::create(0.2f, ccp(600, 0)),
				CCSequence::create(
				CCDelayTime::create(0.05f),
				CCShow::create(),
				CCFadeIn::create(0.1f),
				nullptr
				)
				),
				nullptr
				));
		}
	}
}
Beispiel #22
0
/* =============================================================================
 =============================================================================== */
bool CWorld::addLayout(CLayout &Layout, int iNdx)
{
	if (!Layout.getName().size()) 
		Layout.setName(getFileNameBase(Layout.getLink()));
	if (!Layout.getName().size()) 
		Layout.setName("New Layout");
	if (getLayoutSet().getLayoutIndex(Layout.getName()) != -1)
	{
		string	str;
		for (int i = 1; getLayoutSet().getLayoutIndex(str = getNewName(Layout.getName(), i)) != -1; i++);
		Layout.setName(str);
	}

	bool	bRet = getLayoutSet().addLayout(Layout, iNdx);
	return bRet;
}
Beispiel #23
0
//static
CLayout * SBMLDocumentLoader::createLayout(const Layout & sbmlLayout,
    const std::map<std::string, std::string> & modelmap,
    std::map<std::string, std::string> & layoutmap
#ifdef USE_CRENDER_EXTENSION
    , const std::map<std::string, std::string>& globalIdToKeyMap
    //,const std::map<std::string,std::map<std::string,std::string> >& globalColorIdToKeyMapMap
    //,const std::map<std::string,std::map<std::string,std::string> >& globalGradientIdToKeyMapMap
    //,const std::map<std::string,std::map<std::string,std::string> >& globalLineEndingIdToKeyMapMap
#endif /* USE_CRENDER_EXTENSION */
    , const CCopasiContainer * pParent
                                          )
{
  CLayout* layout = new CLayout(sbmlLayout, layoutmap, pParent);

  //compartments
  unsigned C_INT32 i, iMax = sbmlLayout.getListOfCompartmentGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const CompartmentGlyph* tmp
        = dynamic_cast<const CompartmentGlyph*>(sbmlLayout.getListOfCompartmentGlyphs()->get(i));

      if (tmp)
        layout->addCompartmentGlyph(new CLCompartmentGlyph(*tmp, modelmap, layoutmap));
    }

  //species
  iMax = sbmlLayout.getListOfSpeciesGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const SpeciesGlyph* tmp
        = dynamic_cast<const SpeciesGlyph*>(sbmlLayout.getListOfSpeciesGlyphs()->get(i));

      if (tmp)
        layout->addMetaboliteGlyph(new CLMetabGlyph(*tmp, modelmap, layoutmap));
    }

  //reactions
  iMax = sbmlLayout.getListOfReactionGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const ReactionGlyph* tmp
        = dynamic_cast<const ReactionGlyph*>(sbmlLayout.getListOfReactionGlyphs()->get(i));

      if (tmp)
        layout->addReactionGlyph(new CLReactionGlyph(*tmp, modelmap, layoutmap));
    }

  //text
  iMax = sbmlLayout.getListOfTextGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const TextGlyph* tmp
        = dynamic_cast<const TextGlyph*>(sbmlLayout.getListOfTextGlyphs()->get(i));

      if (tmp)
        layout->addTextGlyph(new CLTextGlyph(*tmp, modelmap, layoutmap));
    }

  //additional
  iMax = sbmlLayout.getListOfAdditionalGraphicalObjects()->size();

  for (i = 0; i < iMax; ++i)
    {
      const GraphicalObject* graphical
        = dynamic_cast<const GraphicalObject*>(sbmlLayout.getListOfAdditionalGraphicalObjects()->get(i));

      if (graphical)
        layout->addGeneralGlyph(new CLGeneralGlyph(*graphical, modelmap, layoutmap));
    }

  //second pass text (the text glyph can refer to other glyphs. These references can)
  //only be resolved after all glyphs are created).
  iMax = sbmlLayout.getListOfTextGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const TextGlyph* tmp
        = dynamic_cast<const TextGlyph*>(sbmlLayout.getListOfTextGlyphs()->get(i));

      if (tmp)
        postprocessTextGlyph(*tmp, layoutmap);
    }

#ifdef USE_CRENDER_EXTENSION
  RenderLayoutPlugin* rlPlugin = (RenderLayoutPlugin*) sbmlLayout.getPlugin("render");
  assert(rlPlugin != NULL);

  // import the local render information
  iMax = rlPlugin->getNumLocalRenderInformationObjects();
  std::map<std::string, std::string> idToKeyMap;
  CLLocalRenderInformation* pLRI = NULL;

  //std::map<std::string,std::string> colorIdToKeyMap;
  //std::map<std::string,std::string> gradientIdToKeyMap;
  //std::map<std::string,std::string> lineEndingIdToKeyMap;
  //std::map<std::string,std::map<std::string,std::string> > colorIdToKeyMapMap;
  //std::map<std::string,std::map<std::string,std::string> > gradientIdToKeyMapMap;
  //std::map<std::string,std::map<std::string,std::string> > lineEndingIdToKeyMapMap;
  for (i = 0; i < iMax; ++i)
    {
      //colorIdToKeyMap.clear();
      //gradientIdToKeyMap.clear();
      //lineEndingIdToKeyMap.clear();
      //pLRI=new CLLocalRenderInformation(*sbmlLayout.getRenderInformation(i),colorIdToKeyMap,gradientIdToKeyMap,lineEndingIdToKeyMap,layout);
      pLRI = new CLLocalRenderInformation(*rlPlugin->getRenderInformation(i), layout);

      if (rlPlugin->getRenderInformation(i)->isSetId())
        idToKeyMap.insert(std::pair<std::string, std::string>(rlPlugin->getRenderInformation(i)->getId(), pLRI->getKey()));
      else
        idToKeyMap.insert(std::pair<std::string, std::string>(pLRI->getKey(), pLRI->getKey()));

      //colorIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getKey(),colorIdToKeyMap));
      //gradientIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getKey(),gradientIdToKeyMap));
      //lineEndingIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getKey(),lineEndingIdToKeyMap));
      // fix the references to layout objects in id lists
      size_t j, jMax = pLRI->getNumStyles();

      for (j = 0; j < jMax; j++)
        {
          SBMLDocumentLoader::convertLayoutObjectIds(*(pLRI->getStyle(j)), layoutmap);
        }

      layout->addLocalRenderInformation(pLRI);
    }

  // fix the references
  // we have to consider the global ids as well
  // since all ids in these two map should be unique, we can just combine them
  size_t count = idToKeyMap.size() + globalIdToKeyMap.size();
  idToKeyMap.insert(globalIdToKeyMap.begin(), globalIdToKeyMap.end());
  // make sure the ids were really unique
  assert(idToKeyMap.size() == count);
  SBMLDocumentLoader::convertRenderInformationReferencesIds<CLLocalRenderInformation>(layout->getListOfLocalRenderInformationObjects(), idToKeyMap);
  // fix the color ids, gradient ids and line ending ids.
  /*
  std::map<std::string,std::map<std::string,std::string> >::const_iterator mapPos;
  std::map<std::string,std::map<std::string,std::string> > expandedColorIdToKeyMapMap, expandedGradientIdToKeyMapMap, expandedLineEndingIdToKeyMapMap;
  for(i=0;i < iMax; ++i)
  {
      pLRI=dynamic_cast<CLLocalRenderInformation*>(layout->getRenderInformation(i));
      assert(pLRI != NULL);

      std::set<std::string> chain;
      SBMLDocumentLoader::expandIdToKeyMaps<CLLocalRenderInformation>(pLRI,
                         layout->getListOfLocalRenderInformationObjects(),
                         expandedColorIdToKeyMapMap,
                         expandedGradientIdToKeyMapMap,
                         expandedLineEndingIdToKeyMapMap,
                         colorIdToKeyMapMap,
                         gradientIdToKeyMapMap,
                         lineEndingIdToKeyMapMap,
                         chain,
                         globalColorIdToKeyMapMap,
                         globalGradientIdToKeyMapMap,
                         globalLineEndingIdToKeyMapMap
                         );
      SBMLDocumentLoader::convertPropertyKeys<CLLocalRenderInformation>(pLRI,expandedColorIdToKeyMapMap[pLRI->getKey()],expandedGradientIdToKeyMapMap[pLRI->getKey()],expandedLineEndingIdToKeyMapMap[pLRI->getKey()]);
  }
  */
#endif /* USE_CRENDER_EXTENSION */

  return layout;
}
Beispiel #24
0
void CStrengthenItem::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);

	CItem &item =  *(m_itemList.at(uIdx));// m_itemData.itemList.at(uIdx);

	pCell->setTag(uIdx);

	const ItemData * itemData = DataCenter::sharedData()->getItemDesc()->getCfg(item.itemId);

	for (int i = 1; i <=11; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		if (!child) continue;
		lay->removeChild(child);
		pCell->addChild(child);

		if (i==1)
		{
			CImageView *bgImg = (CImageView*)child;
			if (m_toHero>0)
			{
				if (!item.canUse&&item.armor.hero!=m_toHero)
				{
					CColorView *colorView = CColorView::create(ccc4(0,0,0,100));
					colorView->setContentSize(bgImg->getContentSize());
 					colorView->setPosition(bgImg->getPosition());
					pCell->addChild(colorView,1);
				}
				
				if(item.armor.hero<=0)
				{
					//记录库存
					m_iCountEquipStock++;
				}
			}
			
			bgImg->setTouchEnabled(true);
			bgImg->setUserData(m_itemList.at(uIdx));
			bgImg->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onTouchItem));
		}
		else if (i==2)
		{
			((CButton*)child)->setEnabled(false);
			CCSprite *mask = CCSprite::createWithTexture(setItemQualityTexture(item.quality));
			mask->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
			child->addChild(mask, 10);

			CCSprite *prop = CCSprite::create(GetImageName(1, item.quality, item.iconId).c_str());
			if (!prop)
			{
				prop = CImageView::create("prop/32003.png");
			}
			prop->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
			child->addChild(prop);

			//添加星星
			CLayout* pStarLayout = getStarLayout(item.iStar);
			child->addChild(pStarLayout, 10);
		}
		else if (i==3)
		{
			CLabel *label = (CLabel*)child;
			if(itemData)
			{
				label->setString(itemData->itemName.c_str());
			}
		}
		else if (i==4)
		{
			CLabel *label = (CLabel*)child;
			
			if (item.itemLevel==0)
			{
				label->removeFromParent();
			}
			else
			{
				label->setString(CCString::createWithFormat("+%d",item.itemLevel)->getCString());
				label->setPositionX(pCell->getChildByTag(3)->getPositionX()+pCell->getChildByTag(3)->getContentSize().width+10);
			}
		}
		else if (i==5)
		{
			CLabel *label = (CLabel*)child;
			if (item.itemLevel==0)
			{
				label->setVisible(false);
			}
			else
			{
				label->setVisible(true);
				//if (item.itemLevel==item.armor.strenLv)
				//{
				//	label->setString(CCString::createWithFormat("Lv.%s",GETLANGSTR(229))->getCString());
				//}
				//else
				//{
				//	label->setString(CCString::createWithFormat("Lv.%d",item.itemLevel)->getCString());
				//}
				label->setString(CCString::createWithFormat("+%d",item.itemLevel)->getCString());
			}
		}
		else if (i==6)
		{
			CCSprite *head = (CCSprite*)child;
			if (item.armor.hero>0)
			{
				CCSprite *img = CCSprite::create(getImageName(&item.armor).c_str());
				if(!img)
				{
					img = CCSprite::create("headIcon/101.png");
					CCLOG("ERROR CStrengthenItem::addTableCell");
				}

				CCSprite *mask = (CCSprite*) lay->getChildByTag(7);
				lay->removeChild(mask);
				pCell->addChild(mask);

				img->setScale(0.53f);
				img->setPosition(ccp(head->getContentSize().width/2,head->getContentSize().height/2+14));
				head->addChild(img);
			}
			else
			{
				pCell->removeChild(child);
			}
		}
		else if (i==7)
		{
			pCell->removeChild(child);
		}
		else if (i==8)
		{
			child->setVisible(item.stren);
		}
		else if(i==9)
		{
			if (item.itemLevel==0)
			{
				child->setVisible(false);
			}
			else
			{
				child->setVisible(true);
			}
		}
		else if( i ==10)
		{
			CCNode* pCombatTip = (CCNode*)child;
			pCombatTip->setVisible(item.armor.armorType != 5);
		}
		else if (i==11)
		{
			CLabelAtlas* pLabel = (CLabelAtlas*)child;
			pLabel->setAnchorPoint(ccp(0, 0.5f));
			pLabel->setString(ToString(item.armor.combat));
			pLabel->setVisible(item.armor.armorType != 5);
		}
	}
}
Beispiel #25
0
void TuiManager::parseControl(Node* container,xml_node<char> *item)
{ 
	int tag = atof(item->first_attribute("tag")->value());
	int x = atof(item->first_attribute("x")->value());
	int y = atof(item->first_attribute("y")->value());
	int w = atoi(item->first_attribute("width")->value());
	int h = atoi(item->first_attribute("height")->value());
	int rotation = atof(item->first_attribute("rotation")->value());

	if(strcmp(item->first_attribute("type")->value(), kTuiContainerPanel) == 0){//panel
		CWidgetWindow* pPanel = createPanel(tag,x,y,w,h,rotation);
		container->addChild(pPanel);
		//recursive
		for( xml_node<char> *iitem = item->first_node( kTuiNodeControl );iitem != NULL; iitem = iitem->next_sibling()){
			parseControl(pPanel,iitem);
		}

	}else if (strcmp(item->first_attribute("type")->value(), kTuiControlCell) == 0){//cell
		//recursive
		for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){
			parseControl(container, iitem);
		}

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlImage) == 0){//image
		const char* file = item->first_attribute("image")->value();
		float scaleX = atof(item->first_attribute("scaleX")->value());
		float scaleY = atof(item->first_attribute("scaleY")->value());
		CImageView *pImg = createImage(tag, file, scaleX, scaleY, x, y, rotation);
		container->addChild(pImg);
	
	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlImage9) == 0){//image9
		const char* file = item->first_attribute("image")->value();
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		float up = atof(item->first_attribute("up")->value());
		float down = atof(item->first_attribute("down")->value());
		float left = atof(item->first_attribute("left")->value());
		float right = atof(item->first_attribute("right")->value());
		CImageViewScale9 *pImg = createImage9(tag,file,x,y,w,h,up,down,left,right,rotation);
		container->addChild(pImg);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlButton) == 0){//button
		const char* normal = item->first_attribute("normal")->value();
		const char* select = item->first_attribute("select")->value();
		const char* disable = item->first_attribute("disable")->value();
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		CButton *pBtn = createBtn(tag,normal,select,disable,x,y,w,h,rotation);
		container->addChild(pBtn);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlToggleView) == 0){//toggleView
		const char* normal = item->first_attribute("normal")->value();
		const char* select = item->first_attribute("select")->value();
		const char* disable = item->first_attribute("disable")->value();
		float exclusion = atof(item->first_attribute("exclusion")->value());
		CToggleView* toggle = createToggleView(tag,exclusion,normal,select,disable,x,y,rotation);
		container->addChild(toggle);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlSlider) == 0){//slider
		const char* bg = item->first_attribute("bg")->value();
		const char* progress = item->first_attribute("progress")->value();
		const char* thumb = item->first_attribute("thumb")->value();
		CSlider *pSlider = createSlider(tag,bg,progress,thumb,x,y,rotation);
		container->addChild(pSlider);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlProgress) == 0){//progress
		const char* bg = item->first_attribute("bg")->value();
		const char* progress = item->first_attribute("progress")->value();
		CProgressBar *pProgress = createProgress(tag,bg,progress,x,y,rotation);
		container->addChild(pProgress);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlLabel) == 0){//label
		float size = atof(item->first_attribute("textSize")->value());
		int alignment = atoi(item->first_attribute("alignment")->value());
		const char* text = item->first_attribute("text")->value();
		const char* font = item->first_attribute("textFont")->value();
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		
		int r = atoi(item->first_attribute("red")->value());
		int g = atoi(item->first_attribute("green")->value());
		int b = atoi(item->first_attribute("blue")->value());
		int r2 = atoi(item->first_attribute("strokeRed")->value());
		int g2 = atoi(item->first_attribute("strokeGreen")->value());
		int b2 = atoi(item->first_attribute("strokeBlue")->value());
		int strokeSize = atoi(item->first_attribute("strokeSize")->value());
		int shadowDistance = atoi(item->first_attribute("shadowDistance")->value());
		int shadowBlur = atoi(item->first_attribute("shadowBlur")->value());
		CLabel *pLabel = createLabel(tag, text, font, alignment, size, r, g, b, x, y, w, h,
									r2,g2,b2,strokeSize,shadowDistance,shadowBlur,rotation);
		container->addChild(pLabel);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlLabelAtlas) == 0){//labelAtlas
		const char* imgPath = item->first_attribute("image")->value();
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		CLabelAtlas *pLabAtlas = createLabelAtlas(tag,imgPath,x,y,w,h,rotation);
		container->addChild(pLabAtlas);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlArmature) == 0){//armature
		const char* xml = item->first_attribute("xml")->value();
		const char* png = item->first_attribute("png")->value();
		const char* plist = item->first_attribute("plist")->value();
		const char* name = item->first_attribute("name")->value();
		Armature *pArmature = createArmature(tag,name,png,plist,xml,x,y,rotation);
		container->addChild(pArmature);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlAnim) == 0){//animation
		const char* png = item->first_attribute("png")->value();
		const char* plist = item->first_attribute("plist")->value();
		const char* name = item->first_attribute("name")->value();
		Sprite *pSprite = createAnim(tag,name,png,plist,x,y,rotation);
		container->addChild(pSprite);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlControl) == 0){//controlView
		const char* baseboard = item->first_attribute("baseboard")->value();
		const char* joystick = item->first_attribute("joystick")->value();
		CControlView *pControl = createControl(tag,baseboard,joystick,x,y,rotation);
		container->addChild(pControl);

	}else if (strcmp(item->first_attribute("type")->value(), kTuiContainerScroll) == 0){//scrollView
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		int direction = atof(item->first_attribute("direction")->value());
		int innerWidth = atoi(item->first_attribute("innerWidth")->value());
		int innerHeight = atoi(item->first_attribute("innerHeight")->value());
		CScrollView *pView = createScrollView(tag, direction, innerWidth, innerHeight, x, y, w, h, rotation);
		container->addChild(pView);
		//recursive
		for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){
			parseControl(pView->getContainer(), iitem);
		}

	}else if (strcmp(item->first_attribute("type")->value(), kTuiContainerLayout) == 0){//layout
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		CLayout *pLayout = createLayout(tag, x, y, w, h, rotation);
		container->addChild(pLayout);
		//recursive
		for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){
			parseControl(pLayout, iitem);
		}
		Vector<Node*> vet = pLayout->getChildren();
		for (Node *pChild : vet){//Offset coordinates Because CLayout zero point in the lower left corner
			pChild->setPosition(pChild->getPosition() + Point(w / 2, h / 2));
		}

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlListView) == 0){//listView
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		const char* img = item->first_attribute("image")->value();
		float num = atof(item->first_attribute("num")->value());
		CListView* pList = createListView(tag,img,x,y,w,h,rotation);
		container->addChild(pList);

		for(int i=0; i<num;i++){//add item
			xml_node<char> *iitem = item->first_node( kTuiNodeControl );
			w = atof(iitem->first_attribute("width")->value());
			h = atof(iitem->first_attribute("height")->value());

			CLayout *pLayout = createLayout(i,0,0,w,h,rotation);
			for( xml_node<char> *iiitem = iitem->first_node( kTuiNodeControl );iiitem!=NULL; iiitem = iiitem->next_sibling()){
				parseControl(pLayout,iiitem);
			}
			Vector<Node*> vet = pLayout->getChildren();
			for(Node *pChild : vet){//Offset coordinates Because CLayout zero point in the lower left corner
				if(pChild->getTag() > 0)
					pChild->setPosition(pChild->getPosition()+Point(w/2,h/2));
			}
			pList->insertNodeAtLast(pLayout);
		}
		pList->reloadData();

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlPageView) == 0){//pageView
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		float num = atoi(item->first_attribute("num")->value());
		int dir = atoi(item->first_attribute("direction")->value());
		const char* img = item->first_attribute("image")->value();
		CPageView *pPageView = createPageView(tag, img, dir, num, x, y, w, h, rotation);
		container->addChild(pPageView);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlCheckBox) == 0){//checkBox
		const char* normal1 = item->first_attribute("normal1")->value();
		const char* normal2 = item->first_attribute("normal2")->value();
		const char* select1 = item->first_attribute("select1")->value();
		const char* select2 = item->first_attribute("select2")->value();
		const char* disable1 = item->first_attribute("disable1")->value();
		const char* disable2 = item->first_attribute("disable2")->value();
		CCheckBox *pCheckBox = createCheckBox(tag,normal1,normal2,select1,select2,disable1,disable2,x,y,rotation);
		container->addChild(pCheckBox);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlArmatureBtn) == 0){//ArmatureBtn
		const char* png = item->first_attribute("png")->value();
		const char* plist = item->first_attribute("plist")->value();
		const char* name = item->first_attribute("name")->value();
		const char* xml = item->first_attribute("xml")->value();
		ArmatureBtn *pArmBtn = createArmatureBtn(tag,name,png,plist,xml,x,y,rotation);
		container->addChild(pArmBtn);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlNumbericStepper) == 0){//NumbericStepper
		const char* lnormal = item->first_attribute("lnormal")->value();
		const char* rnormal = item->first_attribute("rnormal")->value();
		const char* lselect = item->first_attribute("lselect")->value();
		const char* rselect = item->first_attribute("rselect")->value();
		const char* ldisable = item->first_attribute("ldisable")->value();
		const char* rdisable = item->first_attribute("rdisable")->value();
		const char* stepBg = item->first_attribute("stepBg")->value();
		NumericStepper *pNumStep = createNumStep(tag,lnormal,lselect,ldisable,rnormal,rselect,rdisable,stepBg,x,y,rotation);
		container->addChild(pNumStep);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlPaticle) == 0){//Paticle
		const char* plist = item->first_attribute("plist")->value();
		ParticleSystem *pPartical = createParticle(tag,plist,x,y);
		container->addChild(pPartical);

	}else if (strcmp(item->first_attribute("type")->value(), kTuiControlTable) == 0){//TableView
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		float num = atoi(item->first_attribute("num")->value());
		int dir = atoi(item->first_attribute("direction")->value());
		int cellWidth = atoi(item->first_attribute("cellWidth")->value());
		int cellHeight = atoi(item->first_attribute("cellHeight")->value());
		const char* img = item->first_attribute("image")->value();
		CTableView *pView = createTableView(tag, img, dir, num, cellWidth, cellHeight, x, y, w, h, rotation);
		container->addChild(pView);

	}else if (strcmp(item->first_attribute("type")->value(), kTuiControlGridView) == 0){//GridView
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		int cellWidth = atoi(item->first_attribute("cellWidth")->value());
		int cellHeight = atoi(item->first_attribute("cellHeight")->value());
		int column = atoi(item->first_attribute("column")->value());
		int num = atoi(item->first_attribute("num")->value());
		const char* img = item->first_attribute("image")->value();
		CGridView *pView = createGridView(tag, img, column, num, cellWidth, cellHeight, x, y, w, h, rotation);
		container->addChild(pView);
	
	}else if (strcmp(item->first_attribute("type")->value(), kTuiControlGridPageView) == 0){//GridPageView
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		int cellWidth = atoi(item->first_attribute("cellWidth")->value());
		int cellHeight = atoi(item->first_attribute("cellHeight")->value());
		int column = atoi(item->first_attribute("column")->value());
		int row = atoi(item->first_attribute("row")->value());
		int num = atoi(item->first_attribute("num")->value());
		int dir = atoi(item->first_attribute("direction")->value());
		const char* img = item->first_attribute("image")->value();
		CGridPageView *pView = createGridPageView(tag, img, dir, column, row, num, cellWidth, cellHeight, x, y, w, h, rotation);
		container->addChild(pView);

	}else if(strcmp(item->first_attribute("type")->value(),kTuiControlEditBox) == 0){//EditBox
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		const char* img = item->first_attribute("image")->value();
		int inputMode = atoi(item->first_attribute("inputMode")->value());
		int inputFlag = atoi(item->first_attribute("inputFlag")->value());
		EditBox *pEdit = createEditBox(tag, img, inputMode, inputFlag, x, y, w, h, rotation);
		container->addChild(pEdit);

	}else if (strcmp(item->first_attribute("type")->value(), kTuiControlMovieView) == 0){//MovieView
		const char* png = item->first_attribute("png")->value();
		const char* plist = item->first_attribute("plist")->value();
		const char* json = item->first_attribute("json")->value();
		MovieView *pMovieView = createMovieView(tag, json, plist, png, x, y, rotation);
		container->addChild(pMovieView);

	}else if (strcmp(item->first_attribute("type")->value(), kTuiContainerCircleMenu) == 0){//CircleMenu
		float w = atof(item->first_attribute("width")->value());
		float h = atof(item->first_attribute("height")->value());
		CircleMenu *pMenu = createCircleMenu(tag, x, y, w, h, rotation);
		container->addChild(pMenu);
		//recursive
		for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){
			parseControl(pMenu, iitem);
		}
		pMenu->reloadData();
	}
}
Beispiel #26
0
void CCommandLayer::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
	CCity &data = m_commandData.cityList[uIdx];

	CLayout *lay = UICloneMgr::cloneLayout(m_cell);
	for (int i=1;i<=6;++i)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);
		if (i==1)
		{
			child->setTag(uIdx+100);
			child->setUserData((void*)&m_commandData.cityList[uIdx]);
			((CButton*)child)->setOnClickListener(this,ccw_click_selector(CCommandLayer::onSelectCity));
		}
		else if(i==3)
		{
			CLabel *name = (CLabel*)child;
			name->setString(data.cityName.c_str());
		}
		else if (i==2)
		{
			((CButton*)child)->setEnabled(false);
			CCSprite *prop = CCSprite::create(CCString::createWithFormat("command/%d.jpg",data.cityId*10)->getCString());
			if (prop)
			{
				prop->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
				child->addChild(prop,0,1);
			}
			else 
			{
				prop = CImageView::create("command/30.jpg");
				prop->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
				child->addChild(prop,0,1);
			}
		}

		else if(i==4)
		{
			CLabel *level = (CLabel*)child;
			level->setString(CCString::createWithFormat(GETLANGSTR(230),data.level)->getCString());
		}
		else if (i==5)
		{
			UserData *user = DataCenter::sharedData()->getUser()->getUserData();
			if (user->getRoleFood()>=data.lvFood)
			{
				child->setVisible(false);
			}
		}
		else if (i==6)
 		{
			UserData *user = DataCenter::sharedData()->getUser()->getUserData();
			if (m_commandData.cityInfo.level>=data.level&&m_commandData.cityInfo.cityId!=data.cityId&&user->getRoleFood()>=data.lvFood)
			{
				child->setVisible(false);
			}
			else if(m_commandData.cityInfo.cityId==data.cityId&&user->getRoleFood()>=data.lvFood)
			{
				child->setVisible(false);
			}
 		}
	}
}
Beispiel #27
0
void CHandBookHeroLayer::addTableCell( unsigned int uIdx, CTableViewCell * pCell )
{
	//先克隆外框条
	CLayout *pLay = UICloneMgr::cloneLayout(m_pCellBlank);

	//对应数据
	AtlasIns *pAtlasIns = m_AtlasResponse.mutable_atlas_list()->Mutable(uIdx);

	//赋值
	for (unsigned int i=1; i<=10; i++)
	{
		CCNode *child = pLay->getChildByTag(i);
		pLay->removeChild(child);
		child->setTag(i);
		pCell->addChild(child);
		pCell->setTag(uIdx);
	}

	//1-活动底板
	{
		CImageView* pBoard = dynamic_cast<CImageView*>(pCell->getChildByTag(1));
		pBoard->setTouchEnabled(true);
		pBoard->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickBlank));

		if ( uIdx==m_iSelectIndex )
		{
			pBoard->setTexture(CCTextureCache::sharedTextureCache()->addImage("handBook/bookbg_2.png"));
		}
		else
		{
			pBoard->setTexture(CCTextureCache::sharedTextureCache()->addImage("handBook/bookbg_1.png"));
		}
	}

	//2-组合名字
	{
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(2));
	}

	//3-//组合描述
	{
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(3));
	}

	//4-礼品背景
	//5-礼品
	//10-文字
	{
		CImageView* pGiftBg = dynamic_cast<CImageView*>(pCell->getChildByTag(4));
		CImageView* pGift = dynamic_cast<CImageView*>(pCell->getChildByTag(5));
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(10));

		pLabel->setVisible(false);
		pGift->stopAllActions();

		//奖励领取标志 0未领取(不可领取),1未领取(可领取状态),2 已领取
		switch (pAtlasIns->get_prize())
		{
		case 0:
			{
				pGiftBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
				pGift->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));

			}break;
		case 1:
			{
				pGiftBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
				pGift->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
				ResetAnchorPointAndKeepSamePos(pGift, CCPointCenter);
				pGift->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 0.75f), CCScaleTo::create(0.3f, 0.7f))));

			}break;
		case 2:
			{
				pGiftBg->setVisible(false);
				pGift->setVisible(false);
				pLabel->setVisible(true);
			}break;
		default:
			break;
		}
	}


	//7-进度条
	//8-进度数字
	//9-进度图标
	{
		CProgressBar* pProgress = dynamic_cast<CProgressBar*>(pCell->getChildByTag(7));

		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(8));
		pLabel->setTouchEnabled(true);
		pLabel->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickScoreIcon));

		CImageView* pIcon = dynamic_cast<CImageView*>(pCell->getChildByTag(9));
		pIcon->setTouchEnabled(true);
		pIcon->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickScoreIcon));
	}


	//收集列表
	CCPoint pPos(80, 54);
	int iGapX = 94;
	initListCellIcon( pAtlasIns, pPos, iGapX, pCell );

}
Beispiel #28
0
// This function is a callback from LineServices (the pfnFmt callback)
// Line services calls this to get the formattnig information for
// a non-text object in the layout, i.e. an image or a table or a div.
// We create a dobj and give it back to LS here.
// This is like a dobj constructor.
LSERR WINAPI CEmbeddedILSObj::Fmt(/*[in]*/PCFMTIN pfmtin, /*[out]*/FMTRES* pfmtres)
{
    LSTRACE(Fmt);

    BOOL                fOwnLine;
    INT                 xMinWidth;
    LONG                cchSite;
    LONG                xWidth, yHeight;
    OBJDIM              objdim;
    stylePosition       bPositionType;
    LSERR               lserr           = lserrNone;
    CLineServices*      pLS             = _pLS;
    CFlowLayout*        pFlowLayout     = pLS->_pFlowLayout;
    PLSRUN              plsrun          = PLSRUN(pfmtin->lsfrun.plsrun);
    CLayout*            pLayout         = plsrun->GetLayout(pFlowLayout);
    CElement*           pElementLayout;
    CTreeNode*          pNodeLayout;
    const CCharFormat*  pCF;
    const CFancyFormat* pFF;
    CEmbeddedDobj*      pdobj = new CEmbeddedDobj(this, pfmtin->plsdnTop);

    if(!pdobj)
    {
        lserr = lserrOutOfMemory;
        goto Cleanup;
    }

    // pLayout is the guy we're being asked to format here.
    Assert(pLayout && pLayout!=pFlowLayout);

    pElementLayout  = pLayout->ElementOwner();
    pNodeLayout     = pElementLayout->GetFirstBranch();
    pCF             = pNodeLayout->GetCharFormat();
    pFF             = pNodeLayout->GetFancyFormat();
    bPositionType   = pNodeLayout->GetCascadedposition();

    // for overlapping layouts curtail the range of characters measured
    cchSite = pLS->GetNestedElementCch(pElementLayout);

    ZeroMemory(&objdim, sizeof(OBJDIM));

    // Let's see if this an 'ownline' thingy.  Note that even if the element
    // is not by default and 'ownline' element, we may have morphed it into
    // one -- then too it has to be a block element. If it is not one (like
    // a span, then it will not live on its own line).  Check here.
    fOwnLine = pLS->IsOwnLineSite(plsrun);

    Assert(pElementLayout->IsInlinedElement());

    // Certain sites that only Microsoft supports can break with any
    // characters, so we hack that in right here.
    // BUGBUG (cthrash) This is goofy.  We should have a better way to
    // determine this than checking tag types.
    pdobj->_fIsBreakingSite= pElementLayout->Tag()==ETAG_OBJECT
        || pElementLayout->Tag()==ETAG_MARQUEE
        // This is really unfortunate -- if a site is percent sized then it becomes a breaking
        // site inside table cells. This is primarily for IE4x compat. See IE bug 42336 (SujalP)
        || pFF->_cuvWidth.GetUnitType()==CUnitValue::UNIT_PERCENT
        // One last thing - if we have a morphed non-ownline element inside
        // a table, it's considered a breaking site.
        || (!fOwnLine && !pElementLayout->_fSite);

    // If it's on its own line, and not first on line, FetchRun should have
    // terminated the line before we got here.
    // Assert( !( fOwnLine && !pfmtin->lsfgi.fFirstOnLine) );
    pFlowLayout->GetSiteWidth(pLayout, pLS->_pci,
        pLS->_lsMode==CLineServices::LSMODE_MEASURER,
        pLS->_xWrappingWidth,
        &xWidth, &yHeight, &xMinWidth);

    // v-Dimension computed in VerticalAlignObjects
    // BUGBUG (cthrash) We have rounding errors in LS; don't pass zero
    objdim.heightsRef.dvAscent = 1;
    objdim.heightsRef.dvDescent = 0;
    objdim.heightsRef.dvMultiLineHeight = 1;
    if(_pLS->_fMinMaxPass)
    {
        objdim.heightsPres = objdim.heightsRef;
    }

    if(pLS->_fIsRuby && !pLS->_fIsRubyText)
    {
        pLS->_yMaxHeightForRubyBase = max(pLS->_yMaxHeightForRubyBase, yHeight);
    }

    // We need to store two widths in the dobj: The width corresponding to
    // the wrapping width (urColumnMax) and the minimum width.  LsGetMinDur,
    // however, does not recognize two widths for ILS objects.  We therefore
    // cache the difference, and account for these in an enumeration callback
    // after the LsGetMinDur pass.
    if(!pLS->_fMinMaxPass)
    {
        pdobj->_dvMinMaxDelta = 0;
        objdim.dur = xWidth;
    }
    else
    {
        pdobj->_dvMinMaxDelta = xWidth - xMinWidth;
        objdim.dur = xMinWidth;
    }

    if(pCF->HasCharGrid(TRUE))
    {
        long lCharGridSize = pLS->GetCharGridSize();
        pdobj->_dvMinMaxDelta = pLS->GetClosestGridMultiple(lCharGridSize, pdobj->_dvMinMaxDelta);
        objdim.dur = pLS->GetClosestGridMultiple(lCharGridSize, objdim.dur);
    }

    if(fOwnLine)
    {
        // If we are inside a something like say a PRE then too we do
        // not terminate, because if there was a \r right after the ownline site
        // then we will allow that \r to break the line. We do not check if the
        // subsequent char is a \r because there might be goop(comments, hidden
        // stuff etc etc) between this site and the \r. Hence here we just march
        // forward and if we run into text or layout later on we will terminate
        // the line then. This way we will eat up the goop if any in between.
        if(!pLS->_fScanForCR)
        {
            COneRun* porOut;
            COneRun* por = pLS->_listFree.GetFreeOneRun(plsrun);

            if(!por)
            {
                lserr = lserrOutOfMemory;
                goto Cleanup;
            }

            Assert(plsrun->IsNormalRun());
            Assert(plsrun->_lscch == plsrun->_lscchOriginal);
            por->_lscpBase += plsrun->_lscch;

            // If this object has to be on its own line, then it clearly
            // ends the current line.
            lserr = pLS->TerminateLine(por, CLineServices::TL_ADDEOS, &porOut);
            if(lserr != lserrNone)
            {
                goto Cleanup;
            }

            // Free the one run
            pLS->_listFree.SpliceIn(por);
        }
        else
        {
            // Flip this bit so that we will setup pfmtres properly later on
            fOwnLine = FALSE;
        }

        // If we have an 'ownline' site, by definition this is a breaking
        // site, meaning we can (or more precisely should) break on either
        // side of the site.
        pdobj->_fIsBreakingSite = TRUE;

        // NOTE(SujalP): Bug 65906.
        // We originally used to set ourselves up to collect after space only
        // for morphed elements. As it turns out, we want to collect after space
        // from margins of _all_ ownline sites (including morphed elements),
        // because margins for ownline-sites are not accounted for in
        // VerticalAlignObjects (see CLayout::GetMarginInfo for more details --
        // it returns 0 for ownline sites).
        pLS->_pNodeForAfterSpace = pNodeLayout;

        // All ownline sites have their x position to be 0
        if(pElementLayout->HasFlag(TAGDESC_OWNLINE))
        {
            pLayout->SetXProposed(0);
        }
    }

    if(fOwnLine)
    {
        *pfmtres = fmtrCompletedRun;
    }
    else
    {
        const long urWrappingWidth = max(pfmtin->lsfgi.urColumnMax, pLS->_xWrappingWidth);

        *pfmtres = (pfmtin->lsfgi.fFirstOnLine ||
            pfmtin->lsfgi.urPen+objdim.dur<=urWrappingWidth)?fmtrCompletedRun:fmtrExceededMargin;
    }

    // This is an accessor to the dnode, telling LS to set the dnode pointing
    // to our dobj.
    lserr = LsdnFinishRegular(pLS->_plsc, cchSite, pfmtin->lsfrun.plsrun,
        pfmtin->lsfrun.plschp, (struct dobj*)pdobj, &objdim);

Cleanup:
    return lserr;
}
Beispiel #29
0
void CSignLayer::addGridCell(unsigned int uIdx, CGridViewCell* pCell)
{
// 	CHero *hero = m_currHeroList->at(uIdx);
	CSign &sign = m_signData.signList.at(uIdx);
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);
	pCell->setScale(0.97f);

	for (int i = 1; i <=4; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);
	}


	CImageView *imagView = (CImageView*)pCell->getChildByTag(1);	
	imagView->setTouchEnabled(true);
	imagView->setEnabled(true);
	imagView->setUserData(&m_signData.signList.at(uIdx));
	imagView->setOnPressListener(this, ccw_press_selector(CSignLayer::onPress));
	


	CCSprite *item = nullptr;
	if (sign.prize.thumb>=0)
	{
		CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
		SmartSetRectPrizeColor(pMask, &sign.prize);
		item = CCSprite::create(GetImageName(sign.prize.type, sign.prize.color, sign.prize.thumb).c_str());
		if(!item)
		{
			item = CCSprite::create("headImg/101.png");
			CCLOG("CSignLayer::addGridCell  error load image %d", sign.prize.thumb);
		}
		item->setPosition(ccp(pMask->getContentSize().width/2, pMask->getContentSize().height/2));
		pMask->addChild(item, -1, 2);
		item->setScale(0.9f);
	

		//加数字
		CCLabelAtlas* haveNum = CCLabelAtlas::create("", "label/no_02.png", 9, 15, 46);
		haveNum->setAnchorPoint(ccp(1.0f, 0.0f));
		haveNum->setPosition(ccp(85, 5));
		pMask->addChild(haveNum, 99, 99);

		haveNum->setString(ToString(sign.prize.num));
		if(sign.prize.num<=1)
		{
			haveNum->setVisible(false);
		}

		//添加星星
		if(sign.prize.quality > 0)
		{
			CLayout* pStarLayout = SmartGetStarLayout(&sign.prize);
			pMask->addChild(pStarLayout, 211, 211);
		}
	}

	//vip icon
	CCSprite *vip = (CCSprite*)pCell->getChildByTag(3);
	if (sign.vip>0)
	{ 
		CCTexture2D *texture = CCTextureCache::sharedTextureCache()
											->addImage(CCString::createWithFormat("public/vip_%d.png",sign.vip)->getCString());
		vip->setVisible(true);
		vip->setTexture(texture);
	}
	else
	{
		vip->setVisible(false);
	}

	switch (sign.status)
	{
		//没签
	case 2:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(false);
			//考虑是否加个框标示为可签
			if(uIdx == m_signData.sign && 
				(m_signData.bCanSign || (m_signData.bCanResign && m_signData.resign>0) ) )
			{
				CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
				CCSprite* pRect = CCSprite::create("common/box_light.png");
				pRect->setPosition(ccp(pMask->getPositionX()+pMask->getContentSize().width/2, pMask->getPositionY()+pMask->getContentSize().height/2));
				pCell->addChild(pRect, 100);
				pRect->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 1.03f), CCScaleTo::create(0.3f, 1.0f))));
			}
		}
		break;
		//已签
	case 1:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(true);
			//变黑
			pCell->getChildByTag(1)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(3)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//星星
			CLayout * pStarLay = (CLayout*)pCell->getChildByTag(2)->getChildByTag(211);
			if(pStarLay!=nullptr)
			{
				CCArray* pChildren = pStarLay->getChildren();
				for(int i=0; i<pChildren->count(); i++)
				{
					CCSprite* pStar = dynamic_cast<CCSprite*>(pChildren->objectAtIndex(i));
					if(pStar)
					{
						pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					}
				}
			}
			////数字
			//CCLabelAtlas * pLabel = (CCLabelAtlas*)pCell->getChildByTag(2)->getChildByTag(211);
			//if(pLabel && pLabel->isVisible())
			//{
			//	pLabel->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//}
		}
		break;
	default:
		break;
	}

}
void CHeroEvolveEffectLayer::updateData( )
{
	//面板数据
	int iValue[][2] = { 
		{m_pBaseHero->combat, m_pAimHero->combat}, 
		{m_pBaseHero->hp, m_pAimHero->hp}, 
		{m_pBaseHero->atk, m_pAimHero->atk}, 
		{m_pBaseHero->def, m_pAimHero->def},
		{m_pBaseHero->dex, m_pAimHero->dex}, 
		{m_pBaseHero->hit, m_pAimHero->hit}, 
		{m_pBaseHero->crit, m_pAimHero->crit}, 
		{m_pBaseHero->dodge, m_pAimHero->dodge},
		{m_pBaseHero->renew, m_pAimHero->renew}
	};

	//更新数据
	for(int i=0; i<9; i++)
	{
		CLayout *pLay = (CLayout *)m_pUI->findWidgetById(CCString::createWithFormat("data%d", i+1)->getCString());
		pLay->setVisible(false);
		CLabel *pBaseValue = (CLabel *)pLay->findWidgetById(CCString::createWithFormat("base_value%d", i+1)->getCString());
		pBaseValue->setString(ToString(iValue[i][0]));
		CLabel *pAimValue = (CLabel *)pLay->findWidgetById(CCString::createWithFormat("aim_value%d", i+1)->getCString());
		pAimValue->setString(ToString(iValue[i][1]));
	}
}