Mania++
 All Classes Functions Variables Pages
EventManager.h
1 #ifndef EVENTMANAGER_H_
2 #define EVENTMANAGER_H_
3 
4 #include <vector>
5 #include <functional>
6 
7 #include "Structs.h"
8 #include "../Objects/Map.h"
9 #include "../Objects/Player.h"
10 
11 //* EventManager
16 {
17 public:
21  EventManager();
22 
30  int RegisterPlayerConnect(std::vector<std::function<void(Player)>> functions);
31 
39  int RegisterPlayerDisconnect(std::vector<std::function<void(Player)>> functions);
40 
48  int RegisterPlayerChat(std::vector<std::function<void(Player, std::string)>> functions);
49 
57  int RegisterPlayerManialinkPageAnswer(std::vector<std::function<void(Player, std::string, std::vector<EntryVal>)>> functions);
58 
66  int RegisterEcho(std::vector<std::function<void(std::string, std::string)>> functions);
67 
75  int RegisterBeginMatch(std::vector<std::function<void()>> functions);
76 
84  int RegisterEndMatch(std::vector<std::function<void(std::vector<PlayerRanking>, int)>> functions);
85 
93  int RegisterBeginMap(std::vector<std::function<void(Map)>> functions);
94 
102  int RegisterEndMap(std::vector<std::function<void(Map)>> functions);
103 
111  int RegisterStatusChanged(std::vector<std::function<void(int, std::string)>> functions);
112 
120  int RegisterPlayerCheckpoint(std::vector<std::function<void(Player, int, int, int)>> functions);
121 
129  int RegisterPlayerFinish(std::vector<std::function<void(Player, int)>> functions);
130 
138  int RegisterPlayerIncoherence(std::vector<std::function<void(Player)>> functions);
139 
147  int RegisterBillUpdated(std::vector<std::function<void(int, int, std::string, int)>> functions);
148 
156  int RegisterMapListModified(std::vector<std::function<void(int, int, bool)>> functions);
157 
165  int RegisterPlayerInfoChanged(std::vector<std::function<void(Player)>> functions);
166 
174  int RegisterVoteUpdated(std::vector<std::function<void(std::string, std::string, std::string, std::string)>> functions);
175 
181  void CallPlayerConnect(Player player);
182 
188  void CallPlayerDisconnect(Player player);
189 
197  void CallPlayerChat(Player player, std::string text, bool isRegisteredCommand);
198 
206  void CallPlayerManialinkPageAnswer(Player player, std::string answer, std::vector<EntryVal> entries);
207 
214  void CallEcho(std::string internal, std::string publicEcho);
215 
219  void CallBeginMatch();
220 
227  void CallEndMatch(std::vector<PlayerRanking> rankings, int winnerTeam);
228 
234  void CallBeginMap(Map map);
235 
241  void CallEndMap(Map map);
242 
249  void CallStatusChanged(int statusCode, std::string statusName);
250 
259  void CallPlayerCheckpoint(Player player, int time, int currentLap, int checkpointIndex);
260 
267  void CallPlayerFinish(Player player, int time);
268 
274  void CallPlayerIncoherence(Player player);
275 
284  void CallBillUpdated(int billId, int state, std::string stateName, int transactionId);
285 
293  void CallMapListModified(int currentMap, int nextMap, bool listModified);
294 
300  void CallPlayerInfoChanged(Player player);
301 
310  void CallVoteUpdated(std::string stateName, std::string login, std::string commandName, std::string commandParam);
311 
312 private:
313  std::vector<std::function<void(Player)>> methodsPlayerConnect;
314  std::vector<std::function<void(Player)>> methodsPlayerDisconnect;
315  std::vector<std::function<void(Player, std::string)>> methodsPlayerChat;
316  std::vector<std::function<void(Player, std::string, std::vector<EntryVal>)>> methodsPlayerManialinkPageAnswer;
317  std::vector<std::function<void(std::string, std::string)>> methodsEcho;
318  std::vector<std::function<void()>> methodsBeginMatch;
319  std::vector<std::function<void(std::vector<PlayerRanking>, int)>> methodsEndMatch;
320  std::vector<std::function<void(Map)>> methodsBeginMap;
321  std::vector<std::function<void(Map)>> methodsEndMap;
322  std::vector<std::function<void(int, std::string)>> methodsStatusChanged;
323  std::vector<std::function<void(Player, int, int, int)>> methodsPlayerCheckpoint;
324  std::vector<std::function<void(Player, int)>> methodsPlayerFinish;
325  std::vector<std::function<void(Player)>> methodsPlayerIncoherence;
326  std::vector<std::function<void(int, int, std::string, int)>> methodsBillUpdated;
327  std::vector<std::function<void(int, int, bool)>> methodsMapListModified;
328  std::vector<std::function<void(Player)>> methodsPlayerInfoChanged;
329  std::vector<std::function<void(std::string, std::string, std::string, std::string)>> methodsVoteUpdated;
330 };
331 
332 #endif // EVENTMANAGER_H_
std::vector< std::function< void(Player)> > methodsPlayerConnect
Vector with functions for the PlayerConnect event.
Definition: EventManager.h:313
void CallMapListModified(int currentMap, int nextMap, bool listModified)
Calls all functions which are subscribed to the MapListModified event.
Definition: EventManager.cpp:337
void CallBeginMap(Map map)
Calls all functions which are subscribed to the EndMatch event.
Definition: EventManager.cpp:274
int RegisterBeginMatch(std::vector< std::function< void()>> functions)
Register functions for the BeginMatch callback.
Definition: EventManager.cpp:79
int RegisterMapListModified(std::vector< std::function< void(int, int, bool)>> functions)
Register functions for the MapListModified callback.
Definition: EventManager.cpp:178
int RegisterEndMap(std::vector< std::function< void(Map)>> functions)
Register functions for the EndMap callback.
Definition: EventManager.cpp:112
std::vector< std::function< void(Player, std::string)> > methodsPlayerChat
Vector with functions for the PlayerChat event.
Definition: EventManager.h:315
void CallPlayerManialinkPageAnswer(Player player, std::string answer, std::vector< EntryVal > entries)
Calls all functions which are subscribed to the PlayerManialinkPageAnswer event.
Definition: EventManager.cpp:238
void CallStatusChanged(int statusCode, std::string statusName)
Calls all functions which are subscribed to the StatusChanged event.
Definition: EventManager.cpp:292
EventManager()
Definition: EventManager.cpp:3
int RegisterPlayerIncoherence(std::vector< std::function< void(Player)>> functions)
Register functions for the PlayerIncoherence callback.
Definition: EventManager.cpp:156
Contains all information about a player in easy-to-use format.
Definition: Player.h:10
std::vector< std::function< void()> > methodsBeginMatch
Vector with functions for the BeginMatch event.
Definition: EventManager.h:318
void CallPlayerFinish(Player player, int time)
Calls all functions which are subscribed to the PlayerFinish event.
Definition: EventManager.cpp:310
int RegisterEcho(std::vector< std::function< void(std::string, std::string)>> functions)
Register functions for the Echo callback.
Definition: EventManager.cpp:68
int RegisterPlayerConnect(std::vector< std::function< void(Player)>> functions)
Register functions for the PlayerConnect callback.
Definition: EventManager.cpp:24
int RegisterStatusChanged(std::vector< std::function< void(int, std::string)>> functions)
Register functions for the StatusChanged callback.
Definition: EventManager.cpp:123
std::vector< std::function< void(Player)> > methodsPlayerIncoherence
Vector with functions for the PlayerIncoherence event.
Definition: EventManager.h:325
std::vector< std::function< void(int, int, std::string, int)> > methodsBillUpdated
Vector with functions for the BillUpdated event.
Definition: EventManager.h:326
void CallPlayerConnect(Player player)
Calls all functions which are subscribed to the PlayerConnect event.
Definition: EventManager.cpp:211
std::vector< std::function< void(Player, std::string, std::vector< EntryVal >)> > methodsPlayerManialinkPageAnswer
Vector with functions for the PlayerManialinkPageAnswer event.
Definition: EventManager.h:316
void CallPlayerCheckpoint(Player player, int time, int currentLap, int checkpointIndex)
Calls all functions which are subscribed to the PlayerCheckpoint event.
Definition: EventManager.cpp:301
std::vector< std::function< void(Player)> > methodsPlayerDisconnect
Vector with functions for the PlayerDisconnect event.
Definition: EventManager.h:314
std::vector< std::function< void(std::string, std::string)> > methodsEcho
Vector with functions for the Echo event.
Definition: EventManager.h:317
Contains all information about a map in easy-to-use format.
Definition: Map.h:10
void CallBeginMatch()
Calls all functions which are subscribed to the BeginMatch event.
Definition: EventManager.cpp:256
int RegisterPlayerDisconnect(std::vector< std::function< void(Player)>> functions)
Register functions for the PlayerDisconnect callback.
Definition: EventManager.cpp:35
int RegisterPlayerManialinkPageAnswer(std::vector< std::function< void(Player, std::string, std::vector< EntryVal >)>> functions)
Register functions for the PlayerManialinkPageAnswer callback.
Definition: EventManager.cpp:57
std::vector< std::function< void(Player, int, int, int)> > methodsPlayerCheckpoint
Vector with functions for the PlayerCheckpoint event.
Definition: EventManager.h:323
void CallVoteUpdated(std::string stateName, std::string login, std::string commandName, std::string commandParam)
Calls all functions which are subscribed to the VoteUpdated event.
Definition: EventManager.cpp:355
void CallPlayerInfoChanged(Player player)
Calls all functions which are subscribed to the PlayerInfoChanged event.
Definition: EventManager.cpp:346
std::vector< std::function< void(Player, int)> > methodsPlayerFinish
Vector with functions for the PlayerFinish event.
Definition: EventManager.h:324
std::vector< std::function< void(std::vector< PlayerRanking >, int)> > methodsEndMatch
Vector with functions for the EndMatch event.
Definition: EventManager.h:319
std::vector< std::function< void(int, int, bool)> > methodsMapListModified
Vector with functions for the MapListModified event.
Definition: EventManager.h:327
std::vector< std::function< void(Player)> > methodsPlayerInfoChanged
Vector with functions for the PlayerInfoChanged event.
Definition: EventManager.h:328
int RegisterBeginMap(std::vector< std::function< void(Map)>> functions)
Register functions for the BeginMap callback.
Definition: EventManager.cpp:101
void CallEndMap(Map map)
Calls all functions which are subscribed to the EndMap event.
Definition: EventManager.cpp:283
std::vector< std::function< void(std::string, std::string, std::string, std::string)> > methodsVoteUpdated
Vector with functions for the VoteUpdated event.
Definition: EventManager.h:329
int RegisterPlayerCheckpoint(std::vector< std::function< void(Player, int, int, int)>> functions)
Register functions for the PlayerCheckpoint callback.
Definition: EventManager.cpp:134
int RegisterPlayerInfoChanged(std::vector< std::function< void(Player)>> functions)
Register functions for the PlayerInfoChanged callback.
Definition: EventManager.cpp:189
int RegisterEndMatch(std::vector< std::function< void(std::vector< PlayerRanking >, int)>> functions)
Register functions for the EndMatch callback.
Definition: EventManager.cpp:90
std::vector< std::function< void(Map)> > methodsBeginMap
Vector with functions for the BeginMap event.
Definition: EventManager.h:320
void CallPlayerDisconnect(Player player)
Calls all functions which are subscribed to the PlayerDisconnect event.
Definition: EventManager.cpp:220
int RegisterBillUpdated(std::vector< std::function< void(int, int, std::string, int)>> functions)
Register functions for the BillUpdated callback.
Definition: EventManager.cpp:167
std::vector< std::function< void(int, std::string)> > methodsStatusChanged
Vector with functions for the StatusChanged event.
Definition: EventManager.h:322
int RegisterPlayerChat(std::vector< std::function< void(Player, std::string)>> functions)
Register functions for the PlayerChat callback.
Definition: EventManager.cpp:46
std::vector< std::function< void(Map)> > methodsEndMap
Vector with functions for the EndMap event.
Definition: EventManager.h:321
void CallEcho(std::string internal, std::string publicEcho)
Calls all functions which are subscribed to the Echo event.
Definition: EventManager.cpp:247
void CallBillUpdated(int billId, int state, std::string stateName, int transactionId)
Calls all functions which are subscribed to the BillUpdated event.
Definition: EventManager.cpp:328
void CallPlayerChat(Player player, std::string text, bool isRegisteredCommand)
Calls all functions which are subscribed to the PlayerChat event.
Definition: EventManager.cpp:229
int RegisterVoteUpdated(std::vector< std::function< void(std::string, std::string, std::string, std::string)>> functions)
Register functions for the VoteUpdated callback.
Definition: EventManager.cpp:200
void CallPlayerIncoherence(Player player)
Calls all functions which are subscribed to the PlayerIncoherence event.
Definition: EventManager.cpp:319
void CallEndMatch(std::vector< PlayerRanking > rankings, int winnerTeam)
Calls all functions which are subscribed to the EndMatch event.
Definition: EventManager.cpp:265
Handles events (callbacks) from server to plugins.
Definition: EventManager.h:15
int RegisterPlayerFinish(std::vector< std::function< void(Player, int)>> functions)
Register functions for the PlayerFinish callback.
Definition: EventManager.cpp:145