This commit is contained in:
lilyhuang-github 2025-04-20 22:25:24 -07:00 committed by GitHub
commit 3c841fe03b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 59 additions and 19 deletions

View file

@ -410,6 +410,11 @@ void TabGame::closeRequest(bool forced)
close(); close();
} }
QString TabGame::getCurrentInGameTime() const
{
return QTime::fromMSecsSinceStartOfDay(secondsElapsed * 1000).toString("[hh:mm:ss] ");
}
void TabGame::replayNextEvent(Player::EventProcessingOptions options) void TabGame::replayNextEvent(Player::EventProcessingOptions options)
{ {
processGameEventContainer(replay->event_list(timelineWidget->getCurrentEvent()), nullptr, options); processGameEventContainer(replay->event_list(timelineWidget->getCurrentEvent()), nullptr, options);
@ -448,15 +453,8 @@ void TabGame::replayRewind()
void TabGame::incrementGameTime() void TabGame::incrementGameTime()
{ {
int seconds = ++secondsElapsed; ++secondsElapsed;
int minutes = seconds / 60; timeElapsedLabel->setText(getCurrentInGameTime());
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'));
} }
void TabGame::adminLockChanged(bool lock) void TabGame::adminLockChanged(bool lock)

View file

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

View file

@ -1138,6 +1138,9 @@ MessagesSettingsPage::MessagesSettingsPage()
connect(&messagePopups, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), connect(&messagePopups, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setShowMessagePopups); &SettingsCache::setShowMessagePopups);
localTimeCheckBox.setChecked(SettingsCache::instance().getLocalTime());
connect(&localTimeCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), &SettingsCache::setLocalTime);
mentionPopups.setChecked(SettingsCache::instance().getShowMentionPopup()); mentionPopups.setChecked(SettingsCache::instance().getShowMentionPopup());
connect(&mentionPopups, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), connect(&mentionPopups, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setShowMentionPopups); &SettingsCache::setShowMentionPopups);
@ -1160,6 +1163,7 @@ MessagesSettingsPage::MessagesSettingsPage()
chatGrid->addWidget(&messagePopups, 4, 0); chatGrid->addWidget(&messagePopups, 4, 0);
chatGrid->addWidget(&mentionPopups, 5, 0); chatGrid->addWidget(&mentionPopups, 5, 0);
chatGrid->addWidget(&roomHistory, 6, 0); chatGrid->addWidget(&roomHistory, 6, 0);
chatGrid->addWidget(&localTimeCheckBox, 7, 0);
chatGroupBox = new QGroupBox; chatGroupBox = new QGroupBox;
chatGroupBox->setLayout(chatGrid); chatGroupBox->setLayout(chatGrid);
@ -1342,6 +1346,7 @@ void MessagesSettingsPage::retranslateUi()
aAdd->setText(tr("Add New Message")); aAdd->setText(tr("Add New Message"));
aEdit->setText(tr("Edit Message")); aEdit->setText(tr("Edit Message"));
aRemove->setText(tr("Remove Message")); aRemove->setText(tr("Remove Message"));
localTimeCheckBox.setText(tr("Use Room Time over Real-Life Time"));
} }
SoundSettingsPage::SoundSettingsPage() SoundSettingsPage::SoundSettingsPage()

View file

@ -241,6 +241,7 @@ private:
QCheckBox invertHighlightForeground; QCheckBox invertHighlightForeground;
QCheckBox ignoreUnregUsersMainChat; QCheckBox ignoreUnregUsersMainChat;
QCheckBox ignoreUnregUserMessages; QCheckBox ignoreUnregUserMessages;
QCheckBox localTimeCheckBox;
QCheckBox messagePopups; QCheckBox messagePopups;
QCheckBox mentionPopups; QCheckBox mentionPopups;
QCheckBox roomHistory; QCheckBox roomHistory;

View file

@ -61,6 +61,7 @@ ChatView::ChatView(TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTime
setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
setOpenLinks(false); setOpenLinks(false);
connect(this, &ChatView::anchorClicked, this, &ChatView::openLink); connect(this, &ChatView::anchorClicked, this, &ChatView::openLink);
showInGameTime = SettingsCache::instance().getLocalTime();
} }
void ChatView::retranslateUi() void ChatView::retranslateUi()
@ -102,10 +103,9 @@ void ChatView::appendHtml(const QString &html)
void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor) void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor)
{ {
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum(); bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
QString htmlText = QString htmlText =
"<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" + "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>"; getCurrentTime() + html + "</font>";
if (optionalIsBold) if (optionalIsBold)
htmlText = "<b>" + htmlText + "</b>"; htmlText = "<b>" + htmlText + "</b>";
@ -168,7 +168,7 @@ void ChatView::appendMessage(QString message,
timeFormat.setForeground(serverMessageColor); timeFormat.setForeground(serverMessageColor);
timeFormat.setFontWeight(QFont::Bold); timeFormat.setFontWeight(QFont::Bold);
cursor.setCharFormat(timeFormat); cursor.setCharFormat(timeFormat);
cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm:ss] ")); cursor.insertText(getCurrentTime());
} }
// nickname // nickname
@ -457,6 +457,15 @@ bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> u
(userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin)); (userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin));
} }
QString ChatView::getCurrentTime() const
{
if (game && showInGameTime) {
return game->getCurrentInGameTime();
} else {
return QDateTime::currentDateTime().toString("[hh:mm:ss] ");
}
}
void ChatView::actMessageClicked() void ChatView::actMessageClicked()
{ {
emit messageClickedSignal(); emit messageClickedSignal();

View file

@ -1,6 +1,7 @@
#ifndef CHATVIEW_H #ifndef CHATVIEW_H
#define CHATVIEW_H #define CHATVIEW_H
#include "../../client/tabs/tab_game.h"
#include "../../client/tabs/tab_supervisor.h" #include "../../client/tabs/tab_supervisor.h"
#include "../user/user_list_widget.h" #include "../user/user_list_widget.h"
#include "room_message_type.h" #include "room_message_type.h"
@ -16,7 +17,6 @@ class QTextTable;
class QMouseEvent; class QMouseEvent;
class UserContextMenu; class UserContextMenu;
class UserListProxy; class UserListProxy;
class TabGame;
class UserMessagePosition class UserMessagePosition
{ {
@ -56,6 +56,7 @@ private:
QStringList highlightedWords; QStringList highlightedWords;
bool evenNumber; bool evenNumber;
bool showTimestamps; bool showTimestamps;
bool showInGameTime;
HoveredItemType hoveredItemType; HoveredItemType hoveredItemType;
QString hoveredContent; QString hoveredContent;
QAction *messageClicked; QAction *messageClicked;
@ -77,7 +78,6 @@ private:
QColor otherUserColor = QColor(0, 65, 255); // dark blue QColor otherUserColor = QColor(0, 65, 255); // dark blue
QColor serverMessageColor = QColor(0x85, 0x15, 0x15); QColor serverMessageColor = QColor(0x85, 0x15, 0x15);
QColor linkColor; QColor linkColor;
private slots: private slots:
void openLink(const QUrl &link); void openLink(const QUrl &link);
void actMessageClicked(); void actMessageClicked();
@ -106,6 +106,7 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override;
QString getCurrentTime() const;
signals: signals:
void openMessageDialog(const QString &userName, bool focus); void openMessageDialog(const QString &userName, bool focus);
void cardNameHovered(QString cardName); void cardNameHovered(QString cardName);

View file

@ -12,6 +12,11 @@
#include <utility> #include <utility>
const QString MessageLogWidget::getCurrentTime()
{
return ChatView::getCurrentTime();
}
const QString &MessageLogWidget::tableConstant() const const QString &MessageLogWidget::tableConstant() const
{ {
static const QString constant("table"); static const QString constant("table");
@ -615,14 +620,13 @@ void MessageLogWidget::logSetActivePhase(int phaseNumber)
soundEngine->playSound(phase.soundFileName); soundEngine->playSound(phase.soundFileName);
appendHtml("<font color=\"" + phase.color + "\"><b>" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + appendHtml("<font color=\"" + phase.color + "\"><b>" + getCurrentTime() + phase.getName() + "</b></font>");
phase.getName() + "</b></font>");
} }
void MessageLogWidget::logSetActivePlayer(Player *player) void MessageLogWidget::logSetActivePlayer(Player *player)
{ {
appendHtml("<br><font color=\"green\"><b>" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + appendHtml("<br><font color=\"green\"><b>" + getCurrentTime() + QString(tr("%1's turn.")).arg(player->getName()) +
QString(tr("%1's turn.")).arg(player->getName()) + "</b></font><br>"); "</b></font><br>");
} }
void MessageLogWidget::logSetAnnotation(Player *player, CardItem *card, QString newAnnotation) void MessageLogWidget::logSetAnnotation(Player *player, CardItem *card, QString newAnnotation)

View file

@ -26,6 +26,7 @@ private:
MessageContext currentContext; MessageContext currentContext;
QString messagePrefix, messageSuffix; QString messagePrefix, messageSuffix;
const QString getCurrentTime();
const QString &tableConstant() const; const QString &tableConstant() const;
const QString &graveyardConstant() const; const QString &graveyardConstant() const;
const QString &exileConstant() const; const QString &exileConstant() const;

View file

@ -342,6 +342,7 @@ SettingsCache::SettingsCache()
rememberGameSettings = settings->value("game/remembergamesettings", true).toBool(); rememberGameSettings = settings->value("game/remembergamesettings", true).toBool();
clientID = settings->value("personal/clientid", CLIENT_INFO_NOT_SET).toString(); clientID = settings->value("personal/clientid", CLIENT_INFO_NOT_SET).toString();
clientVersion = settings->value("personal/clientversion", CLIENT_INFO_NOT_SET).toString(); clientVersion = settings->value("personal/clientversion", CLIENT_INFO_NOT_SET).toString();
localTime = settings->value("chat/localtime", false).toBool();
} }
void SettingsCache::setUseTearOffMenus(bool _useTearOffMenus) void SettingsCache::setUseTearOffMenus(bool _useTearOffMenus)
@ -431,6 +432,12 @@ void SettingsCache::setRoomHistory(const QT_STATE_CHANGED_T _roomHistory)
settings->setValue("chat/roomhistory", roomHistory); settings->setValue("chat/roomhistory", roomHistory);
} }
void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T _localTime)
{
localTime = (bool)_localTime;
settings->setValue("chat/localtime", localTime);
}
void SettingsCache::setLang(const QString &_lang) void SettingsCache::setLang(const QString &_lang)
{ {
lang = _lang; lang = _lang;

View file

@ -215,6 +215,7 @@ private:
bool rememberGameSettings; bool rememberGameSettings;
QList<ReleaseChannel *> releaseChannels; QList<ReleaseChannel *> releaseChannels;
bool isPortableBuild; bool isPortableBuild;
bool localTime;
bool roundCardCorners; bool roundCardCorners;
public: public:
@ -602,6 +603,10 @@ public:
{ {
return showMessagePopups; return showMessagePopups;
} }
bool getLocalTime() const
{
return localTime;
}
bool getShowMentionPopup() const bool getShowMentionPopup() const
{ {
return showMentionPopups; return showMentionPopups;
@ -865,6 +870,7 @@ public slots:
void setCardScaling(const QT_STATE_CHANGED_T _scaleCards); void setCardScaling(const QT_STATE_CHANGED_T _scaleCards);
void setStackCardOverlapPercent(const int _verticalCardOverlapPercent); void setStackCardOverlapPercent(const int _verticalCardOverlapPercent);
void setShowMessagePopups(const QT_STATE_CHANGED_T _showMessagePopups); void setShowMessagePopups(const QT_STATE_CHANGED_T _showMessagePopups);
void setLocalTime(const QT_STATE_CHANGED_T _showMessagePopups);
void setShowMentionPopups(const QT_STATE_CHANGED_T _showMentionPopups); void setShowMentionPopups(const QT_STATE_CHANGED_T _showMentionPopups);
void setRoomHistory(const QT_STATE_CHANGED_T _roomHistory); void setRoomHistory(const QT_STATE_CHANGED_T _roomHistory);
void setLeftJustified(const QT_STATE_CHANGED_T _leftJustified); void setLeftJustified(const QT_STATE_CHANGED_T _leftJustified);

View file

@ -88,6 +88,9 @@ void SettingsCache::setStackCardOverlapPercent(const int /* _verticalCardOverlap
void SettingsCache::setShowMessagePopups(const QT_STATE_CHANGED_T /* _showMessagePopups */) void SettingsCache::setShowMessagePopups(const QT_STATE_CHANGED_T /* _showMessagePopups */)
{ {
} }
void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T /*_LocalTime*/)
{
}
void SettingsCache::setShowMentionPopups(const QT_STATE_CHANGED_T /* _showMentionPopus */) void SettingsCache::setShowMentionPopups(const QT_STATE_CHANGED_T /* _showMentionPopus */)
{ {
} }

View file

@ -311,6 +311,9 @@ void SettingsCache::setZoneViewGroupByIndex(int /* _zoneViewGroupByIndex */)
void SettingsCache::setZoneViewSortByIndex(int /* _zoneViewSortByIndex */) void SettingsCache::setZoneViewSortByIndex(int /* _zoneViewSortByIndex */)
{ {
} }
void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T /*_LocalTime*/)
{
}
void SettingsCache::setZoneViewPileView(QT_STATE_CHANGED_T /* _zoneViewPileView */) void SettingsCache::setZoneViewPileView(QT_STATE_CHANGED_T /* _zoneViewPileView */)
{ {
} }

2
vcpkg

@ -1 +1 @@
Subproject commit c63619856b89f0af4d77ba2049396039e4985418 Subproject commit 6f29f12e82a8293156836ad81cc9bf5af41fe836