From 71fff5dbd05ace02292954163562db00fe831caf Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Tue, 11 Mar 2025 19:36:22 -0400 Subject: [PATCH 01/13] local time changes part 1 --- cockatrice/src/client/tabs/tab_game.cpp | 2 +- cockatrice/src/server/chat_view/chat_view.cpp | 25 +- cockatrice/src/server/chat_view/chat_view.h | 4 +- cockatrice/src/server/message_log_widget.cpp | 17 +- cockatrice/src/server/message_log_widget.h | 4 +- webclient/src/i18n-default.json | 383 +----------------- 6 files changed, 46 insertions(+), 389 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_game.cpp b/cockatrice/src/client/tabs/tab_game.cpp index e6c794a6a..e3e0bb3f7 100644 --- a/cockatrice/src/client/tabs/tab_game.cpp +++ b/cockatrice/src/client/tabs/tab_game.cpp @@ -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))); diff --git a/cockatrice/src/server/chat_view/chat_view.cpp b/cockatrice/src/server/chat_view/chat_view.cpp index 33249829d..8e0bca801 100644 --- a/cockatrice/src/server/chat_view/chat_view.cpp +++ b/cockatrice/src/server/chat_view/chat_view.cpp @@ -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 = - "" + - QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + ""; + htmlText = "" + + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + ""; if (optionalIsBold) htmlText = "" + htmlText + ""; @@ -457,6 +457,20 @@ bool ChatView::isModeratorSendingGlobal(QFlags 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)); diff --git a/cockatrice/src/server/chat_view/chat_view.h b/cockatrice/src/server/chat_view/chat_view.h index 586ba90b3..d2d9baf52 100644 --- a/cockatrice/src/server/chat_view/chat_view.h +++ b/cockatrice/src/server/chat_view/chat_view.h @@ -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; diff --git a/cockatrice/src/server/message_log_widget.cpp b/cockatrice/src/server/message_log_widget.cpp index 568253e31..77f679581 100644 --- a/cockatrice/src/server/message_log_widget.cpp +++ b/cockatrice/src/server/message_log_widget.cpp @@ -12,6 +12,19 @@ #include +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); } diff --git a/cockatrice/src/server/message_log_widget.h b/cockatrice/src/server/message_log_widget.h index ef66f21e7..b8b6dd665 100644 --- a/cockatrice/src/server/message_log_widget.h +++ b/cockatrice/src/server/message_log_widget.h @@ -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 diff --git a/webclient/src/i18n-default.json b/webclient/src/i18n-default.json index 3aabe58f6..36abca615 100644 --- a/webclient/src/i18n-default.json +++ b/webclient/src/i18n-default.json @@ -1,382 +1 @@ -{ - "Common": { - "language": "English", - "disconnect": "Disconnect", - "label": { - "confirmPassword": "Confirm Password", - "confirmSure": "Are you sure?", - "country": "Country", - "delete": "Delete", - "email": "Email", - "hostName": "Host Name", - "hostAddress": "Host Address", - "password": "Password", - "passwordAgain": "Password Again", - "port": "Port", - "realName": "Real Name", - "saveChanges": "Save Changes", - "token": "Token", - "username": "Username" - }, - "validation": { - "minChars": "Minimum of {count} {count, plural, one {character} other {characters}} required", - "passwordsMustMatch": "Passwords don't match", - "required": "Required" - }, - "countries": { - "AD": "Andorra", - "AE": "United Arab Emirates", - "AF": "Afghanistan", - "AG": "Antigua and Barbuda", - "AI": "Anguilla", - "AL": "Albania", - "AM": "Armenia", - "AO": "Angola", - "AQ": "Antarctica", - "AR": "Argentina", - "AS": "American Samoa", - "AT": "Austria", - "AU": "Australia", - "AW": "Aruba", - "AX": "Åland Islands", - "AZ": "Azerbaijan", - "BA": "Bosnia and Herzegovina", - "BB": "Barbados", - "BD": "Bangladesh", - "BE": "Belgium", - "BF": "Burkina Faso", - "BG": "Bulgaria", - "BH": "Bahrain", - "BI": "Burundi", - "BJ": "Benin", - "BL": "Saint Barthélemy", - "BM": "Bermuda", - "BN": "Brunei Darussalam", - "BO": "Bolivia", - "BQ": "Bonaire, Sint Eustatius and Saba", - "BR": "Brazil", - "BS": "Bahamas", - "BT": "Bhutan", - "BV": "Bouvet Island", - "BW": "Botswana", - "BY": "Belarus", - "BZ": "Belize", - "CA": "Canada", - "CC": "Cocos (Keeling) Islands", - "CD": "DR Congo", - "CF": "Central African Republic", - "CG": "Republic of the Congo", - "CH": "Switzerland", - "CI": "Ivory Coast", - "CK": "Cook Islands", - "CL": "Chile", - "CM": "Cameroon", - "CN": "China", - "CO": "Colombia", - "CR": "Costa Rica", - "CU": "Cuba", - "CV": "Cape Verde", - "CW": "Curaçao", - "CX": "Christmas Island", - "CY": "Cyprus", - "CZ": "Czechia", - "DE": "Germany", - "DJ": "Djibouti", - "DK": "Denmark", - "DM": "Dominica", - "DO": "Dominican Republic", - "DZ": "Algeria", - "EC": "Ecuador", - "EE": "Estonia", - "EG": "Egypt", - "EH": "Western Sahara", - "ER": "Eritrea", - "ES": "Spain", - "ET": "Ethiopia", - "FI": "Finland", - "FJ": "Fiji", - "FK": "Falkland Islands", - "FM": "Micronesia", - "FO": "Faroe Islands", - "FR": "France", - "GA": "Gabon", - "GB": "United Kingdom", - "GD": "Grenada", - "GE": "Georgia", - "GF": "French Guiana", - "GG": "Guernsey", - "GH": "Ghana", - "GI": "Gibraltar", - "GL": "Greenland", - "GM": "Gambia", - "GN": "Guinea", - "GP": "Guadeloupe", - "GQ": "Equatorial Guinea", - "GR": "Greece", - "GS": "South Georgia and the South Sandwich Islands", - "GT": "Guatemala", - "GU": "Guam", - "GW": "Guinea-Bissau", - "GY": "Guyana", - "HK": "Hong Kong", - "HM": "Heard Island and McDonald Islands", - "HN": "Honduras", - "HR": "Croatia", - "HT": "Haiti", - "HU": "Hungary", - "ID": "Indonesia", - "IE": "Ireland", - "IL": "Israel", - "IM": "Isle of Man", - "IN": "India", - "IO": "British Indian Ocean Territory", - "IQ": "Iraq", - "IR": "Iran", - "IS": "Iceland", - "IT": "Italy", - "JE": "Jersey", - "JM": "Jamaica", - "JO": "Jordan", - "JP": "Japan", - "KE": "Kenya", - "KG": "Kyrgyzstan", - "KH": "Cambodia", - "KI": "Kiribati", - "KM": "Comoros", - "KN": "Saint Kitts and Nevis", - "KP": "North Korea", - "KR": "South Korea", - "KW": "Kuwait", - "KY": "Cayman Islands", - "KZ": "Kazakhstan", - "LA": "Laos", - "LB": "Lebanon", - "LC": "Saint Lucia", - "LI": "Liechtenstein", - "LK": "Sri Lanka", - "LR": "Liberia", - "LS": "Lesotho", - "LT": "Lithuania", - "LU": "Luxembourg", - "LV": "Latvia", - "LY": "Libya", - "MA": "Morocco", - "MC": "Monaco", - "MD": "Moldova", - "ME": "Montenegro", - "MF": "Saint Martin (French part)", - "MG": "Madagascar", - "MH": "Marshall Islands", - "MK": "North Macedonia", - "ML": "Mali", - "MM": "Myanmar", - "MN": "Mongolia", - "MO": "Macao", - "MP": "Northern Mariana Islands", - "MQ": "Martinique", - "MR": "Mauritania", - "MS": "Montserrat", - "MT": "Malta", - "MU": "Mauritius", - "MV": "Maldives", - "MW": "Malawi", - "MX": "Mexico", - "MY": "Malaysia", - "MZ": "Mozambique", - "NA": "Namibia", - "NC": "New Caledonia", - "NE": "Niger", - "NF": "Norfolk Island", - "NG": "Nigeria", - "NI": "Nicaragua", - "NL": "Netherlands", - "NO": "Norway", - "NP": "Nepal", - "NR": "Nauru", - "NU": "Niue", - "NZ": "New Zealand", - "OM": "Oman", - "PA": "Panama", - "PE": "Peru", - "PF": "French Polynesia", - "PG": "Papua New Guinea", - "PH": "Philippines", - "PK": "Pakistan", - "PL": "Poland", - "PM": "Saint Pierre and Miquelon", - "PN": "Pitcairn", - "PR": "Puerto Rico", - "PS": "Palestine", - "PT": "Portugal", - "PW": "Palau", - "PY": "Paraguay", - "QA": "Qatar", - "RE": "Réunion", - "RO": "Romania", - "RS": "Serbia", - "RU": "Russia", - "RW": "Rwanda", - "SA": "Saudi Arabia", - "SB": "Solomon Islands", - "SC": "Seychelles", - "SD": "Sudan", - "SE": "Sweden", - "SG": "Singapore", - "SH": "Saint Helena, Ascension and Tristan da Cunha", - "SI": "Slovenia", - "SJ": "Svalbard and Jan Mayen", - "SK": "Slovakia", - "SL": "Sierra Leone", - "SM": "San Marino", - "SN": "Senegal", - "SO": "Somalia", - "SR": "Suriname", - "SS": "South Sudan", - "ST": "Sao Tome and Principe", - "SV": "El Salvador", - "SX": "Sint Maarten (Dutch part)", - "SY": "Syria", - "SZ": "Eswatini", - "TC": "Turks and Caicos Islands", - "TD": "Chad", - "TF": "TAAF", - "TG": "Togo", - "TH": "Thailand", - "TJ": "Tajikistan", - "TK": "Tokelau", - "TL": "Timor-Leste", - "TM": "Turkmenistan", - "TN": "Tunisia", - "TO": "Tonga", - "TR": "Turkey", - "TT": "Trinidad and Tobago", - "TV": "Tuvalu", - "TW": "Taiwan", - "TZ": "Tanzania", - "UA": "Ukraine", - "UG": "Uganda", - "UM": "United States Minor Outlying Islands", - "US": "United States", - "UY": "Uruguay", - "UZ": "Uzbekistan", - "VA": "Holy See", - "VC": "Saint Vincent and the Grenadines", - "VE": "Venezuela", - "VG": "British Virgin Islands", - "VI": "U.S. Virgin Islands", - "VN": "Viet Nam", - "VU": "Vanuatu", - "WF": "Wallis and Futuna", - "WS": "Samoa", - "YE": "Yemen", - "YT": "Mayotte", - "XK": "Kosovo", - "ZA": "South Africa", - "ZM": "Zambia", - "ZW": "Zimbabwe", - "EU": "European Union" - }, - "languages": { - "en-US": "English - US", - "fr": "French", - "nl": "Dutch", - "pt_BR": "Portuguese - Brazil" - } - }, - "KnownHosts": { - "label": "Host", - "add": "Add new host", - "toast": "Host successfully {mode, select, created {created} deleted {deleted} other {edited}}." - }, - "InitializeContainer": { - "title": "DID YOU KNOW", - "subtitle": "<1>Cockatrice is run by volunteers<1>that love card games!" - }, - "LoginContainer": { - "header": { - "title": "Login", - "subtitle": "A cross-platform virtual tabletop for multiplayer card games." - }, - "footer": { - "registerPrompt": "Not registered yet?", - "registerAction": "Create an account", - "credit": "Cockatrice is an open source project", - "version": "Version" - }, - "content": { - "subtitle1": "Play multiplayer card games online.", - "subtitle2": "Cross-platform virtual tabletop for multiplayer card games. Forever free." - }, - "toasts": { - "passwordResetSuccessToast": "Password Reset Successfully", - "accountActivationSuccess": "Account Activated Successfully" - } - }, - "UnsupportedContainer": { - "title": "Unsupported Browser", - "subtitle1": "Please update your browser and/or check your permissions.", - "subtitle2": "Note: Private browsing causes some browsers to disable certain permissions or features." - }, - "AccountActivationDialog": { - "title": "Account Activation", - "subtitle1": "Your account has not been activated yet.", - "subtitle2": "You need to provide the activation token received in the activation email." - }, - "KnownHostDialog": { - "title": "{mode, select, edit {Edit} other {Add}} Known Host", - "subtitle": "Adding a new host allows you to connect to different servers. Enter the details below to your host list." - }, - "RegistrationDialog": { - "title": "Create New Account" - }, - "RequestPasswordResetDialog": { - "title": "Request Password Reset" - }, - "ResetPasswordDialog": { - "title": "Reset Password" - }, - "AccountActivationForm": { - "error": { - "failed": "Account activation failed" - }, - "label": { - "activate": "Activate Account" - } - }, - "KnownHostForm": { - "help": "Need help adding a new host?", - "label": { - "add": "Add Host", - "find": "Find Host" - } - }, - "LoginForm": { - "label": { - "autoConnect": "Auto Connect", - "forgot": "Forgot Password", - "login": "Login", - "savePassword": "Save Password", - "savedPassword": "Saved Password" - } - }, - "RegisterForm": { - "label": { - "register": "Register" - }, - "toast": { - "registerSuccess": "Registration Successful!" - } - }, - "RequestPasswordResetForm": { - "error": "Request password reset failed", - "mfaEnabled": "Server has multi-factor authentication enabled", - "request": "Request Reset Token", - "skipRequest": "I already have a reset token" - }, - "ResetPasswordForm": { - "error": "Password reset failed", - "label": { - "reset": "Reset Password" - } - } -} +{"Common":{"language":"English","disconnect":"Disconnect","label":{"confirmPassword":"Confirm Password","confirmSure":"Are you sure?","country":"Country","delete":"Delete","email":"Email","hostName":"Host Name","hostAddress":"Host Address","password":"Password","passwordAgain":"Password Again","port":"Port","realName":"Real Name","saveChanges":"Save Changes","token":"Token","username":"Username"},"validation":{"minChars":"Minimum of {count} {count, plural, one {character} other {characters}} required","passwordsMustMatch":"Passwords don't match","required":"Required"},"countries":{"AD":"Andorra","AE":"United Arab Emirates","AF":"Afghanistan","AG":"Antigua and Barbuda","AI":"Anguilla","AL":"Albania","AM":"Armenia","AO":"Angola","AQ":"Antarctica","AR":"Argentina","AS":"American Samoa","AT":"Austria","AU":"Australia","AW":"Aruba","AX":"Åland Islands","AZ":"Azerbaijan","BA":"Bosnia and Herzegovina","BB":"Barbados","BD":"Bangladesh","BE":"Belgium","BF":"Burkina Faso","BG":"Bulgaria","BH":"Bahrain","BI":"Burundi","BJ":"Benin","BL":"Saint Barthélemy","BM":"Bermuda","BN":"Brunei Darussalam","BO":"Bolivia","BQ":"Bonaire, Sint Eustatius and Saba","BR":"Brazil","BS":"Bahamas","BT":"Bhutan","BV":"Bouvet Island","BW":"Botswana","BY":"Belarus","BZ":"Belize","CA":"Canada","CC":"Cocos (Keeling) Islands","CD":"DR Congo","CF":"Central African Republic","CG":"Republic of the Congo","CH":"Switzerland","CI":"Ivory Coast","CK":"Cook Islands","CL":"Chile","CM":"Cameroon","CN":"China","CO":"Colombia","CR":"Costa Rica","CU":"Cuba","CV":"Cape Verde","CW":"Curaçao","CX":"Christmas Island","CY":"Cyprus","CZ":"Czechia","DE":"Germany","DJ":"Djibouti","DK":"Denmark","DM":"Dominica","DO":"Dominican Republic","DZ":"Algeria","EC":"Ecuador","EE":"Estonia","EG":"Egypt","EH":"Western Sahara","ER":"Eritrea","ES":"Spain","ET":"Ethiopia","FI":"Finland","FJ":"Fiji","FK":"Falkland Islands","FM":"Micronesia","FO":"Faroe Islands","FR":"France","GA":"Gabon","GB":"United Kingdom","GD":"Grenada","GE":"Georgia","GF":"French Guiana","GG":"Guernsey","GH":"Ghana","GI":"Gibraltar","GL":"Greenland","GM":"Gambia","GN":"Guinea","GP":"Guadeloupe","GQ":"Equatorial Guinea","GR":"Greece","GS":"South Georgia and the South Sandwich Islands","GT":"Guatemala","GU":"Guam","GW":"Guinea-Bissau","GY":"Guyana","HK":"Hong Kong","HM":"Heard Island and McDonald Islands","HN":"Honduras","HR":"Croatia","HT":"Haiti","HU":"Hungary","ID":"Indonesia","IE":"Ireland","IL":"Israel","IM":"Isle of Man","IN":"India","IO":"British Indian Ocean Territory","IQ":"Iraq","IR":"Iran","IS":"Iceland","IT":"Italy","JE":"Jersey","JM":"Jamaica","JO":"Jordan","JP":"Japan","KE":"Kenya","KG":"Kyrgyzstan","KH":"Cambodia","KI":"Kiribati","KM":"Comoros","KN":"Saint Kitts and Nevis","KP":"North Korea","KR":"South Korea","KW":"Kuwait","KY":"Cayman Islands","KZ":"Kazakhstan","LA":"Laos","LB":"Lebanon","LC":"Saint Lucia","LI":"Liechtenstein","LK":"Sri Lanka","LR":"Liberia","LS":"Lesotho","LT":"Lithuania","LU":"Luxembourg","LV":"Latvia","LY":"Libya","MA":"Morocco","MC":"Monaco","MD":"Moldova","ME":"Montenegro","MF":"Saint Martin (French part)","MG":"Madagascar","MH":"Marshall Islands","MK":"North Macedonia","ML":"Mali","MM":"Myanmar","MN":"Mongolia","MO":"Macao","MP":"Northern Mariana Islands","MQ":"Martinique","MR":"Mauritania","MS":"Montserrat","MT":"Malta","MU":"Mauritius","MV":"Maldives","MW":"Malawi","MX":"Mexico","MY":"Malaysia","MZ":"Mozambique","NA":"Namibia","NC":"New Caledonia","NE":"Niger","NF":"Norfolk Island","NG":"Nigeria","NI":"Nicaragua","NL":"Netherlands","NO":"Norway","NP":"Nepal","NR":"Nauru","NU":"Niue","NZ":"New Zealand","OM":"Oman","PA":"Panama","PE":"Peru","PF":"French Polynesia","PG":"Papua New Guinea","PH":"Philippines","PK":"Pakistan","PL":"Poland","PM":"Saint Pierre and Miquelon","PN":"Pitcairn","PR":"Puerto Rico","PS":"Palestine","PT":"Portugal","PW":"Palau","PY":"Paraguay","QA":"Qatar","RE":"Réunion","RO":"Romania","RS":"Serbia","RU":"Russia","RW":"Rwanda","SA":"Saudi Arabia","SB":"Solomon Islands","SC":"Seychelles","SD":"Sudan","SE":"Sweden","SG":"Singapore","SH":"Saint Helena, Ascension and Tristan da Cunha","SI":"Slovenia","SJ":"Svalbard and Jan Mayen","SK":"Slovakia","SL":"Sierra Leone","SM":"San Marino","SN":"Senegal","SO":"Somalia","SR":"Suriname","SS":"South Sudan","ST":"Sao Tome and Principe","SV":"El Salvador","SX":"Sint Maarten (Dutch part)","SY":"Syria","SZ":"Eswatini","TC":"Turks and Caicos Islands","TD":"Chad","TF":"TAAF","TG":"Togo","TH":"Thailand","TJ":"Tajikistan","TK":"Tokelau","TL":"Timor-Leste","TM":"Turkmenistan","TN":"Tunisia","TO":"Tonga","TR":"Turkey","TT":"Trinidad and Tobago","TV":"Tuvalu","TW":"Taiwan","TZ":"Tanzania","UA":"Ukraine","UG":"Uganda","UM":"United States Minor Outlying Islands","US":"United States","UY":"Uruguay","UZ":"Uzbekistan","VA":"Holy See","VC":"Saint Vincent and the Grenadines","VE":"Venezuela","VG":"British Virgin Islands","VI":"U.S. Virgin Islands","VN":"Viet Nam","VU":"Vanuatu","WF":"Wallis and Futuna","WS":"Samoa","YE":"Yemen","YT":"Mayotte","XK":"Kosovo","ZA":"South Africa","ZM":"Zambia","ZW":"Zimbabwe","EU":"European Union"},"languages":{"en-US":"English - US","fr":"French","nl":"Dutch","pt_BR":"Portuguese - Brazil"}},"KnownHosts":{"label":"Host","add":"Add new host","toast":"Host successfully {mode, select, created {created} deleted {deleted} other {edited}}."},"InitializeContainer":{"title":"DID YOU KNOW","subtitle":"<1>Cockatrice is run by volunteers<1>that love card games!"},"LoginContainer":{"header":{"title":"Login","subtitle":"A cross-platform virtual tabletop for multiplayer card games."},"footer":{"registerPrompt":"Not registered yet?","registerAction":"Create an account","credit":"Cockatrice is an open source project","version":"Version"},"content":{"subtitle1":"Play multiplayer card games online.","subtitle2":"Cross-platform virtual tabletop for multiplayer card games. Forever free."},"toasts":{"passwordResetSuccessToast":"Password Reset Successfully","accountActivationSuccess":"Account Activated Successfully"}},"UnsupportedContainer":{"title":"Unsupported Browser","subtitle1":"Please update your browser and/or check your permissions.","subtitle2":"Note: Private browsing causes some browsers to disable certain permissions or features."},"AccountActivationDialog":{"title":"Account Activation","subtitle1":"Your account has not been activated yet.","subtitle2":"You need to provide the activation token received in the activation email."},"KnownHostDialog":{"title":"{mode, select, edit {Edit} other {Add}} Known Host","subtitle":"Adding a new host allows you to connect to different servers. Enter the details below to your host list."},"RegistrationDialog":{"title":"Create New Account"},"RequestPasswordResetDialog":{"title":"Request Password Reset"},"ResetPasswordDialog":{"title":"Reset Password"},"AccountActivationForm":{"error":{"failed":"Account activation failed"},"label":{"activate":"Activate Account"}},"KnownHostForm":{"help":"Need help adding a new host?","label":{"add":"Add Host","find":"Find Host"}},"LoginForm":{"label":{"autoConnect":"Auto Connect","forgot":"Forgot Password","login":"Login","savePassword":"Save Password","savedPassword":"Saved Password"}},"RegisterForm":{"label":{"register":"Register"},"toast":{"registerSuccess":"Registration Successful!"}},"RequestPasswordResetForm":{"error":"Request password reset failed","mfaEnabled":"Server has multi-factor authentication enabled","request":"Request Reset Token","skipRequest":"I already have a reset token"},"ResetPasswordForm":{"error":"Password reset failed","label":{"reset":"Reset Password"}}} \ No newline at end of file From a9d3e73c1599e8fca78d85ba18de36d4e9cddcc6 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:00:04 -0400 Subject: [PATCH 02/13] add in-game time as checkbox in settings --- cockatrice/src/dialogs/dlg_settings.cpp | 9 +++++++++ cockatrice/src/dialogs/dlg_settings.h | 3 ++- cockatrice/src/settings/cache_settings.cpp | 6 ++++++ cockatrice/src/settings/cache_settings.h | 6 ++++++ dbconverter/src/mocks.cpp | 3 +++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/dialogs/dlg_settings.cpp b/cockatrice/src/dialogs/dlg_settings.cpp index 058455069..079a5749e 100644 --- a/cockatrice/src/dialogs/dlg_settings.cpp +++ b/cockatrice/src/dialogs/dlg_settings.cpp @@ -1100,6 +1100,10 @@ MessagesSettingsPage::MessagesSettingsPage() connect(&messagePopups, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), &SettingsCache::setShowMessagePopups); + localTimeCheckBox.setChecked(SettingsCache::instance().getLocalTime()); + connect(&localTimeCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), + &SettingsCache::setLocalTime); + mentionPopups.setChecked(SettingsCache::instance().getShowMentionPopup()); connect(&mentionPopups, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), &SettingsCache::setShowMentionPopups); @@ -1112,6 +1116,9 @@ MessagesSettingsPage::MessagesSettingsPage() connect(customAlertString, SIGNAL(textChanged(QString)), &SettingsCache::instance(), SLOT(setHighlightWords(QString))); + + + auto *chatGrid = new QGridLayout; chatGrid->addWidget(&chatMentionCheckBox, 0, 0); chatGrid->addWidget(&invertMentionForeground, 0, 1); @@ -1123,6 +1130,7 @@ MessagesSettingsPage::MessagesSettingsPage() chatGrid->addWidget(&messagePopups, 4, 0); chatGrid->addWidget(&mentionPopups, 5, 0); chatGrid->addWidget(&roomHistory, 6, 0); + chatGrid->addWidget(&localTimeCheckBox, 7, 0); chatGroupBox = new QGroupBox; chatGroupBox->setLayout(chatGrid); @@ -1305,6 +1313,7 @@ void MessagesSettingsPage::retranslateUi() aAdd->setText(tr("Add New Message")); aEdit->setText(tr("Edit Message")); aRemove->setText(tr("Remove Message")); + localTimeCheckBox.setText(tr("Enable In-Game Time")); } SoundSettingsPage::SoundSettingsPage() diff --git a/cockatrice/src/dialogs/dlg_settings.h b/cockatrice/src/dialogs/dlg_settings.h index 6ebe47307..d70478d31 100644 --- a/cockatrice/src/dialogs/dlg_settings.h +++ b/cockatrice/src/dialogs/dlg_settings.h @@ -239,6 +239,7 @@ private: QCheckBox invertHighlightForeground; QCheckBox ignoreUnregUsersMainChat; QCheckBox ignoreUnregUserMessages; + QCheckBox localTimeCheckBox; QCheckBox messagePopups; QCheckBox mentionPopups; QCheckBox roomHistory; @@ -252,7 +253,7 @@ private: QLabel hexHighlightLabel; QLabel customAlertStringLabel; QLabel explainMessagesLabel; - + void storeSettings(); void updateMentionPreview(); void updateHighlightPreview(); diff --git a/cockatrice/src/settings/cache_settings.cpp b/cockatrice/src/settings/cache_settings.cpp index 0dc082f0d..87ff3709d 100644 --- a/cockatrice/src/settings/cache_settings.cpp +++ b/cockatrice/src/settings/cache_settings.cpp @@ -420,6 +420,12 @@ void SettingsCache::setRoomHistory(const QT_STATE_CHANGED_T _roomHistory) settings->setValue("chat/roomhistory", roomHistory); } +void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T _showMessagePopups) +{ + localTime = (bool)_showMessagePopups; + settings->setValue("chat/localtime", localTime); +} + void SettingsCache::setLang(const QString &_lang) { lang = _lang; diff --git a/cockatrice/src/settings/cache_settings.h b/cockatrice/src/settings/cache_settings.h index eaecdf73c..28f77f1b0 100644 --- a/cockatrice/src/settings/cache_settings.h +++ b/cockatrice/src/settings/cache_settings.h @@ -200,6 +200,7 @@ private: bool rememberGameSettings; QList releaseChannels; bool isPortableBuild; + bool localTime; public: SettingsCache(); @@ -558,6 +559,10 @@ public: { return showMessagePopups; } + bool getLocalTime() const + { + return localTime; + } bool getShowMentionPopup() const { return showMentionPopups; @@ -810,6 +815,7 @@ public slots: void setCardScaling(const QT_STATE_CHANGED_T _scaleCards); void setStackCardOverlapPercent(const int _verticalCardOverlapPercent); void setShowMessagePopups(const QT_STATE_CHANGED_T _showMessagePopups); + void setLocalTime(const QT_STATE_CHANGED_T _showMessagePopups); void setShowMentionPopups(const QT_STATE_CHANGED_T _showMentionPopups); void setRoomHistory(const QT_STATE_CHANGED_T _roomHistory); void setLeftJustified(const QT_STATE_CHANGED_T _leftJustified); diff --git a/dbconverter/src/mocks.cpp b/dbconverter/src/mocks.cpp index e2f6ed4df..e6861c460 100644 --- a/dbconverter/src/mocks.cpp +++ b/dbconverter/src/mocks.cpp @@ -88,6 +88,9 @@ void SettingsCache::setStackCardOverlapPercent(const int /* _verticalCardOverlap void SettingsCache::setShowMessagePopups(const QT_STATE_CHANGED_T /* _showMessagePopups */) { } +void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T _showMessagePopups /*_LocalTime*/) +{ +} void SettingsCache::setShowMentionPopups(const QT_STATE_CHANGED_T /* _showMentionPopus */) { } From 1dade7b9f779cf496cb0521f781ef0da62d79584 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:23:50 -0400 Subject: [PATCH 03/13] implement UI component --- cockatrice/src/server/chat_view/chat_view.cpp | 34 ++++++++++--------- cockatrice/src/server/chat_view/chat_view.h | 1 + cockatrice/src/server/message_log_widget.cpp | 27 +++++++++------ cockatrice/src/server/message_log_widget.h | 1 + 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/cockatrice/src/server/chat_view/chat_view.cpp b/cockatrice/src/server/chat_view/chat_view.cpp index 8e0bca801..6463854a6 100644 --- a/cockatrice/src/server/chat_view/chat_view.cpp +++ b/cockatrice/src/server/chat_view/chat_view.cpp @@ -61,6 +61,7 @@ ChatView::ChatView(TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTime setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); setOpenLinks(false); connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &))); + showInGameTime = SettingsCache::instance().getLocalTime(); } void ChatView::retranslateUi() @@ -102,11 +103,9 @@ void ChatView::appendHtml(const QString &html) void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor) { bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum(); - QString htmlText; - - htmlText = "" + - QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + ""; - + QString htmlText = "" + getCurrentTime() + html + ""; + if (optionalIsBold) htmlText = "" + htmlText + ""; @@ -168,7 +167,7 @@ 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(getCurrentTime()); } // nickname @@ -459,16 +458,19 @@ bool ChatView::isModeratorSendingGlobal(QFlags u 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')); + if (showInGameTime) { + 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] "); + } } void ChatView::actMessageClicked() diff --git a/cockatrice/src/server/chat_view/chat_view.h b/cockatrice/src/server/chat_view/chat_view.h index d2d9baf52..856e62eca 100644 --- a/cockatrice/src/server/chat_view/chat_view.h +++ b/cockatrice/src/server/chat_view/chat_view.h @@ -57,6 +57,7 @@ private: QStringList highlightedWords; bool evenNumber; bool showTimestamps; + bool showInGameTime; HoveredItemType hoveredItemType; QString hoveredContent; QAction *messageClicked; diff --git a/cockatrice/src/server/message_log_widget.cpp b/cockatrice/src/server/message_log_widget.cpp index 77f679581..69eb79eda 100644 --- a/cockatrice/src/server/message_log_widget.cpp +++ b/cockatrice/src/server/message_log_widget.cpp @@ -14,15 +14,19 @@ 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')); + if (showInGameTime) { + 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 @@ -628,13 +632,13 @@ void MessageLogWidget::logSetActivePhase(int phaseNumber) soundEngine->playSound(phase.soundFileName); - appendHtml("" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + + appendHtml("" + getCurrentTime() + phase.name + ""); } void MessageLogWidget::logSetActivePlayer(Player *player) { - appendHtml("
" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + + appendHtml("
" + getCurrentTime() + QString(tr("%1's turn.")).arg(player->getName()) + "
"); } @@ -874,6 +878,7 @@ void MessageLogWidget::connectToPlayer(Player *player) MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *seconds, QWidget *parent) : ChatView(_tabSupervisor, _game, true, parent), mulliganNumber(0), currentContext(MessageContext_None) { + showInGameTime = SettingsCache::instance().getLocalTime(); elapsedSeconds = seconds; ChatView::setTime(seconds); } diff --git a/cockatrice/src/server/message_log_widget.h b/cockatrice/src/server/message_log_widget.h index b8b6dd665..833141bd1 100644 --- a/cockatrice/src/server/message_log_widget.h +++ b/cockatrice/src/server/message_log_widget.h @@ -26,6 +26,7 @@ private: MessageContext currentContext; QString messagePrefix, messageSuffix; int *elapsedSeconds; + bool showInGameTime; const QString getCurrentTime(); const QString &tableConstant() const; From ea76370c48e53d1b40ca82bc7e4ac0cccc11cc75 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:34:29 -0400 Subject: [PATCH 04/13] update cache settings name --- cockatrice/src/settings/cache_settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/settings/cache_settings.cpp b/cockatrice/src/settings/cache_settings.cpp index 87ff3709d..bdd6fd387 100644 --- a/cockatrice/src/settings/cache_settings.cpp +++ b/cockatrice/src/settings/cache_settings.cpp @@ -420,9 +420,9 @@ void SettingsCache::setRoomHistory(const QT_STATE_CHANGED_T _roomHistory) settings->setValue("chat/roomhistory", roomHistory); } -void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T _showMessagePopups) +void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T _localTime) { - localTime = (bool)_showMessagePopups; + localTime = (bool)_localTime; settings->setValue("chat/localtime", localTime); } From 5742cf5c15290f9182b2e57134199725ceb6f306 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Thu, 13 Mar 2025 12:25:05 -0400 Subject: [PATCH 05/13] formatting --- cockatrice/src/dialogs/dlg_settings.cpp | 6 +----- cockatrice/src/dialogs/dlg_settings.h | 2 +- cockatrice/src/server/chat_view/chat_view.cpp | 7 ++++--- cockatrice/src/server/message_log_widget.cpp | 7 +++---- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/cockatrice/src/dialogs/dlg_settings.cpp b/cockatrice/src/dialogs/dlg_settings.cpp index 079a5749e..ccffc1cdb 100644 --- a/cockatrice/src/dialogs/dlg_settings.cpp +++ b/cockatrice/src/dialogs/dlg_settings.cpp @@ -1101,8 +1101,7 @@ MessagesSettingsPage::MessagesSettingsPage() &SettingsCache::setShowMessagePopups); localTimeCheckBox.setChecked(SettingsCache::instance().getLocalTime()); - connect(&localTimeCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), - &SettingsCache::setLocalTime); + connect(&localTimeCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), &SettingsCache::setLocalTime); mentionPopups.setChecked(SettingsCache::instance().getShowMentionPopup()); connect(&mentionPopups, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), @@ -1116,9 +1115,6 @@ MessagesSettingsPage::MessagesSettingsPage() connect(customAlertString, SIGNAL(textChanged(QString)), &SettingsCache::instance(), SLOT(setHighlightWords(QString))); - - - auto *chatGrid = new QGridLayout; chatGrid->addWidget(&chatMentionCheckBox, 0, 0); chatGrid->addWidget(&invertMentionForeground, 0, 1); diff --git a/cockatrice/src/dialogs/dlg_settings.h b/cockatrice/src/dialogs/dlg_settings.h index d70478d31..a601e5023 100644 --- a/cockatrice/src/dialogs/dlg_settings.h +++ b/cockatrice/src/dialogs/dlg_settings.h @@ -253,7 +253,7 @@ private: QLabel hexHighlightLabel; QLabel customAlertStringLabel; QLabel explainMessagesLabel; - + void storeSettings(); void updateMentionPreview(); void updateHighlightPreview(); diff --git a/cockatrice/src/server/chat_view/chat_view.cpp b/cockatrice/src/server/chat_view/chat_view.cpp index 6463854a6..876abb300 100644 --- a/cockatrice/src/server/chat_view/chat_view.cpp +++ b/cockatrice/src/server/chat_view/chat_view.cpp @@ -103,9 +103,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 = "" + getCurrentTime() + html + ""; - + QString htmlText = + "" + + getCurrentTime() + html + ""; + if (optionalIsBold) htmlText = "" + htmlText + ""; diff --git a/cockatrice/src/server/message_log_widget.cpp b/cockatrice/src/server/message_log_widget.cpp index 69eb79eda..77116191f 100644 --- a/cockatrice/src/server/message_log_widget.cpp +++ b/cockatrice/src/server/message_log_widget.cpp @@ -632,14 +632,13 @@ void MessageLogWidget::logSetActivePhase(int phaseNumber) soundEngine->playSound(phase.soundFileName); - appendHtml("" + getCurrentTime() + - phase.name + ""); + appendHtml("" + getCurrentTime() + phase.name + ""); } void MessageLogWidget::logSetActivePlayer(Player *player) { - appendHtml("
" + getCurrentTime() + - QString(tr("%1's turn.")).arg(player->getName()) + "
"); + appendHtml("
" + getCurrentTime() + QString(tr("%1's turn.")).arg(player->getName()) + + "
"); } void MessageLogWidget::logSetAnnotation(Player *player, CardItem *card, QString newAnnotation) From ac0cb561459bdedb92358de14a4132370ce3fc4c Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Wed, 19 Mar 2025 14:17:55 -0400 Subject: [PATCH 06/13] update wording --- cockatrice/src/dialogs/dlg_settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cockatrice/src/dialogs/dlg_settings.cpp b/cockatrice/src/dialogs/dlg_settings.cpp index ccffc1cdb..a6ad383d6 100644 --- a/cockatrice/src/dialogs/dlg_settings.cpp +++ b/cockatrice/src/dialogs/dlg_settings.cpp @@ -1309,7 +1309,7 @@ void MessagesSettingsPage::retranslateUi() aAdd->setText(tr("Add New Message")); aEdit->setText(tr("Edit Message")); aRemove->setText(tr("Remove Message")); - localTimeCheckBox.setText(tr("Enable In-Game Time")); + localTimeCheckBox.setText(tr("Use Room Time over Real-Life Time")); } SoundSettingsPage::SoundSettingsPage() From cbfa291dc156889c72bbc9a26e83ec8651bfb2c1 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Tue, 25 Mar 2025 20:30:34 -0400 Subject: [PATCH 07/13] add mock to tests to fix cicd error --- tests/carddatabase/mocks.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/carddatabase/mocks.cpp b/tests/carddatabase/mocks.cpp index f399179c3..170d6e3d6 100644 --- a/tests/carddatabase/mocks.cpp +++ b/tests/carddatabase/mocks.cpp @@ -290,6 +290,9 @@ void SettingsCache::setZoneViewGroupByIndex(int /* _zoneViewGroupByIndex */) void SettingsCache::setZoneViewSortByIndex(int /* _zoneViewSortByIndex */) { } +void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T _showMessagePopups /*_LocalTime*/) +{ +} void SettingsCache::setZoneViewPileView(QT_STATE_CHANGED_T /* _zoneViewPileView */) { } From 4ca399cf3518f0d648b99c106829b71d6dd1a7a5 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Tue, 25 Mar 2025 20:34:23 -0400 Subject: [PATCH 08/13] fixed issue with setting not persisting --- cockatrice/src/settings/cache_settings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cockatrice/src/settings/cache_settings.cpp b/cockatrice/src/settings/cache_settings.cpp index bdd6fd387..4ba165284 100644 --- a/cockatrice/src/settings/cache_settings.cpp +++ b/cockatrice/src/settings/cache_settings.cpp @@ -331,6 +331,7 @@ SettingsCache::SettingsCache() rememberGameSettings = settings->value("game/remembergamesettings", true).toBool(); clientID = settings->value("personal/clientid", CLIENT_INFO_NOT_SET).toString(); clientVersion = settings->value("personal/clientversion", CLIENT_INFO_NOT_SET).toString(); + localTime = settings->value("chat/localtime", false).toBool(); } void SettingsCache::setUseTearOffMenus(bool _useTearOffMenus) From a4a96b7432273586c5b371acb093fa8503106cc3 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Tue, 25 Mar 2025 20:41:03 -0400 Subject: [PATCH 09/13] should fix cicd --- dbconverter/src/mocks.cpp | 2 +- tests/carddatabase/mocks.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dbconverter/src/mocks.cpp b/dbconverter/src/mocks.cpp index e6861c460..fa79bf45c 100644 --- a/dbconverter/src/mocks.cpp +++ b/dbconverter/src/mocks.cpp @@ -88,7 +88,7 @@ void SettingsCache::setStackCardOverlapPercent(const int /* _verticalCardOverlap void SettingsCache::setShowMessagePopups(const QT_STATE_CHANGED_T /* _showMessagePopups */) { } -void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T _showMessagePopups /*_LocalTime*/) +void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T /*_LocalTime*/) { } void SettingsCache::setShowMentionPopups(const QT_STATE_CHANGED_T /* _showMentionPopus */) diff --git a/tests/carddatabase/mocks.cpp b/tests/carddatabase/mocks.cpp index 170d6e3d6..18172a0eb 100644 --- a/tests/carddatabase/mocks.cpp +++ b/tests/carddatabase/mocks.cpp @@ -290,7 +290,7 @@ void SettingsCache::setZoneViewGroupByIndex(int /* _zoneViewGroupByIndex */) void SettingsCache::setZoneViewSortByIndex(int /* _zoneViewSortByIndex */) { } -void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T _showMessagePopups /*_LocalTime*/) +void SettingsCache::setLocalTime(const QT_STATE_CHANGED_T /*_LocalTime*/) { } void SettingsCache::setZoneViewPileView(QT_STATE_CHANGED_T /* _zoneViewPileView */) From 15c1b429fca601430ba81870ec1b1b06a6947027 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Sat, 12 Apr 2025 12:22:21 -0400 Subject: [PATCH 10/13] update logic to tab_game, and make message_log_widet/chat_view reliant --- cockatrice/src/client/tabs/tab_game.cpp | 18 ++++++++---------- cockatrice/src/client/tabs/tab_game.h | 2 ++ cockatrice/src/server/chat_view/chat_view.cpp | 17 ++--------------- cockatrice/src/server/chat_view/chat_view.h | 6 ++---- cockatrice/src/server/message_log_widget.cpp | 19 ++----------------- cockatrice/src/server/message_log_widget.h | 4 +--- 6 files changed, 17 insertions(+), 49 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_game.cpp b/cockatrice/src/client/tabs/tab_game.cpp index 4fb53d0d2..317778006 100644 --- a/cockatrice/src/client/tabs/tab_game.cpp +++ b/cockatrice/src/client/tabs/tab_game.cpp @@ -408,6 +408,11 @@ void TabGame::closeRequest(bool forced) close(); } +QString TabGame::getCurrentInGameTime() const +{ + return QTime::fromMSecsSinceStartOfDay(secondsElapsed * 1000).toString("[hh:mm:ss] "); +} + void TabGame::replayNextEvent(Player::EventProcessingOptions options) { processGameEventContainer(replay->event_list(timelineWidget->getCurrentEvent()), nullptr, options); @@ -446,15 +451,8 @@ void TabGame::replayRewind() void TabGame::incrementGameTime() { - int seconds = ++secondsElapsed; - int minutes = seconds / 60; - 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')); + ++secondsElapsed; + timeElapsedLabel->setText(getCurrentInGameTime()); } void TabGame::adminLockChanged(bool lock) @@ -1679,7 +1677,7 @@ void TabGame::createPlayerListDock(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, &MessageLogWidget::showCardInfoPopup, this, &TabGame::showCardInfoPopup); connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); diff --git a/cockatrice/src/client/tabs/tab_game.h b/cockatrice/src/client/tabs/tab_game.h index 096998728..b791810c0 100644 --- a/cockatrice/src/client/tabs/tab_game.h +++ b/cockatrice/src/client/tabs/tab_game.h @@ -92,6 +92,7 @@ private: QCompleter *completer; QStringList autocompleteUserList; QStackedWidget *mainWidget; + bool showInGameTime; // Replay related members GameReplay *replay; @@ -224,6 +225,7 @@ public: void retranslateUi() override; void updatePlayerListDockTitle(); void closeRequest(bool forced = false) override; + QString getCurrentInGameTime() const; const QMap &getPlayers() const { return players; diff --git a/cockatrice/src/server/chat_view/chat_view.cpp b/cockatrice/src/server/chat_view/chat_view.cpp index 876abb300..e4d9eb14d 100644 --- a/cockatrice/src/server/chat_view/chat_view.cpp +++ b/cockatrice/src/server/chat_view/chat_view.cpp @@ -457,18 +457,10 @@ bool ChatView::isModeratorSendingGlobal(QFlags u (userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin)); } -QString ChatView::getCurrentTime() +QString ChatView::getCurrentTime() const { if (showInGameTime) { - 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')); + return game->getCurrentInGameTime(); } else { return QDateTime::currentDateTime().toString("[hh:mm:ss] "); } @@ -552,11 +544,6 @@ 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)); diff --git a/cockatrice/src/server/chat_view/chat_view.h b/cockatrice/src/server/chat_view/chat_view.h index 856e62eca..33488c660 100644 --- a/cockatrice/src/server/chat_view/chat_view.h +++ b/cockatrice/src/server/chat_view/chat_view.h @@ -1,6 +1,7 @@ #ifndef CHATVIEW_H #define CHATVIEW_H +#include "../../client/tabs/tab_game.h" #include "../../client/tabs/tab_supervisor.h" #include "../user/user_list_widget.h" #include "room_message_type.h" @@ -16,7 +17,6 @@ class QTextTable; class QMouseEvent; class UserContextMenu; class UserListProxy; -class TabGame; class UserMessagePosition { @@ -44,7 +44,6 @@ private: HoveredCard, HoveredUser }; - int *elapsedSeconds{}; const UserListProxy *const userListProxy; UserContextMenu *userContextMenu; QString lastSender; @@ -79,7 +78,6 @@ 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(); @@ -105,10 +103,10 @@ 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; + QString getCurrentTime() const; signals: void openMessageDialog(const QString &userName, bool focus); void cardNameHovered(QString cardName); diff --git a/cockatrice/src/server/message_log_widget.cpp b/cockatrice/src/server/message_log_widget.cpp index 77116191f..fdaf0eafd 100644 --- a/cockatrice/src/server/message_log_widget.cpp +++ b/cockatrice/src/server/message_log_widget.cpp @@ -14,19 +14,7 @@ const QString MessageLogWidget::getCurrentTime() { - if (showInGameTime) { - 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] "); - } + return ChatView::getCurrentTime(); } const QString &MessageLogWidget::tableConstant() const @@ -874,10 +862,7 @@ void MessageLogWidget::connectToPlayer(Player *player) 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) { - showInGameTime = SettingsCache::instance().getLocalTime(); - elapsedSeconds = seconds; - ChatView::setTime(seconds); } diff --git a/cockatrice/src/server/message_log_widget.h b/cockatrice/src/server/message_log_widget.h index 833141bd1..8eed1b05b 100644 --- a/cockatrice/src/server/message_log_widget.h +++ b/cockatrice/src/server/message_log_widget.h @@ -25,8 +25,6 @@ private: Player *mulliganPlayer; MessageContext currentContext; QString messagePrefix, messageSuffix; - int *elapsedSeconds; - bool showInGameTime; const QString getCurrentTime(); const QString &tableConstant() const; @@ -105,7 +103,7 @@ public slots: public: void connectToPlayer(Player *player); - MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *elapsedSeconds, QWidget *parent = nullptr); + MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, QWidget *parent = nullptr); }; #endif From 53ba286b3eed70438df9cb1538549ec1d73f4d51 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Fri, 18 Apr 2025 11:54:07 -0400 Subject: [PATCH 11/13] merge --- cockatrice/src/server/message_log_widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cockatrice/src/server/message_log_widget.cpp b/cockatrice/src/server/message_log_widget.cpp index fa28db09f..1ce003f28 100644 --- a/cockatrice/src/server/message_log_widget.cpp +++ b/cockatrice/src/server/message_log_widget.cpp @@ -620,7 +620,7 @@ void MessageLogWidget::logSetActivePhase(int phaseNumber) soundEngine->playSound(phase.soundFileName); - appendHtml("" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + + appendHtml("" + getCurrentTime() + phase.getName() + ""); } From 6f8e0100b5d2095bb50d708aabeabb0f4730f81a Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Fri, 18 Apr 2025 11:58:08 -0400 Subject: [PATCH 12/13] formatting --- cockatrice/src/server/message_log_widget.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cockatrice/src/server/message_log_widget.cpp b/cockatrice/src/server/message_log_widget.cpp index 1ce003f28..0d6b3131c 100644 --- a/cockatrice/src/server/message_log_widget.cpp +++ b/cockatrice/src/server/message_log_widget.cpp @@ -620,8 +620,7 @@ void MessageLogWidget::logSetActivePhase(int phaseNumber) soundEngine->playSound(phase.soundFileName); - appendHtml("" + getCurrentTime() + - phase.getName() + ""); + appendHtml("" + getCurrentTime() + phase.getName() + ""); } void MessageLogWidget::logSetActivePlayer(Player *player) From e9600b5ea1358f8f899e6de8a4ed5300b21c1875 Mon Sep 17 00:00:00 2001 From: Lily <112970249+lilyhuang-github@users.noreply.github.com> Date: Fri, 18 Apr 2025 12:21:58 -0400 Subject: [PATCH 13/13] fixed exception --- cockatrice/src/server/chat_view/chat_view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cockatrice/src/server/chat_view/chat_view.cpp b/cockatrice/src/server/chat_view/chat_view.cpp index 37a8cf075..1ffe696b4 100644 --- a/cockatrice/src/server/chat_view/chat_view.cpp +++ b/cockatrice/src/server/chat_view/chat_view.cpp @@ -459,7 +459,7 @@ bool ChatView::isModeratorSendingGlobal(QFlags u QString ChatView::getCurrentTime() const { - if (showInGameTime) { + if (game && showInGameTime) { return game->getCurrentInGameTime(); } else { return QDateTime::currentDateTime().toString("[hh:mm:ss] ");