LobbyWindow.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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<CLabel> getAccountNameLabel();
  21. std::shared_ptr<CTextInput> getMessageInput();
  22. std::shared_ptr<CTextBox> getGameChat();
  23. };
  24. class LobbyClient : public NetworkClient
  25. {
  26. LobbyWindow * window;
  27. void onPacketReceived(const std::vector<uint8_t> & message) override;
  28. void onConnectionFailed(const std::string & errorMessage) override;
  29. void onConnectionEstablished() override;
  30. void onDisconnected() override;
  31. public:
  32. explicit LobbyClient(LobbyWindow * window);
  33. void sendMessage(const JsonNode & data);
  34. };
  35. class LobbyWindow : public CWindowObject
  36. {
  37. std::string chatHistory;
  38. std::shared_ptr<LobbyWidget> widget;
  39. std::shared_ptr<LobbyClient> connection;
  40. void tick(uint32_t msPassed);
  41. public:
  42. LobbyWindow();
  43. void doSendChatMessage();
  44. void onGameChatMessage(const std::string & sender, const std::string & message, const std::string & when);
  45. };