Files

36 lines
688 B
C++
Raw Permalink Normal View History

2020-12-03 17:47:36 +03:00
#include "pch.h"
#include "TTextBoxMessage.h"
#include "pb.h"
TTextBoxMessage::TTextBoxMessage(const char* text, float time)
2020-12-03 17:47:36 +03:00
{
NextMessage = nullptr;
Time = time;
EndTicks = pb::time_ticks + static_cast<int>(time * 1000.0f);
if (text)
{
const auto textLen = strlen(text) + 1;
2021-10-02 17:45:31 +03:00
Text = new char[textLen];
2020-12-03 17:47:36 +03:00
if (Text)
2021-09-09 11:40:54 +03:00
strncpy(Text, text, textLen);
2020-12-03 17:47:36 +03:00
}
else
Text = nullptr;
}
TTextBoxMessage::~TTextBoxMessage()
{
2021-10-02 17:45:31 +03:00
delete[] Text;
2020-12-03 17:47:36 +03:00
}
float TTextBoxMessage::TimeLeft() const
{
return static_cast<float>(EndTicks - pb::time_ticks) * 0.001f;
}
void TTextBoxMessage::Refresh(float time)
{
this->Time = time;
this->EndTicks = pb::time_ticks + static_cast<int>(time * 1000.0f);
}