135 lines
1.7 KiB
C++
135 lines
1.7 KiB
C++
#include "const.h"
|
|
#include "text2.h"
|
|
|
|
Text2::Text2()
|
|
{
|
|
init(nullptr, nullptr, 0);
|
|
}
|
|
|
|
Text2::~Text2()
|
|
{
|
|
init(nullptr, nullptr, 0);
|
|
}
|
|
|
|
void Text2::init(LTexture *texture, SDL_Renderer *renderer, Uint8 height)
|
|
{
|
|
Text::init(texture, renderer, height);
|
|
mPosX = 0;
|
|
mPosY = 0;
|
|
mKerning = 0;
|
|
mCaption = "";
|
|
mSpeed = 0;
|
|
mCounter = 0;
|
|
mIndex = 0;
|
|
mLenght = 0;
|
|
mCompleted = false;
|
|
mEnabled = false;
|
|
mEnabledCounter = 0;
|
|
mId = -1;
|
|
}
|
|
|
|
void Text2::setPosX(int value)
|
|
{
|
|
mPosX = value;
|
|
}
|
|
|
|
void Text2::setPosY(int value)
|
|
{
|
|
mPosY = value;
|
|
}
|
|
|
|
void Text2::setKerning(int value)
|
|
{
|
|
mKerning = value;
|
|
}
|
|
|
|
void Text2::setCaption(std::string text)
|
|
{
|
|
mCaption = text;
|
|
mLenght = text.length();
|
|
}
|
|
|
|
void Text2::setSpeed(Uint16 value)
|
|
{
|
|
mSpeed = value;
|
|
mCounter = value;
|
|
}
|
|
|
|
void Text2::setEnabled(bool value)
|
|
{
|
|
mEnabled = value;
|
|
}
|
|
|
|
bool Text2::IsEnabled()
|
|
{
|
|
return mEnabled;
|
|
}
|
|
|
|
void Text2::setEnabledCounter(Uint16 value)
|
|
{
|
|
mEnabledCounter = value;
|
|
}
|
|
|
|
Uint16 Text2::getEnabledCounter()
|
|
{
|
|
return mEnabledCounter;
|
|
}
|
|
|
|
void Text2::update()
|
|
{
|
|
if (mEnabled)
|
|
{
|
|
if (mCompleted == false)
|
|
{
|
|
if (mCounter > 0)
|
|
{
|
|
--mCounter;
|
|
}
|
|
if (mCounter == 0)
|
|
{
|
|
++mIndex;
|
|
mCounter = mSpeed;
|
|
}
|
|
if (mIndex == mLenght)
|
|
{
|
|
mCompleted = true;
|
|
}
|
|
}
|
|
if (mCompleted)
|
|
{
|
|
if (mEnabledCounter > 0)
|
|
{
|
|
--mEnabledCounter;
|
|
}
|
|
else if (mEnabledCounter == 0)
|
|
{
|
|
if (mId < 0)
|
|
{
|
|
mEnabled = false;
|
|
}
|
|
else
|
|
{
|
|
//mIntroEvents[mId] = EVENT_COMPLETED;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void Text2::render()
|
|
{
|
|
if (mEnabled)
|
|
{
|
|
Text::write(mPosX, mPosY, mCaption, mKerning, mIndex);
|
|
}
|
|
}
|
|
|
|
void Text2::center(int x)
|
|
{
|
|
setPosX(x - (lenght(mCaption, mKerning) / 2));
|
|
}
|
|
|
|
void Text2::setId(int id)
|
|
{
|
|
mId = id;
|
|
} |