本文整理汇总了C++中sf::String::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ String::getSize方法的具体用法?C++ String::getSize怎么用?C++ String::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::String
的用法示例。
在下文中一共展示了String::getSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendSfString
void PC::sendSfString(Entity* entity, sf::String message)
{
playButtonSound();
if(message.getSize() <= 5)
{
msfString = message;
}
}
示例2: toKatakana
// Accepts input (stringin) and returns sf::String with corresponding kana
sf::String toKatakana (sf::String InputString)
{
std::size_t InputLength = InputString.getSize();
sf::Uint32 lastChar1 = 0;
sf::Uint32 lastChar2 = 0;
sf::Uint32 lastChar3 = 0;
if (InputLength > 0)
lastChar1 = InputString[(InputLength - 1)];
if (InputLength > 1)
lastChar2 = InputString[(InputLength - 2)];
if (InputLength > 2)
lastChar3 = InputString[(InputLength - 3)];
// Return string
sf::String kanaOut;
// A/a a
if (lastChar1 == 65 || lastChar1 == 97)
{
// Y/y ya
if (lastChar2 == 89 || lastChar2 == 121)
{
// K/k kya
if (lastChar3 == 75 || lastChar3 == 107)
{
lastChar1 = 12461;
kanaOut += lastChar1;
lastChar2 = 12515;
kanaOut += lastChar2;
}
// N/n nya
else if (lastChar3 == 78 || lastChar3 == 110)
{
lastChar1 = 12491;
kanaOut += lastChar1;
lastChar2 = 12515;
kanaOut += lastChar2;
}
// H/h hya
else if (lastChar3 == 72 || lastChar3 == 104)
{
lastChar1 = 12498;
kanaOut += lastChar1;
lastChar2 = 12515;
kanaOut += lastChar2;
}
// M/m mya
else if (lastChar3 == 77 || lastChar3 == 109)
{
lastChar1 = 12511;
kanaOut += lastChar1;
lastChar2 = 12515;
kanaOut += lastChar2;
}
// R/r rya
else if (lastChar3 == 82 || lastChar3 == 114)
{
lastChar1 = 12522;
kanaOut += lastChar1;
lastChar2 = 12515;
kanaOut += lastChar2;
}
// G/g gya
else if (lastChar3 == 71 || lastChar3 == 103)
{
lastChar1 = 12462;
kanaOut += lastChar1;
lastChar2 = 12515;
kanaOut += lastChar2;
}
// B/b bya
else if (lastChar3 == 66 || lastChar3 == 98)
{
lastChar1 = 12499;
kanaOut += lastChar1;
lastChar2 = 12515;
kanaOut += lastChar2;
}
// P/p pya
else if (lastChar3 == 80 || lastChar3 == 112)
{
lastChar1 = 12500;
kanaOut += lastChar1;
lastChar2 = 12515;
kanaOut += lastChar2;
}
else
{
lastChar1 = 12516;
kanaOut += lastChar1;
}
}
// H/h ha
else if (lastChar2 == 72 || lastChar2 == 104)
{
// S/s sha
if (lastChar3 == 83 || lastChar3 == 115)
{
lastChar1 = 12471;
kanaOut += lastChar1;
//.........这里部分代码省略.........
示例3: Widget
Label::Label(Updatable *parent, const sf::String &string, const sf::Font &font, const sf::Vector2f &position, int characterSize) : Widget(parent, sf::FloatRect(position.x, position.y, characterSize * string.getSize(), characterSize)), m_text(string, font)
{
m_focus=false;
setPosition(position);
setCharacterSize(characterSize);
}
示例4: translate
sf::String CommandTranslator::translate(const sf::String& cmd) const
{
//Commands shall be in the following format:
//1. For Variables
// {set|get} {varname}
//2. For functions
// {run} {funcname} {param}*
size_t i = 0;
for(i = 0; i < cmd.getSize(); i++)
if(!isspace(cmd[i])) break;;
size_t lastpos = 0;
int op = 0;
while(i < cmd.getSize())
{
if(cmd.substring(i, 3) == "get")
{
op = 1;
}
else if(cmd.substring(i, 3) == "set")
{
op = 2;
}
else if(cmd.substring(i, 3) == "run")
{
op = 3;
}
i = i + 4;
for(; i < cmd.getSize(); i++)
if(!isspace(cmd[i])) break;
lastpos = i;
for(; i < cmd.getSize(); i++)
if(isspace(cmd[i])) break;
sf::String str = cmd.substring(lastpos, i - lastpos);
printf("Text is \"%s\"\n", str.toAnsiString().c_str());
++i;
std::vector<sf::String> params;
while(i < cmd.getSize())
{
for(; i < cmd.getSize(); i++)
if(!isspace(cmd[i])) break;
lastpos = i;
for(; i < cmd.getSize(); i++)
if(isspace(cmd[i])) break;
sf::String param = cmd.substring(lastpos, i - lastpos);
printf("Param is \"%s\"\n", param.toAnsiString().c_str());
params.push_back(param);
}
if(op < 3) //Var operation
{
auto it = m_vars.begin();
if((it = m_vars.find(str)) != m_vars.end())
{
return it->second(op, params.size() > 0 ? params[0] : sf::String());
}
}
else
{
//Run operation
auto it = m_funcs.find(str);
if(it != m_funcs.end())
{
it->second(params);
return sf::String();
}
}
i++;
}
return sf::String();
}