| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <array> |
| 7 |
#include <deque> |
| 8 |
#include <functional> |
| 9 |
#include <memory> |
| 10 |
#include <string> |
| 11 |
#include <utility> |
| 12 |
|
| 13 |
class NetPlayChatUI |
| 14 |
{ |
| 15 |
public: |
| 16 |
explicit NetPlayChatUI(std::function<void(const std::string&)> callback); |
| 17 |
~NetPlayChatUI(); |
| 18 |
|
| 19 |
using Color = std::array<float, 3>; |
| 20 |
|
| 21 |
void Display(); |
| 22 |
void AppendChat(std::string message, Color color); |
| 23 |
void SendChatMessage(); |
| 24 |
void Activate(); |
| 25 |
|
| 26 |
private: |
| 27 |
char m_message_buf[256] = {}; |
| 28 |
bool m_scroll_to_bottom = false; |
| 29 |
bool m_activate = false; |
| 30 |
bool m_is_scrolled_to_bottom = true; |
| 31 |
|
| 32 |
std::deque<std::pair<std::string, Color>> m_messages; |
| 33 |
std::function<void(const std::string&)> m_message_callback; |
| 34 |
}; |
| 35 |
|
| 36 |
extern std::unique_ptr<NetPlayChatUI> g_netplay_chat_ui; |