OpenTTD Source
20241108-master-g80f628063a
|
GUI for handling chat messages. More...
#include "../stdafx.h"
#include "../strings_func.h"
#include "../autocompletion.h"
#include "../blitter/factory.hpp"
#include "../console_func.h"
#include "../video/video_driver.hpp"
#include "../querystring_gui.h"
#include "../town.h"
#include "../window_func.h"
#include "../toolbar_gui.h"
#include "../core/geometry_func.hpp"
#include "../zoom_func.h"
#include "../timer/timer.h"
#include "../timer/timer_window.h"
#include "network.h"
#include "network_client.h"
#include "network_base.h"
#include "../widgets/network_chat_widget.h"
#include "table/strings.h"
#include "../safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | ChatMessage |
Container for a message. More... | |
class | NetworkChatAutoCompletion |
struct | NetworkChatWindow |
Window to enter the chat message in. More... | |
Functions | |
static bool | HaveChatMessages (bool show_all) |
Test if there are any chat messages to display. More... | |
void CDECL | NetworkAddChatMessage (TextColour colour, uint duration, const std::string &message) |
Add a text message to the 'chat window' to be shown. More... | |
void | NetworkReInitChatBoxSize () |
Initialize all font-dependent chat box sizes. | |
void | NetworkInitChatMessage () |
Initialize all buffers of the chat visualisation. | |
void | NetworkUndrawChatMessage () |
Hide the chatbox. | |
void | NetworkDrawChatMessage () |
Draw the chat message-box. | |
static void | SendChat (const std::string &buf, DestType type, int dest) |
Send an actual chat message. More... | |
void | ShowNetworkChatQueryWindow (DestType type, int dest) |
Show the chat window. More... | |
Variables | |
static const uint | NETWORK_CHAT_LINE_SPACING = 3 |
Spacing between chat lines. | |
static std::deque< ChatMessage > | _chatmsg_list |
The actual chat message list. | |
static bool | _chatmessage_dirty = false |
Does the chat message need repainting? | |
static bool | _chatmessage_visible = false |
Is a chat message visible. | |
static uint | MAX_CHAT_MESSAGES = 0 |
The limit of chat messages to show. | |
static std::chrono::steady_clock::time_point | _chatmessage_dirty_time |
Time the chat history was marked dirty. More... | |
static PointDimension | _chatmsg_box |
The chatbox grows from the bottom so the coordinates are pixels from the left and pixels from the bottom. More... | |
static ReusableBuffer< uint8_t > | _chatmessage_backup |
Backup in case text is moved. | |
static IntervalTimer< TimerWindow > | network_message_expired_interval (std::chrono::seconds(1), [](auto) { auto now=std::chrono::steady_clock::now();for(auto &cmsg :_chatmsg_list) { if(now > cmsg.remove_time &&_chatmessage_dirty_time< cmsg.remove_time) { _chatmessage_dirty_time=now;_chatmessage_dirty=true;break;} } }) |
Check if a message is expired on a regular interval. | |
static constexpr NWidgetPart | _nested_chat_window_widgets [] |
The widgets of the chat window. More... | |
static WindowDesc | _chat_window_desc (WDP_MANUAL, nullptr, 0, 0, WC_SEND_NETWORK_MSG, WC_NONE, 0, _nested_chat_window_widgets) |
The description of the chat window. | |
GUI for handling chat messages.
Definition in file network_chat_gui.cpp.
|
inlinestatic |
Test if there are any chat messages to display.
show_all | Set if all messages should be included, instead of unexpired only. |
Definition at line 68 of file network_chat_gui.cpp.
References _chatmsg_list.
void CDECL NetworkAddChatMessage | ( | TextColour | colour, |
uint | duration, | ||
const std::string & | message | ||
) |
Add a text message to the 'chat window' to be shown.
colour | The colour this message is to be shown in |
duration | The duration of the chat message in seconds |
message | message itself |
Definition at line 86 of file network_chat_gui.cpp.
References _chatmessage_dirty, _chatmessage_dirty_time, _chatmsg_list, ChatMessage::colour, MAX_CHAT_MESSAGES, ChatMessage::message, and ChatMessage::remove_time.
|
static |
Send an actual chat message.
buf | The message to send. |
type | The type of destination. |
dest | The actual destination index. |
Definition at line 255 of file network_chat_gui.cpp.
References _network_server, and ClientNetworkGameSocketHandler::SendChat().
void ShowNetworkChatQueryWindow | ( | DestType | type, |
int | dest | ||
) |
Show the chat window.
type | The type of destination. |
dest | The actual destination index. |
Definition at line 445 of file network_chat_gui.cpp.
References _chat_window_desc, CloseWindowByClass(), and WC_SEND_NETWORK_MSG.
Referenced by NetworkClientListWindow::OnClickClientChat(), and NetworkClientListWindow::OnClickCompanyChat().
|
static |
Time the chat history was marked dirty.
This is used to determine if expired messages have recently expired and should cause a redraw to hide them.
Definition at line 54 of file network_chat_gui.cpp.
Referenced by NetworkAddChatMessage().
|
static |
The chatbox grows from the bottom so the coordinates are pixels from the left and pixels from the bottom.
The height is the maximum height.
Definition at line 60 of file network_chat_gui.cpp.
Referenced by NetworkInitChatMessage(), and NetworkReInitChatBoxSize().
|
staticconstexpr |
The widgets of the chat window.
Definition at line 417 of file network_chat_gui.cpp.