本文整理汇总了C++中mygui::UString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ UString::size方法的具体用法?C++ UString::size怎么用?C++ UString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygui::UString
的用法示例。
在下文中一共展示了UString::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressed
bool WinState::keyPressed(const OIS::KeyEvent &e)
{
MyGUI::UString txt = user_name_txt->getCaption();
if ((int)e.key==14 && txt.size()>0)
{
txt.resize(txt.size()-1);
}
else
{
if (((int)e.text >=65 && (int)e.text<=90) || ((int)e.text>=97 && (int)e.text<=122))
{
if (txt.size()<CONSTANTS_MAX_USERNAME_SIZE) txt.push_back(e.text);
}
}
user_name_txt->setCaption(txt);
if ((e.key == OIS::KC_ESCAPE) || (e.key == OIS::KC_RETURN) || (e.key == OIS::KC_R))
{
cout << "NEW RECORD TO SAVE" << endl;
save_record();
popState();
}
return true;
}
示例2: keyPressed
bool PlayState::keyPressed(const OIS::KeyEvent &e)
{
if (!user_name_txt->getVisible())
{
// if (paused) pause(); // ESTO NO ES NECESARIO. AL HACER UN PUSHSTATE EL GAMEMANAGER LLAMARÁ A PAUSE() AUTOMATICAMENTE
// else
if (!paused)
{
if (e.key == OIS::KC_P) {
paused = true;
pushState(PauseState::getSingletonPtr());
}
else if (e.key == OIS::KC_G) {
paused = true;
game_over();
}
else if (e.key == OIS::KC_W) {
win();
}
else if (e.key == OIS::KC_UP)
{
_pacmanDir = UP_DIR;
}
else if (e.key == OIS::KC_DOWN) {
_pacmanDir = DOWN_DIR;
}
else if (e.key == OIS::KC_LEFT) {
_pacmanDir = LEFT_DIR;
}
else if (e.key == OIS::KC_RIGHT) {
_pacmanDir = RIGHT_DIR;
}
// else if (e.key == OIS::KC_ESCAPE) {
// popState();
// pushState(IntroState::getSingletonPtr());
// }
}
}
else
{
sounds::getInstance()->play_effect("eat_fruit");
MyGUI::UString txt = user_name_txt->getCaption();
if ((int)e.key==14 && txt.size()>0) txt.resize(txt.size()-1);
else
{
if (((int)e.text >=65 && (int)e.text<=90) || ((int)e.text>=97 && (int)e.text<=122))
{
if (txt.size()<3) txt.push_back(e.text);
}
}
user_name_txt->setCaption(txt);
if (e.key==OIS::KC_RETURN)
{
cout << "NEW RECORD TO SAVE" << endl;
records::getInstance()->add_record(txt,get_score());
records::getInstance()->saveFile(NULL);
sounds::getInstance()->play_effect("eat_ghost");
user_name_txt->setVisible(false);
popState();
stopWorld = false;
}
}
return true;
}
示例3:
//--------------------------------------------------------------------------------
void Chat::_Log(const MyGUI::UString& str, const MyGUI::UString& color)
{
while(mList->getItemCount() > 200)
mList->removeItemAt(0);
std::wstring tmp;
std::vector<std::wstring> lines;
lines.clear();
MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(MyGUI::FontManager::getInstance().getDefaultFont());
int ctr = 0;
for(size_t i = 0; i < str.size(); i++)
{
if(ctr + font->getGlyphInfo((int)str[i])->width > mList->getWidth() - 35)
{
ctr = 0;
if(str[i] != L' ')
tmp.push_back(L'-');
else
while(str[i] == L' ' && i < str.size()){i++;}
lines.push_back(tmp);
tmp.clear();
}
tmp.push_back(str[i]);
ctr += font->getGlyphInfo((int)str[i])->width;
if (i >= str.size() - 1)
{
ctr = 0;
lines.push_back(tmp);
tmp.clear();
}
}
for (unsigned int i = 0 ; i < lines.size() ; i++)
{
if (i == 0)
{
std::wstring toAdd;
toAdd += lines[i].substr(0, lines[i].find(L":") + 1);
toAdd += color;
toAdd += lines[i].substr(lines[i].find(L":") + 1, lines[i].size());
mList->addItem(toAdd);
}
else
{
std::wstring toAdd = color;
toAdd += lines[i];
mList->addItem(toAdd);
}
}
mList->beginToItemLast();
}