Upgrade the game volume setting to the new format

This commit is contained in:
Henrik Rydgård 2025-02-12 09:49:30 -06:00
parent 33c4516e72
commit fef4a86225
5 changed files with 22 additions and 5 deletions

View file

@ -745,12 +745,24 @@ static const ConfigSetting graphicsSettings[] = {
ConfigSetting("DisplayRefreshRate", &g_Config.iDisplayRefreshRate, g_Config.iDisplayRefreshRate, CfgFlag::PER_GAME),
};
static int LegacyVolumeToNewVolume(int legacy, int max) {
float multiplier = Volume10ToMultiplier(legacy);
return std::clamp(MultiplierToVolume100(multiplier), 0, max);
}
static int DefaultGameVolume() {
return LegacyVolumeToNewVolume(g_Config.iLegacyGameVolume, 100);
}
static const ConfigSetting soundSettings[] = {
ConfigSetting("Enable", &g_Config.bEnableSound, true, CfgFlag::PER_GAME),
ConfigSetting("AudioBackend", &g_Config.iAudioBackend, 0, CfgFlag::PER_GAME),
ConfigSetting("ExtraAudioBuffering", &g_Config.bExtraAudioBuffering, false, CfgFlag::DEFAULT),
ConfigSetting("GlobalVolume", &g_Config.iGameVolume, VOLUME_FULL, CfgFlag::PER_GAME),
// Legacy volume settings, these get auto upgraded through default handlers on the new settings. NOTE: Must be before the new ones in the order here.
ConfigSetting("GlobalVolume", &g_Config.iLegacyGameVolume, VOLUME_FULL, CfgFlag::PER_GAME | CfgFlag::DONT_SAVE),
ConfigSetting("GameVolume", &g_Config.iGameVolume, &DefaultGameVolume, CfgFlag::PER_GAME),
ConfigSetting("ReverbVolume", &g_Config.iReverbVolume, VOLUME_FULL, CfgFlag::PER_GAME),
ConfigSetting("AltSpeedRelativeVolume", &g_Config.iAltSpeedVolume, VOLUMEHI_FULL, CfgFlag::PER_GAME),
ConfigSetting("AchievementSoundVolume", &g_Config.iAchievementSoundVolume, 6, CfgFlag::PER_GAME),
@ -1468,6 +1480,7 @@ bool Config::Save(const char *saveReason) {
return true;
}
// A lot more cleanup tasks should be moved into here, and some of these are severely outdated.
void Config::PostLoadCleanup(bool gameSpecific) {
// Override ppsspp.ini JIT value to prevent crashing
jitForcedOff = DefaultCpuCore() != (int)CPUCore::JIT && (g_Config.iCpuCore == (int)CPUCore::JIT || g_Config.iCpuCore == (int)CPUCore::JIT_IR);
@ -1502,6 +1515,9 @@ void Config::PostLoadCleanup(bool gameSpecific) {
if (g_Config.sCustomDriver == "Default") {
g_Config.sCustomDriver = "";
}
// Convert old volume settings.
}
void Config::PreSaveCleanup(bool gameSpecific) {

View file

@ -281,12 +281,13 @@ public:
int iAudioBackend;
// Volume settings, 0-10
int iGameVolume;
int iLegacyGameVolume;
int iReverbVolume;
int iAltSpeedVolume;
int iAchievementSoundVolume;
// Newer volume settings, 0-100
int iGameVolume;
int iUIVolume;
bool bExtraAudioBuffering; // For bluetooth

View file

@ -414,7 +414,7 @@ void __AudioUpdate(bool resetRecording) {
}
if (g_Config.bEnableSound) {
float multiplier = Volume10ToMultiplier(std::clamp(g_Config.iGameVolume, 0, VOLUME_FULL));
float multiplier = Volume100ToMultiplier(std::clamp(g_Config.iGameVolume, 0, VOLUMEHI_FULL));
if (PSP_CoreParameter().fpsLimit != FPSLimit::NORMAL || PSP_CoreParameter().fastForward) {
if (g_Config.iAltSpeedVolume != -1) {
// Multiply in the alt speed volume instead of replacing like before.

View file

@ -656,7 +656,7 @@ void GameSettingsScreen::CreateAudioSettings(UI::ViewGroup *audioSettings) {
// This is here because it now only applies to in-game. Muting the menu sounds is separate.
CheckBox *enableSound = audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound")));
PopupSliderChoice *volume = audioSettings->Add(new PopupSliderChoice(&g_Config.iGameVolume, VOLUME_OFF, VOLUME_FULL, VOLUME_FULL, a->T("Game volume"), screenManager()));
PopupSliderChoice *volume = audioSettings->Add(new PopupSliderChoice(&g_Config.iGameVolume, VOLUME_OFF, VOLUMEHI_FULL, VOLUMEHI_FULL, a->T("Game volume"), screenManager()));
volume->SetEnabledPtr(&g_Config.bEnableSound);
volume->SetZeroLabel(a->T("Mute"));

View file

@ -527,7 +527,7 @@ int main(int argc, const char* argv[])
g_Config.sMACAddress = "12:34:56:78:9A:BC";
g_Config.iFirmwareVersion = PSP_DEFAULT_FIRMWARE;
g_Config.iPSPModel = PSP_MODEL_SLIM;
g_Config.iGameVolume = VOLUME_FULL;
g_Config.iGameVolume = VOLUMEHI_FULL;
g_Config.iReverbVolume = VOLUME_FULL;
g_Config.internalDataDirectory.clear();
g_Config.bUseExperimentalAtrac = newAtrac;