本文整理汇总了C++中cegui::String类的典型用法代码示例。如果您正苦于以下问题:C++ String类的具体用法?C++ String怎么用?C++ String使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPlayerShopAddBuyNum
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;
}
示例2: updateLoginWelcomeText
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);
}
示例3: logEvent
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;
}
}
}
示例4:
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);
}
}
示例5:
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");
}
}
示例6: ParseText
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
}
}
}
示例7: AcceptsWindowAsChild
//------------------------------------------------------------------------
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");
}
示例8: initialiseAvailableWidgetsMap
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);
}
示例9: getPoints
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;
}
示例10: loadRawDataContainer
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");
}
示例11: interp
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));
}
示例12: postChatText
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 ) );
}
}
示例13: HandleEnterKey
//.........这里部分代码省略.........
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;
}
示例14: save
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);
//.........这里部分代码省略.........
示例15:
inline Ogre::String operator +(const Ogre::String& l,const CEGUI::String& o)
{
return l+o.c_str();
}