10#include "../common/Logger/Logger.hpp"
15 : _uiFactory(uiFactory), _graphics(graphics) {}
22 LOG_ERROR(
"[ChatWidget] Failed to create text input");
28 _textInput->SetPlaceholder(
"Type a message...");
41 LOG_INFO(
"[ChatWidget] Initialized");
52 if (IsKeyPressed(KEY_ENTER)) {
63 int bgX =
static_cast<int>(
_posX);
64 int bgY =
static_cast<int>(
_posY);
76 for (
size_t i = startIdx; i <
_messages.size(); ++i) {
79 static_cast<int>(messageY), 12, 0xFFFFFFFF);
96 _messages.emplace_back(playerId, playerName, message, timestamp);
103 LOG_DEBUG(
"[ChatWidget] Added message from ", playerName,
": ", message);
135 while (!message.empty() && std::isspace(
static_cast<unsigned char>(message.front()))) {
136 message.erase(message.begin());
138 while (!message.empty() && std::isspace(
static_cast<unsigned char>(message.back()))) {
142 if (message.empty()) {
146 LOG_DEBUG(
"[ChatWidget] Sending message: '", message,
151 LOG_DEBUG(
"[ChatWidget] Calling onMessageSent callback...");
153 LOG_DEBUG(
"[ChatWidget] Callback completed");
155 LOG_ERROR(
"[ChatWidget] No callback registered!");
161 LOG_DEBUG(
"[ChatWidget] Message sent and input cleared");
Abstract interface for graphics rendering operations.
virtual void DrawText(int fontHandle, const char *text, int x, int y, int fontSize, unsigned int color)=0
Draw text using a loaded font.
virtual void DrawRectangleLines(int x, int y, int width, int height, unsigned int color)=0
Draw a rectangle outline (alias for DrawRect)
virtual void DrawRectangle(int x, int y, int width, int height, unsigned int color)=0
Draw a filled rectangle (alias for DrawRectFilled)
Abstract factory interface for creating UI elements.
virtual std::unique_ptr< ITextInput > CreateTextInput()=0
Create a text input instance.