本文整理汇总了C++中sf::String::toAnsiString方法的典型用法代码示例。如果您正苦于以下问题:C++ String::toAnsiString方法的具体用法?C++ String::toAnsiString怎么用?C++ String::toAnsiString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::String
的用法示例。
在下文中一共展示了String::toAnsiString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: log
void Logger::log(sf::String message)
{
if (isLoggingEnabled)
{
time_t now = time(0);
tm *localTime = localtime(&now);
std::clog << 1900 + localTime->tm_year << ".";
std::clog << 1 + localTime->tm_mon << ".";
std::clog << localTime->tm_mday << ". ";
std::clog << localTime->tm_hour << ":";
std::clog << localTime->tm_min << ":";
std::clog << localTime->tm_sec << " [";
std::clog << className.toAnsiString() << "] ";
std::clog << message.toAnsiString();
std::clog << std::endl;
}
}
示例2: QString
String::String(sf::String str)
: QString(str.toAnsiString().c_str())
{ }
示例3: error
void error(sf::String s)
{
std::cout << "Error: " << s.toAnsiString() << std::endl;
}
示例4: log
void log(sf::String s)
{
std::cout << "BEngine: " << s.toAnsiString() << std::endl;
}
示例5: load
int Game::load(sf::String path, SFG::SplashScreen* ss)
{
if(m_game_console.init() != 0)
SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__,
"Failed to init console"
);
if(!m_timing_font.loadFromFile("Fonts/arial.ttf"))
SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__,
"Failed to load font"
);
printf("Setting font... ");
m_timing_display.setFont(m_timing_font);
printf("Done.\n");
m_timing_display.setString("Asd");
XMLReader reader;
sf::String out;
if (basicLoadFile(path.toWideString(), out) != 0)
{
printf("[Error] Failed to load file %s in %s:%d\n", path.toAnsiString().c_str(), __FILE__, __LINE__);
return -1;
}
reader.setSource(out);
//Start parsing
if (reader.parse() != 0)
{
//Errors happening
}
//For now, we only need to load the gamestates up...
//Get the loading gamestate (with fancy animations and stuff)
int ret = 0;
auto sugs = SFG::Pointer<GameState>(new StartupGameState());
if ((ret = loadGamestate(reader, L"Startup", sugs)) < 0)
{
printf("[Error] Failed to load Startup Gamestate in %s:%d from file \"%s\" with Code %d.\n", __FILE__, __LINE__, path.toAnsiString().c_str(), ret);
}
//The first gamestate always needs to be inited
this->g_gamestates[0]->init(this->window);
//Get the menu gamestate
SFG::Pointer<GameState> menu(new MenuGameState());
if ((ret = loadGamestate(reader, L"Menu", menu)) < 0)
{
printf("[Error] Failed to load Menu Gamestate in %s:%d from file \"%s\" with Code %d.\n", __FILE__, __LINE__, path.toAnsiString().c_str(), ret);
}
//Get all other gamestates
for (size_t i = 2; ; i++)
{
sf::String path = L"xml/gamestate#" + std::to_wstring(i) + L"/";
sf::String ret = reader.getValue(path);
if (ret == L"__xml_failure")
{
break;
}
else
{
//#TODO: Add custom gamestate
//STILL_TO_DO(__FILE__, __LINE__);
int res = loadGamestate(reader, reader.getValue(path + "name."), SFG::Pointer<GameState>(nullptr));
if (res != 0)
{
std::string tmp = reader.getValue(path + "name.").toAnsiString();
SFG::Util::printLog(SFG::Util::LogMessageType::Error, __FILE__, __LINE__, "Failed to load custom gamestate named \"%s\"", tmp.c_str());
}
}
}
//Reading done
if (ss != nullptr)
{
//Tell the SplashScreen to disappear
ss->notify(SFG::SplashScreen::SplashScreenMessages::LoadingDone);
}
return 0;
}
示例6: loadGamestate
int Game::loadGamestate(const XMLReader& reader, const sf::String& GSname, const SFG::Pointer<GameState>& included)
{
SFG::Pointer<GameState> GS_ptr;
sf::String GSxmlpath = L"xml/gamestate[" + GSname + L"]";
auto str = reader.getValue(GSxmlpath, 0);
if (str == L"__xml_failure")
{
printf("[Error] Unspecified startup gamestate in %s:%d.\n", __FILE__, __LINE__);
return -2;
}
else
{
if (str == L"#included")
{
//Use default
GS_ptr.reset(included);
if (!GS_ptr.isValid() && included.getElement() != nullptr)
{
printf("[Critical] Failed to allocate memory for \"%s\" in %s:%d\n",GSname.toAnsiString().c_str(), __FILE__, __LINE__);
return -1;
}
}
else
{
//Use specified
//#TODO
STILL_TO_DO(__FILE__, __LINE__);
//We first need an instance of a DLLLoadedGameState
GS_ptr.reset(new DLLLoadedGameState());
//Set the name
GS_ptr->setName(GSname);
if (GS_ptr->getName() == "__xml_failure")
{
SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__, "Failed to get Gamestate name, aborting.");
return -1;
}
//Then, load the specified file
if (GS_ptr.cast<DLLLoadedGameState>()->loadFromDll(str.toAnsiString().c_str()) != 0)
{
SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__,
"Failed to load gamestate \"%s\" from DLL", str.toAnsiString().c_str());
return -2;
}
//We actually should be done
}
//Get all modules
sf::String uses = reader.getValue(GSxmlpath + L"uses.");
if (uses != L"__xml_failure")
{
//We have specifiers
size_t begin = 0;
size_t last = 0;
//Begin needs to be checked as the last module wouldn't be counted otherwise
while ((last = uses.find(L',', last)) != sf::String::InvalidPos || begin != sf::String::InvalidPos)
{
sf::String string;
if (last == sf::String::InvalidPos)
{
//If the end would otherwise exceed the string length, set it to the maximum (sf::String::end()).
//string = sf::String(uses.begin() + begin, uses.end());
string = uses.substring(begin, uses.getSize() - begin);
}
else
{
//If a ',' was found, use its position
//string = sf::String(uses.begin() + begin, uses.begin() + last);
string = uses.substring(begin, last - begin);
}
//Check for module names
if (string == L"G2D")
{
SFG::Pointer<ModuleG2D> ptr(new ModuleG2D());
if (!ptr.isValid())
{
char buf[512];
#ifdef _WIN32
strerror_s(buf, errno);
#else
strerror_r(errno, buf, 512);
#endif // _WIN32
printf("[Error] Failed to create Module G2D in %s:%d: %s\n", __FILE__, __LINE__, buf);
return -3;
}
GS_ptr->addModule(ptr);
}
else
{
//#TODO: Add more modules (sound etc.)
STILL_TO_DO(__FILE__, __LINE__);
}
if(last != sf::String::InvalidPos) begin = last + 1; //if a ',' was found, go search on for the next one
else begin = last; //Meaning begin is sf::String::npos
//.........这里部分代码省略.........
示例7: loadTexture
void ResourcesManager::loadTexture(sf::String textureName)
{
if (this->_textures.find(textureName) == this->_textures.end() && !this->_textures[textureName].loadFromFile("resources/" + textureName))
std::cerr << "Texture " << textureName.toAnsiString() << " couldn't be loaded" << std::endl;
}
示例8: addToInput
void cConsole::addToInput(sf::String str)
{
input.append(str.toAnsiString(locale("russian")));
inputDisplay += str;
}