-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventProcessor.hpp
executable file
·117 lines (91 loc) · 2.82 KB
/
eventProcessor.hpp
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2022 Maximilian Dittgen, [email protected]
#include <SFML/Graphics.hpp>
#include <vector>
#include <string>
using std::vector;
using std::string;
class OptionRunner {
private:
vector<int> window_res = {900,255};
sf::RenderWindow window;
char accept = 'c';
public:
OptionRunner(){
}
void homepage() {
// Create a window
window.create(sf::VideoMode(window_res.at(0),window_res.at(1)),"Potential event!");
window.setFramerateLimit(5);
}
void input_homepage (){
sf::Event event;
// closing window
while (window.pollEvent(event)){
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyPressed){
if (event.key.code == sf::Keyboard::Escape)
window.close();
if (event.key.code == sf::Keyboard::Y){
accept = 'y';
window.close();
}
if (event.key.code == sf::Keyboard::N)
accept = 'n';
window.close();
}
}
}
// returns 'y' for accept, 'n' for next event, 'c' to close
char run_homepage(vector<string> vec) {
homepage();
while (window.isOpen()){
input_homepage();
draw_homepage(vec);
}
return accept;
}
void draw_homepage(vector<string> vec) {
window.clear(sf::Color::White);
sf::Font regular;
sf::Font bold;
regular.loadFromFile("fonts/Ubuntu-R.ttf");
bold.loadFromFile("fonts/Ubuntu-B.ttf");
sf::Text home_title;
home_title.setFont(bold);
home_title.setFillColor(sf::Color::Black);
home_title.setCharacterSize(25);
home_title.setPosition(25, 50);
home_title.setString("Event found: press \"y\" to add to calendar, \"n\" to see next event,\nor any other key to close");
sf::Text home_text;
home_text.setFont(regular);
home_text.setFillColor(sf::Color::Blue);
home_text.setCharacterSize(23);
home_text.setPosition(25, 120);
home_text.setString(vec.at(6).length() > 72 ? vec.at(6).substr(0,69) + "..." : vec.at(6));
sf::Text home_text_2;
home_text_2.setFont(regular);
home_text_2.setFillColor(sf::Color::Black);
home_text_2.setCharacterSize(15);
home_text_2.setPosition(25, 150);
home_text_2.setString("Location: " + vec.at(7));
sf::Text home_text_3;
home_text_3.setFont(regular);
home_text_3.setFillColor(sf::Color::Black);
home_text_3.setCharacterSize(15);
home_text_3.setPosition(25, 170);
home_text_3.setString("Date: " + vec.at(1) + "/" + vec.at(2) + "/" + vec.at(0));
sf::Text home_text_4;
home_text_4.setFont(regular);
home_text_4.setFillColor(sf::Color::Black);
home_text_4.setCharacterSize(15);
home_text_4.setPosition(25, 190);
home_text_4.setString("Time: " + vec.at(3) + ":" + vec.at(4));
window.draw(home_title);
window.draw(home_text);
window.draw(home_text_2);
window.draw(home_text_3);
window.draw(home_text_4);
window.display();
}
} ;