From 3880644afeb92d4718cf6fbe6fa534d00e1482da Mon Sep 17 00:00:00 2001 From: Collecting Date: Mon, 12 Jan 2026 06:42:09 +0000 Subject: [PATCH] feat(multiplayer): More QoL Improvements Signed-off-by: Collecting --- src/citron/multiplayer/chat_room.h | 42 ++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/citron/multiplayer/chat_room.h b/src/citron/multiplayer/chat_room.h index 2b34db41c..0c1e05eab 100644 --- a/src/citron/multiplayer/chat_room.h +++ b/src/citron/multiplayer/chat_room.h @@ -4,28 +4,33 @@ #pragma once -#include // time tracking -#include // storing timestamps +#include #include #include #include -#include -#include +#include + +#include +#include +#include #include -#include +#include +#include +#include + #include "network/network.h" namespace Ui { -class ChatRoom; + class ChatRoom; } namespace Core { -class AnnounceMultiplayerSession; + class AnnounceMultiplayerSession; } +class QPushButton; class ConnectionError; class ComboBoxProxyModel; - class ChatMessage; class ChatRoom : public QWidget { @@ -33,14 +38,14 @@ class ChatRoom : public QWidget { public: explicit ChatRoom(QWidget* parent); + ~ChatRoom(); + void Initialize(Network::RoomNetwork* room_network); void Shutdown(); void RetranslateUi(); void SetPlayerList(const Network::RoomMember::MemberList& member_list); void Clear(); void AppendStatusMessage(const QString& msg); - ~ChatRoom(); - void SetModPerms(bool is_mod); void UpdateIconDisplay(); @@ -63,20 +68,35 @@ signals: void UserPinged(); private: - static constexpr u32 max_chat_lines = 1000; void AppendChatMessage(const QString&); bool ValidateMessage(const std::string&); void SendModerationRequest(Network::RoomMessageTypes type, const std::string& nickname); + QColor GetPlayerColor(const std::string& nickname, int index) const; + void HighlightPlayer(const std::string& nickname); + QPushButton* send_message = nullptr; + static constexpr u32 max_chat_lines = 1000; bool has_mod_perms = false; QStandardItemModel* player_list; std::unique_ptr ui; std::unordered_set block_list; std::unordered_map icon_cache; std::unordered_map color_overrides; + + // Highlight tracking with smooth fade-in/out + struct HighlightState { + float opacity = 0.0f; + QPointer animation; + QTimer* linger_timer = nullptr; + }; + std::unordered_map highlight_states; + + bool is_compact_mode = false; + bool member_scrollbar_hidden = false; bool chat_muted = false; bool show_timestamps = true; Network::RoomNetwork* room_network = nullptr; + std::vector sent_message_timestamps; static constexpr size_t MAX_MESSAGES_PER_INTERVAL = 3; static constexpr std::chrono::seconds THROTTLE_INTERVAL{5};