LobbyWindow.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * LobbyWindow.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 "../gui/InterfaceObjectConfigurable.h"
  12. #include "../windows/CWindowObject.h"
  13. #include "../../lib/network/NetworkClient.h"
  14. class LobbyWindow;
  15. class LobbyWidget : public InterfaceObjectConfigurable
  16. {
  17. LobbyWindow * window;
  18. public:
  19. LobbyWidget(LobbyWindow * window);
  20. std::shared_ptr<CTextInput> getMessageInput();
  21. std::shared_ptr<CTextBox> getGameChat();
  22. };
  23. class LobbyClient : public NetworkClient
  24. {
  25. LobbyWindow * window;
  26. void onPacketReceived(const std::vector<uint8_t> & message) override;
  27. void onConnectionFailed(const std::string & errorMessage) override;
  28. void onDisconnected() override;
  29. public:
  30. explicit LobbyClient(LobbyWindow * window);
  31. void sendMessage(const JsonNode & data);
  32. };
  33. class LobbyWindow : public CWindowObject
  34. {
  35. std::string chatHistory;
  36. std::shared_ptr<LobbyWidget> widget;
  37. std::shared_ptr<LobbyClient> connection;
  38. void tick(uint32_t msPassed);
  39. public:
  40. LobbyWindow();
  41. void doSendChatMessage();
  42. void onGameChatMessage(const std::string & sender, const std::string & message, const std::string & when);
  43. };