mirror of
https://github.com/iAmInActions/SpaceCadetPinballPPC.git
synced 2026-08-15 05:16:36 +00:00
TTextBoxMessage v1, ready.
TTextBox v1.
This commit is contained in:
37
SpaceCadetPinball/TTextBoxMessage.cpp
Normal file
37
SpaceCadetPinball/TTextBoxMessage.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "pch.h"
|
||||
#include "TTextBoxMessage.h"
|
||||
#include "memory.h"
|
||||
#include "pb.h"
|
||||
|
||||
TTextBoxMessage::TTextBoxMessage(char* text, float time)
|
||||
{
|
||||
NextMessage = nullptr;
|
||||
Time = time;
|
||||
EndTicks = pb::time_ticks + static_cast<int>(time * 1000.0f);
|
||||
if (text)
|
||||
{
|
||||
const auto textLen = strlen(text) + 1;
|
||||
Text = memory::allocate(textLen);
|
||||
if (Text)
|
||||
strcpy_s(Text, textLen, text);
|
||||
}
|
||||
else
|
||||
Text = nullptr;
|
||||
}
|
||||
|
||||
TTextBoxMessage::~TTextBoxMessage()
|
||||
{
|
||||
if (Text)
|
||||
memory::free(Text);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user