summaryrefslogtreecommitdiff
path: root/kurator/src/Log.cpp
blob: 06891763aeafeddea8d19ea9876f4a434e485ada (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "Log.h"

#include <memory>
#include <utility>

#include <raylib.h>
#include <imgui.h>

#include <kurator/stats/events.h>

#include "EventLog.h"
#include "Session.h"


namespace kurator
{


struct Dumper
{
	Dumper();
	~Dumper();
	void operator()(const stats::ShipLeft& event);
};


Log::Log(std::shared_ptr<Session> _session, EventLog _events) :
	session {std::move(_session)},
	events {std::move(_events)}
{
}


void
Log::update(const float)
{
	if (IsKeyPressed(KEY_SPACE))
		session->pop();
}


void
Log::draw() const
{
	ClearBackground(BLACK);
	events.for_each(Dumper{});
}


Dumper::Dumper()
{
	ImGui::Begin("Event Log");
}


Dumper::~Dumper()
{
	ImGui::End();
}


void
Dumper::operator()(const stats::ShipLeft& event)
{
	ImGui::Text("%3.1f (%d) destroyed", event.time, event.ship.id);
}


}  // namespace kurator