mirror of
https://git.eden-emu.dev/archive/citron
synced 2026-03-23 01:56:08 -04:00
feat(multiplayer): More QoL Improvements
Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
@@ -4,28 +4,33 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono> // time tracking
|
#include <chrono>
|
||||||
#include <vector> // storing timestamps
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <QDialog>
|
#include <vector>
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
|
#include <QAbstractAnimation>
|
||||||
|
#include <QEasingCurve>
|
||||||
|
#include <QPointer>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QVariant>
|
#include <QTimer>
|
||||||
|
#include <QVariantAnimation>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ChatRoom;
|
class ChatRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class AnnounceMultiplayerSession;
|
class AnnounceMultiplayerSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
class ConnectionError;
|
class ConnectionError;
|
||||||
class ComboBoxProxyModel;
|
class ComboBoxProxyModel;
|
||||||
|
|
||||||
class ChatMessage;
|
class ChatMessage;
|
||||||
|
|
||||||
class ChatRoom : public QWidget {
|
class ChatRoom : public QWidget {
|
||||||
@@ -33,14 +38,14 @@ class ChatRoom : public QWidget {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ChatRoom(QWidget* parent);
|
explicit ChatRoom(QWidget* parent);
|
||||||
|
~ChatRoom();
|
||||||
|
|
||||||
void Initialize(Network::RoomNetwork* room_network);
|
void Initialize(Network::RoomNetwork* room_network);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
void RetranslateUi();
|
void RetranslateUi();
|
||||||
void SetPlayerList(const Network::RoomMember::MemberList& member_list);
|
void SetPlayerList(const Network::RoomMember::MemberList& member_list);
|
||||||
void Clear();
|
void Clear();
|
||||||
void AppendStatusMessage(const QString& msg);
|
void AppendStatusMessage(const QString& msg);
|
||||||
~ChatRoom();
|
|
||||||
|
|
||||||
void SetModPerms(bool is_mod);
|
void SetModPerms(bool is_mod);
|
||||||
void UpdateIconDisplay();
|
void UpdateIconDisplay();
|
||||||
|
|
||||||
@@ -63,20 +68,35 @@ signals:
|
|||||||
void UserPinged();
|
void UserPinged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr u32 max_chat_lines = 1000;
|
|
||||||
void AppendChatMessage(const QString&);
|
void AppendChatMessage(const QString&);
|
||||||
bool ValidateMessage(const std::string&);
|
bool ValidateMessage(const std::string&);
|
||||||
void SendModerationRequest(Network::RoomMessageTypes type, const std::string& nickname);
|
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;
|
bool has_mod_perms = false;
|
||||||
QStandardItemModel* player_list;
|
QStandardItemModel* player_list;
|
||||||
std::unique_ptr<Ui::ChatRoom> ui;
|
std::unique_ptr<Ui::ChatRoom> ui;
|
||||||
std::unordered_set<std::string> block_list;
|
std::unordered_set<std::string> block_list;
|
||||||
std::unordered_map<std::string, QPixmap> icon_cache;
|
std::unordered_map<std::string, QPixmap> icon_cache;
|
||||||
std::unordered_map<std::string, std::string> color_overrides;
|
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 chat_muted = false;
|
||||||
bool show_timestamps = true;
|
bool show_timestamps = true;
|
||||||
Network::RoomNetwork* room_network = nullptr;
|
Network::RoomNetwork* room_network = nullptr;
|
||||||
|
|
||||||
std::vector<std::chrono::steady_clock::time_point> sent_message_timestamps;
|
std::vector<std::chrono::steady_clock::time_point> sent_message_timestamps;
|
||||||
static constexpr size_t MAX_MESSAGES_PER_INTERVAL = 3;
|
static constexpr size_t MAX_MESSAGES_PER_INTERVAL = 3;
|
||||||
static constexpr std::chrono::seconds THROTTLE_INTERVAL{5};
|
static constexpr std::chrono::seconds THROTTLE_INTERVAL{5};
|
||||||
|
|||||||
Reference in New Issue
Block a user