Posant make_uniques, s'ha quedat tot enmerdat per culpa d'un struct
This commit is contained in:
@@ -95,15 +95,15 @@ Text::Text(std::string bitmapFile, std::string textFile, SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
texture = new Texture(renderer, bitmapFile);
|
||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture);
|
||||
texture = std::make_unique<Texture>(renderer, bitmapFile);
|
||||
sprite = std::make_unique<Sprite>((SDL_Rect){0, 0, boxWidth, boxHeight}, texture.get());
|
||||
|
||||
// Inicializa variables
|
||||
fixedWidth = false;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Text::Text(std::string textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
Text::Text(std::string textFile, Texture *texture)
|
||||
{
|
||||
// Carga los offsets desde el fichero
|
||||
textFile_t tf = LoadTextFile(textFile);
|
||||
@@ -119,15 +119,14 @@ Text::Text(std::string textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
this->texture = nullptr;
|
||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture);
|
||||
sprite = std::make_unique<Sprite>((SDL_Rect){0, 0, boxWidth, boxHeight});
|
||||
|
||||
// Inicializa variables
|
||||
fixedWidth = false;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
Text::Text(textFile_t *textFile, Texture *texture)
|
||||
{
|
||||
// Inicializa variables desde la estructura
|
||||
boxHeight = textFile->boxHeight;
|
||||
@@ -140,23 +139,12 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
this->texture = nullptr;
|
||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture);
|
||||
sprite = std::make_unique<Sprite>((SDL_Rect){0, 0, boxWidth, boxHeight});
|
||||
|
||||
// Inicializa variables
|
||||
fixedWidth = false;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Text::~Text()
|
||||
{
|
||||
delete sprite;
|
||||
if (texture != nullptr)
|
||||
{
|
||||
delete texture;
|
||||
}
|
||||
}
|
||||
|
||||
// Escribe texto en pantalla
|
||||
void Text::write(int x, int y, std::string text, int kerning, int lenght)
|
||||
{
|
||||
@@ -259,7 +247,7 @@ int Text::lenght(std::string text, int kerning)
|
||||
}
|
||||
|
||||
// Devuelve el valor de la variable
|
||||
int Text::getCharacterSize()
|
||||
int Text::getCharacterSize() const
|
||||
{
|
||||
return boxWidth;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user