mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-15 06:52:15 -07:00
local time changes part 1
This commit is contained in:
parent
5238087ddf
commit
71fff5dbd0
6 changed files with 46 additions and 389 deletions
|
|
@ -1681,7 +1681,7 @@ void TabGame::createPlayerListDock(bool bReplay)
|
|||
|
||||
void TabGame::createMessageDock(bool bReplay)
|
||||
{
|
||||
messageLog = new MessageLogWidget(tabSupervisor, this);
|
||||
messageLog = new MessageLogWidget(tabSupervisor, this, &secondsElapsed);
|
||||
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)));
|
||||
|
|
|
|||
|
|
@ -102,10 +102,10 @@ 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 =
|
||||
"<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
|
||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
|
||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
|
||||
if (optionalIsBold)
|
||||
htmlText = "<b>" + htmlText + "</b>";
|
||||
|
|
@ -457,6 +457,20 @@ 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 +549,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;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,19 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
const QString MessageLogWidget::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'));
|
||||
}
|
||||
|
||||
const QString &MessageLogWidget::tableConstant() const
|
||||
{
|
||||
static const QString constant("table");
|
||||
|
|
@ -858,7 +871,9 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
|||
SLOT(logAlwaysLookAtTopCard(Player *, CardZone *, bool)));
|
||||
}
|
||||
|
||||
MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, QWidget *parent)
|
||||
MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *seconds, QWidget *parent)
|
||||
: ChatView(_tabSupervisor, _game, true, parent), mulliganNumber(0), currentContext(MessageContext_None)
|
||||
{
|
||||
elapsedSeconds = seconds;
|
||||
ChatView::setTime(seconds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ private:
|
|||
Player *mulliganPlayer;
|
||||
MessageContext currentContext;
|
||||
QString messagePrefix, messageSuffix;
|
||||
int *elapsedSeconds;
|
||||
|
||||
const QString getCurrentTime();
|
||||
const QString &tableConstant() const;
|
||||
const QString &graveyardConstant() const;
|
||||
const QString &exileConstant() const;
|
||||
|
|
@ -102,7 +104,7 @@ public slots:
|
|||
|
||||
public:
|
||||
void connectToPlayer(Player *player);
|
||||
MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, QWidget *parent = nullptr);
|
||||
MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *elapsedSeconds, QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue