//------------------------------------------------------------------------- void FKCW_UI_Table::arrangeItems() { unsigned int nItemCount = m_tNodes.count(); int nColumnCount = (m_bLayerDirectionHorizontal ? nItemCount / m_nWindowRowCount + (int)(nItemCount % m_nWindowRowCount > 0) : m_nWindowColumnCount); int nRowCount = (m_bLayerDirectionHorizontal ? m_nWindowRowCount : nItemCount / m_nWindowColumnCount + (int)(nItemCount % m_nWindowColumnCount > 0)); m_tLayerSize = cczDenormalizeTo(ccz((float)nColumnCount, (float)nRowCount), m_tCellSize); int nItemNum = 0; if (CCArray* __pArray = (&m_tNodes)) { for (unsigned int __idx = 0; __idx < __pArray->data->num; ++__idx) { if ( CCNode* pNode = ( CCNode* )*(__pArray->data->arr + __idx)) { pNode->setPosition(ccpShift(m_tWindowRect.origin, cczDenormalizeTo( ccz( m_bFillDirectionHorizontal ? nItemNum % nColumnCount : nItemNum / nRowCount, nRowCount - 1 - (m_bFillDirectionHorizontal ? nItemNum / nColumnCount : nItemNum % nRowCount)), m_tCellSize))); ++nItemNum; } } } }
GIUnitParametersNode* GIUnitParametersNode::create(float baseW) { GIUnitParametersNode* result = new GIUnitParametersNode(baseW); result->autorelease(); result->setContentSize(ccz(68, 110)); result->setAnchorPoint(ccp(0, 0)); return result; }
bool CCTableWorker::init(const CCRect& tWindowRect, int nWindowColumnCount, int nWindowRowCount, bool bFillDirectionHorizontal, bool bLayerDirectionHorizontal) { m_tWindowRect = tWindowRect; m_nWindowColumnCount = nWindowColumnCount; m_nWindowRowCount = nWindowRowCount; m_bFillDirectionHorizontal = bFillDirectionHorizontal; m_bLayerDirectionHorizontal = bLayerDirectionHorizontal; m_tCellSize = cczNormalizeTo(m_tWindowRect.size, ccz(m_nWindowColumnCount, m_nWindowRowCount)); return true; }
void CCTableWorker::arrangeItems() { unsigned int nItemCount = m_tNodes.count(); int nColumnCount = (m_bLayerDirectionHorizontal ? nItemCount / m_nWindowRowCount + (int)(nItemCount % m_nWindowRowCount > 0) : m_nWindowColumnCount); int nRowCount = (m_bLayerDirectionHorizontal ? m_nWindowRowCount : nItemCount / m_nWindowColumnCount + (int)(nItemCount % m_nWindowColumnCount > 0)); m_tLayerSize = cczDenormalizeTo(ccz((float)nColumnCount, (float)nRowCount), m_tCellSize); int nItemNum = 0; CCARRAY_FOREACH_OBJECT(&m_tNodes, CCNode*, pNode) { pNode->setPosition(ccpShift(m_tWindowRect.origin, cczDenormalizeTo( ccz( m_bFillDirectionHorizontal ? nItemNum % nColumnCount : nItemNum / nRowCount, nRowCount - 1 - (m_bFillDirectionHorizontal ? nItemNum / nColumnCount : nItemNum % nRowCount)), m_tCellSize))); ++nItemNum; } }
GIUnitParametersNode::GIUnitParametersNode(float baseW) { statsFrame = CCLayerColor::create(CocosHelper::normalColor(), baseW, 109); statsFrame->setAnchorPoint(ccp(0, 0)); statsFrame->setPosition(ccp(0, 0)); addChild(statsFrame); _labelType = CCLabelTTF::create("", MAX_DEFAULT_FONT, 10); _labelType->setAnchorPoint(ccp(0, 0)); _labelType->setPosition(ccp(8, _topStart - 9)); _labelType->setContentSize(ccz(30, 12)); _labelType->setColor(MAX_COLOR_WHITE); addChild(_labelType); }
StageUI_Base::StageUI_Base() { m_pkUIPercentLabel = NULL; m_pkUILayer = 0; m_pkUnzipProgress = 0; m_pkBackgroundImage = 0; m_pkProgressBgImage = 0; m_pkUnzipTextImage = 0; m_pkUILayer = new NDUIDialog; m_pkUILayer->Initialization(); m_pkUILayer->SetAlwaysFullScreen(true); m_pkUILayer->NoMask(); getPercentLabel(); if (m_pkUILayer) { m_pkUILayer->AddChild( m_pkUIPercentLabel, 1 ); m_pkUIPercentLabel->SetText(CONVERT_GBK_TO_UTF8("正在检查是否需要更新……")); } m_pkBackgroundImage = new NDUIImage; m_pkBackgroundImage->Initialization(); m_pkUnzipTextImage = new NDUIImage; m_pkUnzipTextImage->Initialization(); m_pkProgressBgImage = new NDUIImage; m_pkProgressBgImage->Initialization(); m_pkUnzipProgress = new NDUIExp; m_pkUnzipProgress->Initialization(); m_pkUnzipProgress->SetNoText(); m_pkUnzipProgress->setMaskMode(true); m_pkUnzipProgress->setMaskPercent(0.1f); //m_pkUnzipProgress->SetFgDrawFirst(); unsigned long uiBgDataSize = 0; unsigned long uiBgProgressDataSize = 0; unsigned long uiFgProgressDataSize = 0; unsigned long uiProgressEffectSize = 0; unsigned long uiUnzipTextSize = 0; unsigned char* pszBgImageFileData = 0; unsigned char* pszBgProgressImageData = 0; unsigned char* pszFgProgressImageData = 0; unsigned char* pszProgressEffectData = 0; unsigned char* pszUnzipTextData = 0; string strPath = ""; float fWinScale = 2.0f; CCSize kWinSize = ccz(0,0); CCSize kRealWinSize = CCDirector::sharedDirector()->getWinSize(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) strPath = "assets/install_res/"; fWinScale = 1.0f; #elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) strPath = "../install_res/"; fWinScale = 2.0f; #endif CCRect kRect = m_pkUILayer->GetFrameRect(); float fHeight = CCDirector::sharedDirector()->getWinSize().height; float fWidth = CCDirector::sharedDirector()->getWinSize().width; float fWindowScale = fHeight / fWidth; float fRealScreenHeight = 960.0f / fWinScale; float fRealScreenWidth = 640.0f / fWinScale; float fCtrlScale = fWidth / fRealScreenWidth; float fCurHeight = (fHeight - fRealScreenHeight * fCtrlScale) / 2.0f * fWinScale; kWinSize = ccz(fRealScreenWidth * fCtrlScale * fWinScale,fRealScreenHeight * fCtrlScale * fWinScale); m_pkBackgroundImage->SetFrameRect(CCRectMake(0,fCurHeight,kWinSize.width,kWinSize.height)); //m_nOffsetHeight = fCurHeight; m_strBgImageFile = strPath + string("bg_image.png"); m_strBgProgressImage = strPath + string("bg_progress.png"); m_strFgProgressImage = strPath + string("fg_progress.png"); m_strProgressEffect = strPath + string("progress_effect.png"); m_strUnzipTextFile = strPath + string("load_text.png"); pszBgImageFileData = __getFileData(m_strBgImageFile.c_str(),"rb",&uiBgDataSize); pszBgProgressImageData = __getFileData(m_strBgProgressImage.c_str(),"rb",&uiBgProgressDataSize); pszFgProgressImageData = __getFileData(m_strFgProgressImage.c_str(),"rb",&uiFgProgressDataSize); pszProgressEffectData = __getFileData(m_strProgressEffect.c_str(),"rb",&uiProgressEffectSize); pszUnzipTextData = __getFileData(m_strUnzipTextFile.c_str(),"rb",&uiUnzipTextSize); if (0 == pszBgImageFileData || 0 == pszBgProgressImageData || 0 == pszFgProgressImageData || 0 == pszProgressEffectData || 0 == pszUnzipTextData) { WriteConErr("Data Error!!\n"); return; } float fProgressWidth = kWinSize.width * 0.9f; CCRect kProgressRect = CCRectMake((kWinSize.width - fProgressWidth) / 2.0f, kWinSize.height * 0.8f + fCurHeight, fProgressWidth, fProgressWidth * 0.086207); // kProgressRect.origin.x *= fWinScale; // kProgressRect.origin.y *= fWinScale; // kProgressRect.size.width *= fWinScale; // kProgressRect.size.height *= fWinScale; CCRect kTextRect = kProgressRect; kTextRect.origin.y -= kTextRect.size.height; m_pkUIPercentLabel->SetFrameRect(kTextRect); m_pkUnzipProgress->SetFrameRect(kProgressRect); m_pkProgressBgImage->SetFrameRect(kProgressRect); //GetUIRootNew()->addDlg(m_pkUILayer); NDPicture* pkUnzipTextPicture = new NDPicture; pkUnzipTextPicture->Initialization(pszUnzipTextData, uiUnzipTextSize); NDPicture* pkBgPicture = new NDPicture; pkBgPicture->Initialization(pszBgImageFileData, uiBgDataSize); NDPicture* pkEffectPicture = new NDPicture; pkEffectPicture->Initialization(pszProgressEffectData, uiProgressEffectSize); NDPicture* pkBgProgressPic = new NDPicture; pkBgProgressPic->Initialization(pszBgProgressImageData, uiBgProgressDataSize); NDPicture* pkFgProgressPic = new NDPicture; pkFgProgressPic->Initialization(pszFgProgressImageData, uiFgProgressDataSize); m_pkBackgroundImage->SetPicture(pkBgPicture); m_pkUnzipProgress->SetPicture(pkBgProgressPic, pkFgProgressPic); m_pkProgressBgImage->SetPicture(pkEffectPicture); m_pkUnzipTextImage->SetPicture(pkUnzipTextPicture); //m_pkUnzipTextImage->SetFrameRect(kUnzipTextRect); //m_pkUILayer->SetZOrder(1000); GetUIRootNew()->AddChild(m_pkUILayer); showProgress(false); m_pkUILayer->AddChild(m_pkBackgroundImage, 0); m_pkUILayer->AddChild(m_pkProgressBgImage, 2); m_pkUILayer->AddChild(m_pkUnzipProgress, 1); }