From 433d9459e09cd9ce3a1d02cc78d901b66d25335f Mon Sep 17 00:00:00 2001 From: rainmakerv2 <30595646+rainmakerv3@users.noreply.github.com> Date: Sun, 22 Dec 2024 21:46:45 +0800 Subject: [PATCH] Disable trophy pop-up with config setting (#1834) --- src/common/config.cpp | 12 +++++++++++ src/common/config.h | 2 ++ src/core/libraries/np_trophy/trophy_ui.cpp | 6 +++++- src/qt_gui/settings_dialog.cpp | 8 ++++++- src/qt_gui/settings_dialog.ui | 25 ++++++++++------------ src/qt_gui/translations/en.ts | 5 +++++ 6 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 9d5a99d9..deef0fa8 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -34,6 +34,7 @@ namespace Config { static bool isNeo = false; static bool isFullscreen = false; static bool playBGM = false; +static bool isTrophyPopupDisabled = false; static int BGMvolume = 50; static bool enableDiscordRPC = false; static u32 screenWidth = 1280; @@ -98,6 +99,10 @@ bool isFullscreenMode() { return isFullscreen; } +bool getisTrophyPopupDisabled() { + return isTrophyPopupDisabled; +} + bool getPlayBGM() { return playBGM; } @@ -294,6 +299,10 @@ void setFullscreenMode(bool enable) { isFullscreen = enable; } +void setisTrophyPopupDisabled(bool disable) { + isTrophyPopupDisabled = disable; +} + void setPlayBGM(bool enable) { playBGM = enable; } @@ -549,6 +558,7 @@ void load(const std::filesystem::path& path) { isNeo = toml::find_or(general, "isPS4Pro", false); isFullscreen = toml::find_or(general, "Fullscreen", false); playBGM = toml::find_or(general, "playBGM", false); + isTrophyPopupDisabled = toml::find_or(general, "isTrophyPopupDisabled", false); BGMvolume = toml::find_or(general, "BGMvolume", 50); enableDiscordRPC = toml::find_or(general, "enableDiscordRPC", true); logFilter = toml::find_or(general, "logFilter", ""); @@ -667,6 +677,7 @@ void save(const std::filesystem::path& path) { data["General"]["isPS4Pro"] = isNeo; data["General"]["Fullscreen"] = isFullscreen; + data["General"]["isTrophyPopupDisabled"] = isTrophyPopupDisabled; data["General"]["playBGM"] = playBGM; data["General"]["BGMvolume"] = BGMvolume; data["General"]["enableDiscordRPC"] = enableDiscordRPC; @@ -763,6 +774,7 @@ void saveMainWindow(const std::filesystem::path& path) { void setDefaultValues() { isNeo = false; isFullscreen = false; + isTrophyPopupDisabled = false; playBGM = false; BGMvolume = 50; enableDiscordRPC = true; diff --git a/src/common/config.h b/src/common/config.h index a4e6c3b1..701aadb1 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -19,6 +19,7 @@ bool isNeoMode(); bool isFullscreenMode(); bool getPlayBGM(); int getBGMvolume(); +bool getisTrophyPopupDisabled(); bool getEnableDiscordRPC(); bool getSeparateUpdateEnabled(); bool getCompatibilityEnabled(); @@ -62,6 +63,7 @@ void setGpuId(s32 selectedGpuId); void setScreenWidth(u32 width); void setScreenHeight(u32 height); void setFullscreenMode(bool enable); +void setisTrophyPopupDisabled(bool disable); void setPlayBGM(bool enable); void setBGMvolume(int volume); void setEnableDiscordRPC(bool enable); diff --git a/src/core/libraries/np_trophy/trophy_ui.cpp b/src/core/libraries/np_trophy/trophy_ui.cpp index 55ef7b8d..4bb8c824 100644 --- a/src/core/libraries/np_trophy/trophy_ui.cpp +++ b/src/core/libraries/np_trophy/trophy_ui.cpp @@ -5,6 +5,7 @@ #include #include #include "common/assert.h" +#include "common/config.h" #include "common/singleton.h" #include "imgui/imgui_std.h" #include "trophy_ui.h" @@ -82,7 +83,10 @@ void TrophyUI::Draw() { void AddTrophyToQueue(const std::filesystem::path& trophyIconPath, const std::string& trophyName) { std::lock_guard lock(queueMtx); - if (current_trophy_ui.has_value()) { + + if (Config::getisTrophyPopupDisabled()) { + return; + } else if (current_trophy_ui.has_value()) { TrophyInfo new_trophy; new_trophy.trophy_icon_path = trophyIconPath; new_trophy.trophy_name = trophyName; diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index 09d3674f..97c891e4 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -194,6 +194,7 @@ SettingsDialog::SettingsDialog(std::span physical_devices, QWidge ui->updaterGroupBox->installEventFilter(this); #endif ui->GUIgroupBox->installEventFilter(this); + ui->disableTrophycheckBox->installEventFilter(this); // Input ui->hideCursorGroupBox->installEventFilter(this); @@ -263,6 +264,8 @@ void SettingsDialog::LoadValuesFromConfig() { ui->dumpShadersCheckBox->setChecked(toml::find_or(data, "GPU", "dumpShaders", false)); ui->nullGpuCheckBox->setChecked(toml::find_or(data, "GPU", "nullGpu", false)); ui->playBGMCheckBox->setChecked(toml::find_or(data, "General", "playBGM", false)); + ui->disableTrophycheckBox->setChecked( + toml::find_or(data, "General", "isTrophyPopupDisabled", false)); ui->BGMVolumeSlider->setValue(toml::find_or(data, "General", "BGMvolume", 50)); ui->discordRPCCheckbox->setChecked( toml::find_or(data, "General", "enableDiscordRPC", true)); @@ -397,6 +400,8 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) { #endif } else if (elementName == "GUIgroupBox") { text = tr("GUIgroupBox"); + } else if (elementName == "disableTrophycheckBox") { + text = tr("disableTrophycheckBox"); } // Input @@ -485,6 +490,7 @@ void SettingsDialog::UpdateSettings() { Config::setBackButtonBehavior(TouchPadIndex[ui->backButtonBehaviorComboBox->currentIndex()]); Config::setNeoMode(ui->ps4proCheckBox->isChecked()); Config::setFullscreenMode(ui->fullscreenCheckBox->isChecked()); + Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked()); Config::setPlayBGM(ui->playBGMCheckBox->isChecked()); Config::setNeoMode(ui->ps4proCheckBox->isChecked()); Config::setLogType(ui->logTypeComboBox->currentText().toStdString()); @@ -549,4 +555,4 @@ void SettingsDialog::ResetInstallFolders() { } Config::setGameInstallDirs(settings_install_dirs_config); } -} \ No newline at end of file +} diff --git a/src/qt_gui/settings_dialog.ui b/src/qt_gui/settings_dialog.ui index cce728f6..faa0bf84 100644 --- a/src/qt_gui/settings_dialog.ui +++ b/src/qt_gui/settings_dialog.ui @@ -59,9 +59,9 @@ 0 - 0 - 832 - 431 + -97 + 815 + 618 @@ -469,6 +469,13 @@ 11 + + + + Disable Trophy Pop-ups + + + @@ -561,16 +568,6 @@ - - - - - 0 - 61 - - - - @@ -696,7 +693,7 @@ 5 - + true diff --git a/src/qt_gui/translations/en.ts b/src/qt_gui/translations/en.ts index 9eccec8e..ddaa4fe0 100644 --- a/src/qt_gui/translations/en.ts +++ b/src/qt_gui/translations/en.ts @@ -1201,6 +1201,11 @@ GUIgroupBox Play Title Music:\nIf a game supports it, enable playing special music when selecting the game in the GUI. + + + disableTrophycheckBox + Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). + hideCursorGroupBox