summaryrefslogtreecommitdiff
path: root/kurator/src/Pause.cpp
blob: 9b28ef3e583ca30da10f3bbaf43358d80dab4515 (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
#include "Pause.h"

#include <memory>
#include <utility>

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

#include "Scene.h"
#include "Session.h"


namespace kurator
{


Pause::Pause(std::shared_ptr<Session> _session, std::shared_ptr<Scene> _scene) :
	session {std::move(_session)},
	scene {std::move(_scene)},
	frame {scene}
{
}


void
Pause::update(float)
{
	frame.update();
	ImGui::SetNextWindowSize({GetScreenWidth()/3.0f, 0.0f}, ImGuiCond_Once);
	ImGui::SetNextWindowPos({GetScreenWidth()/2.0f, GetScreenHeight()/2.0f}, ImGuiCond_Once, {0.5f, 0.5f});
	if (ImGui::Begin("Pause", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) {
		if (ImGui::Button("Unpause", {-1.0f, 0.0f}))
			restore();
		if (ImGui::Button("Exit to Menu", {-1.0f, 0.0f}))
			session->pop();
		if (ImGui::Button("Exit to Desktop", {-1.0f, 0.0f}))
			session->quit();
	}
	ImGui::End();
	if (IsKeyPressed(KEY_ESCAPE))
		restore();
}


void
Pause::draw() const
{
	ClearBackground(BLACK);
	frame.draw();
}


void
Pause::restore() const
{
	session->set(scene);
}


}  // namespace kurator