Esempio n. 1
0
void Player::drawHud(sf::RenderWindow& rw) const
{
	static bool firstRun = true;
	static sf::Font font;
	if(firstRun) 
	{
		firstRun = false;
		font.LoadFromFile("silesiana.otf", 50,  L"A�BC�DE�FGHIJKL�MN�O�PRS�TUWYZ��a�bc�de�fghijkl�mn�o�prs�tuwyz��XxVvQq0123456789~!@#$%^&*()_-[]\\;',./{}:\"<>?=-+ ");
	}

	sf::Sprite hud(hudimg, sf::Vector2f(0, 350));
	rw.Draw(hud);

	int hbarheight= health * hbarimg.GetHeight();
	sf::Sprite hbar(hbarimg, sf::Vector2f(42, 376 + hbarimg.GetHeight() - hbarheight));
	hbar.SetSubRect(sf::IntRect(0, hbarimg.GetHeight() - hbarheight, hbarimg.GetWidth(), hbarimg.GetHeight()));
	rw.Draw(hbar);

	std::wstring str;
	for(int i=0;i<4;i++)
	{
		if(i<msgList.size())
		str += msgList[i] + L"\n";
	}
	sf::String msgs(str, font, 30);
	msgs.SetColor(sf::Color(120, 10, 10));
	msgs.SetPosition(200, 450);
	rw.Draw(msgs);
}
Esempio n. 2
0
  bool FontHandler::LoadFromFile(const typeAssetID theAssetID, sf::Font& theAsset)
  {
    // Start with a return result of false
    bool anResult = false;

    // Retrieve the filename for this asset
    std::string anFilename = GetFilename(theAssetID);

    // Was a valid filename found? then attempt to load the asset from anFilename
    if(anFilename.length() > 0)
    {
      // Load the asset from a file
#if (SFML_VERSION_MAJOR < 2)
      anResult = theAsset.LoadFromFile(anFilename);
#else
      anResult = theAsset.loadFromFile(anFilename);
#endif
    }
    else
    {
      ELOG() << "FontHandler::LoadFromFile(" << theAssetID
        << ") No filename provided!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return anResult;
  }
Esempio n. 3
0
void Player::drawAtributes(sf::RenderWindow& rw) const
{
	static bool firstRun = true;
	static sf::Image tlo;
	static sf::Font font;
	if(firstRun)
	{
		tlo.LoadFromFile("Images/tlo.png");
		firstRun = false;
		font.LoadFromFile("silesiana.otf", 50,  L"A�BC�DE�FGHIJKL�MN�O�PRS�TUWYZ��a�bc�de�fghijkl�mn�o�prs�tuwyz��XxVvQq0123456789~!@#$%^&*()_-[]\\;',./{}:\"<>?=-+ ");
	}
	sf::Sprite tloH(tlo);
	rw.Draw(tloH);
	
	std::wstringstream ss;
	if(selectedAttribute == 0)
	{
		ss << L"Exp: " << xp << L"\n";
		ss << L"> Poziom obrony: " << defLevel << L"\n";
		ss << L"Poziom ataku: " << attLevel << L"\n";
	}
	else
	{
		ss << L"Exp: " << xp << L"\n";
		ss << L"Poziom obrony: " << defLevel << L"\n";
		ss << L"> Poziom ataku: " << attLevel << L"\n";
	}
	sf::String t(ss.str(), font, 30.f);
	t.SetColor(sf::Color(20, 18, 160));
	t.SetPosition(20.f, 20.0);
	rw.Draw(t);
}
Esempio n. 4
0
void Param::lire_Texte(std::ifstream &fichier, sf::String &destination, sf::Font &myFont)
{
    std::string ligne;
    int x, y, z;
    lire_string(fichier, ligne);
    destination.SetText(traduire(ligne.c_str()));
    lire_position(fichier, x, y);
    destination.SetPosition(x, y);
    lire_string(fichier, ligne);
    if(ligne != "default" && !myFont.LoadFromFile(ligne))
    {
        std::cerr << "Erreur lors du chargement de la police '" << ligne << "'" << std::endl;
        myFont = sf::Font::GetDefaultFont();
    }
    else if(ligne == "default")
        myFont = sf::Font::GetDefaultFont();
    lire_int(fichier, x);
    destination.SetSize(x);
    lire_string(fichier, ligne);
    set_police(destination, ligne.c_str());
    lire_couleur(fichier, x, y, z);
    destination.SetColor(sf::Color(x, y, z));
    lire_int(fichier, x);
    destination.SetRotation(x);
}
Esempio n. 5
0
int log_setup_1(){
	//Load Font
	if( PTSANS_loaded == false ){
		if (!PTSANS.LoadFromFile("PTN57F.ttf", 50)) return -1;
		PTSANS_loaded = true;
	}

	//Setup Strings
	log_string.SetFont( PTSANS );
	log_string.SetSize(24.f);
	log_string.SetColor( sf::Color(255, 255, 255) );
	log_string.SetPosition(100.f, 600.f);

	log_name.SetFont( PTSANS );
	log_name.SetSize(40.f);
	log_name.SetColor( sf::Color(255, 255, 255) );
	log_name.SetPosition(100.f, 550.f);
}
Esempio n. 6
0
bool FontManager::load(Path name, sf::Font & dst)
{
	//Fetch the possible locations for this font.
	DataManager::Paths paths = app->data.paths(Path("fonts") + name);
	
	//Try to load the font.
	bool success = false;
	for (int i = 0; i < paths.size() && !success; i++) {
		success = dst.LoadFromFile(paths[i].c_str(), 16);
	}
	
	//Return success.
	if (success) {
		LOG(DEBUG,   "loaded font '%s'", name.c_str());
	} else {
		LOG(WARNING, "unable to find font '%s'", name.c_str());
	}
	return success;
}
Esempio n. 7
0
void Player::drawInventory(sf::RenderWindow& rw) const
{
	static bool firstRun = true;
	static sf::Image tlo;
	static sf::Font font;
	if(firstRun) 
	{
		tlo.LoadFromFile("Images/inv.png");
		firstRun = false;
		font.LoadFromFile("silesiana.otf", 50,  L"A�BC�DE�FGHIJKL�MN�O�PRS�TUWYZ��a�bc�de�fghijkl�mn�o�prs�tuwyz��XxVvQq0123456789~!@#$%^&*()_-[]\\;',./{}:\"<>?=-+ ");
	}

	sf::Sprite tloH(tlo);
	rw.Draw(tloH);
	
	std::stringstream ss;
	ss<<"Masz " << coins << " $";
	sf::String t(ss.str(), font, 30.f);
	t.SetColor(sf::Color(20, 18, 160));
	t.SetPosition(600.f, 30.f);
	rw.Draw(t);

	float posy = 30.0;
	int i = 0;
	for(std::vector<Item>::const_iterator it = inventory.begin(); it != inventory.end(); it++)
	{
		std::wstring name = it->getName();
		if(i == weapon)
		{
			name += L" (uzbrojny - bro�)";
		}
		if(i == armor)
		{
			name += L" (uzbrojny - zbroja)";
		}
		sf::String t(name, font, 30.f);
		t.SetColor(sf::Color(20, 18, 160));
		if(selectedItem == i)
			t.SetColor(sf::Color(200, 18, 160));
		t.SetPosition(20.f, posy);
		rw.Draw(t);
		posy += 30.0;
		i++;
	}
	if(0 <= selectedItem && selectedItem < inventory.size())
	{
		TextArea desc(inventory[selectedItem].getDesc(), 400, font);
		desc.SetPosition(300, 50);
		rw.Draw(desc);
		Item::Type type = inventory[selectedItem].getProperty();
		if(type == 0)
		{
			TextArea desc1(L"Bron - Atak + " +inventory[selectedItem].getBoost(), 400,font);
			desc1.SetPosition(350,250);
			rw.Draw(desc1);
		}
		else if(type == 1)
		{
			TextArea desc1(L"Zbroja - Obrona + " +inventory[selectedItem].getBoost(), 400,font);
			desc1.SetPosition(350,250);
			rw.Draw(desc1);
		}
		else if(type == 2)
		{
			TextArea desc1(L"Helm - Obrona + " +inventory[selectedItem].getBoost(), 400,font);
			desc1.SetPosition(350,250);
			rw.Draw(desc1);
		}
		else if(type == 3)
		{
			TextArea desc1(L"Mikstura", 460,font);
			desc1.SetPosition(350,250);
			rw.Draw(desc1);
		}

		
	}
}
void PrepareFont(sf::Font &MyFont)
{
    MyFont.LoadFromFile(string(res_path)+string(font_name), 20);
}