update logic to tab_game, and make message_log_widet/chat_view reliant

This commit is contained in:
Lily 2025-04-12 12:22:21 -04:00
parent 3dec02c53e
commit 15c1b429fc
No known key found for this signature in database
GPG key ID: D916CEDDF4F93CE7
6 changed files with 17 additions and 49 deletions

View file

@ -408,6 +408,11 @@ void TabGame::closeRequest(bool forced)
close();
}
QString TabGame::getCurrentInGameTime() const
{
return QTime::fromMSecsSinceStartOfDay(secondsElapsed * 1000).toString("[hh:mm:ss] ");
}
void TabGame::replayNextEvent(Player::EventProcessingOptions options)
{
processGameEventContainer(replay->event_list(timelineWidget->getCurrentEvent()), nullptr, options);
@ -446,15 +451,8 @@ void TabGame::replayRewind()
void TabGame::incrementGameTime()
{
int seconds = ++secondsElapsed;
int minutes = seconds / 60;
seconds -= minutes * 60;
int hours = minutes / 60;
minutes -= hours * 60;
timeElapsedLabel->setText(QString::number(hours).rightJustified(2, '0') + ":" +
QString::number(minutes).rightJustified(2, '0') + ":" +
QString::number(seconds).rightJustified(2, '0'));
++secondsElapsed;
timeElapsedLabel->setText(getCurrentInGameTime());
}
void TabGame::adminLockChanged(bool lock)
@ -1679,7 +1677,7 @@ void TabGame::createPlayerListDock(bool bReplay)
void TabGame::createMessageDock(bool bReplay)
{
messageLog = new MessageLogWidget(tabSupervisor, this, &secondsElapsed);
messageLog = new MessageLogWidget(tabSupervisor, this);
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfoFrameWidget, SLOT(setCard(QString)));
connect(messageLog, &MessageLogWidget::showCardInfoPopup, this, &TabGame::showCardInfoPopup);
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));

View file

@ -92,6 +92,7 @@ private:
QCompleter *completer;
QStringList autocompleteUserList;
QStackedWidget *mainWidget;
bool showInGameTime;
// Replay related members
GameReplay *replay;
@ -224,6 +225,7 @@ public:
void retranslateUi() override;
void updatePlayerListDockTitle();
void closeRequest(bool forced = false) override;
QString getCurrentInGameTime() const;
const QMap<int, Player *> &getPlayers() const
{
return players;

View file

@ -457,18 +457,10 @@ bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> u
(userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin));
}
QString ChatView::getCurrentTime()
QString ChatView::getCurrentTime() const
{
if (showInGameTime) {
int seconds = *elapsedSeconds;
int minutes = seconds / 60;
seconds -= minutes * 60;
int hours = minutes / 60;
minutes -= hours * 60;
return QString("[%1:%2:%3] ")
.arg(QString::number(hours).rightJustified(2, '0'))
.arg(QString::number(minutes).rightJustified(2, '0'))
.arg(QString::number(seconds).rightJustified(2, '0'));
return game->getCurrentInGameTime();
} else {
return QDateTime::currentDateTime().toString("[hh:mm:ss] ");
}
@ -552,11 +544,6 @@ void ChatView::leaveEvent(QEvent * /*event*/)
setMouseTracking(false);
}
void ChatView::setTime(int *time)
{
elapsedSeconds = time;
}
QTextFragment ChatView::getFragmentUnderMouse(const QPoint &pos) const
{
QTextCursor cursor(cursorForPosition(pos));

View file

@ -1,6 +1,7 @@
#ifndef CHATVIEW_H
#define CHATVIEW_H
#include "../../client/tabs/tab_game.h"
#include "../../client/tabs/tab_supervisor.h"
#include "../user/user_list_widget.h"
#include "room_message_type.h"
@ -16,7 +17,6 @@ class QTextTable;
class QMouseEvent;
class UserContextMenu;
class UserListProxy;
class TabGame;
class UserMessagePosition
{
@ -44,7 +44,6 @@ private:
HoveredCard,
HoveredUser
};
int *elapsedSeconds{};
const UserListProxy *const userListProxy;
UserContextMenu *userContextMenu;
QString lastSender;
@ -79,7 +78,6 @@ private:
QColor otherUserColor = QColor(0, 65, 255); // dark blue
QColor serverMessageColor = QColor(0x85, 0x15, 0x15);
QColor linkColor;
QString getCurrentTime();
private slots:
void openLink(const QUrl &link);
void actMessageClicked();
@ -105,10 +103,10 @@ protected:
void enterEvent(QEvent *event) override;
#endif
void leaveEvent(QEvent *event) override;
void setTime(int *time);
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
QString getCurrentTime() const;
signals:
void openMessageDialog(const QString &userName, bool focus);
void cardNameHovered(QString cardName);

View file

@ -14,19 +14,7 @@
const QString MessageLogWidget::getCurrentTime()
{
if (showInGameTime) {
int seconds = *elapsedSeconds;
int minutes = seconds / 60;
seconds -= minutes * 60;
int hours = minutes / 60;
minutes -= hours * 60;
return QString("[%1:%2:%3] ")
.arg(QString::number(hours).rightJustified(2, '0'))
.arg(QString::number(minutes).rightJustified(2, '0'))
.arg(QString::number(seconds).rightJustified(2, '0'));
} else {
return QDateTime::currentDateTime().toString("[hh:mm:ss] ");
}
return ChatView::getCurrentTime();
}
const QString &MessageLogWidget::tableConstant() const
@ -874,10 +862,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
SLOT(logAlwaysLookAtTopCard(Player *, CardZone *, bool)));
}
MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *seconds, QWidget *parent)
MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, QWidget *parent)
: ChatView(_tabSupervisor, _game, true, parent), mulliganNumber(0), currentContext(MessageContext_None)
{
showInGameTime = SettingsCache::instance().getLocalTime();
elapsedSeconds = seconds;
ChatView::setTime(seconds);
}

View file

@ -25,8 +25,6 @@ private:
Player *mulliganPlayer;
MessageContext currentContext;
QString messagePrefix, messageSuffix;
int *elapsedSeconds;
bool showInGameTime;
const QString getCurrentTime();
const QString &tableConstant() const;
@ -105,7 +103,7 @@ public slots:
public:
void connectToPlayer(Player *player);
MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *elapsedSeconds, QWidget *parent = nullptr);
MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, QWidget *parent = nullptr);
};
#endif