本文整理汇总了C++中cegui::String::size方法的典型用法代码示例。如果您正苦于以下问题:C++ String::size方法的具体用法?C++ String::size怎么用?C++ String::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cegui::String
的用法示例。
在下文中一共展示了String::size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddChatText
/***********************************************************
method to correctly add chat text
***********************************************************/
void ChatBox::AddChatText(const CEGUI::String& pText, CEGUI::Listbox * listbox)
{
using namespace CEGUI;
// If there's text then add it
if(pText.size())
{
// Add the Editbox text to the history Listbox
LeftWrappedListItem* chatItem;
if(listbox->getItemCount() == mHistorySize)
{
/* We have reached the capacity of the Listbox so re-use the first Listbox item.
This code is a little crafty. By default the ListboxTextItem is created with
the auto-delete flag set to true, which results in its automatic deletion when
removed from the Listbox. So we change that flag to false, extract the item
from the Listbox, change its text, put the auto-delete flag back to true, and
finally put the item back into the Listbox. */
chatItem = static_cast<LeftWrappedListItem*>(listbox->getListboxItemFromIndex(0));
chatItem->setAutoDeleted(false);
listbox->removeItem(chatItem);
chatItem->setAutoDeleted(true);
chatItem->setText(pText);
}
else
{
// Create a new listbox item
chatItem = new LeftWrappedListItem(pText);
}
listbox->addItem(chatItem);
listbox->ensureItemIsVisible(listbox->getItemCount());
}
}
示例2: handleFontCreationButtonClicked
bool FontDemo::handleFontCreationButtonClicked(const EventArgs& e)
{
FontManager& fontMgr(FontManager::getSingleton());
CEGUI::String fontName = d_fontNameEditbox->getText();
bool fontNameExists = fontMgr.isDefined(fontName);
if(fontNameExists ||fontName.size() == 0)
{
d_fontEditorInfoLabel->setText("Font name already in use.");
return true;
}
CEGUI::String fontFileName = d_fontFileNameSelector->getSelectedItem()->getText();
CEGUI::String fontSizeString = d_fontSizeEditbox->getText();
float fontSize = CEGUI::PropertyHelper<float>::fromString(fontSizeString);
if(fontSize == 0.0f)
return true;
bool antiAlias = d_fontAntiAliasCheckbox->isSelected();
AutoScaledMode autoScaleMode = static_cast<AutoScaledMode>(getAutoScaleMode());
String::size_type pos = fontFileName.rfind(".imageset");
if(pos != -1)
{
CEGUI::Font& createdFont = fontMgr.createPixmapFont(fontName, fontFileName, Font::getDefaultResourceGroup(), autoScaleMode,
CEGUI::Sizef(1280.0f, 720.0f), XREA_THROW);
}
else
{
CEGUI::Font& createdFont = fontMgr.createFreeTypeFont(fontName, fontSize, antiAlias, fontFileName, Font::getDefaultResourceGroup(), autoScaleMode,
CEGUI::Sizef(1280.0f, 720.0f), XREA_THROW);
}
ListboxItem* item = new MyListItem(fontName, 0);
d_fontSelector->addItem(item);
d_fontSelector->setItemSelectState(item, true);
return true;
}
示例3: 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);
}
示例4: textAccepted
bool Dan::textAccepted(const CEGUI::EventArgs&)
{
CEGUI::String text = CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->getText();
std::cout<<CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->getText()<<std::endl;
std::cout<<CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->getText().size()<<std::endl;
if(text.empty())
return true;
if(text.size() != 9)
{
_time = 1.0f;
CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/W")->setProperty("Image","set:UI4 image:w1");
}else
{
if(_callback)
_callback->uploadPassword(Ogre::StringConverter::parseInt(text.c_str()));
}
CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->setText("");
return true;
}
示例5: setupLocalGame
// Activated by the button in the GUI, prepares a Local Game
bool Game::setupLocalGame(const CEGUI::EventArgs& e)
{
// Let's parse the number of players
CEGUI::String Msg = OgreFW::getSingletonPtr()->mGUIRootWindow->getChild("ConsoleRoot/EditBox")->getText();
// Be careful with the content of the textfield!
int nplayers = 2;
if (Msg.size() == 1) {
// Let's do a wonderful chained type cast!
nplayers = boost::lexical_cast<int>(Msg.c_str());
if (nplayers > 4) nplayers = 4;
if (nplayers == 0) nplayers = 2;
}
std::cout << "Setup game IS CALLED! Players: " << nplayers << std::endl;
populatePlayers(nplayers);
currentGameStage = PLAYING_STATE;
SetIsNetworkGame(false);
setupGUI();
return true;
}
示例6: textAccepted
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;
}
示例7: HandleEnterKey
//.........这里部分代码省略.........
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;
}