Skip to content

Commit 0ed0b1b

Browse files
committed
Achievement: Fix default custom sound effect behavior
1 parent d37550f commit 0ed0b1b

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

pcsx2-qt/Settings/AchievementSettingsWidget.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include <QtWidgets/QMessageBox>
1919

2020
const char* AchievementSettingsWidget::AUDIO_FILE_FILTER = QT_TRANSLATE_NOOP("AchievementSettingsWidget", "WAV Audio Files (*.wav)");
21+
static constexpr const char* DEFAULT_INFO_SOUND_NAME = "sounds/achievements/message.wav";
22+
static constexpr const char* DEFAULT_UNLOCK_SOUND_NAME = "sounds/achievements/unlock.wav";
23+
static constexpr const char* DEFAULT_LBSUBMIT_SOUND_NAME = "sounds/achievements/lbsubmit.wav";
2124

2225
AchievementSettingsWidget::AchievementSettingsWidget(SettingsWindow* settings_dialog, QWidget* parent)
2326
: SettingsWidget(settings_dialog, parent)
@@ -44,9 +47,9 @@ AchievementSettingsWidget::AchievementSettingsWidget(SettingsWindow* settings_di
4447
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.achievementNotificationsDuration, "Achievements", "NotificationsDuration", Pcsx2Config::AchievementsOptions::DEFAULT_NOTIFICATION_DURATION);
4548
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.leaderboardNotificationsDuration, "Achievements", "LeaderboardsDuration", Pcsx2Config::AchievementsOptions::DEFAULT_LEADERBOARD_DURATION);
4649

47-
SettingWidgetBinder::BindWidgetToFileSetting(sif, m_ui.notificationSoundPath, m_ui.notificationSoundBrowse, m_ui.notificationSoundOpen, m_ui.notificationSoundReset, "Achievements", "InfoSoundName", Path::Combine(EmuFolders::Resources, EmuConfig.Achievements.DEFAULT_INFO_SOUND_NAME), qApp->translate("AchievementSettingsWidget", AUDIO_FILE_FILTER), true, false);
48-
SettingWidgetBinder::BindWidgetToFileSetting(sif, m_ui.unlockSoundPath, m_ui.unlockSoundBrowse, m_ui.unlockSoundOpen, m_ui.unlockSoundReset, "Achievements", "UnlockSoundName", Path::Combine(EmuFolders::Resources, EmuConfig.Achievements.DEFAULT_UNLOCK_SOUND_NAME), qApp->translate("AchievementSettingsWidget", AUDIO_FILE_FILTER), true, false);
49-
SettingWidgetBinder::BindWidgetToFileSetting(sif, m_ui.lbSoundPath, m_ui.lbSoundBrowse, m_ui.lbSoundOpen, m_ui.lbSoundReset, "Achievements", "LBSubmitSoundName", Path::Combine(EmuFolders::Resources, EmuConfig.Achievements.DEFAULT_LBSUBMIT_SOUND_NAME), qApp->translate("AchievementSettingsWidget", AUDIO_FILE_FILTER), true, false);
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);
5053

5154
dialog()->registerWidgetHelp(m_ui.enable, tr("Enable Achievements"), tr("Unchecked"), tr("When enabled and logged in, PCSX2 will scan for achievements on startup."));
5255
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."));

pcsx2/Achievements.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ namespace Achievements
6363
static constexpr float LEADERBOARD_STARTED_NOTIFICATION_TIME = 3.0f;
6464
static constexpr float LEADERBOARD_FAILED_NOTIFICATION_TIME = 3.0f;
6565

66+
static constexpr const char* DEFAULT_INFO_SOUND_NAME = "sounds/achievements/message.wav";
67+
static constexpr const char* DEFAULT_UNLOCK_SOUND_NAME = "sounds/achievements/unlock.wav";
68+
static constexpr const char* DEFAULT_LBSUBMIT_SOUND_NAME = "sounds/achievements/lbsubmit.wav";
69+
6670
static constexpr float INDICATOR_FADE_IN_TIME = 0.1f;
6771
static constexpr float INDICATOR_FADE_OUT_TIME = 0.5f;
6872

@@ -1142,7 +1146,11 @@ void Achievements::DisplayAchievementSummary()
11421146
}
11431147

11441148
if (EmuConfig.Achievements.SoundEffects && EmuConfig.Achievements.InfoSound)
1145-
Common::PlaySoundAsync(EmuConfig.Achievements.InfoSoundName.c_str());
1149+
Common::PlaySoundAsync(
1150+
(EmuConfig.Achievements.InfoSoundName.empty()
1151+
? Path::Combine(EmuFolders::Resources, DEFAULT_INFO_SOUND_NAME)
1152+
: EmuConfig.Achievements.InfoSoundName).c_str()
1153+
);
11461154
}
11471155

11481156
void Achievements::DisplayHardcoreDeferredMessage()
@@ -1194,7 +1202,11 @@ void Achievements::HandleUnlockEvent(const rc_client_event_t* event)
11941202
}
11951203

11961204
if (EmuConfig.Achievements.SoundEffects && EmuConfig.Achievements.UnlockSound)
1197-
Common::PlaySoundAsync(EmuConfig.Achievements.UnlockSoundName.c_str());
1205+
Common::PlaySoundAsync(
1206+
(EmuConfig.Achievements.UnlockSoundName.empty()
1207+
? Path::Combine(EmuFolders::Resources, DEFAULT_UNLOCK_SOUND_NAME)
1208+
: EmuConfig.Achievements.UnlockSoundName).c_str()
1209+
);
11981210
}
11991211

12001212
void Achievements::HandleGameCompleteEvent(const rc_client_event_t* event)
@@ -1315,7 +1327,11 @@ void Achievements::HandleLeaderboardSubmittedEvent(const rc_client_event_t* even
13151327
}
13161328

13171329
if (EmuConfig.Achievements.SoundEffects && EmuConfig.Achievements.LBSubmitSound)
1318-
Common::PlaySoundAsync(EmuConfig.Achievements.LBSubmitSoundName.c_str());
1330+
Common::PlaySoundAsync(
1331+
(EmuConfig.Achievements.LBSubmitSoundName.empty()
1332+
? Path::Combine(EmuFolders::Resources, DEFAULT_LBSUBMIT_SOUND_NAME)
1333+
: EmuConfig.Achievements.LBSubmitSoundName).c_str()
1334+
);
13191335
}
13201336

13211337
void Achievements::HandleLeaderboardScoreboardEvent(const rc_client_event_t* event)

pcsx2/Config.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,9 +1285,6 @@ struct Pcsx2Config
12851285
static constexpr u32 MAXIMUM_NOTIFICATION_DURATION = 30;
12861286
static constexpr u32 DEFAULT_NOTIFICATION_DURATION = 5;
12871287
static constexpr u32 DEFAULT_LEADERBOARD_DURATION = 10;
1288-
static constexpr const char* DEFAULT_INFO_SOUND_NAME = "sounds/achievements/message.wav";
1289-
static constexpr const char* DEFAULT_UNLOCK_SOUND_NAME = "sounds/achievements/unlock.wav";
1290-
static constexpr const char* DEFAULT_LBSUBMIT_SOUND_NAME = "sounds/achievements/lbsubmit.wav";
12911288

12921289
static const char* OverlayPositionNames[(size_t)AchievementOverlayPosition::MaxCount + 1];
12931290

pcsx2/Pcsx2Config.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,15 +1884,6 @@ void Pcsx2Config::AchievementsOptions::LoadSave(SettingsWrapper& wrap)
18841884
{
18851885
SettingsWrapSection("Achievements");
18861886

1887-
if (InfoSoundName.empty())
1888-
InfoSoundName = Path::Combine(EmuFolders::Resources, DEFAULT_INFO_SOUND_NAME);
1889-
1890-
if (UnlockSoundName.empty())
1891-
UnlockSoundName = Path::Combine(EmuFolders::Resources, DEFAULT_UNLOCK_SOUND_NAME);
1892-
1893-
if (LBSubmitSoundName.empty())
1894-
LBSubmitSoundName = Path::Combine(EmuFolders::Resources, DEFAULT_LBSUBMIT_SOUND_NAME);
1895-
18961887
SettingsWrapBitBool(Enabled);
18971888
SettingsWrapBitBoolEx(HardcoreMode, "ChallengeMode");
18981889
SettingsWrapBitBool(EncoreMode);

0 commit comments

Comments
 (0)