-
Notifications
You must be signed in to change notification settings - Fork 1
/
credits-screen.cc
80 lines (61 loc) · 2 KB
/
credits-screen.cc
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
70
71
72
73
74
75
76
77
78
79
80
#include "credits-screen.hh"
#include "resource-cache.hh"
#include "helpers.hh"
CreditsScreen::CreditsScreen(SDL_Window *window) :
Screen(window),
background(window, ResourceCache::GetTexture("background"))
{
this->widgets.push_back(new ImageButtonWidget(this,
ResourceCache::GetTexture("main-menu"),
0.02, 0.02, 0.05,
TextAnchor::RIGHT, TextAnchor::BOTTOM,
{255, 0, 0, 200},
{255, 255, 255, 200}));
this->widgets.push_back(new ImageWidget(this,
ResourceCache::GetTexture("credits"),
0.0, 0.0, 0.6,
TextAnchor::CENTER, TextAnchor::CENTER));
}
CreditsScreen::~CreditsScreen() {
}
void CreditsScreen::SwitchScreen(const map<string, string> &lastState) {
this->state.clear();
this->state["name"] = "menu-ongoing";
for (auto w : this->widgets)
w->Reset();
}
void CreditsScreen::HandleEvent(const SDL_Event &e) {
for (auto w : this->widgets)
w->HandleEvent(e);
}
void CreditsScreen::HandleWidgetEvent(int event_type, Widget *widget) {
switch (event_type) {
case BUTTON_CLICK:
PlaySound("button-click");
if (widget == this->widgets[0]) { // Main Menu
this->state["name"] = "credits-manu-selected";
}
break;
case BUTTON_MOUSE_ENTER:
PlaySound("mouse-over");
break;
}
}
void CreditsScreen::Reset() {
this->state.clear();
this->state["name"] = "credits-ongoing";
}
void CreditsScreen::Save(ostream &s) const {
}
void CreditsScreen::Load(istream &s) {
}
void CreditsScreen::Advance(float dt) {
for (auto w : this->widgets)
w->Advance(dt);
}
void CreditsScreen::Render(Renderer *renderer) {
this->background.Draw();
for (auto w : this->widgets)
w->Render(renderer);
renderer->PresentScreen();
}