bool OnPlayerShopAddBuyNum(const CEGUI::EventArgs& e) { CEGUI::Window* wnd = WEArgs(e).window; if(!wnd) return false; CEGUI::Window* goodsWnd = wnd->getParent(); if (goodsWnd) { CGoods* goods = static_cast<CGoods*>(goodsWnd->getUserData()); if (!goods) return false; PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods); if (pGoodsItem!=NULL) { char str[32]; // 取得输入框控件名 CEGUI::String name = wnd->getName(); name.assign(name, 0, name.find_last_of("/")); name += "/BuyNum"; CEGUI::Window* buyNumWnd = GetWndMgr().getWindow(name); ulong num = atoi(buyNumWnd->getText().c_str()); if (num>=pGoodsItem->groupNum) { sprintf(str,"%d",num); wnd->disable(); } else sprintf(str,"%d",++num); buyNumWnd->setText(ToCEGUIString(str)); pGoodsItem->readyTradeNum = num; } } return true; }
void GameMenuDemo::updateLoginWelcomeText(float passedTime) { if(d_timeSinceLoginAccepted <= 0.0f) return; static const CEGUI::String firstPart = "Welcome "; CEGUI::String displayText = firstPart + d_userName; CEGUI::String finalText; int progress = static_cast<int>(d_timeSinceLoginAccepted / 0.08f); if(progress > 0) finalText += displayText.substr(0, std::min<unsigned int>(displayText.length(), progress)); finalText += "[font='DejaVuSans-12']"; double blinkPeriod = 0.8; double blinkTime = std::modf(static_cast<double>(d_timeSinceStart), &blinkPeriod); if(blinkTime > 0.55 || d_currentWriteFocus != WF_TopBar) finalText += "[colour='00000000']"; finalText += reinterpret_cast<const encoded_char*>("❚"); d_topBarLabel->setText(finalText); }
void CEGUILogger::logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level) { //just reroute to the Ember logging service static std::string cegui("(CEGUI) "); if (d_level >= level) { switch (level) { case CEGUI::Insane: Log::slog("CEGUI", Log::VERBOSE) << cegui << message.c_str() << Log::END_MESSAGE; break; case CEGUI::Informative: Log::slog("CEGUI", Log::VERBOSE) << cegui << message.c_str() << Log::END_MESSAGE; break; case CEGUI::Standard: Log::slog("CEGUI", Log::INFO) << cegui << message.c_str() << Log::END_MESSAGE; break; case CEGUI::Warnings: Log::slog("CEGUI", Log::WARNING) << cegui << message.c_str() << Log::END_MESSAGE; break; case CEGUI::Errors: Log::slog("CEGUI", Log::FAILURE) << cegui << message.c_str() << Log::END_MESSAGE; break; } } }
virtual void loadRawDataContainer (const CEGUI::String &filename, CEGUI::RawDataContainer &output, const CEGUI::String &resourceGroup) { ZFile file; if (file.Open(filename.c_str())) { int fn = file.GetSize(); char *ptr = new char [fn+1]; file.Read(ptr, fn); ptr[fn] = 0; output.setData((CEGUI::uint8*)ptr); output.setSize(fn); } }
void CNebula2Logger::logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level) { if (Enable && level <= getLoggingLevel()) switch (level) { case CEGUI::Errors: //nKernelServer::Instance()->Error("%s\n", message.c_str()); ///!!! TODO //break; case CEGUI::Standard: case CEGUI::Informative: case CEGUI::Insane: n_printf("%s\n", message.c_str()); break; default: n_error("Unknown CEGUI logging level\n"); } }
void GameConsoleWindow::ParseText(CEGUI::String inMsg) { // I personally like working with std::string. So i'm going to convert it here. std::string inString = inMsg.c_str(); if (inString.length() >= 1) // Be sure we got a string longer than 0 { if (inString.at(0) == '/') // Check if the first letter is a 'command' { std::string::size_type commandEnd = inString.find(" ", 1); std::string command = inString.substr(1, commandEnd - 1); std::string commandArgs = inString.substr(commandEnd + 1, inString.length() - (commandEnd + 1)); //convert command to lower case for(std::string::size_type i=0; i < command.length(); i++) { command[i] = tolower(command[i]); } // Begin processing if (command == "say") { std::string outString = "You:" + inString; // Append our 'name' to the message we'll display in the list OutputText(outString); } else if (command == "quit") { // do a /quit } else if (command == "help") { // do a /help } else { std::string outString = "<" + inString + "> is an invalid command."; (this)->OutputText(outString,CEGUI::Colour(1.0f,0.0f,0.0f)); // With red ANGRY colors! } } // End if else { (this)->OutputText(inString); // no commands, just output what they wrote } } }
//------------------------------------------------------------------------ bool WindowContext::AcceptsWindowAsChild() const { // Validations wxASSERT_MSG(m_pWindow != NULL, wxT("Window member is NULL")); const CEGUI::String strWindowType = m_pWindow->getType(); // These require different parent / child handling. // The current type must not be equal to the checks below // Because of the "find" instead of exact matches, it works for different // looknfeels, e.g. both "TaharezLook/Combobox" and "Windowslook/Combobox". return strWindowType.find("Combobox") == CEGUI::String::npos && strWindowType.find("ComboDropList") == CEGUI::String::npos && strWindowType.find("ListHeader") == CEGUI::String::npos && strWindowType.find("Combobox") == CEGUI::String::npos && strWindowType.find("ListBox") == CEGUI::String::npos && strWindowType.find("MultiColumnList"); }
int CEGUILuaBindScriptModule::executeScriptGlobal(const CEGUI::String &function_name) { lua_State * d_state = LuaScript::Instance( ).GetLuaVM( ); int top = lua_gettop(d_state); // get the function from lua lua_getglobal(d_state, function_name.c_str()); // is it a function if (!lua_isfunction(d_state,-1)) { lua_settop(d_state,top); throw CEGUI::ScriptException("Unable to get Lua global: '"+function_name+"' as name not represent a global Lua function" ); } // call it int error = lua_pcall(d_state,0,1,0); // handle errors if (error) { CEGUI::String errMsg = lua_tostring(d_state,-1); lua_pop(d_state,1); throw CEGUI::ScriptException("Unable to evaluate Lua global: '"+function_name+"\n\n"+errMsg+"\n"); } // get return value if (!lua_isnumber(d_state,-1)) { // log that return value is invalid. return -1 and move on. lua_settop(d_state,top); CEGUI::ScriptException("Unable to get Lua global : '"+function_name+"' return value as it's not a number" ); return -1; } int ret = (int)lua_tonumber(d_state,-1); lua_pop(d_state,1); // return it return ret; }
void WidgetDemo::initialiseAvailableWidgetsMap() { //Retrieve the widget look types and add a Listboxitem for each widget, to the right scheme in the map CEGUI::WindowFactoryManager& windowFactorymanager = CEGUI::WindowFactoryManager::getSingleton(); CEGUI::WindowFactoryManager::FalagardMappingIterator falMappingIter = windowFactorymanager.getFalagardMappingIterator(); while(!falMappingIter.isAtEnd()) { CEGUI::String falagardBaseType = falMappingIter.getCurrentValue().d_windowType; int slashPos = falagardBaseType.find_first_of('/'); CEGUI::String group = falagardBaseType.substr(0, slashPos); CEGUI::String name = falagardBaseType.substr(slashPos + 1, falagardBaseType.size() - 1); if(group.compare("SampleBrowserSkin") != 0) { std::map<CEGUI::String, WidgetListType>::iterator iter = d_skinListItemsMap.find(group); if(iter == d_skinListItemsMap.end()) { //Create new list d_skinListItemsMap[group]; } WidgetListType& widgetList = d_skinListItemsMap.find(group)->second; addItemToWidgetList(name, widgetList); } ++falMappingIter; } //Add the default types as well d_skinListItemsMap["No Skin"]; WidgetListType& defaultWidgetsList = d_skinListItemsMap["No Skin"]; addItemToWidgetList("DefaultWindow", defaultWidgetsList); addItemToWidgetList("DragContainer", defaultWidgetsList); addItemToWidgetList("VerticalLayoutContainer", defaultWidgetsList); addItemToWidgetList("HorizontalLayoutContainer", defaultWidgetsList); addItemToWidgetList("GridLayoutContainer", defaultWidgetsList); }
int GamePlate::getPoints() { CEGUI::Window* window = d_window->getChild("ImageWindowObject"); CEGUI::String objectImage = window->getProperty("Image"); if(objectImage.compare(HUDDemo::s_imageNameBread) == 0) return 2; else if(objectImage.compare(HUDDemo::s_imageNamePoo) == 0) return -6; else if(objectImage.compare(HUDDemo::s_imageNameSteak) == 0) return -13; else if(objectImage.compare(HUDDemo::s_imageNamePrizza) == 0) return 3; else if(objectImage.compare(HUDDemo::s_imageNameVegPeople) == 0) return 1; else if(objectImage.compare(HUDDemo::s_imageNameVegFruits) == 0) return 88; return 0; }
void CEGUIResourceProvider::loadRawDataContainer(const CEGUI::String &filename, CEGUI::RawDataContainer &output, const CEGUI::String &resourceGroup) { DBG(0, "%s", filename.c_str()); if (strcmp(filename.c_str(), "TaharezLook.scheme") == 0) { DBG(0, "size %d", sizeof(taharez_look_schem)); output.setData((CEGUI::uint8*)taharez_look_schem); output.setSize(sizeof(taharez_look_schem)); return; } if (strcmp(filename.c_str(), "TaharezLook.imageset") == 0) { DBG(0, "size %d", sizeof(taharez_look_imageset)); output.setData((CEGUI::uint8*)taharez_look_imageset); output.setSize(sizeof(taharez_look_imageset)); return; } if (strcmp(filename.c_str(), "TaharezLook.tga") == 0) { DBG(0, "size %d", sizeof(taharez_look_tga)); output.setData((CEGUI::uint8*)taharez_look_tga); output.setSize(sizeof(taharez_look_tga)); return; } if (strcmp(filename.c_str(), "Commonwealth-10.font") == 0) { DBG(0, "size %d", sizeof(commonwealth_10_font)); output.setData((CEGUI::uint8*)commonwealth_10_font); output.setSize(sizeof(commonwealth_10_font)); return; } if (strcmp(filename.c_str(), "Commonv2c.ttf") == 0) { DBG(0, "size %d", sizeof(commonv2c_ttf)); output.setData((CEGUI::uint8*)commonv2c_ttf); output.setSize(sizeof(commonv2c_ttf)); return; } if (strcmp(filename.c_str(), "TaharezLook.looknfeel") == 0) { DBG(0, "size %d", sizeof(taharez_look_looknfeel)); output.setData((CEGUI::uint8*)taharez_look_looknfeel); output.setSize(sizeof(taharez_look_looknfeel)); return; } if (strcmp(filename.c_str(), "DejaVuSans-10.font") == 0) { DBG(0, "size %d", sizeof(dejavu_sans_10_font)); output.setData((CEGUI::uint8*)dejavu_sans_10_font); output.setSize(sizeof(dejavu_sans_10_font)); return; } if (strcmp(filename.c_str(), "DejaVuSans.ttf") == 0) { DBG(0, "size %d", sizeof(dejavu_sans_ttf)); output.setData((CEGUI::uint8*)dejavu_sans_ttf); output.setSize(sizeof(dejavu_sans_ttf)); return; } throw CEGUI::GenericException("failed"); }
CEGUI::Event::Connection FalconScriptingModule::subscribeEvent(CEGUI::EventSet* target, const CEGUI::String& name, CEGUI::Event::Group group, const CEGUI::String& subscriber_name) { FalconInterpreter interp(d_vm, subscriber_name.c_str()); return target->subscribeEvent(name, group, CEGUI::Event::Subscriber(interp)); }
void ImplChatNetworkingVRC::postChatText( const CEGUI::String& text, const std::string& recipient ) { // check for commands if ( !text.compare( 0, 1, "/" ) ) { std::vector< std::string > args; yaf3d::explode( text.c_str(), " ", &args ); // all commands without arguments go here if ( args.size() == 1 ) { if ( ( args[ 0 ] == "/names" ) || ( args[ 0 ] == "/NAMES" ) ) { tChatData chatdata; chatdata._sessionID = _clientSID; NOMINATED_REPLICAS_FUNCTION_CALL( 1, &_serverSID, RPC_RequestMemberList( chatdata ) ); return; } else { _p_protVRC->recvMessage( "", "", VRC_CMD_LIST ); return; } } // all commands with one single argument go here else if ( ( args.size() > 1 ) && ( ( args[ 0 ] == "/nick" ) || ( args[ 0 ] == "/NICK" ) ) ) { tChatData chatdata; chatdata._sessionID = _clientSID; strcpy( chatdata._nickname, &( text.c_str()[ 6 ] ) ); NOMINATED_REPLICAS_FUNCTION_CALL( 1, &_serverSID, RPC_RequestChangeNickname( chatdata ) ); return; } else { _p_protVRC->recvMessage( "", "", VRC_CMD_LIST ); return; } } else // if no command given then send the raw text { // prepare the telegram tChatMsg textdata; memset( textdata._text, 0, sizeof( textdata._text ) ); // zero out the text buffer textdata._recipientID = 0 ; // init to non-whisper message // determine the length of utf8 string and copy the content into send buffer CEGUI::String lenstr( text ); memcpy( textdata._text, lenstr.data(), std::min( ( std::size_t )lenstr.utf8_stream_len( sizeof( textdata._text ) - 1, 0 ), ( std::size_t )sizeof( textdata._text ) - 2 ) ); assert( sizeof( textdata._text ) > 3 ); textdata._text[ sizeof( textdata._text ) - 1 ] = 0; // terminate the string to be on the safe side textdata._text[ sizeof( textdata._text ) - 2 ] = 0; // terminate the string to be on the safe side textdata._text[ sizeof( textdata._text ) - 3 ] = 0; // terminate the string to be on the safe side textdata._sessionID = _clientSID; // are we whispering to somebody? if ( recipient.length() ) { // try to find the session ID of recipient std::map< int, std::string >::iterator p_recipientID = _nickNames.begin(), p_end = _nickNames.end(); for ( ; p_recipientID != p_end; ++p_recipientID ) { if ( p_recipientID->second == recipient ) { // set the recipient session ID textdata._recipientID = p_recipientID->first; break; } } } NOMINATED_REPLICAS_FUNCTION_CALL( 1, &_serverSID, RPC_PostChatText( textdata ) ); } }
/*********************************************************** handle send button event ***********************************************************/ bool ChatBox::HandleEnterKey (const CEGUI::EventArgs& e) { const CEGUI::KeyEventArgs& we = static_cast<const CEGUI::KeyEventArgs&>(e); const CEGUI::WindowEventArgs& wine = static_cast<const CEGUI::WindowEventArgs&>(e); if(we.scancode == CEGUI::Key::LeftControl || we.scancode == CEGUI::Key::RightControl) { _control_key_on = true; return true; } if(we.scancode == CEGUI::Key::LeftShift || we.scancode == CEGUI::Key::RightShift) { _shift_key_on = true; return true; } if(wine.window->getName() == "Chat/edit") { if(we.scancode == CEGUI::Key::Return) { HandleSend (e); CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")); bed->deactivate(); return true; } if(we.scancode == CEGUI::Key::ArrowUp) { if(_itltext == _lasttexts.end()) _itltext = _lasttexts.begin(); else { std::list<std::string>::iterator ittmp = _itltext; ++ittmp; if(ittmp != _lasttexts.end()) ++_itltext; } try { if(_itltext != _lasttexts.end()) { CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText( (const unsigned char *)_itltext->c_str()); } else { CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText(""); } } catch(...){} return true; } if(we.scancode == CEGUI::Key::ArrowDown) { if(_itltext != _lasttexts.end()) { if(_itltext != _lasttexts.begin()) --_itltext; else _itltext = _lasttexts.end(); } if(_itltext != _lasttexts.end()) { CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText( (const unsigned char *)_itltext->c_str()); } else { CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText(""); } return true; } if(we.scancode == CEGUI::Key::ArrowUp || we.scancode == CEGUI::Key::ArrowDown) return true; // paste text if(we.scancode == CEGUI::Key::V && _control_key_on) { CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")); if(bed->isActive()) { if(_text_copyed != "") { size_t selB = bed->getSelectionStartIndex(); size_t selE = bed->getSelectionLength(); CEGUI::String str = bed->getText(); if(selE > 0) { str = str.erase(selB, selE); } if(str.size() + _text_copyed.size() < bed->getMaxTextLength()) { size_t idx = bed->getCaratIndex(); str = str.insert(idx, (unsigned char *)_text_copyed.c_str()); bed->setText(str); bed->setCaratIndex(idx + _text_copyed.size()); } } return true; } } } // copy text if(we.scancode == CEGUI::Key::C && _control_key_on) { CEGUI::Window * actw = _myChat->getActiveChild(); if(actw != NULL) { if(actw->getName() == "Chat/edit") { CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (actw); size_t selB = bed->getSelectionStartIndex(); size_t selE = bed->getSelectionLength(); if(selE > 0) { CEGUI::String str = bed->getText().substr(selB, selE); _text_copyed = str.c_str(); } return true; } else { CEGUI::MultiLineEditbox* txt = static_cast<CEGUI::MultiLineEditbox *>(actw); size_t selB = txt->getSelectionStartIndex(); size_t selE = txt->getSelectionLength(); if(selE > 0) { CEGUI::String str = txt->getText().substr(selB, selE); _text_copyed = str.c_str(); } return true; } } } return false; }
void Saver::save(CEGUI::String filename) { TiXmlDocument doc; TiXmlElement * scene = new TiXmlElement( "scene" ); //scene attrib setup if (!author.empty()) scene->SetAttribute("author",author.c_str()); scene->SetAttribute("formatVersion",MAXVERSION); //environment entry TiXmlElement *environment = new TiXmlElement( "environment" ); //TiXmlText * text = new TiXmlText( "World" ); //environment->LinkEndChild( text ); TiXmlElement *skybox = new TiXmlElement( "skyBox" ); TiXmlElement *fog = new TiXmlElement( "fog" ); fog->SetAttribute("mode","none"); skybox->SetAttribute("material","Examples/MorningSkyBox"); environment->LinkEndChild(skybox); environment->LinkEndChild(fog); if (assign) { TiXmlElement *el = new TiXmlElement("colourAmbient"); el->SetAttribute("r","0.2980392"); el->SetAttribute("g","0.2980392"); el->SetAttribute("b","0.2980392"); environment->LinkEndChild(el); el = new TiXmlElement("newtonWorld"); el->SetAttribute("x1","-100000"); el->SetAttribute("y1","-100000"); el->SetAttribute("z1","-100000"); el->SetAttribute("x2","100000"); el->SetAttribute("y2","100000"); el->SetAttribute("z2","100000"); environment->LinkEndChild(el); el = new TiXmlElement("player"); el->SetAttribute("x","0"); el->SetAttribute("y","100"); el->SetAttribute("z","0"); /*el->SetAttribute("x2","100000"); el->SetAttribute("y2","100000"); el->SetAttribute("z2","100000");*/ environment->LinkEndChild(el); el = new TiXmlElement("fade"); el->SetAttribute("speed","0.5"); el->SetAttribute("duration","3"); el->SetAttribute("overlay","Overlays/FadeInOut"); el->SetAttribute("material","Materials/OverlayMaterial"); el->SetAttribute("startFade","true"); environment->LinkEndChild(el); } scene->LinkEndChild(environment); //nodes entry TiXmlElement *nodes = new TiXmlElement( "nodes" ); for (i=0; i!=StObjs_s.size(); i++) { TiXmlElement *node = new TiXmlElement( "node" ); node->SetAttribute("name",StObjs_s[i]->getName().c_str()); node->SetAttribute("id",rand() % 1000 + 1); //pos orient scale and what contains TiXmlElement *pos = new TiXmlElement( "position" ); TiXmlElement *quat = new TiXmlElement( "rotation" ); TiXmlElement *scale = new TiXmlElement( "scale" ); TiXmlElement *entity; if (StObjs[i]->type!="") { entity = new TiXmlElement( StObjs[i]->type.c_str() ); } else { entity=new TiXmlElement("entity"); } pos->SetAttribute("x",Ogre::StringConverter::toString(StObjs_s[i]->getPosition().x*mScaler).c_str()); pos->SetAttribute("y",Ogre::StringConverter::toString(StObjs_s[i]->getPosition().y*mScaler).c_str()); pos->SetAttribute("z",Ogre::StringConverter::toString(StObjs_s[i]->getPosition().z*mScaler).c_str()); quat->SetAttribute("qw",Ogre::StringConverter::toString(StObjs_s[i]->getOrientation().w).c_str()); quat->SetAttribute("qx",Ogre::StringConverter::toString(StObjs_s[i]->getOrientation().x).c_str()); quat->SetAttribute("qy",Ogre::StringConverter::toString(StObjs_s[i]->getOrientation().y).c_str()); quat->SetAttribute("qz",Ogre::StringConverter::toString(StObjs_s[i]->getOrientation().z).c_str()); scale->SetAttribute("x",Ogre::StringConverter::toString(StObjs_s[i]->getScale().x*mScaler).c_str()); scale->SetAttribute("y",Ogre::StringConverter::toString(StObjs_s[i]->getScale().y*mScaler).c_str()); scale->SetAttribute("z",Ogre::StringConverter::toString(StObjs_s[i]->getScale().z*mScaler).c_str()); entity->SetAttribute("name",StObjs[i]->ent->getName().c_str()); entity->SetAttribute("meshFile",StObjs[i]->ent->getMesh()->getName().c_str()); entity->SetAttribute("castShadows","true"); if (!St_mats[i].empty()) { entity->SetAttribute("materialFile",St_mats[i].c_str()); entity->SetAttribute("scaleU",Ogre::StringConverter::toString(scaleU[i]).c_str()); entity->SetAttribute("scaleV",Ogre::StringConverter::toString(scaleV[i]).c_str()); entity->SetAttribute("scrollU",Ogre::StringConverter::toString(scrollU[i]).c_str()); entity->SetAttribute("scrollV",Ogre::StringConverter::toString(scrollV[i]).c_str()); } node->LinkEndChild(pos); //if (!(StObjs_s[i]->getOrientation()==Quaternion::IDENTITY)) //{ node->LinkEndChild(quat); //} //if (!(StObjs_s[i]->getScale()==Vector3(1,1,1))) //{ node->LinkEndChild(scale); //} node->LinkEndChild(entity); //already made nodes put into <nodes> nodes->LinkEndChild(node); } for (i=0; i!=PhysObjs.size(); i++) { TiXmlElement *node = new TiXmlElement( "node" ); node->SetAttribute("name",PhysObjs[i]->node->getName().c_str()); node->SetAttribute("id",rand() % 1000 + 1); //pos orient scale and what contains TiXmlElement *pos = new TiXmlElement( "position" ); TiXmlElement *quat = new TiXmlElement( "rotation" ); TiXmlElement *scale = new TiXmlElement( "scale" ); TiXmlElement *entity = new TiXmlElement( "phys" ); SceneNode* n = PhysObjs[i]->node; pos->SetAttribute("x",Ogre::StringConverter::toString(n->getPosition().x*mScaler).c_str()); pos->SetAttribute("y",Ogre::StringConverter::toString(n->getPosition().y*mScaler).c_str()); pos->SetAttribute("z",Ogre::StringConverter::toString(n->getPosition().z*mScaler).c_str()); quat->SetAttribute("qw",Ogre::StringConverter::toString(n->getOrientation().w).c_str()); quat->SetAttribute("qx",Ogre::StringConverter::toString(n->getOrientation().x).c_str()); quat->SetAttribute("qy",Ogre::StringConverter::toString(n->getOrientation().y).c_str()); quat->SetAttribute("qz",Ogre::StringConverter::toString(n->getOrientation().z).c_str()); scale->SetAttribute("x",Ogre::StringConverter::toString(n->getScale().x*mScaler).c_str()); scale->SetAttribute("y",Ogre::StringConverter::toString(n->getScale().y*mScaler).c_str()); scale->SetAttribute("z",Ogre::StringConverter::toString(n->getScale().z*mScaler).c_str()); entity->SetAttribute("name",PhysObjs[i]->ent->getName().c_str()); entity->SetAttribute("meshFile",PhysObjs[i]->ent->getMesh()->getName().c_str()); entity->SetAttribute("castShadows","true"); node->LinkEndChild(pos); //if (!(n->getOrientation()==Quaternion::IDENTITY)) //{ node->LinkEndChild(quat); //} //if (!(n->getScale()==Vector3(1,1,1))) //{ node->LinkEndChild(scale); //} node->LinkEndChild(entity); //already made nodes put into <nodes> nodes->LinkEndChild(node); } for (i=0; i!=lights.size(); i++) { TiXmlElement *node = new TiXmlElement( "node" ); node->SetAttribute("name",lights[i]->getName().c_str()); node->SetAttribute("id",rand() % 1000 + 1); //pos orient scale and what contains TiXmlElement *pos = new TiXmlElement( "position" ); TiXmlElement *quat = new TiXmlElement( "rotation" ); TiXmlElement *scale = new TiXmlElement( "scale" ); TiXmlElement *light = new TiXmlElement( "light" ); SceneNode* n = lights[i]; Light* l = (Ogre::Light*)n->getAttachedObject(0); pos->SetAttribute("x",Ogre::StringConverter::toString(n->getPosition().x*mScaler).c_str()); pos->SetAttribute("y",Ogre::StringConverter::toString(n->getPosition().y*mScaler).c_str()); pos->SetAttribute("z",Ogre::StringConverter::toString(n->getPosition().z*mScaler).c_str()); quat->SetAttribute("qw",Ogre::StringConverter::toString(n->getOrientation().w).c_str()); quat->SetAttribute("qx",Ogre::StringConverter::toString(n->getOrientation().x).c_str()); quat->SetAttribute("qy",Ogre::StringConverter::toString(n->getOrientation().y).c_str()); quat->SetAttribute("qz",Ogre::StringConverter::toString(n->getOrientation().z).c_str()); scale->SetAttribute("x",Ogre::StringConverter::toString(n->getScale().x*mScaler).c_str()); scale->SetAttribute("y",Ogre::StringConverter::toString(n->getScale().y*mScaler).c_str()); scale->SetAttribute("z",Ogre::StringConverter::toString(n->getScale().z*mScaler).c_str()); light->SetAttribute("name",l->getName().c_str()); light->SetAttribute("castShadows","true"); light->SetAttribute("type","spot"); TiXmlElement *light1 = new TiXmlElement( "colourDiffuse" ); TiXmlElement *light2 = new TiXmlElement( "colourSpecular" ); TiXmlElement *light3 = new TiXmlElement( "normal" ); TiXmlElement *light4 = new TiXmlElement( "lightAttenuation" ); TiXmlElement *light5 = new TiXmlElement( "lightRange" ); light1->SetAttribute("r",StringConverter::toString(l->getDiffuseColour().r).c_str()); light1->SetAttribute("g",StringConverter::toString(l->getDiffuseColour().g).c_str()); light1->SetAttribute("b",StringConverter::toString(l->getDiffuseColour().b).c_str()); light2->SetAttribute("r",StringConverter::toString(l->getSpecularColour().r).c_str()); light2->SetAttribute("g",StringConverter::toString(l->getSpecularColour().g).c_str()); light2->SetAttribute("b",StringConverter::toString(l->getSpecularColour().b).c_str()); light3->SetAttribute("x",StringConverter::toString(l->getDirection().x).c_str()); light3->SetAttribute("y",StringConverter::toString(l->getDirection().y).c_str()); light3->SetAttribute("z",StringConverter::toString(l->getDirection().z).c_str()); light4->SetAttribute("range",StringConverter::toString(l->getAttenuationRange()).c_str()); light5->SetAttribute("inner",StringConverter::toString(l->getSpotlightInnerAngle()).c_str()); light5->SetAttribute("outer",StringConverter::toString(l->getSpotlightOuterAngle()).c_str()); light->LinkEndChild(light1); light->LinkEndChild(light2); light->LinkEndChild(light3); light->LinkEndChild(light4); light->LinkEndChild(light5); node->LinkEndChild(pos); //if (!(n->getOrientation()==Quaternion::IDENTITY)) //{ node->LinkEndChild(quat); //} //if (!(n->getScale()==Vector3(1,1,1))) //{ node->LinkEndChild(scale); //} node->LinkEndChild(light); //already made nodes put into <nodes> nodes->LinkEndChild(node); } TiXmlElement *ainodes = new TiXmlElement( "aiNodes" ); for (i=0; i!=npcNodes.size(); i++) { TiXmlElement *npcnode = new TiXmlElement( "npcnode" ); npcnode->SetAttribute("x",StringConverter::toString(npcNodes[i]->getPosition().x*mScaler).c_str()); npcnode->SetAttribute("y",StringConverter::toString(npcNodes[i]->getPosition().y*mScaler).c_str()); npcnode->SetAttribute("z",StringConverter::toString(npcNodes[i]->getPosition().z*mScaler).c_str()); ainodes->LinkEndChild(npcnode); } //put nodes to <scene> scene->LinkEndChild(nodes); scene->LinkEndChild(ainodes); //bind it and save doc.LinkEndChild( scene ); doc.SaveFile( filename.c_str() ); }
inline Ogre::String operator +(const Ogre::String& l,const CEGUI::String& o) { return l+o.c_str(); }
bool Dan::textAccepted(const CEGUI::EventArgs&) { if(!check()) return false; CodingFormatInterface * format = _coding->queryInterface<CodingFormatInterface>(); CEGUI::String text = CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->getText(); if(text.empty()) return true; if(text.size() <= 9) { this->warning(L"输入未满9位"); }else { format->clear(); LockInterface * lock = _dataServer->queryInterface<LockInterface>(); DataServerInterface * data = _dataServer->queryInterface<DataServerInterface>(); std::string code = lock->getLockCode2(); format->decode10(code, 60); unsigned int oCheck = format->getCheck8(60); if(data->loadCodingData()) { CodingFormatInterface * lockData = _dataServer->queryInterface<CodingFormatInterface>(); unsigned int oId = lockData->getLockID(); if(format->decode10(std::string(text.c_str()),28)) { if(format->getBackCheck() != oCheck ||format->getBackID() != (oId%128)) { warning(L"开机码和报账码不匹配,请重新报账"); }else { lockData->setLockLeavings(format->getBackLeavingsIndex()); data->saveCodingData(); unsigned int index = format->getBackLeavingsIndex(); unsigned int profits = format->index2Profits(index); unsigned int levings = data->getLevingsProfits(); data->setLevingsProfits(levings + profits); data->cleanCostBackTimeCode2(); data->save(); if(check()) { warning(L"报账成功"); } } } else { warning(L"无效开机码"); } }else { warning(L"内部数据错误,请联系开发商!"); } } CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->setText(""); return true; }
CEGUI::String LinkButtonParser::Parse(const CEGUI::String &str) { std::string szStr = CEGUIStringToAnsiChar( str ); size_t parentWinPos,IDPos,TextPos,ColorPos,endPos; parentWinPos = IDPos = TextPos = ColorPos = endPos = CEGUI::String::npos; char ParentWinName[128] = ""; char LinkID[32] = ""; char LinkText[128] = ""; char ColorVal[32] = ""; parentWinPos = str.find("WIN:"); IDPos = str.find("ID:"); TextPos = str.find("TEXT:"); ColorPos = str.find("COLOR:"); std::string wndName("LinkBtn_"),temp; static DWORD LinkWndCounter = 0; wndName += CEGUI::PropertyHelper::intToString(LinkWndCounter++).c_str(); CEGUI::Window *linkWnd = 0; if (CEGUI::WindowManager::getSingleton().isWindowPresent(wndName) == false) { linkWnd = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Button",wndName); linkWnd->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&LinkButtonParser::OnLinkBtnClicked,this)); //解析父窗口 if (parentWinPos != CEGUI::String::npos) { temp = szStr.substr(parentWinPos+5); endPos = temp.find("'"); strcpy_s<128>(ParentWinName,temp.substr(0,endPos).c_str()); CEGUI::Window *pParentWnd = CEGUI::WindowManager::getSingleton().getWindow(ParentWinName); pParentWnd->addChildWindow(linkWnd); } //解析ID if (IDPos != CEGUI::String::npos) { temp = szStr.substr(IDPos+3); endPos = temp.find(" "); strcpy_s<32>(LinkID,temp.substr(0,endPos).c_str()); LinkMap[linkWnd] = LinkID; } //解析链接按钮文本 if (TextPos != CEGUI::String::npos) { temp = szStr.substr(TextPos+6); endPos = temp.find("'"); strcpy_s<128>(LinkText,temp.substr(0,endPos).c_str()); float fWidth = linkWnd->getFont()->getTextExtent(LinkText); float fheight = linkWnd->getFont()->getFontHeight(); linkWnd->setSize(CEGUI::UVector2(cegui_absdim(fWidth),cegui_absdim(fheight))); //解析链接按钮文本的颜色 if (ColorPos != CEGUI::String::npos) { temp = szStr.substr(ColorPos+6); endPos = temp.find(" "); strcpy_s(ColorVal,temp.substr(0,endPos).c_str()); temp = "[COLOR "; temp += ColorVal; temp += "]"; temp += CEGUI::String(LinkText).c_str(); linkWnd->setText(ToCEGUIString(temp.c_str())); } else linkWnd->setText(ToCEGUIString(LinkText)); } } return wndName; }
// 添加货物列表 void SetPlayerShopGoodsItemInfo(PlayerShop::tagGoodsItem& tgGoodsItem, int index) { /// 项目背景图 CEGUI::Window* wnd; char tempText[256]; char strImageFilePath[128] = ""; char strImageFileName[128] = ""; sprintf(tempText, "PlayerShop/backgrond/Goods%d", index+1); CEGUI::Window* goodsWnd = GetWndMgr().getWindow(tempText); goodsWnd->setUserData(tgGoodsItem.pItemGoods); goodsWnd->setVisible(true); //根据商店状态设置UI排列 int shopState = GetPlayerShop().GetCurShopState(); if(shopState >= 0 && shopState < PlayerShop::SHOP_STATE) { //设置商店 if(shopState == PlayerShop::SET_SHOP) { sprintf(tempText, "PlayerShop/backgrond/Goods%d/BuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/AddBuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/SubBuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/Text", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setText(ToCEGUIString("双击重新设置价格")); } //开店 else if(shopState == PlayerShop::OPEN_SHOP) { sprintf(tempText, "PlayerShop/backgrond/Goods%d/BuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/AddBuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/SubBuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/Text", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); } // 逛商店页面 else if( shopState == PlayerShop::SHOPPING_SHOP) { sprintf(tempText, "PlayerShop/backgrond/Goods%d/Text", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); } } // 设置物品上架信息 // 物品图片 sprintf(tempText, "PlayerShop/backgrond/Goods%d/Icon", index+1); CEGUI::DefaultWindow* iconWnd = WDefaultWindow(GetWndMgr().getWindow(tempText)); if(iconWnd && tgGoodsItem.goodsIconId != 0) { // 获得当前背包栏对应的物品图标数据,并将该图标设置成对应背包组件的额外图片。 const char *strIconPath = GetGame()->GetPicList()->GetPicFilePathName(CPicList::PT_GOODS_ICON, tgGoodsItem.goodsIconId); GetFilePath(strIconPath,strImageFilePath); GetFileName(strIconPath,strImageFileName); CEGUI::String strImagesetName = "GoodIcon/"; strImagesetName += strImageFileName; SetBackGroundImage(iconWnd,strImagesetName.c_str(),strImageFilePath,strImageFileName); // 当物品数大于1的时候才显示数量 if(tgGoodsItem.tradeType==PlayerShop::TT_GROUP && tgGoodsItem.oneGroupNum>=1) { char strGoodsNum[32]; sprintf_s(strGoodsNum,"%4d",tgGoodsItem.oneGroupNum); iconWnd->setText(strGoodsNum); } } // 物品数 sprintf(tempText, "PlayerShop/backgrond/Goods%d/Num", index+1); wnd = GetWndMgr().getWindow(tempText); if (wnd) { if (tgGoodsItem.tradeType==PlayerShop::TT_SINGLE) { sprintf_s(tempText,"剩%d件",tgGoodsItem.groupNum); }else if (tgGoodsItem.tradeType==PlayerShop::TT_GROUP) { sprintf_s(tempText,"剩%d组",tgGoodsItem.groupNum); } wnd->setText(ToCEGUIString(tempText)); } // 物品名 sprintf(tempText, "PlayerShop/backgrond/Goods%d/Name", index+1); wnd = GetWndMgr().getWindow(tempText); if (wnd) { char strGoodsName[32] = ""; DWORD dwNameSize = (DWORD)strlen(tgGoodsItem.strGoodsName.c_str()); if (tgGoodsItem.tradeType==PlayerShop::TT_SINGLE&&dwNameSize>18) { _snprintf(strGoodsName,19,"%s",tgGoodsItem.strGoodsName.c_str()); sprintf((strGoodsName+18),"..."); }else if (tgGoodsItem.tradeType==PlayerShop::TT_GROUP&&dwNameSize>10) { _snprintf(strGoodsName,11,"%s",tgGoodsItem.strGoodsName.c_str()); sprintf((strGoodsName+10),"..."); } else sprintf(strGoodsName,"%s",tgGoodsItem.strGoodsName.c_str()); wnd->setText(ToCEGUIString(strGoodsName)); wnd->setTooltipText(tgGoodsItem.strGoodsName); } // 交易方式 sprintf(tempText, "PlayerShop/backgrond/Goods%d/TradeType", index+1); wnd = GetWndMgr().getWindow(tempText); if (wnd) { if (tgGoodsItem.tradeType==PlayerShop::TT_SINGLE) { wnd->setText(ToCEGUIString("单个贩卖")); //CEGUI::FreeTypeFont * font = static_cast<CEGUI::FreeTypeFont*>( wnd->getFont() ); //font->setPointSize(8); } else if (tgGoodsItem.tradeType==PlayerShop::TT_GROUP) { wnd->setText(ToCEGUIString("成组贩卖")); } } // 价格 sprintf(tempText, "PlayerShop/backgrond/Goods%d/Price", index+1); wnd = GetWndMgr().getWindow(tempText); if (wnd) { sprintf(tempText,"%d",tgGoodsItem.price); wnd->setText(tempText); } }
bool ConsoleAdapter::consoleInputBox_KeyUp(const CEGUI::EventArgs& args) { const CEGUI::KeyEventArgs& keyargs = static_cast<const CEGUI::KeyEventArgs&>(args); if(keyargs.scancode != CEGUI::Key::Tab) { mTabPressed = false; } switch(keyargs.scancode) { case CEGUI::Key::ArrowUp: { if(mBackend->getHistory().getHistoryPosition() == 0) { mCommandLine = mInputBox->getText().c_str(); } else { // we are not at the command line but in the history // => write back the editing mBackend->getHistory().changeHistory(mBackend->getHistory().getHistoryPosition(), mInputBox->getText().c_str()); } mBackend->getHistory().moveBackwards(); if(mBackend->getHistory().getHistoryPosition() != 0) { mInputBox->setText(mBackend->getHistory().getHistoryString()); } return true; } case CEGUI::Key::ArrowDown: { if(mBackend->getHistory().getHistoryPosition() > 0) { mBackend->getHistory().changeHistory(mBackend->getHistory().getHistoryPosition(), mInputBox->getText().c_str()); mBackend->getHistory().moveForwards(); if(mBackend->getHistory().getHistoryPosition() == 0) { mInputBox->setText(mCommandLine); } else { mInputBox->setText(mBackend->getHistory().getHistoryString()); } } return true; } case CEGUI::Key::Tab: { std::string sCommand(mInputBox->getText().c_str()); // only process commands if(sCommand[0] != '/') { return true; } sCommand = sCommand.substr(1, mInputBox->getCaretIndex() - 1); if(mTabPressed == true) { const std::set< std::string > commands(mBackend->getPrefixes(sCommand)); if(commands.size() > 0) { std::set< std::string >::const_iterator iCommand(commands.begin()); std::string sMessage(""); mSelected = (mSelected + 1) % commands.size(); int select(0); while(iCommand != commands.end()) { if(select == mSelected) { std::string sCommandLine(mInputBox->getText().c_str()); // compose the new command line: old text before the caret + selected command mInputBox->setText(sCommandLine.substr(0, mInputBox->getCaretIndex()) + iCommand->substr(mInputBox->getCaretIndex() - 1)); mInputBox->setSelection(mInputBox->getCaretIndex(), 0xFFFFFFFF); } sMessage += *iCommand + ' '; ++iCommand; ++select; } mBackend->pushMessage(sMessage); } } else { mTabPressed = true; mSelected = 0; const std::set< std::string > commands(mBackend->getPrefixes(sCommand)); if(commands.size() == 0) { // TODO: Error reporting? } else { // if any command starts with the current prefix if(commands.size() == 1) { mInputBox->setText(std::string("/") + *(commands.begin()) + ' '); // this will be at the end of the text mInputBox->setCaretIndex(0xFFFFFFFF); } else { //If there are multiple matches we need to find the lowest common denominator. We'll do this by iterating through all characters and then checking with all the possible commands if they match that prefix, until we get a false. std::set< std::string >::const_iterator iSelected(commands.begin()); std::set< std::string >::const_iterator iCommand(commands.begin()); std::string sCommonPrefix(*iCommand); int select = 1; ++iCommand; while(iCommand != commands.end()) { if(select == mSelected) { iSelected = iCommand; } std::string::size_type i(0); while((i < sCommonPrefix.length()) && (i < (*iCommand).length())) { if(sCommonPrefix[i] != (*iCommand)[i]) { break; } ++i; } if(i < sCommonPrefix.length()) { sCommonPrefix = sCommonPrefix.substr(0, i); } ++select; ++iCommand; } mInputBox->setText(std::string("/") + sCommonPrefix + iSelected->substr(sCommonPrefix.length())); mInputBox->setCaretIndex(sCommonPrefix.length() + 1); mInputBox->setSelection(sCommonPrefix.length() + 1, 0xFFFFFFFF); } } } return true; } case CEGUI::Key::Return: case CEGUI::Key::NumpadEnter: { if (mReturnKeyDown) { mReturnKeyDown = false; if(mInputBox->getSelectionLength() > 0) { unsigned long ulSelectionEnd(mInputBox->getSelectionEndIndex()); mInputBox->setText(mInputBox->getText() + ' '); mInputBox->setCaretIndex(ulSelectionEnd + 1); mInputBox->setSelection(mInputBox->getCaretIndex(), mInputBox->getCaretIndex()); } else { const CEGUI::String consoleText(mInputBox->getText()); mInputBox->setText(CEGUI::String("")); mBackend->pushMessage(("> " + consoleText).c_str()); // run the command mBackend->runCommand(consoleText.c_str()); EventCommandExecuted.emit(consoleText.c_str()); } } return true; } default: { break; } } return false; }
/*********************************************************** handle send button event ***********************************************************/ bool ChatBox::HandleEnterKey (const CEGUI::EventArgs& e) { const CEGUI::KeyEventArgs& we = static_cast<const CEGUI::KeyEventArgs&>(e); const CEGUI::WindowEventArgs& wine = static_cast<const CEGUI::WindowEventArgs&>(e); if(we.scancode == CEGUI::Key::LeftControl || we.scancode == CEGUI::Key::RightControl) { _control_key_on = true; return true; } if(we.scancode == CEGUI::Key::LeftShift || we.scancode == CEGUI::Key::RightShift) { _shift_key_on = true; return true; } if(we.scancode == CEGUI::Key::LeftAlt || we.scancode == CEGUI::Key::RightAlt) { return true; } if(wine.window->getName() == "Chat/edit") { if(we.scancode == CEGUI::Key::Return) { HandleSend (e); CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")); bed->deactivate(); return true; } if(we.scancode == CEGUI::Key::ArrowUp) { if(_itltext == _lasttexts.end()) _itltext = _lasttexts.begin(); else { std::list<std::string>::iterator ittmp = _itltext; ++ittmp; if(ittmp != _lasttexts.end()) ++_itltext; } try { CEGUI::Window *windowchat = CEGUI::WindowManager::getSingleton().getWindow("Chat/edit"); std::string text = ""; if(_itltext != _lasttexts.end()) text = *_itltext; if(windowchat) windowchat->setText((const unsigned char *)text.c_str()); } catch(...){} //++_currSelectedch; //if(_currSelectedch >= (int)_channels.size()) // --_currSelectedch; //else //{ // std::list<std::string>::const_iterator it = _channels.begin(); // std::list<std::string>::const_iterator end = _channels.end(); // for(int cc=0; cc<_currSelectedch && it != end; ++it, ++cc); // CEGUI::PushButton * bch = static_cast<CEGUI::PushButton *> // (CEGUI::WindowManager::getSingleton().getWindow("Chat/bChannel")); // bch->setProperty("Text", *it); //} return true; } if(we.scancode == CEGUI::Key::ArrowDown) { if(_itltext != _lasttexts.end()) { if(_itltext != _lasttexts.begin()) --_itltext; else _itltext = _lasttexts.end(); } CEGUI::Window *windowchat = CEGUI::WindowManager::getSingleton().getWindow("Chat/edit"); std::string text = ""; if(_itltext != _lasttexts.end()) text = *_itltext; if(windowchat) windowchat->setText((const unsigned char *)text.c_str()); //--_currSelectedch; //if(_currSelectedch < 0) // ++_currSelectedch; //else //{ // std::list<std::string>::const_iterator it = _channels.begin(); // std::list<std::string>::const_iterator end = _channels.end(); // for(int cc=0; cc<_currSelectedch && it != end; ++it, ++cc); // CEGUI::PushButton * bch = static_cast<CEGUI::PushButton *> // (CEGUI::WindowManager::getSingleton().getWindow("Chat/bChannel")); // bch->setProperty("Text", *it); //} return true; } if(we.scancode == CEGUI::Key::ArrowUp || we.scancode == CEGUI::Key::ArrowDown) return true; // paste text if(we.scancode == CEGUI::Key::V && _control_key_on) { CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")); if(bed && bed->isActive()) { if(_text_copyed != "") { size_t selB = bed->getSelectionStartIndex(); size_t selE = bed->getSelectionLength(); CEGUI::String str = bed->getText(); if(selE > 0) { str = str.erase(selB, selE); } if(str.size() + _text_copyed.size() < bed->getMaxTextLength()) { size_t idx = bed->getCaratIndex(); str = str.insert(idx, (unsigned char *)_text_copyed.c_str()); bed->setText(str); bed->setCaratIndex(idx + _text_copyed.size()); } } return true; } } } // copy text if(we.scancode == CEGUI::Key::C && _control_key_on) { CEGUI::Window * actw = _myChat->getActiveChild(); if(actw != NULL) { if(actw->getName() == "Chat/edit") { CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (actw); size_t selB = bed->getSelectionStartIndex(); size_t selE = bed->getSelectionLength(); if(selE > 0) { CEGUI::String str = bed->getText().substr(selB, selE); _text_copyed = str.c_str(); } return true; } else { CEGUI::MultiLineEditbox* txt = static_cast<CEGUI::MultiLineEditbox *>(actw); size_t selB = txt->getSelectionStartIndex(); size_t selE = txt->getSelectionLength(); if(selE > 0) { CEGUI::String str = txt->getText().substr(selB, selE); _text_copyed = str.c_str(); } return true; } } } return false; }
bool SelectorHelper::ShowLeaderboard( const CEGUI::EventArgs &e ) { CEGUI::WindowManager *wmgr = CEGUI::WindowManager::getSingletonPtr(); CEGUI::Window* leaderboardWindow, *leaderboardName, *leaderboardNextLevel, *leaderboardBackToMenu; CEGUI::Window* leaderboardWindows[10]; leaderboardWindow = wmgr->getWindow("Leaderboard"); leaderboardName = wmgr->getWindow("Leaderboard/LevelName"); leaderboardNextLevel = wmgr->getWindow("Leaderboard/NextLevel"); leaderboardBackToMenu = wmgr->getWindow("Leaderboard/BackToMenu"); for (int i = 0; i < 10; i++) { std::stringstream ss; ss << "Leaderboard/" << i; leaderboardWindows[i] = wmgr->getWindow(ss.str()); } CEGUI::System::getSingleton().setGUISheet(leaderboardWindow); leaderboardBackToMenu->removeEvent(CEGUI::PushButton::EventClicked); leaderboardBackToMenu->subscribeEvent(CEGUI::PushButton::EventClicked, &SelectorHelper::SwitchToLevelSelectMenu); int levelViewerIndex = *static_cast<const CEGUI::MouseEventArgs*>(&e)->window->getName().rbegin() - '1'; CEGUI::String name = levelViewers[levelViewerIndex]->window->getName(); leaderboardNextLevel->setVisible(false); /* leaderboardNextLevel->removeEvent(CEGUI::PushButton::EventClicked); leaderboardNextLevel ->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MenuActivity::awdawd, this)); */ for (int i = 0; i < 10; i++) leaderboardWindows[i]->setAlpha(0.0); Leaderboard leaderboard = Leaderboard::findLeaderboard(name.c_str()); leaderboardName->setText(name.c_str()); OBAnimationManager::startAnimation("SpinPopup", leaderboardName); OBAnimationManager::startAnimation("SpinPopup", leaderboardNextLevel, 0.5); OBAnimationManager::startAnimation("SpinPopup", leaderboardBackToMenu, 0.5); std::multimap<double, LeaderboardEntry, greater<double> > highscores = leaderboard.getHighscores(); std::multimap<double, LeaderboardEntry>::iterator iter; int i = 0; for (iter = highscores.begin(); iter != highscores.end(); iter++) { LeaderboardEntry entry = iter->second; std::stringstream ss; size_t namelen = entry.name.length(); ss << std::left << setw(55-namelen) << entry.name << setw(15) << entry.score << setw(15) << entry.getTimeTaken() << setw(25) << entry.getTimeEntered(); leaderboardWindows[i]->setText(ss.str()); OBAnimationManager::startAnimation("FadeInFromLeft", leaderboardWindows[i], 1.0, 1.0 + 0.2f*i); i++; } }
void MenuState::ValidateNAMEIP() { // This shouldn't be here!!! // Socket needs to be closed/reset before IO_Service is reset. if(LC::Client::getSingletonPtr()->socket_) { boost::shared_ptr<tcp::socket> sockets; sockets = LC::Client::getSingletonPtr()->socket_; boost::system::error_code error; sockets->shutdown(boost::asio::socket_base::shutdown_both, error); sockets->close(error); } LC::Client::getSingletonPtr()->socket_.reset(); // May be overly drastic. TheApplication.ResetIOService(); if(m_IsHost) { // Create Server. std::string userName = wmgr->getWindow("LIGHTCYCLEMENU/Name/EditBox")->getText().c_str(); Server::getSingletonPtr()->reset(TheApplication.getIOService(), userName); // Create Client. // Need better way of doing this. tcp::resolver resolver(*TheApplication.getIOService()); std::ostringstream ss; int portnumber = TheApplication.getPortNumber(); ss << portnumber; tcp::resolver::query query("127.0.0.1", ss.str().c_str()); tcp::resolver::iterator iterator = resolver.resolve(query); Client::getSingletonPtr()->reset(TheApplication.getIOService(), iterator, userName); wmgr->getWindow("LIGHTCYCLEMENU/Lobby/ConnectedIP")->setText("IP: SERVER"); wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->setText(""); wmgr->getWindow("LIGHTCYCLEMENU/Name/EditBox")->setText(""); } else { std::string text = wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->getText().c_str(); // Check for valid IP address. boost::system::error_code ec; boost::asio::ip::address address = boost::asio::ip::address::from_string(text, ec); std::string userName = wmgr->getWindow("LIGHTCYCLEMENU/Name/EditBox")->getText().c_str(); if(!ec && userName.length()>=1) { CEGUI::String IPAddress = wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->getText(); // Need better way of doing this. tcp::resolver resolver(*TheApplication.getIOService()); std::ostringstream ss; int portnumber = TheApplication.getPortNumber(); ss << portnumber; tcp::resolver::query query(IPAddress.c_str(), ss.str().c_str()); tcp::resolver::iterator iterator = resolver.resolve(query); Client::getSingletonPtr()->reset(TheApplication.getIOService(), iterator, userName); wmgr->getWindow("LIGHTCYCLEMENU/Lobby/ConnectedIP")->setText("IP: " + address.to_string()); } else if(ec) { wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->setText("Invalid Address"); CEGUI::Editbox *editBox = static_cast<CEGUI::Editbox*>(wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")); editBox->setCaratIndex(editBox->getText().length()); } } }
void ChatManager::onReceive( const std::string& channel, const std::string& sender, const CEGUI::String& msg ) { std::string smsg( reinterpret_cast< const char* >( msg.c_str() ) ); if ( !_serverMode ) notifyAppWindow( channel + " [" + sender + "] " + smsg ); }