He fet un "manolete" i he pasat a c++ i smartpointers la cárrega de surfaces desde gif. Sembla que no ha petat res
Precárrega i asignació de paletes a les textures Ara si algú toca una paleta, que siga conscient que la textura es compartida durant tot el joc
This commit is contained in:
@@ -77,33 +77,8 @@ std::shared_ptr<TextFile> loadTextFile(const std::string &file_path)
|
||||
return tf;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Text::Text(const std::string &bitmap_file, const std::string &text_file, SDL_Renderer *renderer)
|
||||
{
|
||||
// Carga los offsets desde el fichero
|
||||
auto tf = loadTextFile(text_file);
|
||||
|
||||
// Inicializa variables desde la estructura
|
||||
box_height_ = tf->box_height;
|
||||
box_width_ = tf->box_width;
|
||||
for (int i = 0; i < 128; ++i)
|
||||
{
|
||||
offset_[i].x = tf->offset[i].x;
|
||||
offset_[i].y = tf->offset[i].y;
|
||||
offset_[i].w = tf->offset[i].w;
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
texture_ = std::make_shared<Texture>(renderer, bitmap_file);
|
||||
sprite_ = std::make_unique<Sprite>(texture_, (SDL_Rect){0, 0, box_width_, box_height_});
|
||||
|
||||
// Inicializa variables
|
||||
fixed_width_ = false;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Text::Text(std::shared_ptr<Texture> texture, const std::string &text_file)
|
||||
: texture_(texture)
|
||||
{
|
||||
// Carga los offsets desde el fichero
|
||||
auto tf = loadTextFile(text_file);
|
||||
@@ -127,7 +102,6 @@ Text::Text(std::shared_ptr<Texture> texture, const std::string &text_file)
|
||||
|
||||
// Constructor
|
||||
Text::Text(std::shared_ptr<Texture> texture, std::shared_ptr<TextFile> text_file)
|
||||
: texture_(texture)
|
||||
{
|
||||
// Inicializa variables desde la estructura
|
||||
box_height_ = text_file->box_height;
|
||||
@@ -265,16 +239,4 @@ void Text::reLoadTexture()
|
||||
void Text::setFixedWidth(bool value)
|
||||
{
|
||||
fixed_width_ = value;
|
||||
}
|
||||
|
||||
// Carga una paleta de colores para el texto
|
||||
void Text::addPalette(const std::string &path)
|
||||
{
|
||||
texture_->addPalette(path);
|
||||
}
|
||||
|
||||
// Establece una paleta de colores para el texto
|
||||
void Text::setPalette(int index)
|
||||
{
|
||||
texture_->setPalette(index);
|
||||
}
|
||||
Reference in New Issue
Block a user