|
11 | 11 | #include "pcsx2/Achievements.h" |
12 | 12 | #include "pcsx2/Config.h" |
13 | 13 | #include "pcsx2/Host.h" |
| 14 | +#include "common/HostSys.h" |
14 | 15 |
|
15 | 16 | #include "common/StringUtil.h" |
16 | 17 |
|
@@ -47,9 +48,55 @@ AchievementSettingsWidget::AchievementSettingsWidget(SettingsWindow* settings_di |
47 | 48 | SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.achievementNotificationsDuration, "Achievements", "NotificationsDuration", Pcsx2Config::AchievementsOptions::DEFAULT_NOTIFICATION_DURATION); |
48 | 49 | SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.leaderboardNotificationsDuration, "Achievements", "LeaderboardsDuration", Pcsx2Config::AchievementsOptions::DEFAULT_LEADERBOARD_DURATION); |
49 | 50 |
|
50 | | - SettingWidgetBinder::BindWidgetToFileSetting(sif, m_ui.notificationSoundPath, m_ui.notificationSoundBrowse, m_ui.notificationSoundOpen, m_ui.notificationSoundReset, "Achievements", "InfoSoundName", Path::Combine(EmuFolders::Resources, DEFAULT_INFO_SOUND_NAME), qApp->translate("AchievementSettingsWidget", AUDIO_FILE_FILTER), true, false); |
51 | | - SettingWidgetBinder::BindWidgetToFileSetting(sif, m_ui.unlockSoundPath, m_ui.unlockSoundBrowse, m_ui.unlockSoundOpen, m_ui.unlockSoundReset, "Achievements", "UnlockSoundName", Path::Combine(EmuFolders::Resources, DEFAULT_UNLOCK_SOUND_NAME), qApp->translate("AchievementSettingsWidget", AUDIO_FILE_FILTER), true, false); |
52 | | - SettingWidgetBinder::BindWidgetToFileSetting(sif, m_ui.lbSoundPath, m_ui.lbSoundBrowse, m_ui.lbSoundOpen, m_ui.lbSoundReset, "Achievements", "LBSubmitSoundName", Path::Combine(EmuFolders::Resources, DEFAULT_LBSUBMIT_SOUND_NAME), qApp->translate("AchievementSettingsWidget", AUDIO_FILE_FILTER), true, false); |
| 51 | + SettingWidgetBinder::BindWidgetToFileSetting(sif, m_ui.notificationSoundPath, m_ui.notificationSoundBrowse, nullptr, nullptr, "Achievements", "InfoSoundName", Path::Combine(EmuFolders::Resources, DEFAULT_INFO_SOUND_NAME), qApp->translate("AchievementSettingsWidget", AUDIO_FILE_FILTER), true, false); |
| 52 | + SettingWidgetBinder::BindWidgetToFileSetting(sif, m_ui.unlockSoundPath, m_ui.unlockSoundBrowse, nullptr, nullptr, "Achievements", "UnlockSoundName", Path::Combine(EmuFolders::Resources, DEFAULT_UNLOCK_SOUND_NAME), qApp->translate("AchievementSettingsWidget", AUDIO_FILE_FILTER), true, false); |
| 53 | + SettingWidgetBinder::BindWidgetToFileSetting(sif, m_ui.lbSoundPath, m_ui.lbSoundBrowse, nullptr, nullptr, "Achievements", "LBSubmitSoundName", Path::Combine(EmuFolders::Resources, DEFAULT_LBSUBMIT_SOUND_NAME), qApp->translate("AchievementSettingsWidget", AUDIO_FILE_FILTER), true, false); |
| 54 | + |
| 55 | + // Preview Button |
| 56 | + |
| 57 | + QObject::connect(m_ui.notificationSoundOpen, &QAbstractButton::clicked, m_ui.notificationSoundOpen, [&]() { |
| 58 | + const QByteArray path = m_ui.notificationSoundPath->text().toUtf8(); |
| 59 | + Common::PlaySoundAsync( |
| 60 | + (path.isEmpty() |
| 61 | + ? Path::Combine(EmuFolders::Resources, DEFAULT_INFO_SOUND_NAME) |
| 62 | + : path.constData()).c_str() |
| 63 | + ); |
| 64 | + }); |
| 65 | + |
| 66 | + QObject::connect(m_ui.unlockSoundOpen, &QAbstractButton::clicked, m_ui.unlockSoundOpen, [&]() { |
| 67 | + const QByteArray path = m_ui.unlockSoundPath->text().toUtf8(); |
| 68 | + Common::PlaySoundAsync( |
| 69 | + (path.isEmpty() |
| 70 | + ? Path::Combine(EmuFolders::Resources, DEFAULT_UNLOCK_SOUND_NAME) |
| 71 | + : path.constData()).c_str() |
| 72 | + ); |
| 73 | + }); |
| 74 | + |
| 75 | + QObject::connect(m_ui.lbSoundOpen, &QAbstractButton::clicked, m_ui.lbSoundOpen, [&]() { |
| 76 | + const QByteArray path = m_ui.lbSoundPath->text().toUtf8(); |
| 77 | + Common::PlaySoundAsync( |
| 78 | + (path.isEmpty() |
| 79 | + ? Path::Combine(EmuFolders::Resources, DEFAULT_LBSUBMIT_SOUND_NAME) |
| 80 | + : path.constData()).c_str() |
| 81 | + ); |
| 82 | + }); |
| 83 | + |
| 84 | + // Reset button |
| 85 | + |
| 86 | + QObject::connect(m_ui.notificationSoundReset, &QAbstractButton::clicked, m_ui.notificationSoundReset, [&]() { |
| 87 | + m_ui.notificationSoundPath->clear(); |
| 88 | + Host::RemoveBaseSettingValue("Achievements", "InfoSoundName"); |
| 89 | + }); |
| 90 | + |
| 91 | + QObject::connect(m_ui.unlockSoundReset, &QAbstractButton::clicked, m_ui.unlockSoundReset, [&]() { |
| 92 | + m_ui.unlockSoundPath->clear(); |
| 93 | + Host::RemoveBaseSettingValue("Achievements", "UnlockSoundName"); |
| 94 | + }); |
| 95 | + |
| 96 | + QObject::connect(m_ui.lbSoundReset, &QAbstractButton::clicked, m_ui.lbSoundReset, [&]() { |
| 97 | + m_ui.lbSoundPath->clear(); |
| 98 | + Host::RemoveBaseSettingValue("Achievements", "LBSubmitSoundName"); |
| 99 | + }); |
53 | 100 |
|
54 | 101 | dialog()->registerWidgetHelp(m_ui.enable, tr("Enable Achievements"), tr("Unchecked"), tr("When enabled and logged in, PCSX2 will scan for achievements on startup.")); |
55 | 102 | dialog()->registerWidgetHelp(m_ui.hardcoreMode, tr("Enable Hardcore Mode"), tr("Unchecked"), tr("\"Challenge\" mode for achievements, including leaderboard tracking. Disables save state, cheats, and slowdown functions.")); |
|
0 commit comments