From b9001dfb550ecf4a93649c45425684800876cbc7 Mon Sep 17 00:00:00 2001 From: Pablo-Dallegri Date: Fri, 7 May 2021 10:29:49 -0300 Subject: [PATCH 1/5] Rename cg_alerts to cg_alerts_show --- Resources/Scripts/Gui/Preferences.as | 2 +- Sources/Client/Client_Input.cpp | 8 ++++---- Sources/Client/Client_Update.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Resources/Scripts/Gui/Preferences.as b/Resources/Scripts/Gui/Preferences.as index 1fffb620..090d46b4 100644 --- a/Resources/Scripts/Gui/Preferences.as +++ b/Resources/Scripts/Gui/Preferences.as @@ -660,7 +660,7 @@ namespace spades { layouter.AddHeading(_Tr("Preferences", "Feedbacks")); layouter.AddVolumeSlider(_Tr("Preferences", "Chat Notify Sounds"), "cg_chatBeep"); layouter.AddToggleField(_Tr("Preferences", "Hit Indicator"), "cg_hitIndicator"); - layouter.AddToggleField(_Tr("Preferences", "Show Alerts"), "cg_alerts"); + layouter.AddToggleField(_Tr("Preferences", "Show Alerts"), "cg_alerts_show"); layouter.AddHeading(_Tr("Preferences", "AoS 0.75/0.76 Compatibility")); layouter.AddToggleField(_Tr("Preferences", "Allow Unicode"), "cg_unicode"); diff --git a/Sources/Client/Client_Input.cpp b/Sources/Client/Client_Input.cpp index 4031cf47..e737a135 100644 --- a/Sources/Client/Client_Input.cpp +++ b/Sources/Client/Client_Input.cpp @@ -82,7 +82,7 @@ DEFINE_SPADES_SETTING(cg_keySaveMap, "8"); DEFINE_SPADES_SETTING(cg_switchToolByWheel, "1"); DEFINE_SPADES_SETTING(cg_debugCorpse, "0"); -DEFINE_SPADES_SETTING(cg_alerts, "1"); +DEFINE_SPADES_SETTING(cg_alerts_show, "1"); SPADES_SETTING(cg_manualFocus); DEFINE_SPADES_SETTING(cg_keyAutoFocus, "MiddleMouseButton"); @@ -481,7 +481,7 @@ namespace spades { if (world->GetLocalPlayer()->IsToolSelectable(Player::ToolBlock)) { SetSelectedTool(Player::ToolBlock); } else { - if (cg_alerts) + if (cg_alerts_show) ShowAlert(_Tr("Client", "Out of Blocks"), AlertType::Error); else PlayAlertSound(); @@ -493,7 +493,7 @@ namespace spades { if (world->GetLocalPlayer()->IsToolSelectable(Player::ToolWeapon)) { SetSelectedTool(Player::ToolWeapon); } else { - if (cg_alerts) + if (cg_alerts_show) ShowAlert(_Tr("Client", "Out of Ammo"), AlertType::Error); else PlayAlertSound(); @@ -505,7 +505,7 @@ namespace spades { if (world->GetLocalPlayer()->IsToolSelectable(Player::ToolGrenade)) { SetSelectedTool(Player::ToolGrenade); } else { - if (cg_alerts) + if (cg_alerts_show) ShowAlert(_Tr("Client", "Out of Grenades"), AlertType::Error); else PlayAlertSound(); diff --git a/Sources/Client/Client_Update.cpp b/Sources/Client/Client_Update.cpp index ca07115a..38d9b2e5 100644 --- a/Sources/Client/Client_Update.cpp +++ b/Sources/Client/Client_Update.cpp @@ -53,7 +53,7 @@ SPADES_SETTING(cg_blood); DEFINE_SPADES_SETTING(cg_ejectBrass, "1"); DEFINE_SPADES_SETTING(cg_hitFeedbackSoundGain, "0.2"); -SPADES_SETTING(cg_alerts); +SPADES_SETTING(cg_alerts_show); SPADES_SETTING(cg_centerMessage); SPADES_SETTING(cg_shake); @@ -1276,7 +1276,7 @@ namespace spades { void Client::LocalPlayerBuildError(BuildFailureReason reason) { SPADES_MARK_FUNCTION(); - if (!cg_alerts) { + if (!cg_alerts_show) { PlayAlertSound(); return; } From 3349ac54abbff192c1bc44fd7fa411f9b3d33887 Mon Sep 17 00:00:00 2001 From: Pablo-Dallegri Date: Fri, 7 May 2021 11:00:17 -0300 Subject: [PATCH 2/5] Add alerts volume slider --- Resources/Scripts/Gui/Preferences.as | 1 + Sources/Client/Client.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Resources/Scripts/Gui/Preferences.as b/Resources/Scripts/Gui/Preferences.as index 090d46b4..c49f1083 100644 --- a/Resources/Scripts/Gui/Preferences.as +++ b/Resources/Scripts/Gui/Preferences.as @@ -661,6 +661,7 @@ namespace spades { layouter.AddVolumeSlider(_Tr("Preferences", "Chat Notify Sounds"), "cg_chatBeep"); layouter.AddToggleField(_Tr("Preferences", "Hit Indicator"), "cg_hitIndicator"); layouter.AddToggleField(_Tr("Preferences", "Show Alerts"), "cg_alerts_show"); + layouter.AddVolumeSlider(_Tr("Preferences", "Alerts Sounds"), "cg_alerts_volume"); layouter.AddHeading(_Tr("Preferences", "AoS 0.75/0.76 Compatibility")); layouter.AddToggleField(_Tr("Preferences", "Allow Unicode"), "cg_unicode"); diff --git a/Sources/Client/Client.cpp b/Sources/Client/Client.cpp index acf3984f..221ebb11 100644 --- a/Sources/Client/Client.cpp +++ b/Sources/Client/Client.cpp @@ -56,6 +56,7 @@ #include "NetClient.h" DEFINE_SPADES_SETTING(cg_chatBeep, "1"); +DEFINE_SPADES_SETTING(cg_alerts_volume, "1"); DEFINE_SPADES_SETTING(cg_serverAlert, "1"); @@ -537,7 +538,9 @@ namespace spades { void Client::PlayAlertSound() { Handle chunk = audioDevice->RegisterSound("Sounds/Feedback/Alert.opus"); - audioDevice->PlayLocal(chunk.GetPointerOrNull(), AudioParam()); + AudioParam params; + params.volume = (float)cg_alerts_volume; + audioDevice->PlayLocal(chunk.GetPointerOrNull(), params); } /** Records chat message/game events to the log file. */ From 4fd3329c1d921aac98352436cd166e0359840969 Mon Sep 17 00:00:00 2001 From: Pablo-Dallegri Date: Fri, 7 May 2021 11:46:14 -0300 Subject: [PATCH 3/5] Revert cg_alerts renaming --- Resources/Scripts/Gui/Preferences.as | 2 +- Sources/Client/Client_Input.cpp | 8 ++++---- Sources/Client/Client_Update.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Resources/Scripts/Gui/Preferences.as b/Resources/Scripts/Gui/Preferences.as index c49f1083..386fd021 100644 --- a/Resources/Scripts/Gui/Preferences.as +++ b/Resources/Scripts/Gui/Preferences.as @@ -660,7 +660,7 @@ namespace spades { layouter.AddHeading(_Tr("Preferences", "Feedbacks")); layouter.AddVolumeSlider(_Tr("Preferences", "Chat Notify Sounds"), "cg_chatBeep"); layouter.AddToggleField(_Tr("Preferences", "Hit Indicator"), "cg_hitIndicator"); - layouter.AddToggleField(_Tr("Preferences", "Show Alerts"), "cg_alerts_show"); + layouter.AddToggleField(_Tr("Preferences", "Show Alerts"), "cg_alerts"); layouter.AddVolumeSlider(_Tr("Preferences", "Alerts Sounds"), "cg_alerts_volume"); layouter.AddHeading(_Tr("Preferences", "AoS 0.75/0.76 Compatibility")); diff --git a/Sources/Client/Client_Input.cpp b/Sources/Client/Client_Input.cpp index e737a135..4031cf47 100644 --- a/Sources/Client/Client_Input.cpp +++ b/Sources/Client/Client_Input.cpp @@ -82,7 +82,7 @@ DEFINE_SPADES_SETTING(cg_keySaveMap, "8"); DEFINE_SPADES_SETTING(cg_switchToolByWheel, "1"); DEFINE_SPADES_SETTING(cg_debugCorpse, "0"); -DEFINE_SPADES_SETTING(cg_alerts_show, "1"); +DEFINE_SPADES_SETTING(cg_alerts, "1"); SPADES_SETTING(cg_manualFocus); DEFINE_SPADES_SETTING(cg_keyAutoFocus, "MiddleMouseButton"); @@ -481,7 +481,7 @@ namespace spades { if (world->GetLocalPlayer()->IsToolSelectable(Player::ToolBlock)) { SetSelectedTool(Player::ToolBlock); } else { - if (cg_alerts_show) + if (cg_alerts) ShowAlert(_Tr("Client", "Out of Blocks"), AlertType::Error); else PlayAlertSound(); @@ -493,7 +493,7 @@ namespace spades { if (world->GetLocalPlayer()->IsToolSelectable(Player::ToolWeapon)) { SetSelectedTool(Player::ToolWeapon); } else { - if (cg_alerts_show) + if (cg_alerts) ShowAlert(_Tr("Client", "Out of Ammo"), AlertType::Error); else PlayAlertSound(); @@ -505,7 +505,7 @@ namespace spades { if (world->GetLocalPlayer()->IsToolSelectable(Player::ToolGrenade)) { SetSelectedTool(Player::ToolGrenade); } else { - if (cg_alerts_show) + if (cg_alerts) ShowAlert(_Tr("Client", "Out of Grenades"), AlertType::Error); else PlayAlertSound(); diff --git a/Sources/Client/Client_Update.cpp b/Sources/Client/Client_Update.cpp index 38d9b2e5..ca07115a 100644 --- a/Sources/Client/Client_Update.cpp +++ b/Sources/Client/Client_Update.cpp @@ -53,7 +53,7 @@ SPADES_SETTING(cg_blood); DEFINE_SPADES_SETTING(cg_ejectBrass, "1"); DEFINE_SPADES_SETTING(cg_hitFeedbackSoundGain, "0.2"); -SPADES_SETTING(cg_alerts_show); +SPADES_SETTING(cg_alerts); SPADES_SETTING(cg_centerMessage); SPADES_SETTING(cg_shake); @@ -1276,7 +1276,7 @@ namespace spades { void Client::LocalPlayerBuildError(BuildFailureReason reason) { SPADES_MARK_FUNCTION(); - if (!cg_alerts_show) { + if (!cg_alerts) { PlayAlertSound(); return; } From b6e0153e6263549e58b4ea0f161a9881240c2eb3 Mon Sep 17 00:00:00 2001 From: Pablo-Dallegri Date: Fri, 7 May 2021 11:52:16 -0300 Subject: [PATCH 4/5] Rename new cvar --- Resources/Scripts/Gui/Preferences.as | 2 +- Sources/Client/Client.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Resources/Scripts/Gui/Preferences.as b/Resources/Scripts/Gui/Preferences.as index 386fd021..9de09cc1 100644 --- a/Resources/Scripts/Gui/Preferences.as +++ b/Resources/Scripts/Gui/Preferences.as @@ -661,7 +661,7 @@ namespace spades { layouter.AddVolumeSlider(_Tr("Preferences", "Chat Notify Sounds"), "cg_chatBeep"); layouter.AddToggleField(_Tr("Preferences", "Hit Indicator"), "cg_hitIndicator"); layouter.AddToggleField(_Tr("Preferences", "Show Alerts"), "cg_alerts"); - layouter.AddVolumeSlider(_Tr("Preferences", "Alerts Sounds"), "cg_alerts_volume"); + layouter.AddVolumeSlider(_Tr("Preferences", "Alerts Sounds"), "cg_alertSounds"); layouter.AddHeading(_Tr("Preferences", "AoS 0.75/0.76 Compatibility")); layouter.AddToggleField(_Tr("Preferences", "Allow Unicode"), "cg_unicode"); diff --git a/Sources/Client/Client.cpp b/Sources/Client/Client.cpp index 221ebb11..dd489c9b 100644 --- a/Sources/Client/Client.cpp +++ b/Sources/Client/Client.cpp @@ -56,7 +56,7 @@ #include "NetClient.h" DEFINE_SPADES_SETTING(cg_chatBeep, "1"); -DEFINE_SPADES_SETTING(cg_alerts_volume, "1"); +DEFINE_SPADES_SETTING(cg_alertSounds, "1"); DEFINE_SPADES_SETTING(cg_serverAlert, "1"); @@ -539,7 +539,7 @@ namespace spades { void Client::PlayAlertSound() { Handle chunk = audioDevice->RegisterSound("Sounds/Feedback/Alert.opus"); AudioParam params; - params.volume = (float)cg_alerts_volume; + params.volume = (float)cg_alertSounds; audioDevice->PlayLocal(chunk.GetPointerOrNull(), params); } From a4f3e067d87182135dbac6c13e86280db620d5fa Mon Sep 17 00:00:00 2001 From: Pablo-Dallegri Date: Fri, 7 May 2021 11:56:17 -0300 Subject: [PATCH 5/5] Fix displayed string --- Resources/Scripts/Gui/Preferences.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Scripts/Gui/Preferences.as b/Resources/Scripts/Gui/Preferences.as index 9de09cc1..6cf1bd1e 100644 --- a/Resources/Scripts/Gui/Preferences.as +++ b/Resources/Scripts/Gui/Preferences.as @@ -661,7 +661,7 @@ namespace spades { layouter.AddVolumeSlider(_Tr("Preferences", "Chat Notify Sounds"), "cg_chatBeep"); layouter.AddToggleField(_Tr("Preferences", "Hit Indicator"), "cg_hitIndicator"); layouter.AddToggleField(_Tr("Preferences", "Show Alerts"), "cg_alerts"); - layouter.AddVolumeSlider(_Tr("Preferences", "Alerts Sounds"), "cg_alertSounds"); + layouter.AddVolumeSlider(_Tr("Preferences", "Alert Sounds"), "cg_alertSounds"); layouter.AddHeading(_Tr("Preferences", "AoS 0.75/0.76 Compatibility")); layouter.AddToggleField(_Tr("Preferences", "Allow Unicode"), "cg_unicode");