Beispiel #1
0
void IniFile::ExportToFile(vfs::Path file, const std::string& headerComments) const
{
  std::ofstream stream(file.toCString());

	if (!headerComments.empty())
	{
		// Split the header text into lines and export it as INI comment
		std::vector<std::string> lines = utils::split( headerComments, "\n" );

		for (std::size_t i = 0; i < lines.size(); ++i)
		{
			stream << "# " << lines[i] << std::endl;
		}

		// add some additional line break after the header
		stream << std::endl;
	}

	for (Sections::const_iterator i = _settings.begin(); i != _settings.end(); ++i)
	{
		stream << "[" << i->first << "]" << std::endl;

		for (Options::const_iterator kv = i->second.begin(); kv != i->second.end(); ++kv)
		{
			stream << kv->key << " = " << kv->value << std::endl;
		}
		
		stream << std::endl;
	}
}
Beispiel #2
0
void FontCollection::addFont(const int key, const std::string& name, vfs::Path pathFont, const int size, const NColor& color )
{
  TTF_Font* ttf = TTF_OpenFont(pathFont.toCString(), size);
  if( ttf == NULL )
  {
    std::string errorStr( TTF_GetError() );
#ifdef CAESARIA_PLATFORM_WIN
    errorStr += "\n Is it only latin symbols in path to game?";
#endif
    OSystem::error( "CRITICAL!!! ", errorStr );
    THROW( errorStr );
  }

  Font font0;
  font0._d->ttfFont = ttf;

  SDL_Color c = { color.red(), color.green(), color.blue(), color.alpha() };
  font0._d->color = c;
  setFont( key, name, font0);
}