mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 18:33:03 -07:00
Merge bd7190f03c into fb482f037e
This commit is contained in:
commit
8e1e35bf88
12 changed files with 66 additions and 9 deletions
|
|
@ -29,13 +29,17 @@ void GameState::incrementGameTime()
|
||||||
void GameState::setGameTime(int _secondsElapsed)
|
void GameState::setGameTime(int _secondsElapsed)
|
||||||
{
|
{
|
||||||
secondsElapsed = _secondsElapsed;
|
secondsElapsed = _secondsElapsed;
|
||||||
|
emit updateTimeElapsedLabel(formatElapsedTime(_secondsElapsed));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GameState::formatElapsedTime(int _secondsElapsed)
|
||||||
|
{
|
||||||
int seconds = _secondsElapsed;
|
int seconds = _secondsElapsed;
|
||||||
int minutes = seconds / 60;
|
int minutes = seconds / 60;
|
||||||
seconds -= minutes * 60;
|
seconds -= minutes * 60;
|
||||||
int hours = minutes / 60;
|
int hours = minutes / 60;
|
||||||
minutes -= hours * 60;
|
minutes -= hours * 60;
|
||||||
|
|
||||||
emit updateTimeElapsedLabel(QString::number(hours).rightJustified(2, '0') + ":" +
|
return QString::number(hours).rightJustified(2, '0') + ":" + QString::number(minutes).rightJustified(2, '0') + ":" +
|
||||||
QString::number(minutes).rightJustified(2, '0') + ":" +
|
QString::number(seconds).rightJustified(2, '0');
|
||||||
QString::number(seconds).rightJustified(2, '0'));
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,11 @@ public:
|
||||||
return hostId;
|
return hostId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getSecondsElapsed() const
|
||||||
|
{
|
||||||
|
return secondsElapsed;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updateTimeElapsedLabel(QString newTime);
|
void updateTimeElapsedLabel(QString newTime);
|
||||||
void gameStarted(bool resuming);
|
void gameStarted(bool resuming);
|
||||||
|
|
@ -121,6 +126,9 @@ public slots:
|
||||||
void incrementGameTime();
|
void incrementGameTime();
|
||||||
void setGameTime(int _secondsElapsed);
|
void setGameTime(int _secondsElapsed);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static QString formatElapsedTime(int _secondsElapsed);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer *gameTimer;
|
QTimer *gameTimer;
|
||||||
int secondsElapsed;
|
int secondsElapsed;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#include "message_log_widget.h"
|
#include "message_log_widget.h"
|
||||||
|
|
||||||
|
#include "../../client/settings/cache_settings.h"
|
||||||
#include "../../client/settings/card_counter_settings.h"
|
#include "../../client/settings/card_counter_settings.h"
|
||||||
#include "../../client/sound_engine.h"
|
#include "../../client/sound_engine.h"
|
||||||
|
#include "../../game/game_state.h"
|
||||||
#include "../../game/phase.h"
|
#include "../../game/phase.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../../game/player/player_logic.h"
|
||||||
#include "../../interface/widgets/tabs/tab_game.h"
|
#include "../../interface/widgets/tabs/tab_game.h"
|
||||||
|
|
@ -10,6 +12,7 @@
|
||||||
|
|
||||||
#include <libcockatrice/protocol/pb/context_move_card.pb.h>
|
#include <libcockatrice/protocol/pb/context_move_card.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/context_mulligan.pb.h>
|
#include <libcockatrice/protocol/pb/context_mulligan.pb.h>
|
||||||
|
#include <libcockatrice/settings/chat_settings.h>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
@ -826,6 +829,14 @@ void MessageLogWidget::appendHtmlServerMessage(const QString &html, bool optiona
|
||||||
ChatView::appendHtmlServerMessage(messagePrefix + html + messageSuffix, optionalIsBold, optionalFontColor);
|
ChatView::appendHtmlServerMessage(messagePrefix + html + messageSuffix, optionalIsBold, optionalFontColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MessageLogWidget::getCurrentTime() const
|
||||||
|
{
|
||||||
|
if (SettingsCache::instance().chat().getUseGameTime()) {
|
||||||
|
return "[" + GameState::formatElapsedTime(game->getGameState()->getSecondsElapsed()) + "] ";
|
||||||
|
}
|
||||||
|
return ChatView::getCurrentTime();
|
||||||
|
}
|
||||||
|
|
||||||
void MessageLogWidget::connectToPlayerEventHandler(PlayerEventHandler *playerEventHandler)
|
void MessageLogWidget::connectToPlayerEventHandler(PlayerEventHandler *playerEventHandler)
|
||||||
{
|
{
|
||||||
connect(playerEventHandler, &PlayerEventHandler::logSay, this, &MessageLogWidget::logSay);
|
connect(playerEventHandler, &PlayerEventHandler::logSay, this, &MessageLogWidget::logSay);
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,9 @@ public slots:
|
||||||
void appendHtmlServerMessage(const QString &html,
|
void appendHtmlServerMessage(const QString &html,
|
||||||
bool optionalIsBold = false,
|
bool optionalIsBold = false,
|
||||||
QString optionalFontColor = QString()) override;
|
QString optionalFontColor = QString()) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] QString getCurrentTime() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold,
|
||||||
|
|
||||||
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>";
|
||||||
|
|
@ -179,6 +179,11 @@ void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ChatView::getCurrentTime() const
|
||||||
|
{
|
||||||
|
return QDateTime::currentDateTime().toString("[hh:mm:ss] ");
|
||||||
|
}
|
||||||
|
|
||||||
void ChatView::appendCardTag(QTextCursor &cursor, const QString &cardName)
|
void ChatView::appendCardTag(QTextCursor &cursor, const QString &cardName)
|
||||||
{
|
{
|
||||||
QTextCharFormat oldFormat = cursor.charFormat();
|
QTextCharFormat oldFormat = cursor.charFormat();
|
||||||
|
|
@ -290,7 +295,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
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,8 @@ public:
|
||||||
ChatView(TabSupervisor *_tabSupervisor, AbstractGame *_game, bool _showTimestamps, QWidget *parent = nullptr);
|
ChatView(TabSupervisor *_tabSupervisor, AbstractGame *_game, bool _showTimestamps, QWidget *parent = nullptr);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void appendHtml(const QString &html);
|
void appendHtml(const QString &html);
|
||||||
void virtual appendHtmlServerMessage(const QString &html,
|
virtual void
|
||||||
bool optionalIsBold = false,
|
appendHtmlServerMessage(const QString &html, bool optionalIsBold = false, QString optionalFontColor = QString());
|
||||||
QString optionalFontColor = QString());
|
|
||||||
void appendMessage(QString message,
|
void appendMessage(QString message,
|
||||||
RoomMessageTypeFlags messageType = {},
|
RoomMessageTypeFlags messageType = {},
|
||||||
const ServerInfo_User &userInfo = {},
|
const ServerInfo_User &userInfo = {},
|
||||||
|
|
@ -119,6 +118,7 @@ public:
|
||||||
QString getRecentChatLog(int maxMessages = 50) const;
|
QString getRecentChatLog(int maxMessages = 50) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
[[nodiscard]] virtual QString getCurrentTime() const;
|
||||||
void enterEvent(QEnterEvent *event) override;
|
void enterEvent(QEnterEvent *event) override;
|
||||||
void leaveEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,10 @@ MessagesSettingsPage::MessagesSettingsPage()
|
||||||
connect(&roomHistory, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().chat(),
|
connect(&roomHistory, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().chat(),
|
||||||
&ChatSettings::setRoomHistory);
|
&ChatSettings::setRoomHistory);
|
||||||
|
|
||||||
|
useGameTimeCheckBox.setChecked(SettingsCache::instance().chat().getUseGameTime());
|
||||||
|
connect(&useGameTimeCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().chat(),
|
||||||
|
&ChatSettings::setUseGameTime);
|
||||||
|
|
||||||
customAlertString = new QLineEdit();
|
customAlertString = new QLineEdit();
|
||||||
customAlertString->setText(SettingsCache::instance().chat().getHighlightWords());
|
customAlertString->setText(SettingsCache::instance().chat().getHighlightWords());
|
||||||
connect(customAlertString, &QLineEdit::textChanged, &SettingsCache::instance().chat(),
|
connect(customAlertString, &QLineEdit::textChanged, &SettingsCache::instance().chat(),
|
||||||
|
|
@ -76,6 +80,7 @@ MessagesSettingsPage::MessagesSettingsPage()
|
||||||
chatGrid->addWidget(&messagePopups, 5, 0);
|
chatGrid->addWidget(&messagePopups, 5, 0);
|
||||||
chatGrid->addWidget(&mentionPopups, 6, 0);
|
chatGrid->addWidget(&mentionPopups, 6, 0);
|
||||||
chatGrid->addWidget(&roomHistory, 7, 0);
|
chatGrid->addWidget(&roomHistory, 7, 0);
|
||||||
|
chatGrid->addWidget(&useGameTimeCheckBox, 8, 0);
|
||||||
chatGroupBox = new QGroupBox;
|
chatGroupBox = new QGroupBox;
|
||||||
chatGroupBox->setLayout(chatGrid);
|
chatGroupBox->setLayout(chatGrid);
|
||||||
|
|
||||||
|
|
@ -256,6 +261,7 @@ void MessagesSettingsPage::retranslateUi()
|
||||||
messagePopups.setText(tr("Enable desktop notifications for private messages"));
|
messagePopups.setText(tr("Enable desktop notifications for private messages"));
|
||||||
mentionPopups.setText(tr("Enable desktop notification for mentions"));
|
mentionPopups.setText(tr("Enable desktop notification for mentions"));
|
||||||
roomHistory.setText(tr("Enable room message history on join"));
|
roomHistory.setText(tr("Enable room message history on join"));
|
||||||
|
useGameTimeCheckBox.setText(tr("Use game time instead of local time in game logs"));
|
||||||
hexLabel.setText(tr("(Color is hexadecimal)"));
|
hexLabel.setText(tr("(Color is hexadecimal)"));
|
||||||
hexHighlightLabel.setText(tr("(Color is hexadecimal)"));
|
hexHighlightLabel.setText(tr("(Color is hexadecimal)"));
|
||||||
customAlertStringLabel.setText(tr("Separate words with a space, alphanumeric characters only"));
|
customAlertStringLabel.setText(tr("Separate words with a space, alphanumeric characters only"));
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ private:
|
||||||
QCheckBox messagePopups;
|
QCheckBox messagePopups;
|
||||||
QCheckBox mentionPopups;
|
QCheckBox mentionPopups;
|
||||||
QCheckBox roomHistory;
|
QCheckBox roomHistory;
|
||||||
|
QCheckBox useGameTimeCheckBox;
|
||||||
QGroupBox *chatGroupBox;
|
QGroupBox *chatGroupBox;
|
||||||
QGroupBox *highlightGroupBox;
|
QGroupBox *highlightGroupBox;
|
||||||
QGroupBox *messageGroupBox;
|
QGroupBox *messageGroupBox;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ public:
|
||||||
[[nodiscard]] virtual bool getShowMessagePopup() const = 0;
|
[[nodiscard]] virtual bool getShowMessagePopup() const = 0;
|
||||||
[[nodiscard]] virtual bool getShowMentionPopup() const = 0;
|
[[nodiscard]] virtual bool getShowMentionPopup() const = 0;
|
||||||
[[nodiscard]] virtual bool getRoomHistory() const = 0;
|
[[nodiscard]] virtual bool getRoomHistory() const = 0;
|
||||||
|
[[nodiscard]] virtual bool getUseGameTime() const = 0;
|
||||||
[[nodiscard]] virtual QString getHighlightWords() const = 0;
|
[[nodiscard]] virtual QString getHighlightWords() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,11 @@ bool ChatSettings::getRoomHistory() const
|
||||||
return getValue("roomHistory", QString(), QString(), true).toBool();
|
return getValue("roomHistory", QString(), QString(), true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChatSettings::getUseGameTime() const
|
||||||
|
{
|
||||||
|
return getValue("useGameTime", QString(), QString(), false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
QString ChatSettings::getHighlightWords() const
|
QString ChatSettings::getHighlightWords() const
|
||||||
{
|
{
|
||||||
return getValue("highlightWords").toString();
|
return getValue("highlightWords").toString();
|
||||||
|
|
@ -131,6 +136,11 @@ void ChatSettings::setRoomHistory(bool _roomHistory)
|
||||||
setValue(_roomHistory, "roomHistory");
|
setValue(_roomHistory, "roomHistory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatSettings::setUseGameTime(bool _useGameTime)
|
||||||
|
{
|
||||||
|
setValue(_useGameTime, "useGameTime");
|
||||||
|
}
|
||||||
|
|
||||||
void ChatSettings::setHighlightWords(const QString &_highlightWords)
|
void ChatSettings::setHighlightWords(const QString &_highlightWords)
|
||||||
{
|
{
|
||||||
setValue(_highlightWords, "highlightWords");
|
setValue(_highlightWords, "highlightWords");
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ public:
|
||||||
[[nodiscard]] bool getShowMessagePopup() const override;
|
[[nodiscard]] bool getShowMessagePopup() const override;
|
||||||
[[nodiscard]] bool getShowMentionPopup() const override;
|
[[nodiscard]] bool getShowMentionPopup() const override;
|
||||||
[[nodiscard]] bool getRoomHistory() const override;
|
[[nodiscard]] bool getRoomHistory() const override;
|
||||||
|
[[nodiscard]] bool getUseGameTime() const override;
|
||||||
[[nodiscard]] QString getHighlightWords() const override;
|
[[nodiscard]] QString getHighlightWords() const override;
|
||||||
|
|
||||||
void setChatMention(bool _chatMention);
|
void setChatMention(bool _chatMention);
|
||||||
|
|
@ -37,6 +38,7 @@ public:
|
||||||
void setShowMessagePopups(bool _showMessagePopups);
|
void setShowMessagePopups(bool _showMessagePopups);
|
||||||
void setShowMentionPopups(bool _showMentionPopups);
|
void setShowMentionPopups(bool _showMentionPopups);
|
||||||
void setRoomHistory(bool _roomHistory);
|
void setRoomHistory(bool _roomHistory);
|
||||||
|
void setUseGameTime(bool _useGameTime);
|
||||||
void setHighlightWords(const QString &_highlightWords);
|
void setHighlightWords(const QString &_highlightWords);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,12 @@ TEST_F(SettingsDefaultsTest, Chat_RoomHistory_Default)
|
||||||
ASSERT_EQ(s.getRoomHistory(), true);
|
ASSERT_EQ(s.getRoomHistory(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, Chat_UseGameTime_Default)
|
||||||
|
{
|
||||||
|
ChatSettings s(settingsPath, nullptr);
|
||||||
|
ASSERT_EQ(s.getUseGameTime(), false);
|
||||||
|
}
|
||||||
|
|
||||||
// --- PersonalSettings ---
|
// --- PersonalSettings ---
|
||||||
|
|
||||||
TEST_F(SettingsDefaultsTest, Personal_Lang_Default)
|
TEST_F(SettingsDefaultsTest, Personal_Lang_Default)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue