forked from DKU-EmbeddedSystem-Lab/2025_DKU_OpenSourceBasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentSelectMenuState.cpp
More file actions
73 lines (56 loc) · 1.96 KB
/
ContentSelectMenuState.cpp
File metadata and controls
73 lines (56 loc) · 1.96 KB
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
#include "ContentSelectMenuState.hpp"
#include "game.hpp"
#include "config.hpp"
#include <iostream>
ContentSelectMenuState::ContentSelectMenuState(InputManager* manager)
: MenuState(manager), descriptionTexture(nullptr) {}
void ContentSelectMenuState::initialize() {
index = 0;
title_text = new Texture();
title_text->loadFromText("TETRIS", Game::getInstance()->mRenderer->bigFont, config::default_text_color);
descriptionTexture = new Texture();
descriptionTexture->loadFromText("Select Content", Game::getInstance()->mRenderer->mediumFont, config::default_text_color);
int centerX = (config::logical_window_width - 200) / 2;
addButton(new Button(
"Content 1",
[]() {
std::cout << "Content 1 Started!" << std::endl;
Game::getInstance()->pushNewState<Content1MenuState>();
},
centerX, 150, 200, 40
));
addButton(new Button(
"Content 2",
[]() {
std::cout << "Content 2 Started!" << std::endl;
Game::getInstance()->pushNewState<Content2MenuState>();
},
centerX, 200, 200, 40
));
addButton(new Button(
"Content 3",
[]() {
std::cout << "Content 3 Started!" << std::endl;
Game::getInstance()->pushNewState<Content3MenuState>();
},
centerX, 250, 200, 40
));
addButton(new Button(
"Back",
[]() {
Game::getInstance()->popState();
},
centerX, 300, 200, 40
));
}
void ContentSelectMenuState::draw() {
Game::getInstance()->mRenderer->clearScreen();
if (title_text)
title_text->renderCentered(config::logical_window_width / 2, 50);
if (descriptionTexture)
descriptionTexture->renderCentered(config::logical_window_width / 2, 90);
for (auto button : mButtons)
button->draw();
SelectionInputHandler::renderHighlight(mButtons, index);
Game::getInstance()->mRenderer->updateScreen();
}