Repository navigation
Expand file tree
/
Copy pathGUI.cpp
More file actions
67 lines (49 loc) · 1.45 KB
/
Copy pathGUI.cpp
File metadata and controls
67 lines (49 loc) · 1.45 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
//
// Menu.cpp
// e-gui
//
// Created by Thomas Courtman on 21/12/2021.
//
#include "GUI.hpp"
GUI::GUI()
{
// Create the main window
m_rw.create(sf::VideoMode(800, 600),"");
m_menus = Parser::ParseMenu(m_rw, "../main.json");
auto S{"S"};
}
void GUI::Update()
{
// Start the game loop
while (m_rw.isOpen() ) {
// Process events
sf::Event event;
while (m_rw.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed) {
m_rw.close();
} else if (event.type == sf::Event::Resized) {
} else if (event.type == sf::Event::MouseButtonPressed) {
auto t = m_menus.find("main")->second->GetClickedComponent(sf::Mouse::getPosition(m_rw));
std::cout << t->GetName() << "\n";
}
}
// Clear screen
m_rw.clear();
for (auto& m : m_menus) {
auto x = m.second->GetComponents();
for (auto& s : x) {
auto h = s->GetGenericShape().get();
m_rw.draw(*h);
auto p{"S"};
}
}
// Update the window
m_rw.display();
}
}
std::shared_ptr<Menu> GUI::FindMenu(std::string menu_name)
{
return m_menus.find(menu_name)->second;
}