void ChatInput::ShowItems() { if (!m_itemLayer) { m_itemLayer = new NDUIMenuLayer(); m_itemLayer->Initialization(); m_itemLayer->GetCancelBtn()->SetDelegate(this); m_itemLayer->SetDelegate(this); NDUIRecttangle* bkg = new NDUIRecttangle(); bkg->Initialization(); bkg->SetColor(ccc4(253, 253, 253, 255)); bkg->SetFrameRect(CCRectMake(0, m_itemLayer->GetTitleHeight(), 480, m_itemLayer->GetTextHeight())); m_itemLayer->AddChild(bkg); NDPicture* picItem = NDPicturePool::DefaultPool()->AddPicture(GetImgPath("titles.png")); picItem->Cut(CCRectMake(76, 120, 103, 19)); NDUIImage* image = new NDUIImage(); image->Initialization(); image->SetPicture(picItem, true); image->SetFrameRect(CCRectMake(190, 5, picItem->GetSize().width, picItem->GetSize().height)); m_itemLayer->AddChild(image); m_itemBag = new GameItemBag(); m_itemBag->Initialization(ItemMgrObj.GetPlayerBagItems()); m_itemBag->SetPageCount(ItemMgrObj.GetPlayerBagNum()); m_itemBag->SetDelegate(this); m_itemBag->SetFrameRect(CCRectMake(100, 30, ITEM_BAG_W, ITEM_BAG_H)); m_itemLayer->AddChild(m_itemBag); } NDDirector::DefaultDirector()->GetRunningScene()->AddChild(m_itemLayer, CHAT_INPUT_Z); this->Hide(); }
void ChatInput::ShowExpressions() { if (!m_expressionLayer) { m_expressionLayer = new NDUIMenuLayer(); m_expressionLayer->Initialization(); m_expressionLayer->GetCancelBtn()->SetDelegate(this); m_expressionLayer->SetDelegate(this); NDUIRecttangle* bkg = new NDUIRecttangle(); bkg->Initialization(); bkg->SetColor(ccc4(253, 253, 253, 255)); bkg->SetFrameRect(CCRectMake(0, m_expressionLayer->GetTitleHeight(), 480, m_expressionLayer->GetTextHeight())); m_expressionLayer->AddChild(bkg); NDPicture* picExpression = NDPicturePool::DefaultPool()->AddPicture(GetImgPath("titles.png")); picExpression->Cut(CCRectMake(180, 120, 100, 19)); NDUIImage* image = new NDUIImage(); image->Initialization(); image->SetPicture(picExpression, true); image->SetFrameRect(CCRectMake(190, 5, picExpression->GetSize().width, picExpression->GetSize().height)); m_expressionLayer->AddChild(image); for (int index = 0; index < 25; index++) { NDUIButton* btn = new NDUIButton(); btn->Initialization(); btn->SetTag(tag_expression_begin + index); btn->SetDelegate(this); NDPicture* pic = NDPicturePool::DefaultPool()->AddPicture(GetImgPath("face.png")); int row = index / 5; int col = index % 5; pic->Cut(CCRectMake(15 * col, 15 * row , 15, 15)); btn->SetImage(pic, false, CCRectZero, true); btn->SetFrameRect(CCRectMake(80 + col * 60, 35 + row * 50, 40, 40)); m_expressionLayer->AddChild(btn); } } NDDirector::DefaultDirector()->GetRunningScene()->AddChild(m_expressionLayer, CHAT_INPUT_Z); this->Hide(); }
bool DrawAni::doDraw(const int frameIndex, const AniModify* mod_lev2, const AniModify* mod_lev3) { if (!m_pkAni || !m_pkInstance || !m_pkInstance->getOwnerNode()) return false; // get picture to draw NDPicture* pkPicture = getPicture(m_pkAni, frameIndex); if (!pkPicture) return false; // get node screen rect CCRect kNodeRect; NDNode* pkOwnerNode = m_pkInstance->getOwnerNode(); if (pkOwnerNode->IsA(RTCLS(NDTileObj))) { NDTileObj* pkTileObj = (NDTileObj*) pkOwnerNode; if (pkTileObj->isPlayer() || pkTileObj->isPath()) kNodeRect = pkOwnerNode->GetScreenRect(); else kNodeRect = pkOwnerNode->GetPushScreenRect(); } else { kNodeRect = pkOwnerNode->GetScreenRect(); } // node center pos (caution: world map tile obj!) CCPoint centerPos = CCPointMake( kNodeRect.origin.x + kNodeRect.size.width * 0.5f, kNodeRect.origin.y + kNodeRect.size.height * 0.5f); // get node scale (recursive) float nodeScaleX = pkOwnerNode->GetScaleX_R(); float nodeScaleY = pkOwnerNode->GetScaleY_R(); // add offset int sign = pkOwnerNode->isReverse() ? -1 : 1; centerPos.x += m_pkAni->m_kAniModifyEx.getOffsetX() * COORD_SCALE_X_960 * nodeScaleX * sign; centerPos.y += m_pkAni->m_kAniModifyEx.getOffsetY() * COORD_SCALE_Y_960 * nodeScaleY; // apply mod: offset if (mod_lev2) { centerPos.x += mod_lev2->getOffsetX() * COORD_SCALE_X_960 * nodeScaleX * sign; centerPos.y += mod_lev2->getOffsetY() * COORD_SCALE_Y_960 * nodeScaleY; } if (mod_lev3) { centerPos.x += mod_lev3->getOffsetX() * COORD_SCALE_X_960 * nodeScaleX * sign; centerPos.y += mod_lev3->getOffsetY() * COORD_SCALE_Y_960 * nodeScaleY; } // calculate pic size CCSize picSize = pkPicture->GetSize(); if (m_pkAni->m_kAniModifyEx.getStretch()) { picSize.width *= COORD_SCALE_X_960; picSize.height *= COORD_SCALE_Y_960; } else { picSize.width *= RESOURCE_SCALE_960; picSize.height *= RESOURCE_SCALE_960; } if (m_pkAni->m_kAniModifyEx.getFullScreen()) { // apply fullscreen picSize = CCDirector::sharedDirector()->getWinSizeInPixels(); } else { // size override if (m_pkAni->m_kAniModifyEx.sizeOverride()) { picSize = CCSizeMake(m_pkAni->m_kAniModifyEx.getWidth(), m_pkAni->m_kAniModifyEx.getHeight()); } // apply node scale picSize.width *= nodeScaleX; picSize.height *= nodeScaleY; // apply scale picSize.width *= m_pkAni->m_kAniModifyEx.getScale(); picSize.height *= m_pkAni->m_kAniModifyEx.getScale(); // apply mod: scale if (mod_lev2) { picSize.width *= mod_lev2->getScale(); picSize.height *= mod_lev2->getScale(); } if (mod_lev3) { picSize.width *= mod_lev3->getScale(); picSize.height *= mod_lev3->getScale(); } } // apply alpha applyAlpha(pkPicture, mod_lev2); // apply HSL applyHSL(pkPicture, mod_lev2); // target rect to draw in CCRect picRect = CCRectMake(centerPos.x - picSize.width * 0.5f, centerPos.y - picSize.height * 0.5f, picSize.width, picSize.height); // check to disable scissor if (!isAllowScissor()) { NDDirector::DefaultDirector()->DisableScissor(); } // draw if (m_pkInstance && m_pkInstance->getOwnerNode()) { // apply from action: opacity/rotation/gaussianBlur NDNode* pkOwnerNode = m_pkInstance->getOwnerNode(); pkPicture->SetOpacity(pkOwnerNode->getRGBA()->getOpacity()); pkPicture->SetRotation(pkOwnerNode->getCCNode()->getRotation()); pkPicture->SetRotationX(pkOwnerNode->getCCNode()->getRotationX()); pkPicture->SetRotationY(pkOwnerNode->getCCNode()->getRotationY()); pkPicture->setGaussianBlur(pkOwnerNode->getCCNode()->getGaussianBlur()); // toggle reverse bool bReverse = m_pkAni->m_kAniModifyEx.getReverse(); if (pkOwnerNode->isReverse()) bReverse = !bReverse; pkPicture->SetReverse(bReverse); } pkPicture->DrawInRect(picRect); }