Skip to content

Commit 25f2c7f

Browse files
committed
CSettings: add master volume level setting
1 parent 149a0ad commit 25f2c7f

File tree

7 files changed

+217
-80
lines changed

7 files changed

+217
-80
lines changed

Client/core/CClientVariables.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ void CClientVariables::ValidateValues(void)
252252
ClampValue("chat_position_vertical", Chat::Position::Vertical::TOP, Chat::Position::Vertical::BOTTOM);
253253
ClampValue("chat_text_alignment", Chat::Text::Align::LEFT, Chat::Text::Align::RIGHT);
254254
ClampValue("text_scale", 0.8f, 3.0f);
255+
ClampValue("mastervolume", 0.0f, 1.0f);
255256
ClampValue("mtavolume", 0.0f, 1.0f);
256257
ClampValue("voicevolume", 0.0f, 1.0f);
257258
ClampValue("mapalpha", 0, 255);
@@ -309,6 +310,7 @@ void CClientVariables::LoadDefaults(void)
309310
DEFAULT("fly_with_mouse", false); // flying with mouse controls
310311
DEFAULT("steer_with_mouse", false); // steering with mouse controls
311312
DEFAULT("classic_controls", false); // classic/standard controls
313+
DEFAULT("mastervolume", 1.0f); // master volume
312314
DEFAULT("mtavolume", 1.0f); // custom sound's volume
313315
DEFAULT("voicevolume", 1.0f); // voice chat output volume
314316
DEFAULT("mapalpha", 155); // map alpha
@@ -334,6 +336,7 @@ void CClientVariables::LoadDefaults(void)
334336
DEFAULT("multimon_fullscreen_minimize", 1); // 0-off 1-on
335337
DEFAULT("vertical_aim_sensitivity", 0.0015f); // 0.0015f is GTA default setting
336338
DEFAULT("process_priority", 0); // 0-normal 1-above normal 2-high
339+
DEFAULT("mute_master_when_minimized", 0); // 0-off 1-on
337340
DEFAULT("mute_sfx_when_minimized", 0); // 0-off 1-on
338341
DEFAULT("mute_radio_when_minimized", 0); // 0-off 1-on
339342
DEFAULT("mute_mta_when_minimized", 0); // 0-off 1-on

Client/core/CCore.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ CCore::~CCore(void)
184184
// Destroy tray icon
185185
delete m_pTrayIcon;
186186

187+
// Reset GTA volume levels by ignoring master level
188+
m_pLocalGUI->GetMainMenu()->GetSettingsWindow()->ResetGTAVolume();
189+
187190
// Delete the mod manager
188191
delete m_pModManager;
189192
SAFE_DELETE(m_pMessageBox);

Client/core/CSettings.cpp

Lines changed: 170 additions & 67 deletions
Large diffs are not rendered by default.

Client/core/CSettings.h

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,20 +212,26 @@ class CSettings
212212
CGUILabel* m_pCachePathLabel;
213213
CGUILabel* m_pCachePathValue;
214214
CGUIButton* m_pCachePathShowButton;
215+
CGUILabel* m_pLabelMasterVolume;
215216
CGUILabel* m_pLabelRadioVolume;
216217
CGUILabel* m_pLabelSFXVolume;
217218
CGUILabel* m_pLabelMTAVolume;
218219
CGUILabel* m_pLabelVoiceVolume;
220+
CGUILabel* m_pLabelMasterVolumeValue;
219221
CGUILabel* m_pLabelRadioVolumeValue;
220222
CGUILabel* m_pLabelSFXVolumeValue;
221223
CGUILabel* m_pLabelMTAVolumeValue;
222224
CGUILabel* m_pLabelVoiceVolumeValue;
225+
CGUIScrollBar* m_pAudioMasterVolume;
223226
CGUIScrollBar* m_pAudioRadioVolume;
224227
CGUIScrollBar* m_pAudioSFXVolume;
225228
CGUIScrollBar* m_pAudioMTAVolume;
226229
CGUIScrollBar* m_pAudioVoiceVolume;
230+
CGUILabel* m_pAudioRadioLabel;
227231
CGUICheckBox* m_pCheckBoxAudioEqualizer;
228232
CGUICheckBox* m_pCheckBoxAudioAutotune;
233+
CGUILabel* m_pAudioMuteLabel;
234+
CGUICheckBox* m_pCheckBoxMuteMaster;
229235
CGUICheckBox* m_pCheckBoxMuteSFX;
230236
CGUICheckBox* m_pCheckBoxMuteRadio;
231237
CGUICheckBox* m_pCheckBoxMuteMTA;
@@ -336,6 +342,7 @@ class CSettings
336342
bool OnBrightnessChanged(CGUIElement* pElement);
337343
bool OnAnisotropicChanged(CGUIElement* pElement);
338344
bool OnMapAlphaChanged(CGUIElement* pElement);
345+
bool OnMasterVolumeChanged(CGUIElement* pElement);
339346
bool OnRadioVolumeChanged(CGUIElement* pElement);
340347
bool OnSFXVolumeChanged(CGUIElement* pElement);
341348
bool OnMTAVolumeChanged(CGUIElement* pElement);
@@ -392,28 +399,43 @@ class CSettings
392399
int GetMilliseconds(CGUIEdit* pEdit);
393400
void SetMilliseconds(CGUIEdit* pEdit, int milliseconds);
394401

402+
void ResetGTAVolume();
403+
void SetRadioVolume(float fVolume);
404+
void SetSFXVolume(float fVolume);
405+
395406
unsigned int m_uiCaptureKey;
396407
bool m_bCaptureKey;
397408
bool m_bCaptureAxis;
398409

399410
bool m_bIsModLoaded;
400411

401-
unsigned char m_ucOldRadioVolume;
402-
unsigned char m_ucOldSFXVolume;
403-
float m_fOldMTAVolume;
404-
float m_fOldVoiceVolume;
412+
float m_fRadioVolume;
413+
float m_fSFXVolume;
405414

406-
CGUIListItem* m_pSelectedBind;
415+
float m_fOldMasterVolume;
416+
float m_fOldRadioVolume;
417+
float m_fOldSFXVolume;
418+
float m_fOldMTAVolume;
419+
float m_fOldVoiceVolume;
407420

408-
DWORD m_dwFrameCount;
409-
bool m_bShownVolumetricShadowsWarning;
410-
bool m_bShownAllowScreenUploadMessage;
411-
int m_iMaxAnisotropic;
421+
bool m_bOldMuteMaster;
422+
bool m_bOldMuteSFX;
423+
bool m_bOldMuteRadio;
424+
bool m_bOldMuteMTA;
425+
bool m_bOldMuteVoice;
412426

427+
bool m_bMuteMaster;
413428
bool m_bMuteSFX;
414429
bool m_bMuteRadio;
415430
bool m_bMuteMTA;
416431
bool m_bMuteVoice;
417432

433+
CGUIListItem* m_pSelectedBind;
434+
435+
DWORD m_dwFrameCount;
436+
bool m_bShownVolumetricShadowsWarning;
437+
bool m_bShownAllowScreenUploadMessage;
438+
int m_iMaxAnisotropic;
439+
418440
std::list<SKeyBindSection*> m_pKeyBindSections;
419441
};

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3910,14 +3910,16 @@ void CClientGame::IdleHandler(void)
39103910
CLuaArguments Arguments;
39113911
m_pRootEntity->CallEvent("onClientMinimize", Arguments, false);
39123912

3913+
bool bMuteAny = g_pCore->GetCVars()->GetValue<bool>("mute_master_when_minimized");
3914+
39133915
// Apply mute on minimize options
3914-
if (g_pCore->GetCVars()->GetValue<bool>("mute_sfx_when_minimized"))
3916+
if (bMuteAny || g_pCore->GetCVars()->GetValue<bool>("mute_sfx_when_minimized"))
39153917
g_pGame->GetAudio()->SetEffectsMasterVolume(0);
39163918

3917-
if (g_pCore->GetCVars()->GetValue<bool>("mute_radio_when_minimized"))
3919+
if (bMuteAny || g_pCore->GetCVars()->GetValue<bool>("mute_radio_when_minimized"))
39183920
g_pGame->GetAudio()->SetMusicMasterVolume(0);
39193921

3920-
if (g_pCore->GetCVars()->GetValue<bool>("mute_mta_when_minimized"))
3922+
if (bMuteAny || g_pCore->GetCVars()->GetValue<bool>("mute_mta_when_minimized"))
39213923
m_pManager->GetSoundManager()->SetMinimizeMuted(true);
39223924
}
39233925
}

Client/mods/deathmatch/logic/CClientPlayerVoice.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ CClientPlayerVoice::CClientPlayerVoice(CClientPlayer* pPlayer, CVoiceRecorder* p
3535
// Get initial voice volume
3636
m_fVolume = 1.0f;
3737
g_pCore->GetCVars()->Get("voicevolume", m_fVolumeScale);
38+
m_fVolumeScale *= g_pCore->GetCVars()->GetValue<float>("mastervolume");
3839

3940
m_fVolume = m_fVolume * m_fVolumeScale;
4041

@@ -114,6 +115,7 @@ void CClientPlayerVoice::DoPulse(void)
114115
m_CS.Lock();
115116
float fPreviousVolume = 0.0f;
116117
g_pCore->GetCVars()->Get("voicevolume", fPreviousVolume);
118+
fPreviousVolume *= g_pCore->GetCVars()->GetValue<float>("mastervolume");
117119
m_CS.Unlock();
118120

119121
if (fPreviousVolume != m_fVolumeScale && m_pPlayer->IsLocalPlayer() == false)

Client/mods/deathmatch/logic/CClientSoundManager.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,14 @@ int CClientSoundManager::GetFxEffectFromName(const std::string& strEffectName)
258258

259259
void CClientSoundManager::UpdateVolume()
260260
{
261-
// set our master sound volume if the cvar changed
261+
// set our mta or master sound volume if the cvar changed
262262
float fValue = 0.0f;
263263
if (!m_bMinimizeMuted)
264264
{
265265
if (g_pCore->GetCVars()->Get("mtavolume", fValue))
266266
{
267+
fValue *= g_pCore->GetCVars()->GetValue<float>("mastervolume");
268+
267269
if (fValue * 10000 == BASS_GetConfig(BASS_CONFIG_GVOL_STREAM))
268270
return;
269271

0 commit comments

Comments
 (0)