-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlobby.h
More file actions
189 lines (166 loc) · 4.19 KB
/
Copy pathlobby.h
File metadata and controls
189 lines (166 loc) · 4.19 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#ifndef LOBBY_H
#define LOBBY_H
#include <SFML/Graphics.hpp>
#include <algorithm>
#include <cctype>
#include <string>
#include "node.h"
#include "lobbyplayer.h"
#include "boardsettings.h"
#include "resourceloader.h"
using namespace std;
class Node;
class LobbyTile;
class LobbyPlayer;
class LobbyButton;
class LobbyInput;
class LobbySearch;
class LobbyName;
class LobbyButtonStart;
class LobbyButtonEdit;
class LobbyButtonInvite;
class LobbyInvite;
class Lobby {
public:
Node* node;
LobbyTile*** tiles;
bool running = true;
LobbyTile* selected_tile;
DHT dht;
vector<LobbyPlayer*> lobby_players;
vector<LobbyPlayer*> filtered_lobby_players;
vector<LobbyPlayer*> page_lobby_players;
int page = 0;
bool previous;
bool next;
string filter = "";
sf::Texture previous_texture;
sf::Texture next_texture;
sf::Sprite previous_sprite;
sf::Sprite next_sprite;
LobbySearch* input_search;
LobbyName* input_name;
LobbyButtonStart* button_start;
LobbyButtonEdit* button_edit;
LobbyInput* active_input = nullptr;
shared_ptr<ChessInvite> incoming_invite;
shared_ptr<LobbyInvite> lobby_invite;
Lobby(Node* n);
void createArrows();
LobbyTile*** createTiles();
void draw(sf::RenderWindow& window);
void update();
void applyFilter(string expression);
void openPage(int new_page);
void displayInvite();
void acceptInvite();
void rejectInvite();
void selectTile(LobbyTile* tile);
void deselectTile(LobbyTile* tile);
void handlePress(int x, int y);
};
class LobbyButton {
public:
Lobby* lobby;
sf::RectangleShape rect;
bool activated = false;
LobbyButton();
LobbyButton(Lobby* l);
void createRect(sf::Vector2f size, sf::Vector2f position, sf::Color color);
bool checkClick(int x, int y);
virtual void activate();
virtual void deactivate();
virtual void click();
};
class LobbyButtonInvite : public LobbyButton {
public:
char action;
sf::Texture texture;
sf::Sprite sprite;
LobbyButtonInvite();
LobbyButtonInvite(Lobby* l, char c);
void initV();
void initX();
void createSprite(string file);
void click();
};
class LobbyButtonStart : public LobbyButton {
public:
sf::Font font;
sf::Text text;
sf::Text subtext;
bool clickable = false;
LobbyButtonStart(Lobby* l);
void createText(sf::Text& current_text, int font_size, string t, int height_offset, sf::Color color, bool bold);
void changeText(string new_text);
void changeSubtext(string new_subtext);
void makeUnclickable();
void makeClickable();
void activate();
void deactivate();
void click();
};
class LobbyButtonEdit : public LobbyButton {
public:
LobbyName* input;
sf::Texture texture;
sf::Sprite sprite;
LobbyButtonEdit(Lobby* l, LobbyInput* i);
void createSprite(string file);
void activate();
void deactivate();
void click();
};
class LobbyInput {
public:
Lobby* lobby;
sf::RectangleShape rect;
sf::Font font;
sf::Text text;
bool centered;
string value;
bool focused;
int max_length = MAX_NAME_LENGTH;
int font_size = 12;
int max_width = 100;
float height_offset = 1;
LobbyInput(Lobby* l, bool c);
void createRect(sf::Vector2f size, sf::Vector2f position, sf::Color color);
void createText(string f, sf::Color color, bool bold);
bool checkClick(int x, int y);
void displayText(string display);
virtual void handleEnter();
void handleUnicode(uint32_t unicode);
virtual void changedText();
void focus();
virtual void unfocus();
};
class LobbySearch : public LobbyInput {
public:
string placeholder;
LobbySearch(Lobby* l);
void changedText();
void unfocus();
};
class LobbyName : public LobbyInput {
public:
LobbyButtonEdit* edit;
string name;
LobbyName(Lobby* l);
void handleEnter();
void unfocus();
};
class LobbyInvite {
public:
Lobby* lobby;
sf::RectangleShape rect;
sf::Font font;
sf::Text text;
sf::Text subtext;
LobbyButtonInvite* button_v;
LobbyButtonInvite* button_x;
LobbyInvite(Lobby* l, string name);
void createRect(sf::Vector2f size, sf::Vector2f position, sf::Color color);
void createText(sf::Text& current_text, int font_size, string t, sf::Vector2f position_offset, int max_width, sf::Color color, bool bold);
};
#endif