-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
128 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,62 @@ | ||
#pragma once | ||
|
||
#include "../../shared/font.h" | ||
#include "../componente.h" | ||
#include <SFML/Graphics/RenderTarget.hpp> | ||
#include <SFML/Graphics/Text.hpp> | ||
|
||
struct Etiqueta : public sf::Drawable { | ||
struct EstiloTexto { | ||
const int tamano; | ||
const sf::Color &color; | ||
}; | ||
|
||
class Etiqueta : public ComponenteConFont { | ||
private: | ||
sf::Text etiqueta; | ||
|
||
public: | ||
Etiqueta( | ||
const std::string &texto, // | ||
int tamano_fuente, // | ||
const OptionalFont &font // | ||
) { | ||
this->font = font; | ||
etiqueta.setString(texto); | ||
if (font.exists()) { | ||
etiqueta.setFont(*font.get_pointer()); | ||
etiqueta.setCharacterSize(tamano_fuente); | ||
}; | ||
} | ||
Etiqueta( | ||
const std::string &texto, // | ||
int tamano_fuente, // | ||
const sf::Color &color, // | ||
const OptionalFont &font, // | ||
const sf::Vector2f &posicion // | ||
|
||
) | ||
: Etiqueta(texto, tamano_fuente, font) { | ||
etiqueta.setFillColor(color); | ||
etiqueta.setPosition(posicion); | ||
} | ||
|
||
/* Sobrecarga para usar EstiloTexto */ | ||
Etiqueta( | ||
const std::string &texto, // | ||
const EstiloTexto &estilo, // | ||
const OptionalFont &font, // | ||
const sf::Vector2f &posicion // | ||
) | ||
: Etiqueta(texto, estilo.tamano, estilo.color, font, posicion) {} | ||
|
||
void actualizar_texto(const std::string &texto) { // | ||
etiqueta.setString(texto); | ||
} | ||
virtual void draw( | ||
sf::RenderTarget &target, // | ||
sf::RenderStates states // | ||
) const override { | ||
assert(font.exists()); | ||
target.draw(etiqueta); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters