2
0

GameChatHandler.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * GameChatHandler.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../lib/constants/EntityIdentifiers.h"
  12. struct GameChatMessage
  13. {
  14. std::string senderName;
  15. std::string messageText;
  16. std::string dateFormatted;
  17. };
  18. /// Class that manages game chat for current game match
  19. /// Used for all matches - singleplayer, local multiplayer, online multiplayer
  20. class GameChatHandler : boost::noncopyable
  21. {
  22. std::vector<GameChatMessage> chatHistory;
  23. public:
  24. /// Returns all message history for current match
  25. const std::vector<GameChatMessage> & getChatHistory() const;
  26. /// Erases any local state, must be called when client disconnects from match server
  27. void resetMatchState();
  28. /// Must be called when local player sends new message into chat from gameplay mode (adventure map)
  29. void sendMessageGameplay(const std::string & messageText);
  30. /// Must be called when local player sends new message into chat from pregame mode (match lobby)
  31. void sendMessageLobby(const std::string & senderName, const std::string & messageText);
  32. /// Must be called when client receives new chat message from server
  33. void onNewLobbyMessageReceived(const std::string & senderName, const std::string & messageText);
  34. /// Must be called when client receives new chat message from server
  35. void onNewGameMessageReceived(PlayerColor sender, const std::string & messageText);
  36. /// Must be called when client receives new message from "system" sender
  37. void onNewSystemMessageReceived(const std::string & messageText);
  38. };