本文整理汇总了C++中irr::core::stringw类的典型用法代码示例。如果您正苦于以下问题:C++ stringw类的具体用法?C++ stringw怎么用?C++ stringw使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了stringw类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serverCreationRequest
// ----------------------------------------------------------------------------
void CreateServerScreen::serverCreationRequest()
{
const irr::core::stringw name = m_name_widget->getText().trim();
const int max_players = m_max_players_widget->getValue();
m_info_widget->setErrorColor();
if (name.size() < 4 || name.size() > 30)
{
m_info_widget->setText(_("Name has to be between 4 and 30 characters long!"), false);
}
else if (max_players < 2 || max_players > 12)
{
m_info_widget->setText(_("The maxinum number of players has to be between 2 and 12."), false);
}
else
{
m_server_creation_request = new ServerCreationRequest();
CurrentUser::setUserDetails(m_server_creation_request);
m_server_creation_request->addParameter("action", "create_server");
m_server_creation_request->addParameter("name", name);
m_server_creation_request->addParameter("max_players", max_players);
m_server_creation_request->queue();
return;
}
sfx_manager->quickSound("anvil");
}
示例2: createServer
/** In case of WAN it adds the server to the list of servers. In case of LAN
* networking, it registers this game server with the stk server.
*/
void CreateServerScreen::createServer()
{
const irr::core::stringw name = m_name_widget->getText().trim();
const int max_players = m_max_players_widget->getValue();
m_info_widget->setErrorColor();
if (name.size() < 4 || name.size() > 30)
{
m_info_widget->setText(
_("Name has to be between 4 and 30 characters long!"), false);
SFXManager::get()->quickSound("anvil");
return;
}
else if (max_players < 2 || max_players > 12)
{
m_info_widget->setText(
_("The maxinum number of players has to be between 2 and 12."),
false);
SFXManager::get()->quickSound("anvil");
return;
}
// In case of a LAN game, we can create the new server object now
if (NetworkConfig::get()->isLAN())
{
// FIXME Is this actually necessary?? Only in case of WAN, or LAN and WAN?
TransportAddress address(0x7f000001,0); // 127.0.0.1
Server *server = new Server(name, /*lan*/true, max_players,
/*current_player*/1, address);
ServersManager::get()->addServer(server);
}
// In case of a WAN game, we register this server with the
// stk server, and will get the server's id when this
// request is finished.
NetworkConfig::get()->setMaxPlayers(max_players);
NetworkConfig::get()->setServerName(name);
// FIXME: Add the following fields to the create server screen
// FIXME: Long term we might add a 'vote' option (e.g. GP vs single race,
// and normal vs FTL vs time trial could be voted about).
race_manager->setDifficulty(RaceManager::convertDifficulty("hard"));
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
race_manager->setReverseTrack(false);
STKHost::create();
} // createServer
示例3: setLabel
void ButtonWidget::setLabel(const irr::core::stringw &label)
{
// This method should only be called AFTER a widget is added
assert(m_element != NULL);
m_element->setText( label.c_str() );
setText(label);
}
示例4: setLabel
// -----------------------------------------------------------------------------
void RibbonWidget::setLabel(const int id, irr::core::stringw new_name)
{
if (m_labels.size() == 0) return; // ignore this call for ribbons without labels
assert(id >= 0);
assert(id < m_labels.size());
m_labels[id].setText( new_name.c_str() );
m_text = new_name;
}
示例5: notEmpty
/** Checks if the input string is not empty. ( = has characters different
* from a space).
*/
bool notEmpty(const irr::core::stringw& input)
{
const int size = input.size();
int nonEmptyChars = 0;
for (int n=0; n<size; n++)
{
if (input[n] != L' ')
{
nonEmptyChars++;
}
}
return (nonEmptyChars > 0);
} // getExtension
示例6: renameCell
// -----------------------------------------------------------------------------
void ListWidget::renameCell(const int row_index, const int col_index, const irr::core::stringw newName, const int icon)
{
// May only be called AFTER this widget has been add()ed
assert(m_element != NULL);
CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
assert(list != NULL);
list->setCell(row_index, col_index, newName.c_str(), icon);
list->setItemOverrideColor( row_index, EGUI_LBC_TEXT , video::SColor(255,0,0,0) );
list->setItemOverrideColor( row_index, EGUI_LBC_TEXT_HIGHLIGHT, video::SColor(255,255,255,255) );
}
示例7: w_gettext
/**
* \param original Message to translate
* \param context Optional, can be set to differentiate 2 strings that are identical
* in English but could be different in other languages
*/
const wchar_t* Translations::w_gettext(const char* original, const char* context)
{
if (original[0] == '\0') return L"";
#if TRANSLATE_VERBOSE
Log::info("Translations", "Translating %s", original);
#endif
const std::string& original_t = (context == NULL ?
m_dictionary.translate(original) :
m_dictionary.translate_ctxt(context, original));
if (original_t == original)
{
static irr::core::stringw converted_string;
converted_string = StringUtils::utf8ToWide(original);
#if TRANSLATE_VERBOSE
std::wcout << L" translation : " << converted_string << std::endl;
#endif
return converted_string.c_str();
}
// print
//for (int n=0;; n+=4)
static core::stringw original_tw;
original_tw = StringUtils::utf8ToWide(original_t);
const wchar_t* out_ptr = original_tw.c_str();
if (REMOVE_BOM) out_ptr++;
#if TRANSLATE_VERBOSE
std::wcout << L" translation : " << out_ptr << std::endl;
#endif
return out_ptr;
}
示例8: addUnlockedPicture
void FeatureUnlockedCutScene::addUnlockedPicture(irr::video::ITexture* picture,
float w, float h,
irr::core::stringw msg)
{
if (picture == NULL)
{
Log::warn("FeatureUnlockedCutScene::addUnlockedPicture", "Unlockable has no picture: %s",
core::stringc(msg.c_str()).c_str());
picture = irr_driver->getTexture(file_manager->getAsset(FileManager::GUI,"main_help.png"));
}
m_unlocked_stuff.push_back( new UnlockedThing(picture, w, h, msg) );
} // addUnlockedPicture
示例9: addUnlockedPicture
void FeatureUnlockedCutScene::addUnlockedPicture(irr::video::ITexture* picture,
float w, float h,
irr::core::stringw msg)
{
if (picture == NULL)
{
std::cerr << "[FeatureUnlockedCutScene::addUnlockedPicture] WARNING: unlockable has no picture : "
<< core::stringc(msg.c_str()).c_str() << "\n";
picture = irr_driver->getTexture(file_manager->getAsset(FileManager::GUI,"main_help.png"));
}
m_unlocked_stuff.push_back( new UnlockedThing(picture, w, h, msg) );
} // addUnlockedPicture
示例10: setValue
void SpinnerWidget::setValue(irr::core::stringw new_value)
{
const int size = (int)m_labels.size();
for (int n=0; n<size; n++)
{
if (m_labels[n] == new_value)
{
setValue(n);
return;
}
}
Log::fatal("SpinnerWidget::setValue", "Cannot find element named '%s'",
irr::core::stringc(new_value.c_str()).c_str());
}
示例11: setValue
void SpinnerWidget::setValue(irr::core::stringw new_value)
{
const int size = (int)m_labels.size();
for (int n=0; n<size; n++)
{
if (m_labels[n] == new_value)
{
setValue(n);
return;
}
}
std::cerr << "ERROR [SpinnerWidget::setValue] : cannot find element named '"
<< irr::core::stringc(new_value.c_str()).c_str() << "'\n";
assert(false);
}
示例12: split
/** Splits a string into substrings separated by a certain character, and
* returns a std::vector of all those substring. E.g.:
* split("a b=c d=e",' ') --> ["a", "b=c", "d=e"]
* This is the version for wide strings.
* \param s The string to split.
* \param c The character by which the string is split.
*/
std::vector<irr::core::stringw> split(const irr::core::stringw& s, char c,
bool keepSplitChar)
{
try
{
std::vector<irr::core::stringw> result;
irr::s32 start = 0;
while (start < (irr::s32)s.size())
{
irr::s32 i = s.findNext(c, start);
if (i != -1)
{
if (keepSplitChar)
{
int from = start-1;
if (from < 0) from = 0;
result.push_back( s.subString(from, i-from) );
}
else result.push_back( s.subString(start, i-start) );
start = i+1;
}
else
{
if (keepSplitChar)
result.push_back( s.subString(start - 1,
s.size()-start + 1) );
else
result.push_back( s.subString(start, s.size()-start) );
return result;
//start = i+1;
}
}
return result;
}
catch (std::exception& e)
{
(void)e; // avoid warning about unused variable
Log::fatal("StringUtils",
"Fatal error in split(stringw) : %s @ line %i : '%s'.",
__FILE__, __LINE__, e.what());
exit(1);
}
} // split
示例13: xmlEncode
/** Converts a unicode string to plain ASCII using XML entites (e.g. &x00;)
* \param s The input string which should be encoded.
* \return A std:;string with ASCII characters.
*/
std::string xmlEncode(const irr::core::stringw &s)
{
std::ostringstream output;
for(unsigned int i=0; i<s.size(); i++)
{
if (s[i] >= 128 || s[i] == '&' || s[i] == '<' || s[i] == '>' || s[i] == '\"')
{
output << "&#x" << std::hex << std::uppercase << s[i] << ";";
}
else
{
irr::c8 c = (char)(s[i]);
output << c;
}
}
return output.str();
} // xmlEncode
示例14: setLabel
// ----------------------------------------------------------------------------
void RibbonWidget::setLabel(const unsigned int id, irr::core::stringw new_name)
{
if (m_element == NULL)
{
// before adding
m_children[id].setText(new_name);
}
else
{
// after adding
// ignore this call for ribbons without labels
if (m_labels.size() == 0) return;
assert(id < m_labels.size());
m_labels[id].setText(new_name.c_str());
//m_text = new_name;
}
} // setLabel
示例15: encodeToHtmlEntities
/** Converts a unicode string to plain ASCII using html-like & codes.
* \param s The input string which should be encoded.
* \return A std:;string with ASCII characters.
*/
std::string encodeToHtmlEntities(const irr::core::stringw &s)
{
std::ostringstream output;
for(unsigned int i=0; i<s.size(); i++)
{
if(s[i]=='&')
output<<"&";
else
{
if(s[i]<128)
{
irr::c8 c=(char)(s[i]);
output<<c;
}
else
{
output <<"&#x" << std::hex <<std::uppercase<< s[i]<<";";
}
}
}
return output.str();
} // encodeToHtmlEntities