mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-17 07:52:16 -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)
|
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, SIGNAL(cardNameHovered(QString)), cardInfoFrameWidget, SLOT(setCard(QString)));
|
||||||
connect(messageLog, &MessageLogWidget::showCardInfoPopup, this, &TabGame::showCardInfoPopup);
|
connect(messageLog, &MessageLogWidget::showCardInfoPopup, this, &TabGame::showCardInfoPopup);
|
||||||
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
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)
|
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 =
|
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>";
|
||||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
|
||||||
|
|
||||||
if (optionalIsBold)
|
if (optionalIsBold)
|
||||||
htmlText = "<b>" + htmlText + "</b>";
|
htmlText = "<b>" + htmlText + "</b>";
|
||||||
|
|
@ -457,6 +457,20 @@ 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()
|
||||||
|
{
|
||||||
|
|
||||||
|
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()
|
void ChatView::actMessageClicked()
|
||||||
{
|
{
|
||||||
emit messageClickedSignal();
|
emit messageClickedSignal();
|
||||||
|
|
@ -535,6 +549,11 @@ void ChatView::leaveEvent(QEvent * /*event*/)
|
||||||
setMouseTracking(false);
|
setMouseTracking(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatView::setTime(int *time)
|
||||||
|
{
|
||||||
|
elapsedSeconds = time;
|
||||||
|
}
|
||||||
|
|
||||||
QTextFragment ChatView::getFragmentUnderMouse(const QPoint &pos) const
|
QTextFragment ChatView::getFragmentUnderMouse(const QPoint &pos) const
|
||||||
{
|
{
|
||||||
QTextCursor cursor(cursorForPosition(pos));
|
QTextCursor cursor(cursorForPosition(pos));
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ private:
|
||||||
HoveredCard,
|
HoveredCard,
|
||||||
HoveredUser
|
HoveredUser
|
||||||
};
|
};
|
||||||
|
int *elapsedSeconds{};
|
||||||
const UserListProxy *const userListProxy;
|
const UserListProxy *const userListProxy;
|
||||||
UserContextMenu *userContextMenu;
|
UserContextMenu *userContextMenu;
|
||||||
QString lastSender;
|
QString lastSender;
|
||||||
|
|
@ -77,7 +78,7 @@ 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;
|
||||||
|
QString getCurrentTime();
|
||||||
private slots:
|
private slots:
|
||||||
void openLink(const QUrl &link);
|
void openLink(const QUrl &link);
|
||||||
void actMessageClicked();
|
void actMessageClicked();
|
||||||
|
|
@ -103,6 +104,7 @@ protected:
|
||||||
void enterEvent(QEvent *event) override;
|
void enterEvent(QEvent *event) override;
|
||||||
#endif
|
#endif
|
||||||
void leaveEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
|
void setTime(int *time);
|
||||||
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;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,19 @@
|
||||||
|
|
||||||
#include <utility>
|
#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
|
const QString &MessageLogWidget::tableConstant() const
|
||||||
{
|
{
|
||||||
static const QString constant("table");
|
static const QString constant("table");
|
||||||
|
|
@ -858,7 +871,9 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
||||||
SLOT(logAlwaysLookAtTopCard(Player *, CardZone *, bool)));
|
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)
|
: ChatView(_tabSupervisor, _game, true, parent), mulliganNumber(0), currentContext(MessageContext_None)
|
||||||
{
|
{
|
||||||
|
elapsedSeconds = seconds;
|
||||||
|
ChatView::setTime(seconds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,9 @@ private:
|
||||||
Player *mulliganPlayer;
|
Player *mulliganPlayer;
|
||||||
MessageContext currentContext;
|
MessageContext currentContext;
|
||||||
QString messagePrefix, messageSuffix;
|
QString messagePrefix, messageSuffix;
|
||||||
|
int *elapsedSeconds;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
@ -102,7 +104,7 @@ public slots:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void connectToPlayer(Player *player);
|
void connectToPlayer(Player *player);
|
||||||
MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, QWidget *parent = nullptr);
|
MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *elapsedSeconds, QWidget *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue