2023-11-11 16:43:58 +02:00
|
|
|
/*
|
|
|
|
* LobbyWindow.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../gui/InterfaceObjectConfigurable.h"
|
|
|
|
#include "../windows/CWindowObject.h"
|
|
|
|
|
|
|
|
#include "../../lib/network/NetworkClient.h"
|
|
|
|
|
2023-11-12 15:32:54 +02:00
|
|
|
class LobbyWindow;
|
|
|
|
|
2023-11-11 16:43:58 +02:00
|
|
|
class LobbyWidget : public InterfaceObjectConfigurable
|
|
|
|
{
|
2023-11-12 15:32:54 +02:00
|
|
|
LobbyWindow * window;
|
2023-11-11 16:43:58 +02:00
|
|
|
public:
|
2023-11-12 15:32:54 +02:00
|
|
|
LobbyWidget(LobbyWindow * window);
|
|
|
|
|
|
|
|
std::shared_ptr<CTextInput> getMessageInput();
|
2023-11-12 16:35:53 +02:00
|
|
|
std::shared_ptr<CTextBox> getGameChat();
|
2023-11-11 16:43:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class LobbyClient : public NetworkClient
|
|
|
|
{
|
2023-11-12 15:32:54 +02:00
|
|
|
LobbyWindow * window;
|
|
|
|
|
2023-11-11 16:43:58 +02:00
|
|
|
void onPacketReceived(const std::vector<uint8_t> & message) override;
|
2023-11-12 13:27:22 +02:00
|
|
|
void onConnectionFailed(const std::string & errorMessage) override;
|
|
|
|
void onDisconnected() override;
|
2023-11-12 15:32:54 +02:00
|
|
|
|
2023-11-11 16:43:58 +02:00
|
|
|
public:
|
2023-11-12 15:32:54 +02:00
|
|
|
explicit LobbyClient(LobbyWindow * window);
|
|
|
|
|
|
|
|
void sendMessage(const JsonNode & data);
|
2023-11-11 16:43:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class LobbyWindow : public CWindowObject
|
|
|
|
{
|
2023-11-12 16:35:53 +02:00
|
|
|
std::string chatHistory;
|
|
|
|
|
2023-11-11 16:43:58 +02:00
|
|
|
std::shared_ptr<LobbyWidget> widget;
|
|
|
|
std::shared_ptr<LobbyClient> connection;
|
|
|
|
|
2023-11-12 13:27:22 +02:00
|
|
|
void tick(uint32_t msPassed);
|
|
|
|
|
2023-11-11 16:43:58 +02:00
|
|
|
public:
|
|
|
|
LobbyWindow();
|
2023-11-12 15:32:54 +02:00
|
|
|
|
|
|
|
void doSendChatMessage();
|
|
|
|
|
2023-11-12 16:35:53 +02:00
|
|
|
void onGameChatMessage(const std::string & sender, const std::string & message, const std::string & when);
|
2023-11-11 16:43:58 +02:00
|
|
|
};
|