update text2.cpp
This commit is contained in:
@@ -1,121 +1,107 @@
|
||||
#include "const.h"
|
||||
#include "text2.h"
|
||||
|
||||
// Constructor
|
||||
Text2::Text2()
|
||||
{
|
||||
init(nullptr, nullptr, 0, 0);
|
||||
init(nullptr, nullptr, 0);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Text2::~Text2()
|
||||
{
|
||||
init(nullptr, nullptr, 0, 0);
|
||||
init(nullptr, nullptr, 0);
|
||||
}
|
||||
|
||||
// Inicializador
|
||||
void Text2::init(LTexture *texture, SDL_Renderer *renderer, Uint8 type, Uint8 size)
|
||||
void Text2::init(LTexture *texture, SDL_Renderer *renderer, Uint8 height)
|
||||
{
|
||||
Text::init(texture, renderer, type, size);
|
||||
Text::init(texture, renderer, height);
|
||||
mPosX = 0;
|
||||
mPosY = 0;
|
||||
mKerning = 0;
|
||||
mCaption = "";
|
||||
mWrittingSpeed = 0;
|
||||
mWrittingTimer = 0;
|
||||
mSpeed = 0;
|
||||
mCounter = 0;
|
||||
mIndex = 0;
|
||||
mLenght = 0;
|
||||
mWrittingCompleted = false;
|
||||
mCompleted = false;
|
||||
mEnabled = false;
|
||||
mEnabledTimer = 0;
|
||||
mEnabledCounter = 0;
|
||||
mId = -1;
|
||||
mIntroEvents = nullptr;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setPosX(int value)
|
||||
{
|
||||
mPosX = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setPosY(int value)
|
||||
{
|
||||
mPosY = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setKerning(int value)
|
||||
{
|
||||
mKerning = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setCaption(std::string text)
|
||||
{
|
||||
mCaption = text;
|
||||
mLenght = text.length();
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setWrittingSpeed(Uint16 value)
|
||||
void Text2::setSpeed(Uint16 value)
|
||||
{
|
||||
mWrittingSpeed = value;
|
||||
mWrittingTimer = value;
|
||||
mSpeed = value;
|
||||
mCounter = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setEnabled(bool value)
|
||||
{
|
||||
mEnabled = value;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Text2::IsEnabled()
|
||||
{
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setEnabledTimer(Uint16 value)
|
||||
void Text2::setEnabledCounter(Uint16 value)
|
||||
{
|
||||
mEnabledTimer = value;
|
||||
mEnabledCounter = value;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 Text2::getEnabledTimer()
|
||||
Uint16 Text2::getEnabledCounter()
|
||||
{
|
||||
return mEnabledTimer;
|
||||
return mEnabledCounter;
|
||||
}
|
||||
|
||||
// Actualiza el objeto
|
||||
void Text2::update()
|
||||
{
|
||||
if (mEnabled)
|
||||
{
|
||||
if (mWrittingCompleted == false)
|
||||
if (mCompleted == false)
|
||||
{
|
||||
if (mWrittingTimer > 0)
|
||||
if (mCounter > 0)
|
||||
{
|
||||
--mWrittingTimer;
|
||||
--mCounter;
|
||||
}
|
||||
if (mWrittingTimer == 0)
|
||||
if (mCounter == 0)
|
||||
{
|
||||
++mIndex;
|
||||
mWrittingTimer = mWrittingSpeed;
|
||||
mCounter = mSpeed;
|
||||
}
|
||||
if (mIndex == mLenght)
|
||||
{
|
||||
mWrittingCompleted = true;
|
||||
mCompleted = true;
|
||||
}
|
||||
}
|
||||
if (mWrittingCompleted)
|
||||
if (mCompleted)
|
||||
{
|
||||
if (mEnabledTimer > 0)
|
||||
if (mEnabledCounter > 0)
|
||||
{
|
||||
--mEnabledTimer;
|
||||
--mEnabledCounter;
|
||||
}
|
||||
else if (mEnabledTimer == 0)
|
||||
else if (mEnabledCounter == 0)
|
||||
{
|
||||
if (mId < 0)
|
||||
{
|
||||
@@ -123,14 +109,13 @@ void Text2::update()
|
||||
}
|
||||
else
|
||||
{
|
||||
mIntroEvents[mId] = EVENT_COMPLETED;
|
||||
//mIntroEvents[mId] = EVENT_COMPLETED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja el objeto en pantalla
|
||||
void Text2::render()
|
||||
{
|
||||
if (mEnabled)
|
||||
@@ -139,20 +124,12 @@ void Text2::render()
|
||||
}
|
||||
}
|
||||
|
||||
// Centra la cadena de texto a un punto X
|
||||
void Text2::center(int x)
|
||||
{
|
||||
setPosX(x - (lenght(mCaption, mKerning) / 2));
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setId(int id)
|
||||
{
|
||||
mId = id;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Text2::setIntroEvents(Uint8 *value)
|
||||
{
|
||||
mIntroEvents = value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user