mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
update logic to tab_game, and make message_log_widet/chat_view reliant
This commit is contained in:
parent
3dec02c53e
commit
15c1b429fc
6 changed files with 17 additions and 49 deletions
|
|
@ -408,6 +408,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);
|
||||||
|
|
@ -446,15 +451,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)
|
||||||
|
|
@ -1679,7 +1677,7 @@ void TabGame::createPlayerListDock(bool bReplay)
|
||||||
|
|
||||||
void TabGame::createMessageDock(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, 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)));
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -457,18 +457,10 @@ 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()
|
QString ChatView::getCurrentTime() const
|
||||||
{
|
{
|
||||||
if (showInGameTime) {
|
if (showInGameTime) {
|
||||||
int seconds = *elapsedSeconds;
|
return game->getCurrentInGameTime();
|
||||||
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 {
|
} else {
|
||||||
return QDateTime::currentDateTime().toString("[hh:mm:ss] ");
|
return QDateTime::currentDateTime().toString("[hh:mm:ss] ");
|
||||||
}
|
}
|
||||||
|
|
@ -552,11 +544,6 @@ 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));
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
@ -44,7 +44,6 @@ private:
|
||||||
HoveredCard,
|
HoveredCard,
|
||||||
HoveredUser
|
HoveredUser
|
||||||
};
|
};
|
||||||
int *elapsedSeconds{};
|
|
||||||
const UserListProxy *const userListProxy;
|
const UserListProxy *const userListProxy;
|
||||||
UserContextMenu *userContextMenu;
|
UserContextMenu *userContextMenu;
|
||||||
QString lastSender;
|
QString lastSender;
|
||||||
|
|
@ -79,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;
|
||||||
QString getCurrentTime();
|
|
||||||
private slots:
|
private slots:
|
||||||
void openLink(const QUrl &link);
|
void openLink(const QUrl &link);
|
||||||
void actMessageClicked();
|
void actMessageClicked();
|
||||||
|
|
@ -105,10 +103,10 @@ 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;
|
||||||
|
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);
|
||||||
|
|
|
||||||
|
|
@ -14,19 +14,7 @@
|
||||||
|
|
||||||
const QString MessageLogWidget::getCurrentTime()
|
const QString MessageLogWidget::getCurrentTime()
|
||||||
{
|
{
|
||||||
if (showInGameTime) {
|
return 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'));
|
|
||||||
} else {
|
|
||||||
return QDateTime::currentDateTime().toString("[hh:mm:ss] ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &MessageLogWidget::tableConstant() const
|
const QString &MessageLogWidget::tableConstant() const
|
||||||
|
|
@ -874,10 +862,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
||||||
SLOT(logAlwaysLookAtTopCard(Player *, CardZone *, bool)));
|
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)
|
: ChatView(_tabSupervisor, _game, true, parent), mulliganNumber(0), currentContext(MessageContext_None)
|
||||||
{
|
{
|
||||||
showInGameTime = SettingsCache::instance().getLocalTime();
|
|
||||||
elapsedSeconds = seconds;
|
|
||||||
ChatView::setTime(seconds);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,6 @@ private:
|
||||||
Player *mulliganPlayer;
|
Player *mulliganPlayer;
|
||||||
MessageContext currentContext;
|
MessageContext currentContext;
|
||||||
QString messagePrefix, messageSuffix;
|
QString messagePrefix, messageSuffix;
|
||||||
int *elapsedSeconds;
|
|
||||||
bool showInGameTime;
|
|
||||||
|
|
||||||
const QString getCurrentTime();
|
const QString getCurrentTime();
|
||||||
const QString &tableConstant() const;
|
const QString &tableConstant() const;
|
||||||
|
|
@ -105,7 +103,7 @@ public slots:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void connectToPlayer(Player *player);
|
void connectToPlayer(Player *player);
|
||||||
MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *elapsedSeconds, QWidget *parent = nullptr);
|
MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, QWidget *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue