mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
Implement game time
This commit is contained in:
parent
70a35e1dab
commit
a2d1579ae5
3 changed files with 44 additions and 7 deletions
|
|
@ -43,7 +43,6 @@ ChatView::ChatView(TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTime
|
|||
)");
|
||||
linkColor = palette().link().color();
|
||||
}
|
||||
|
||||
userContextMenu = new UserContextMenu(tabSupervisor, this, game);
|
||||
connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||
|
||||
|
|
@ -102,11 +101,19 @@ void ChatView::appendHtml(const QString &html)
|
|||
void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor)
|
||||
{
|
||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||
|
||||
QString htmlText =
|
||||
QString htmlText;
|
||||
/*QString htmlText =
|
||||
"<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
|
||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";*/
|
||||
if (elapsedSeconds != nullptr) {
|
||||
|
||||
htmlText =
|
||||
"<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
|
||||
getCurrentTime() + html + "</font>";
|
||||
} else {
|
||||
htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) +
|
||||
">" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
}
|
||||
if (optionalIsBold)
|
||||
htmlText = "<b>" + htmlText + "</b>";
|
||||
|
||||
|
|
@ -168,7 +175,14 @@ void ChatView::appendMessage(QString message,
|
|||
timeFormat.setForeground(serverMessageColor);
|
||||
timeFormat.setFontWeight(QFont::Bold);
|
||||
cursor.setCharFormat(timeFormat);
|
||||
cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm:ss] "));
|
||||
|
||||
//cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm:ss] "));
|
||||
if (elapsedSeconds != nullptr) {
|
||||
|
||||
cursor.insertText(getCurrentTime());
|
||||
} else {
|
||||
cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm:ss] "));
|
||||
}
|
||||
}
|
||||
|
||||
// nickname
|
||||
|
|
@ -457,6 +471,21 @@ bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> u
|
|||
(userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin));
|
||||
}
|
||||
|
||||
QString ChatView::getCurrentTime()
|
||||
{
|
||||
|
||||
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'));
|
||||
|
||||
}
|
||||
|
||||
void ChatView::actMessageClicked()
|
||||
{
|
||||
emit messageClickedSignal();
|
||||
|
|
@ -535,6 +564,11 @@ 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));
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ private:
|
|||
HoveredCard,
|
||||
HoveredUser
|
||||
};
|
||||
int *elapsedSeconds{};
|
||||
const UserListProxy *const userListProxy;
|
||||
UserContextMenu *userContextMenu;
|
||||
QString lastSender;
|
||||
|
|
@ -77,7 +78,7 @@ 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();
|
||||
|
|
@ -103,6 +104,7 @@ 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;
|
||||
|
|
|
|||
|
|
@ -875,8 +875,9 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
|||
}
|
||||
|
||||
MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *seconds, QWidget *parent)
|
||||
: ChatView(_tabSupervisor, _game, true,seconds, parent), mulliganNumber(0), currentContext(MessageContext_None)
|
||||
: ChatView(_tabSupervisor, _game, true, parent), mulliganNumber(0), currentContext(MessageContext_None)
|
||||
{
|
||||
elapsedSeconds = seconds;
|
||||
ChatView::setTime(seconds);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue