forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameLog.cpp
44 lines (38 loc) · 939 Bytes
/
GameLog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "GameLog.hpp"
GameLog::GameLog()
: log_history_{60}, log_{nullptr}
{ /* DUMMY BODY */ }
void GameLog::clear()
{
log_->resetList();
}
void GameLog::print(const std::string& msg)
{
CEGUI::ListboxTextItem* text;
if(log_->getItemCount() >= log_history_)
{
text = (CEGUI::ListboxTextItem*)log_->getListboxItemFromIndex(0);
text->setAutoDeleted(false);
log_->removeItem(text);
text->setAutoDeleted(true);
text->setText(msg);
}
else
text = new CEGUI::ListboxTextItem(msg);
text->setTextColours(CEGUI::Colour{0.f, 1.f, 0.f});
log_->addItem(text);
//log_->getVertScrollbar()->scrollForwardsByStep();
log_->getVertScrollbar()->setScrollPosition(log_->getVertScrollbar()->getDocumentSize());
}
void GameLog::set_history(std::size_t val)
{
log_history_ = val;
}
std::size_t GameLog::get_history() const
{
return log_history_;
}
void GameLog::init_()
{
log_ = (CEGUI::Listbox*)window_->getChild("FRAME/LOG");
}