-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.h
More file actions
106 lines (85 loc) · 2.05 KB
/
client.h
File metadata and controls
106 lines (85 loc) · 2.05 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
#ifndef _CLIENT_H_
#define _CLIENT_H_
#include <SFML/Graphics.hpp>
#include <enet/enet.h>
#include "screen.h"
#include "ticker.h"
#include "imageManager.h"
#include "mouse.h"
#include "config.h"
#include "entity/world.h"
#include "entity/player.h"
#include "ui/layerDisplay.h"
#include "ui/cubeDisplay.h"
#include "ui/ChatBox.h"
#include "network/packet.h"
#include "Renderer.h"
class Client : public Screen
{
public:
Client(sf::RenderWindow *window, ImageManager *imageManager);
~Client();
int run();
void connect();
void disconnect();
void setPort(int);
void setIp(std::string);
void setPseudo(std::string pseudo);
void setColor(sf::Vector3i color);
void UpdatePlayer(std::string name, sf::Vector3i color);
void UpdateThread();
void StartThread();
void StopThread();
std::string getPseudo();
sf::Vector3i getColor();
private:
void update(sf::Time frametime);
void draw();
void drawConnecting();
void drawNotConnected();
int _layer;
std::string _pseudo;
sf::RenderTexture *_world_display;
Mouse *_mouse;
Ticker *_ticker;
bool _running;
void handleEvent(sf::Event event);
void handlePacket(sf::Packet p);
void onClose();
void onMouseButtonPressed(sf::Event event);
void onMouseButtonReleased(sf::Event event);
void onMouseWheelMoved(sf::Event event);
void onResized(sf::Event event);
void onKeyPressed(sf::Event event);
void sendReliable(Packet *p);
void send(Packet *p);
void updateView();
float _zoom;
int _cube_type;
CubeDisplay *_display_cube;
ChatBox *_chat_box;
Renderer *_renderer;
World *_world;
bool _add_cube;
bool _remove_cube;
bool _main_menu;
Player *_player;
LayerDisplay *_layer_display;
int _port;
std::string _ip;
ENetHost *_client;
ENetPeer *_server;
bool _connected;
int _id;
bool _has_focus;
bool _runningThread;
sf::Thread _thread;
bool _connecting;
float _connectTime;
sf::Font _connectFont;
sf::Text _connectText;
sf::Text _notConnectText;
Input input;
static constexpr float CONNECT_TIME_OUT = 20;
};
#endif /* _CLIENT_H_ */