Commit pa que Mon arregle el codi mentre em dutxe
This commit is contained in:
@@ -1,138 +1,131 @@
|
||||
#include "writer.h"
|
||||
#include "text.h" // for Text
|
||||
|
||||
// Constructor
|
||||
Writer::Writer(Text *text)
|
||||
: text(text)
|
||||
Writer::Writer(std::shared_ptr<Text> text)
|
||||
: text_(text)
|
||||
{
|
||||
// Inicializa variables
|
||||
posX = 0;
|
||||
posY = 0;
|
||||
kerning = 0;
|
||||
caption = "";
|
||||
speed = 0;
|
||||
writingCounter = 0;
|
||||
index = 0;
|
||||
lenght = 0;
|
||||
completed = false;
|
||||
enabled = false;
|
||||
enabledCounter = 0;
|
||||
finished = false;
|
||||
posX_ = 0;
|
||||
posY_ = 0;
|
||||
kerning_ = 0;
|
||||
caption_ = "";
|
||||
speed_ = 0;
|
||||
writingCounter_ = 0;
|
||||
index_ = 0;
|
||||
lenght_ = 0;
|
||||
completed_ = false;
|
||||
enabled_ = false;
|
||||
enabledCounter_ = 0;
|
||||
finished_ = false;
|
||||
}
|
||||
|
||||
// Actualiza el objeto
|
||||
void Writer::update()
|
||||
{
|
||||
if (enabled)
|
||||
if (enabled_)
|
||||
{
|
||||
if (!completed)
|
||||
if (!completed_)
|
||||
{
|
||||
// No completado
|
||||
if (writingCounter > 0)
|
||||
if (writingCounter_ > 0)
|
||||
{
|
||||
writingCounter--;
|
||||
writingCounter_--;
|
||||
}
|
||||
|
||||
else if (writingCounter == 0)
|
||||
else if (writingCounter_ == 0)
|
||||
{
|
||||
index++;
|
||||
writingCounter = speed;
|
||||
index_++;
|
||||
writingCounter_ = speed_;
|
||||
}
|
||||
|
||||
if (index == lenght)
|
||||
if (index_ == lenght_)
|
||||
{
|
||||
completed = true;
|
||||
completed_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Completado
|
||||
if (enabledCounter > 0)
|
||||
if (enabledCounter_ > 0)
|
||||
{
|
||||
enabledCounter--;
|
||||
enabledCounter_--;
|
||||
}
|
||||
else if (enabledCounter == 0)
|
||||
else if (enabledCounter_ == 0)
|
||||
{
|
||||
finished = true;
|
||||
finished_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja el objeto en pantalla
|
||||
void Writer::render()
|
||||
void Writer::render() const
|
||||
{
|
||||
if (enabled)
|
||||
if (enabled_)
|
||||
{
|
||||
text->write(posX, posY, caption, kerning, index);
|
||||
text_->write(posX_, posY_, caption_, kerning_, index_);
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Writer::setPosX(int value)
|
||||
{
|
||||
posX = value;
|
||||
posX_ = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Writer::setPosY(int value)
|
||||
{
|
||||
posY = value;
|
||||
posY_ = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Writer::setKerning(int value)
|
||||
{
|
||||
kerning = value;
|
||||
kerning_ = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Writer::setCaption(std::string text)
|
||||
{
|
||||
caption = text;
|
||||
lenght = text.length();
|
||||
caption_ = text;
|
||||
lenght_ = text.length();
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Writer::setSpeed(int value)
|
||||
{
|
||||
speed = value;
|
||||
writingCounter = value;
|
||||
speed_ = value;
|
||||
writingCounter_ = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Writer::setEnabled(bool value)
|
||||
{
|
||||
enabled = value;
|
||||
enabled_ = value;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Writer::IsEnabled() const
|
||||
{
|
||||
return enabled;
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Writer::setEnabledCounter(int time)
|
||||
void Writer::setFinishedCounter(int time)
|
||||
{
|
||||
enabledCounter = time;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Writer::getEnabledCounter() const
|
||||
{
|
||||
return enabledCounter;
|
||||
enabledCounter_ = time;
|
||||
}
|
||||
|
||||
// Centra la cadena de texto a un punto X
|
||||
void Writer::center(int x)
|
||||
{
|
||||
setPosX(x - (text->lenght(caption, kerning) / 2));
|
||||
setPosX(x - (text_->lenght(caption_, kerning_) / 2));
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Writer::hasFinished() const
|
||||
{
|
||||
return finished;
|
||||
return finished_;
|
||||
}
|
||||
Reference in New Issue
Block a user