-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.h
More file actions
190 lines (133 loc) · 3.06 KB
/
Interface.h
File metadata and controls
190 lines (133 loc) · 3.06 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
190
#pragma once
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <cstring>
#include <vector>
#include "GameBoard.cpp"
#define W 900.f
#define H 900.f
sf::Font font;
class Button
{
private:
sf::Color color;
float width, height;
float x, y;
sf::RectangleShape btn;
sf::Text text;
public:
void create(float pos_x, float pos_y, float w, float h, sf::String text_);
void display(sf::RenderWindow &window);
bool isClicked(float mouse_x, float mouse_y);
void updateText(const char *str);
};
class InputBox
{
private:
sf::RectangleShape box;
sf::String input;
sf::Text info;
sf::Text inputText;
public:
InputBox();
void create(float x, float y, float width, float height, sf::String box_text);
sf::String getInput();
void addToInput(sf::String ch);
void eraseLastCh();
void ereaseText();
void updateInfo(const char *str);
void display(sf::RenderWindow &window);
};
class TextBox
{
private:
sf::Text firstLine;
sf::Text secondLine;
sf::String text1, text2;
void initialize(sf::Text &txt, float y, sf::String str);
public:
void setText(char *str);
void updateText(char *str);
void display(sf::RenderWindow &window);
};
class BoardDot
{
private:
sf::CircleShape circle;
public:
BoardDot(float x, float y, sf::Color color);
void display(sf::RenderWindow &window);
};
class GraphicPawn
{
private:
float x, y;
sf::Texture texture;
sf::Sprite sprite;
sf::RectangleShape rectangle;
public:
GraphicPawn(sf::Color color);
void move(float pos_x, float pos_y);
void display(sf::RenderWindow &window);
bool isClicked(float mouse_x, float mouse_y);
};
class InterfaceGameBoard : public GameBoard
{
private:
std::array<BoardDot *, 40> mainPath;
std::array<BoardDot *, 16> finalPaths;
std::array<BoardDot *, 16> bases;
std::array<GraphicPawn *, 16> graphicPawn;
void setCoord();
void initBoard();
void initPawns();
public:
InterfaceGameBoard();
void moveAndUpdatePawn(int playerIndex, int pawnNr, int dice);
void display(sf::RenderWindow &window);
int clickedPawn(int player_index, float mouse_x, float mouse_y);
};
class Client
{
private:
int port;
// server struct
struct sockaddr_in server; // structura folosita pentru conectare
public:
int sd;
int player_index;
int connect_(const char *sv_adress, const char *input_port);
};
class Interface
{
private:
int menuOrder;
sf::RenderWindow window;
InputBox TextInputBox;
Button Btn;
TextBox InfoText;
Client *C;
char ip[100];
char port[100];
public:
InterfaceGameBoard *gameBoard;
Interface(float width, float height);
void updateStatusText(char *str);
void restart();
int firstScreen();
void gameScreen();
};
struct thData
{
int sd;
bool has_read;
char sv_msg[100];
int info[7];
int chosen_pawn;
Interface *interface;
};