//----------------------------------------------------- M�thodes prot�g�es void SimpleCopyVisitor::visit(const TextNode& node) { #ifdef XSL_TRANSFORM_TRACE clog << "SimpleCopy on TextNode:" << node.content() << endl; #endif _copiedNode = new TextNode(_parentProxy, node.content()); }
void TitleBar::setTitleSprite(const char *name) { removePreTitle(); CCSprite *titleSp = CCSprite::spriteWithSpriteFrameName(name); if(strlen(name)==0) return; if (!titleSp) { titleSp = CCSprite::spriteWithFile(name); } if(titleSp) { titleSp->setPosition(ccp(58, 45)); titleSp->setAnchorPoint(ccp(0, 0.5)); addChild(titleSp); titleSp->setTag(kTitleBarSprite); } else { TextNode* titleLabel = TextNode::textWithString(name, CCSizeMake(300, 40), CCTextAlignmentLeft, 40); titleLabel->setAnchorPoint(CCPointMake(0.0, 0.5)); titleLabel->setPosition(CCPointMake(60, 45)); titleLabel->setShadowColor(ccBLACK); addChild(titleLabel); titleLabel->setTag(kTitleBarLabel); } }
void FriendInvitationLayer::showInvitationCode(const char *invitationCode) { CCSprite *spInvitationBg = CCSprite::spriteWithFile("invitation_bg.png"); spInvitationBg->setPosition(CCPointMake(320, 440)); addChild(spInvitationBg); CCSprite *tempSprite1 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png"); CCSprite *tempSprite2 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png"); CCMenuItem *menuItemSina = CCMenuItemImage::itemFromNormalSprite(tempSprite1, tempSprite2, this, menu_selector(FriendInvitationLayer::inviteFriendFromWeibo)); menuItemSina->setAnchorPoint(CCPointMake(0, 0)); CCMenu *menu = CCMenu::menuWithItem(menuItemSina); menu->setPosition(CCPointMake(280, 505)); addChild(menu); if(CGameData::Inst()->getLoginType() == enLoginReqType_TencentLogin){ menuItemSina ->setIsVisible(CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg); }else if(CGameData::Inst()->getLoginType() == enLoginReqType_SinaLogin){ menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg); }else { menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg|CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg); } TextNode *lbInvitationCode = TextNode::textWithString(invitationCode, CCSizeMake(500, 40), CCTextAlignmentLeft, 32); lbInvitationCode->setColor(ccRED); lbInvitationCode->setPosition(CCPointMake(550, 646)); addChild(lbInvitationCode); }
TEST_F(TextNodeTest, new_text_node) { TextNode *tn; tn = doc.new_text_node("I am text"); ASSERT_EQ("I am text", tn->text()); }
osg::ref_ptr<Object> PrimitivesFactory::createTextNode(const std::string& text, double fontSize, osg::Vec4 color) { TextNode* node = new TextNode(text, fontSize); node->setColor(color); return node; }
TEST_F(TextNodeTest, output) { TextNode *tn; StringOutput out; tn = doc.new_text_node("I am text"); tn->output(out); ASSERT_STREQ("I am text", out.string()); }
void TitleBar::setTitleString(const char* str) { removePreTitle(); TextNode* titleLabel = TextNode::textWithString(str, CCSizeMake(300, 40), CCTextAlignmentLeft, 40); titleLabel->setShadowColor(ccBLACK); titleLabel->setAnchorPoint(CCPointMake(0.0, 0.5)); titleLabel->setPosition(CCPointMake(60, 45)); addChild(titleLabel); titleLabel->setTag(kTitleBarLabel); }
int Paragraph::heightForRange(int start, int len) const { int h=0; for (int i=0;i<m_p->nodes.size();i++) { TextNode node = m_p->nodes[i]; if (node.height() > h) h = node.height(); } return h; }
TextNode *SceneGraph::findTextNode(char *name) { if (!name || strlen(name) <= 0) return NULL; for (TextNode *node = findTextNode(); node; node = node->nextTraversal()) { const char *nodeName = node->getName(); if (nodeName && strlen(nodeName)) { if (!strcmp(name, nodeName)) return node; } } return NULL; }
bool TextOutput::check(sedna::Query &query) { #ifdef SETEST_DEBUG std::cout << "TEST======A======TEST" << std::endl; #endif /* Wrapping text and result in XML Containers and compare them as xml */ if (query.resultCode != SEDNA_QUERY_SUCCEEDED) { //Query exited with error or it was bulk load or update (incorrect test case) return false; } #ifdef SETEST_DEBUG std::cout << "TEST======B======TEST" << std::endl; #endif string answerString; boost::filesystem::path answerFile(fileName); answerString.resize(boost::filesystem::file_size(fileName)); boost::filesystem::ifstream answerFileStream(answerFile); answerFileStream.read(&answerString[0], answerString.size()); Document answerDoc; Element *answerRoot = answerDoc.create_root_node("TextOutput"); //answerRoot->add_child_text(answerString); TextNode* tmpA = answerRoot->add_child_text(answerString); Document resultDoc; Element *resultRoot = answerDoc.create_root_node("TextOutput"); //resultRoot->add_child_text(query.resultString); TextNode* tmpB = resultRoot->add_child_text(query.resultString); #ifdef SETEST_DEBUG std::cout << "TEST======D======TEST" << std::endl; #endif std::istringstream answerStream(answerDoc.write_to_string()); std::istringstream resultStream(answerDoc.write_to_string()); #ifdef SETEST_DEBUG std::cout << "TEST======C======TEST" << std::endl; std::cout << query.resultString << std::endl; std::string tmpBB = string(tmpB->get_content()); std::cout << tmpBB << std::endl; std::cout << "=====================" << std::endl; std::cout << answerString << std::endl; std::string tmpAA = string(tmpA->get_content()); std::cout << tmpAA << std::endl; std::cout << "END======C=======END" << std::endl; #endif XmlDiff xmlDiff(answerStream, resultStream); return !xmlDiff.diff(); }
void TitleBar::removePreTitle() { CCSprite *preSp = (CCSprite*)getChildByTag(kTitleBarSprite); if (preSp) { preSp->removeFromParentAndCleanup(true); preSp = NULL; } TextNode *preLb = (TextNode*)getChildByTag(kTitleBarLabel); if (preLb) { preLb->removeFromParentAndCleanup(true); preLb = NULL; } }
void Card::fengYinUpdate(int cd) { m_FengYinCD -= cd; if (m_FengYinCD <= 0) { m_FengYinCD = 0; setCardState(EN_CARD_STATE_NORMAL); } else { char buf[10]; sprintf(buf, "%d",m_FengYinCD); TextNode* tempText = (TextNode*)getChildByTag(FENGYINPNGTAG+1); tempText->setString(buf); } }
BonusPanel::BonusPanel() { m_commDlg = NULL; m_cntryDialog = NULL; m_lyPanel = CCLayer::node(); addChild(m_lyPanel); CCSprite* spBg = CCSprite::spriteWithFile("bonuspanel.png"); if (spBg) { m_lyPanel->addChild(spBg, -1); spBg->setAnchorPoint(ccp(0,1)); spBg->setPosition(CCPointZero); } char buf[64]; //元宝数 long lGuildCoin = CGameData::Inst()->getGuildCoin(); snprintf(buf, sizeof(buf), "%s:%ld", CGameData::Inst()->getLanguageValue("deadDlgtip6"), lGuildCoin); m_txtCoin = TextNode::textWithString(buf, 22); m_txtCoin->setPosition(CCPointMake(307, -34)); m_txtCoin->setColor(ccBLACK); m_lyPanel->addChild(m_txtCoin); //成员、近5次伤害、上次伤害 TextNode* txtMember = TextNode::textWithString(CGameData::Inst()->getLanguageValue("cntry_member_alone"), 22); txtMember->setPosition(CCPointMake(120, -70)); txtMember->setColor(ccc3(93, 0, 4)); m_lyPanel->addChild(txtMember); TextNode* txtRecentScore = TextNode::textWithString(CGameData::Inst()->getLanguageValue("jifeng_recentscore"), 22); txtRecentScore->setPosition(CCPointMake(270, -70)); txtRecentScore->setColor(ccc3(93, 0, 4)); m_lyPanel->addChild(txtRecentScore); TextNode* txtLastScore = TextNode::textWithString(CGameData::Inst()->getLanguageValue("jifeng_lastscore"), 22); txtLastScore->setPosition(CCPointMake(410, -70)); txtLastScore->setColor(ccc3(93, 0, 4)); m_lyPanel->addChild(txtLastScore); //列表 m_pBonusList = new BonusList(this, callfuncO_selector(BonusPanel::cbBonusList)); m_lyPanel->addChild(m_pBonusList); m_pBonusList->setPosition(CCPointZero); }
int Paragraph::widthForRange(int start, int len) const { int pos,sz,spos,ln; int width = 0; pos = 0; for (int i=0;i<m_p->nodes.size();i++) { TextNode node = m_p->nodes[i]; sz = node.text().size(); if (start > pos+sz) { pos += sz; continue; } spos = start - pos; if (spos + len > sz) { len = spos + len - sz; ln = sz - spos; } else ln = len; width += node.widthForRange(spos,ln); if (len == ln) break; else start = pos + sz; pos += sz; } return width; }
//****************************************************************************** // initConnecting //****************************************************************************** void CommDlg::initConnecting() { CCSprite* sp = CCSprite::spriteWithSpriteFrameName("commdlg.png"); if(sp){ addChild(sp); } char buf[100]; CCSprite *temSp = CCSprite::spriteWithSpriteFrameName("loading0001.png"); temSp->setPosition(CCPointMake(-120 - 15, 30)); addChild(temSp); CCAnimation *loadingAnim = CCAnimation::animation(); char loadingAnimName[100] = {0}; for (int i = 1; i <= 8 ; i++) { sprintf(loadingAnimName, "loading00%02d.png", i); CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName( loadingAnimName ); loadingAnim->addFrame(frame); } loadingAnim->setDelay(1.0f / 8); CCAnimate* loadingAction = CCAnimate::actionWithAnimation(loadingAnim, true); temSp->runAction(CCRepeatForever::actionWithAction(loadingAction)); snprintf(buf, 99, "%s",OcProxy::Inst()->localizedStringStatic("loading_title")); TextNode* lbText = TextNode::textWithString(buf, CCSizeMake(200, 45), CCTextAlignmentCenter,45); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); lbText->setPosition(CCPointMake(60 - 45, 20)); addChild(lbText, 2); CCLabelTTF* ttfText = CCLabelTTF::labelWithString(OcProxy::Inst()->localizedStringStatic("loading_prompt"), CCSizeMake(360, 60), CCTextAlignmentCenter, "default.ttf", 20); ttfText->setColor(ccc3(233, 183, 72)); ttfText->setPosition(CCPointMake(0, -80)); addChild(ttfText); }
DeadDlg::DeadDlg(CCObject *listener,SEL_CallFuncO selector,int type) { // CCLayerColor *layer = CCLayerColor::layerWithColor) m_listener = listener; m_selector = selector; m_backGround = CCSprite::spriteWithSpriteFrameName("fr_window2.png"); m_backGround->setScale(2.0); addChild(m_backGround); m_backGround->setPosition(ccp(320, 500)); CCSprite* spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_button.png"); CCSprite* spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_button.png"); sureItem = CCMenuItemImage::itemFromNormalSprite(spMenu1, spMenu2, this, menu_selector(DeadDlg::menuCallback)); sureItem->setTag(111); sureItem->setPosition(ccp(88, 284)); int need; long hold; if (CGameData::Inst()->chkLogin()) { need = CGameData::Inst()->getCommonInfo()->revive_coin; } else { need = SaveData::Inst()->getReviveCoin(); } if(CGameData::Inst()->getUsrInfo()->login_time > 0){ hold = CGameData::Inst()->getUsrInfo()->coin; SaveData::Inst()->setCurCoin(hold); } else{ hold = SaveData::Inst()->getCurCoin(); } char buf[100]; if(type == enDeadType_normal) { if (hold<need) { strncpy(buf, CGameData::Inst()->getLanguageValue("shopTip14"), 99); } else { strncpy(buf, CGameData::Inst()->getLanguageValue("sureTip"), 99); } } else if(type == enDeadType_free) { strncpy(buf, CGameData::Inst()->getLanguageValue("sureTip"), 99); } TextNode *sureLabel = TextNode::textWithString(buf, 42); sureLabel->setColor(ccc3(255, 255, 255)); sureLabel->setShadowColor(ccBLACK); sureLabel->setPosition(CCPointMake(spMenu1->getContentSize().width * 0.5 - 2, spMenu1->getContentSize().height * 0.5 + 2)); sureItem->addChild(sureLabel); spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_button.png"); spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_button.png"); cancelItem = CCMenuItemImage::itemFromNormalSprite(spMenu1, spMenu2, this, menu_selector(DeadDlg::menuCallback)); cancelItem->setTag(112); cancelItem->setPosition(ccp(394, 284)); TextNode *cancelLabel = TextNode::textWithString(CGameData::Inst()->getLanguageValue("cancelTip"), 42); cancelLabel->setColor(ccc3(255, 255, 255)); cancelLabel->setShadowColor(ccBLACK); cancelLabel->setPosition(CCPointMake(spMenu1->getContentSize().width * 0.5 - 2, spMenu1->getContentSize().height * 0.5 + 2)); cancelItem->addChild(cancelLabel); sureItem->setAnchorPoint(ccp(0, 0)); cancelItem->setAnchorPoint(ccp(0, 0)); CCMenu *menu = CCMenu::menuWithItems(sureItem,cancelItem,NULL); menu->setPosition(ccp(0, 0)); addChild(menu); TextNode *titleLabel = TextNode::textWithString(CGameData::Inst()->getLanguageValue("deadDlgtip1"), 55); titleLabel->setColor(ccc3(122, 37, 8)); addChild(titleLabel); titleLabel->setPosition(ccp(320, 420+255)); if(type == enDeadType_normal) { if (hold<need) { snprintf(buf, 99, "%s%d%s",CGameData::Inst()->getLanguageValue("deadDlgtip2"),need,CGameData::Inst()->getLanguageValue("deadDlgtip3")); } else { snprintf(buf, 99, "%s%d%s",CGameData::Inst()->getLanguageValue("deadDlgtip2"),need,CGameData::Inst()->getLanguageValue("deadDlgtip4")); } infoLabel = TextNode::textWithString(buf, CCSize(388, 70), CCTextAlignmentCenter, 30); infoLabel->setPosition(ccp(320, 300+255)); infoLabel->setColor(ccc3(63, 23, 13)); addChild(infoLabel); } else if(type == enDeadType_free) { snprintf(buf, 99,CGameData::Inst()->getLanguageValue("deadDlgtip7"),CGameData::Inst()->getCommonInfo()->free_revive_lv); infoLabel = TextNode::textWithString(buf, CCSize(388, 110), CCTextAlignmentCenter, 30); infoLabel->setPosition(ccp(320, 300+205)); infoLabel->setColor(ccc3(63, 23, 13)); addChild(infoLabel); } if(type == enDeadType_normal) { snprintf(buf, 99,"%s%ld%s!",CGameData::Inst()->getLanguageValue("deadDlgtip5"),hold,CGameData::Inst()->getLanguageValue("deadDlgtip6")); myYuanbaoLabel = TextNode::textWithString(buf, CCSize(388, 70), CCTextAlignmentCenter, 30); myYuanbaoLabel->setPosition(ccp(320, 190+255)); myYuanbaoLabel->setColor(ccc3(63, 23, 13)); addChild(myYuanbaoLabel); } }
CCLayer* RemindLayer::createRLayer(const char *tStr, int remindType){ CCLayer* layer = new CCLayer(); int tagOpen = 0; int tagClose = 0; bool typeOn; switch (remindType) { case EN_REMIND_ACTIVITY: tagOpen = kActivityOnTag; tagClose = kActivityOffTag; typeOn = CGameData::Inst()->isActivityRemind; break; case EN_REMIND_TWOUP: tagOpen = kTwoupOnTag; tagClose = kTwoupOffTag; typeOn = CGameData::Inst()->isTwoUpRemind; break; case EN_REMIND_CNTRYCD: tagOpen = kCntryCdOnTag; tagClose = kCntryCdOffTag; typeOn = CGameData::Inst()->isCntryCdRemind; break; case EN_REMIND_POWER:{ tagOpen = kPowerOnTag; tagClose = kPowerOffTag; typeOn = CGameData::Inst()->intPowerRemind; CCSprite* spMenu1 = CCSprite::spriteWithFile("pushConfig_tilizhi.png"); CCSprite* spMenu2 = CCSprite::spriteWithFile("pushConfig_tilizhi.png"); CCMenuItem* item = CCMenuItemImage::itemFromNormalSprite(spMenu1,spMenu2, this, menu_selector(RemindLayer::MoveUpKeyboard)); item->setPosition(ccp(0,0)); item->setAnchorPoint(CCPointZero); CCMenu *menu = CCMenu::menuWithItems (item, NULL); menu->setPosition(ccp(-50,20)); layer->addChild(menu, 2); char buf[100]; snprintf(buf, 99,"%d", CGameData::Inst()->intPowerRemind); powerNumber = CCTextFieldTTF::textFieldWithPlaceHolder(buf,CCSizeMake(100, 200) ,CCTextAlignmentCenter,"huakangfont.ttf", 32); powerNumber->setPosition(ccp(12, 40)); powerNumber->setColor(ccWHITE); powerNumber->setDelegate(this); layer->addChild(powerNumber,10); CCEGLView * pGlView = CCDirector::sharedDirector()->getOpenGLView(); pGlView->setIMEKeyboardNumber(); break; } default: tagOpen = kActivityOnTag; tagClose = kActivityOffTag; typeOn = CGameData::Inst()->isCntryCdRemind; break; } CCSprite* spFrame = CCSprite::spriteWithFile("pushConfig_Bg.png"); spFrame->setPosition(CCPointMake(2, 0)); layer->addChild(spFrame); TextNode *remindLabel = TextNode::textWithString(tStr, 32); remindLabel->setColor(ccc3(255, 255, 255)); remindLabel->setShadowColor(ccc3(0, 0, 0)); remindLabel->setPosition(ccp(0,40)); layer->addChild(remindLabel); CCSprite* spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_open.png"); CCSprite* spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_open.png"); CCSprite* spMenu3 = CCSprite::spriteWithSpriteFrameName("fr_open2.png"); CCMenuItem* item1 = CCMenuItemImage::itemFromNormalSprite(spMenu1,spMenu2,spMenu3, this, menu_selector(RemindLayer::switchOnOff)); item1->setPosition(ccp(-170, -50)); item1->setAnchorPoint(ccp(0, 0)); item1->setTag(tagOpen); spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_close.png"); spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_close.png"); spMenu3 = CCSprite::spriteWithSpriteFrameName("fr_close2.png"); CCMenuItem* item2 = CCMenuItemImage::itemFromNormalSprite(spMenu1,spMenu2,spMenu3, this, menu_selector(RemindLayer::switchOnOff)); item2->setPosition(ccp(30, -50)); item2->setAnchorPoint(ccp(0, 0)); item2->setTag(tagClose); item1->setIsEnabled(!typeOn); item2->setIsEnabled(typeOn); CCMenu *menu = CCMenu::menuWithItems (item1,item2, NULL); menu->setPosition(ccp(0, 0)); layer->addChild(menu); return layer; }
// FIXME: Most of the assertions below should be turn into parse errors and be // reported in a cleaner way to the client side. TemplateNode* Parser::parse() { TemplateNode* root = new TemplateNode(); Node* current = root; m_insideClause = false; Tokenizer::Token token; do { assert(m_lastTokenType != Tokenizer::Token::EndOfInput); m_tokenizer->nextToken(token); assert(token.type != Tokenizer::Token::None); switch (token.type) { case Tokenizer::Token::Text: assert(m_lastTokenType != Tokenizer::Token::Text); switch (m_lastTokenType) { case Tokenizer::Token::OpenComment: { assert(m_insideClause); CommentNode* commentNode = new CommentNode(current); commentNode->setText(token.contents); break; } case Tokenizer::Token::OpenVariable: { assert(m_insideClause); std::string variable; assert(splitVariableExpression(token.contents, variable)); VariableNode* variableNode = new VariableNode(current); variableNode->setExpression(VariableExpression::parse(variable)); break; } case Tokenizer::Token::OpenTag: { assert(m_insideClause); std::string tagName; std::vector<std::string> parameters; assert(splitTagExpression(token.contents, tagName, parameters)); if (tagName.size() > 3 && tagName.substr(0, 3) == "end") { std::string tagBaseName = tagName.substr(3); if (TagNodeFactory::self()->isTagRegistered(tagBaseName.c_str())) { assert(current->type() == Node::Tag); TagNode* tagNode = static_cast<TagNode*>(current); assert(tagNode->name() == tagBaseName); assert(!tagNode->isSelfClosing()); current = current->parent(); } else { TagNode* tagNode = new NullTagNode(current); assert(tagNode->isSelfClosing()); } } else { if (TagNodeFactory::self()->isTagRegistered(tagName.c_str())) { TagNode* tagNode = TagNodeFactory::self()->create(tagName.c_str(), current); assert(tagNode); tagNode->setName(tagName); tagNode->setParameters(parameters); if (!tagNode->isSelfClosing()) current = tagNode; } else { TagNode* tagNode = new NullTagNode(current); assert(tagNode->isSelfClosing()); } } break; } default: { TextNode* textNode = new TextNode(current); textNode->setText(token.contents); break; } } break; case Tokenizer::Token::OpenComment: case Tokenizer::Token::OpenVariable: case Tokenizer::Token::OpenTag: assert(!m_insideClause); m_insideClause = true; break; case Tokenizer::Token::CloseComment: case Tokenizer::Token::CloseVariable: case Tokenizer::Token::CloseTag: assert(m_insideClause); m_insideClause = false; break; case Tokenizer::Token::EndOfInput: // Make sure all opening tags have their corresponding closing tags. assert(current == root); break; } m_lastTokenType = token.type; assert(current); } while (token.type != Tokenizer::Token::EndOfInput); return root; }
void Layout::layout(TextNode& text) const { OSG_NOTICE<<"Layout::layout"<<std::endl; Font* font = text.getActiveFont(); Style* style = text.getActiveStyle(); TextTechnique* technique = text.getTextTechnique(); const String& str = text.getText(); if (!text.getTextTechnique()) { OSG_NOTICE<<"Warning: no TextTechnique assigned to Layout"<<std::endl; return; } osg::Vec3 pos(0.0f,0.0f,0.0f); float characterSize = text.getCharacterSize(); osg::Vec3 size(characterSize, characterSize, 0.0); if (style) { size.y() = characterSize; size.z() = characterSize; } osgText::FontResolution resolution(32,32); if (style) { resolution.first = static_cast<unsigned int>(static_cast<float>(resolution.first)*style->getSampleDensity()); resolution.second = static_cast<unsigned int>(static_cast<float>(resolution.second)*style->getSampleDensity()); } float characterWidthScale = 1.0f; bool textIs3D = (style && style->getThicknessRatio()!=0.0); if (!textIs3D) { characterWidthScale = 1.0f/static_cast<float>(resolution.first); } osgText::KerningType kerningType = osgText::KERNING_DEFAULT; technique->start(); unsigned int previousCharcode = 0; for(unsigned int i=0; i<str.size(); ++i) { unsigned int charcode = str[i]; if (size.z()==0.0f) { osgText::Glyph* glyph = font->getGlyph(resolution, charcode); if (glyph) { technique->addCharacter(pos, size, glyph, style); pos += osg::Vec3(size.x()*(glyph->getHorizontalAdvance()*characterWidthScale), 0.0f ,0.0f); } } else { osgText::Glyph3D* glyph = font->getGlyph3D(charcode); OSG_NOTICE<<"pos = "<<pos<<", charcode="<<charcode<<", glyph="<<glyph<< std::endl; if (glyph) { osg::Vec3 local_scale( size ); technique->addCharacter(pos, local_scale, glyph, style); pos += osg::Vec3(size.x()*glyph->getWidth(), 0.0f ,0.0f); } } if (previousCharcode!=0 && charcode!=0) { osg::Vec2 offset = font->getKerning(previousCharcode, charcode, kerningType); OSG_NOTICE<<" offset = "<<offset<< std::endl; pos.x() += offset.x(); pos.y() += offset.y(); } previousCharcode = charcode; } technique->finish(); }
bool MyGame::LoadResource() { // Build scene graph ContainerNode* root = new ContainerNode(); OrthographicProjectionNode* ortho = new OrthographicProjectionNode(); Texture* texTile = Texture::Get("!tile.png"); Texture* texStair = Texture::Get("!stair.png"); Font* texFont = Font::Get("!DroidSans.ttf|texture_size=256"); Cube* floor = new Cube(Vector3f(50.f, 1.f, 50.f), 50.f, "Floor"); floor->SetTexture(texTile); root->AddChild(floor); floor->AddToPhysic(0, Vector3f(0, -.5f, 0)); // Stair float sw = 1.f; // stair depth float sh = 1.0f; // stair height for(int i = 0; i < 5; ++i) { Cube* stair = new Cube(Vector3f(6.f, sh, sw), 4); stair->SetTexture(texStair); root->AddChild(stair); stair->AddToPhysic(0, Vector3f(0, sh / 2.f + (i * sh), 5 + (i * sw))); } TextNode* title = new TextNode(texFont, 12.f, "TAK game sample"); title->SetShader(Shader::Get("!nolight")); title->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 25, 0); ortho->AddChild(title); TextNode* instruction = new TextNode(texFont, 12.f, "Drag and hold left mouse button to rotate, hold right mouse button to zoom"); instruction->SetShader(Shader::Get("!nolight")); instruction->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 45, 0); ortho->AddChild(instruction); m_txtFps = new TextNode(texFont); m_txtFps->SetShader(Shader::Get("!nolight")); m_txtFps->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 65, 0); ortho->AddChild(m_txtFps); m_txtCubeCount = new TextNode(texFont); m_txtCubeCount->SetShader(Shader::Get("!nolight")); m_txtCubeCount->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 85, 0); ortho->AddChild(m_txtCubeCount); Cube* pc1; // front wall pc1 = new Cube(Vector3f(5.5f, 7.f, .5f), 10.f); pc1->SetTexture(texTile); root->AddChild(pc1); pc1->AddToPhysic(0, Vector3f(0, pc1->GetSize().y / 2.f, 9.75f)); // right wall pc1 = new Cube(Vector3f(.5f, 7.f, 10.f), 10.f); pc1->SetTexture(texTile); root->AddChild(pc1); pc1->AddToPhysic(0, Vector3f(-3, pc1->GetSize().y / 2.f, 5)); // right wall pc1 = new Cube(Vector3f(.5f, 7.f, 10.f), 10.f); pc1->SetTexture(texTile); root->AddChild(pc1); pc1->AddToPhysic(0, Vector3f(3, pc1->GetSize().y / 2.f, 5)); // Flag engine logo Sprite* flag = new Sprite(128, 128, Texture::Get("!engineflag.png")); flag->SetShader(Shader::Get("!nolight")); flag->SetPositionAbsolute(GetScene().GetParams().GetWidth() - flag->GetWidth() / 2.f, flag->GetHeight() / 2.f - 20.f, 0); ortho->AddChild(flag); root->AddChild(ortho); GetScene().SetRoot(root); // Setup camera: Camera* camera = new LookAtCamera(Vector3f(0, 0, 5), 25.f); GetScene().SetCamera(camera); return true; }
//setstate void Card::setCardState(int state, int param1) { switch (state) { case EN_CARD_STATE_FNEGYIN: { if (param1 > 0) { Player* pPlayer = (Player*)getParent(); int iOccurOdds = getCanUseNumByAwakeId(enAwakeSkill_16) * 50; if (SaveData::Inst()->getrand()%100+1 <= iOccurOdds || pPlayer->haveAwakeSkill_33()){ //新增 char fileName[100]; CCSprite* spAnim = CCSprite::spriteWithSpriteFrameName("blank.png"); addChild(spAnim,100,FENGYINDEFENSETAG); spAnim->setPosition(getCardPos()); CCAnimation *animation1 = CCAnimation::animation(); for(int i=1;i<=9;i++) { sprintf(fileName, "dikang00%02d.png",i); animation1->addFrameWithFileName(fileName); } animation1->setDelay(1.0/20.0); CCAnimate* animate1 = CCAnimate::actionWithAnimation(animation1); spAnim->runAction(animate1); return; } } m_FengYinCD += param1; if (m_state == state) { char buf[10]; sprintf(buf, "%d",m_FengYinCD); TextNode* tempText = (TextNode*)getChildByTag(FENGYINPNGTAG+1); tempText->setString(buf); } else { if (param1 > 0) { if (m_idx == 0 || m_idx == 5) { Player* pPlayer = (Player*)getParent(); pPlayer->fengYinAutoSkill(m_idx); } } CCSprite* cardLock = CCSprite::spriteWithSpriteFrameName("cardlock.png"); addChild(cardLock,100,FENGYINPNGTAG); cardLock->setPosition(getCardPos()); cardLock->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)CCSequence::actions(CCFadeIn::actionWithDuration(1.0),CCFadeOut::actionWithDuration(1.0),NULL))); char buf[10]; sprintf(buf, "%d",m_FengYinCD); TextNode* textCD = TextNode::textWithString(buf,55); addChild(textCD,101,FENGYINPNGTAG+1); textCD->setPosition(getCardPos()); textCD->setShadowColor(ccBLACK); textCD->setColor(ccWHITE); m_spCard->setColor(ccc3(60, 60, 60)); } } break; case EN_CARD_STATE_NORMAL: if (m_state == EN_CARD_STATE_FNEGYIN) { m_FengYinCD = 0; removeChildByTag(FENGYINPNGTAG, true); removeChildByTag(FENGYINPNGTAG+1, true); removeChildByTag(FENGYINDEFENSETAG, true); if (m_idx == 0 || m_idx == 5) { Player* pPlayer = (Player*)getParent(); pPlayer->unFengYinAutoSkill(m_idx); } } m_spCard->setColor(ccWHITE); break; default: break; } if (state!=m_state) { m_state = state; if (Player *pPlayer = dynamic_cast<Player*>(getParent())) { pPlayer->updateNumByAwakeId(); } if (EN_CARD_STATE_NORMAL==state) { awakeUpdate(true,false); } else if (EN_CARD_STATE_FNEGYIN==state) { awakeUpdate(false,false); } } }
void OutputVisitor::visit(const TextNode& node) { _out << node.content() << endl; }
void AddSFFloat(float value) { switch (GetCurrentNodeType()) { case VRML_NODETYPE_ELEVATIONGRID_HEIGHT: { ElevationGridNode *elev = (ElevationGridNode *)GetCurrentNodeObject(); elev->addHeight(value); } break; case VRML_NODETYPE_BACKGROUND_GROUNDANGLE: { BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject(); bg->addGroundAngle(value); } break; case VRML_NODETYPE_BACKGROUND_SKYANGLE: { BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject(); bg->addSkyAngle(value); } break; case VRML_NODETYPE_INTERPOLATOR_KEY: switch (GetPrevNodeType()) { case VRML_NODETYPE_COLORINTERPOLATOR: { ColorInterpolatorNode *colorInterp = (ColorInterpolatorNode *)GetCurrentNodeObject(); colorInterp->addKey(value); } break; case VRML_NODETYPE_COORDINATEINTERPOLATOR: { CoordinateInterpolatorNode *coordInterp = (CoordinateInterpolatorNode *)GetCurrentNodeObject(); coordInterp->addKey(value); } break; case VRML_NODETYPE_NORMALINTERPOLATOR: { NormalInterpolatorNode *normInterp = (NormalInterpolatorNode *)GetCurrentNodeObject(); normInterp->addKey(value); } break; case VRML_NODETYPE_ORIENTATIONINTERPOLATOR: { OrientationInterpolatorNode *oriInterp = (OrientationInterpolatorNode *)GetCurrentNodeObject(); oriInterp->addKey(value); } break; case VRML_NODETYPE_POSITIONINTERPOLATOR: { PositionInterpolatorNode *posInterp = (PositionInterpolatorNode *)GetCurrentNodeObject(); posInterp->addKey(value); } break; case VRML_NODETYPE_SCALARINTERPOLATOR: { ScalarInterpolatorNode *scalarInterp = (ScalarInterpolatorNode *)GetCurrentNodeObject(); scalarInterp->addKey(value); } break; } break; case VRML_NODETYPE_INTERPOLATOR_KEYVALUE: switch (GetPrevNodeType()) { case VRML_NODETYPE_SCALARINTERPOLATOR: { ScalarInterpolatorNode *scalarInterp = (ScalarInterpolatorNode *)GetCurrentNodeObject(); scalarInterp->addKeyValue(value); } break; } break; case VRML_NODETYPE_LOD_RANGE: { ((LodNode *)GetCurrentNodeObject())->addRange(value); } break; case VRML_NODETYPE_NAVIGATIONINFO_AVATARSIZE: { NavigationInfoNode *navInfo = (NavigationInfoNode *)GetCurrentNodeObject(); navInfo->addAvatarSize(value); } break; case VRML_NODETYPE_TEXT_LENGTH: { TextNode *text = (TextNode *)GetCurrentNodeObject(); text->addLength(value); } break; } }
void CardShop::showCardItem() { CCSprite* sp = CGameData::Inst()->getHeadSprite(1); m_cardSize = sp->getContentSize(); m_iColumn = 640 / m_cardSize.width; m_iGap = (640 - m_iColumn * m_cardSize.width) / (m_iColumn + 1); m_ptStart.x = m_iGap; m_ptStart.y = 720; CCPoint pt; m_iRmBtn = 0; int npIndex = 0; for (int i=0; i<pShopCardsArr->count(); i++) { CShopCardInfo* pShopCard = pShopCardsArr->getObjectAtIndex(i); pt.x = m_ptStart.x + ((npIndex + m_iRmBtn) % m_iColumn) * (m_iGap + m_cardSize.width); pt.y = m_ptStart.y - ((npIndex + m_iRmBtn) / m_iColumn) * (m_iGap + m_cardSize.height); sp = CGameData::Inst()->getHeadSprite(pShopCard->sCid); addChild(sp); sp->setAnchorPoint(ccp(0,1)); sp->setPosition(pt); sp->setTag(CARD_TAG + i); CCSprite* spState = NULL; switch (pShopCard->status) { case 1: spState = CCSprite::spriteWithFile("card_shop_hot.png"); break; case 2: spState = CCSprite::spriteWithFile("card_shop_new.png"); break; case 3: default: spState = CCSprite::spriteWithFile("card_shop_sale.png"); break; } sp->addChild(spState); spState->setPosition(ccp(82, 82)); CCSprite* spPriceBG = CCSprite::spriteWithFile("card_shop_coin.png"); sp->addChild(spPriceBG); spPriceBG->setPosition(ccp(56, 6)); char buf[50]; snprintf(buf, 49, "%d",pShopCard->iPrice); TextNode* textPrice = TextNode::textWithString(buf, 16); spPriceBG->addChild(textPrice); textPrice->setAnchorPoint(ccp(0.5, 0)); textPrice->setPosition(ccp(68, 10)); textPrice->setColor(ccc3(250, 237, 66)); textPrice->setShadowColor(ccBLACK); npIndex++; } m_shopCardNum = npIndex; m_fUpLimitY = gfMoveDownLimitY - (pt.y - m_cardSize.height); if (m_fUpLimitY > 0) { m_pScrollBar = new CScrollBar(); addChild(m_pScrollBar); m_pScrollBar->setTag(1); m_pScrollBar->release(); float dBarSize = 1.0/((m_fUpLimitY / (m_ptStart.y - gfMoveDownLimitY))+2); m_pScrollBar->setBarSize(dBarSize); m_pScrollBar->setPercent(0.0); m_pScrollBar->setPosition(CCPointMake(630, 435)); m_pScrollBar->setScaleY(1); } }
void AddSFString(char *string) { switch (GetCurrentNodeType()) { case VRML_NODETYPE_ANCHOR_PARAMETER: { ((AnchorNode *)GetCurrentNodeObject())->addParameter(string); } break; case VRML_NODETYPE_ANCHOR_URL: { ((AnchorNode *)GetCurrentNodeObject())->addUrl(string); } break; case VRML_NODETYPE_INLINE_URL: { ((InlineNode *)GetCurrentNodeObject())->addUrl(string); } break; case VRML_NODETYPE_AUDIOCLIP_URL: { AudioClipNode *aclip = (AudioClipNode *)GetCurrentNodeObject(); aclip->addUrl(string); } break; case VRML_NODETYPE_BACKGROUND_BACKURL: { BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject(); bg->addBackUrl(string); } break; case VRML_NODETYPE_BACKGROUND_BOTTOMURL: { BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject(); bg->addBottomUrl(string); } break; case VRML_NODETYPE_BACKGROUND_FRONTURL: { BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject(); bg->addFrontUrl(string); } break; case VRML_NODETYPE_BACKGROUND_LEFTURL: { BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject(); bg->addLeftUrl(string); } break; case VRML_NODETYPE_BACKGROUND_RIGHTURL: { BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject(); bg->addRightUrl(string); } break; case VRML_NODETYPE_BACKGROUND_TOPURL: { BackgroundNode *bg = (BackgroundNode *)GetCurrentNodeObject(); bg->addTopUrl(string); } break; case VRML_NODETYPE_FONTSTYLE_JUSTIFY: { FontStyleNode *fs = (FontStyleNode *)GetCurrentNodeObject(); fs->addJustify(string); } break; case VRML_NODETYPE_IMAGETEXTURE_URL: { ImageTextureNode *image = (ImageTextureNode *)GetCurrentNodeObject(); image->addUrl(string); } break; case VRML_NODETYPE_MOVIETEXTURE_URL: { MovieTextureNode *image = (MovieTextureNode *)GetCurrentNodeObject(); image->addUrl(string); } break; case VRML_NODETYPE_NAVIGATIONINFO_TYPE: { NavigationInfoNode *navInfo = (NavigationInfoNode *)GetCurrentNodeObject(); navInfo->addType(string); } break; case VRML_NODETYPE_SCRIPT_URL: { ScriptNode *script = (ScriptNode *)GetCurrentNodeObject(); script->addUrl(string); } break; case VRML_NODETYPE_TEXT_STRING: { TextNode *text = (TextNode *)GetCurrentNodeObject(); text->addString(string); } break; case VRML_NODETYPE_WORLDINFO_INFO: { WorldInfoNode *worldInfo = (WorldInfoNode *)GetCurrentNodeObject(); worldInfo->addInfo(string); } break; } }
//****************************************************************************** // initRetry //****************************************************************************** void CommDlg::initRetry() { CCSprite* sp = CCSprite::spriteWithSpriteFrameName("commdlg.png"); if(sp) addChild(sp); char buf[100]; initBtn(); if(m_iRc == kReqConnectErr){ //title snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("net_error")); TextNode* lbText = TextNode::textWithString(buf,45); lbText->setPosition(CCPointMake(0, 86)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); lbText = TextNode::textWithString(HttpComm::Inst()->getLocalErrStr().c_str(), CCSizeMake(400, 60), CCTextAlignmentCenter,26); lbText->setPosition(CCPointMake(0, 30)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("net_again")); lbText = TextNode::textWithString(buf,26); lbText->setPosition(CCPointMake(0, -16)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); } else{ //服务器来的错误提示 const char* errMsg = CGameData::Inst()->getErrMsg(); if(errMsg != NULL){ TextNode* lbText = TextNode::textWithString(errMsg, CCSizeMake(400, 120), CCTextAlignmentCenter,26); lbText->setAnchorPoint(CCPointMake(0.5, 1)); lbText->setPosition(CCPointMake(0, 100)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); } } }
void MainWindow::processPdfText(TextNode t) { if (t.text == QByteArray("\1")) { // G-Key found document->addLine(t.position()); updateLineSelector(); } }
//****************************************************************************** // initBtn //****************************************************************************** void CommDlg::initBtn() { char buf[100]; //如果还未登录,只显示一个按钮,即要求一定要重试, //付费失败必须重试 if( ((m_iRc == kReqConnectErr) || (m_iRc == 100) || (m_iRc == 401)) && ((CGameData::Inst()->chkLogin() == false) || (CGameData::Inst()->isPaying() ))){ //ok CCSprite* sp = CCSprite::spriteWithSpriteFrameName("fr_button.png"); if(sp){ sp->setPosition(CCPointMake(0, -78)); addChild(sp, 0, kCommBtnTagOk); } snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("sureTip")); TextNode* lbText = TextNode::textWithString(buf, CCSizeMake(100, 36), CCTextAlignmentCenter,kBtnTitleHeight); lbText->setPosition(CCPointMake(-4, -74)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); lbText->setTag(kCommTextTagOk); } else if((m_iRc == kReqConnectErr) || (m_iRc == 100) || (m_iRc == 401)){ //ok CCSprite* sp = CCSprite::spriteWithSpriteFrameName("fr_button.png"); if(sp){ sp->setPosition(CCPointMake(-104, -78)); addChild(sp, 0, kCommBtnTagOk); } snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("sureTip")); TextNode* lbText = TextNode::textWithString(buf, CCSizeMake(100, 36), CCTextAlignmentCenter,kBtnTitleHeight); lbText->setPosition(CCPointMake(-108, -74)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); lbText->setTag(kCommTextTagOk); //cancel sp = CCSprite::spriteWithSpriteFrameName("fr_button.png"); if(sp){ sp->setPosition(CCPointMake(104, -78)); addChild(sp, 0, kCommBtnTagCancel); } snprintf(buf, 99, "%s", CGameData::Inst()->getLanguageValue("cancelTip")); lbText = TextNode::textWithString(buf, CCSizeMake(100, 36), CCTextAlignmentCenter,kBtnTitleHeight); lbText->setPosition(CCPointMake(100, -74)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); lbText->setTag(kCommTextTagCancel); } else if((m_iRc == 502) || (HttpComm::Inst()->getMaintenance() != 0)){ //ok CCSprite* sp = CCSprite::spriteWithSpriteFrameName("fr_button.png"); if(sp){ sp->setPosition(CCPointMake(0, -78)); addChild(sp, 0, kCommBtnTagOk); } snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("sureTip")); TextNode* lbText = TextNode::textWithString(buf, CCSizeMake(100, 36), CCTextAlignmentCenter,kBtnTitleHeight); lbText->setPosition(CCPointMake(-4, -74)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); lbText->setTag(kCommTextTagOk); } //服务器返回的提示,无需重试,仅显示取消按钮(文字显示为确定) else{ const char* errMsg = CGameData::Inst()->getErrMsg(); if(errMsg != NULL){ string eMsg = errMsg; if (eMsg.find("武将不存在")!=string::npos) { //ok CCSprite* sp = CCSprite::spriteWithSpriteFrameName("fr_button.png"); if(sp){ sp->setPosition(CCPointMake(-104, -78)); addChild(sp, 0, kCommBtnTagOk); } snprintf(buf, 99, "%s", CGameData::Inst()->getLanguageValue("re_login")); TextNode* lbText = TextNode::textWithString(buf, CCSizeMake(100, 36), CCTextAlignmentCenter,kBtnTitleHeight); lbText->setPosition(CCPointMake(-108, -74)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); lbText->setTag(kCommTextTagOk); //cancel sp = CCSprite::spriteWithSpriteFrameName("fr_button.png"); if(sp){ sp->setPosition(CCPointMake(104, -78)); addChild(sp, 0, kCommBtnTagCancel); } snprintf(buf, 99, "%s", CGameData::Inst()->getLanguageValue("cancelTip")); lbText = TextNode::textWithString(buf, CCSizeMake(100, 36), CCTextAlignmentCenter,kBtnTitleHeight); lbText->setPosition(CCPointMake(100, -74)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); lbText->setTag(kCommTextTagCancel); return; } } CCSprite* sp = CCSprite::spriteWithSpriteFrameName("fr_button.png"); if(sp){ sp->setPosition(CCPointMake(0, -78)); addChild(sp, 0, kCommBtnTagCancel); } snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("sureTip")); TextNode* lbText = TextNode::textWithString(buf, CCSizeMake(100, 36), CCTextAlignmentCenter,kBtnTitleHeight); lbText->setPosition(CCPointMake(-4, -74)); lbText->setColor(ccWHITE); lbText->setShadowColor(ccBLACK); addChild(lbText, 1); } }