feat(multiplayer): More QoL Improvements

Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
Collecting
2026-01-12 06:42:09 +00:00
parent 447b07a006
commit 3880644afe

View File

@@ -4,28 +4,33 @@
#pragma once
#include <chrono> // time tracking
#include <vector> // storing timestamps
#include <chrono>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <QDialog>
#include <QSortFilterProxyModel>
#include <vector>
#include <QAbstractAnimation>
#include <QEasingCurve>
#include <QPointer>
#include <QStandardItemModel>
#include <QVariant>
#include <QTimer>
#include <QVariantAnimation>
#include <QWidget>
#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::ChatRoom> ui;
std::unordered_set<std::string> block_list;
std::unordered_map<std::string, QPixmap> icon_cache;
std::unordered_map<std::string, std::string> color_overrides;
// Highlight tracking with smooth fade-in/out
struct HighlightState {
float opacity = 0.0f;
QPointer<QVariantAnimation> animation;
QTimer* linger_timer = nullptr;
};
std::unordered_map<std::string, HighlightState> 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<std::chrono::steady_clock::time_point> sent_message_timestamps;
static constexpr size_t MAX_MESSAGES_PER_INTERVAL = 3;
static constexpr std::chrono::seconds THROTTLE_INTERVAL{5};