diff --git a/libs/s25main/Settings.cpp b/libs/s25main/Settings.cpp index bbf93f0b99..9a2a3a9517 100644 --- a/libs/s25main/Settings.cpp +++ b/libs/s25main/Settings.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -116,6 +116,7 @@ void Settings::LoadDefaults() sound.musicVolume = 30; sound.effectsEnabled = true; sound.effectsVolume = 75; + sound.birdsEnabled = true; sound.playlist = s25::files::defaultPlaylist; // } @@ -173,7 +174,7 @@ void Settings::LoadIngameDefaults() } /////////////////////////////////////////////////////////////////////////////// -// Routine zum Laden der Konfiguration +// Routine for loading the configuration void Settings::Load() { libsiedler2::Archiv settings; @@ -200,13 +201,13 @@ void Settings::Load() const libsiedler2::ArchivItem_Ini* iniAddons = static_cast(settings.find("addons")); - // ist eine der Kategorien nicht vorhanden? + // Is one of the categories missing? if(!iniGlobal || !iniVideo || !iniLanguage || !iniDriver || !iniSound || !iniLobby || !iniServer || !iniProxy || !iniInterface || !iniAddons) { throw std::runtime_error("Missing section"); } - // stimmt die Settingsversion? + // Is the settings version correct? if(iniGlobal->getValue("version", 0) != VERSION) throw std::runtime_error("Wrong version"); @@ -258,6 +259,7 @@ void Settings::Load() sound.musicVolume = iniSound->getIntValue("musik_volume"); sound.effectsEnabled = iniSound->getBoolValue("effekte"); sound.effectsVolume = iniSound->getIntValue("effekte_volume"); + sound.birdsEnabled = iniSound->getValue("bird_sounds", true); sound.playlist = iniSound->getValue("playlist"); // } @@ -293,14 +295,14 @@ void Settings::Load() proxy.type = ProxyType(iniProxy->getIntValue("typ")); // } - // leere proxyadresse deaktiviert proxy komplett - // deaktivierter proxy entfernt proxyadresse + // Empty proxy address completely disables proxy. + // Disabled proxy removes proxy address. if(proxy.hostname.empty() || (proxy.type != ProxyType::Socks4 && proxy.type != ProxyType::Socks5)) { proxy.type = ProxyType::None; proxy.hostname.clear(); } - // aktivierter Socks v4 deaktiviert ipv6 + // Enabled Socks v4 disables IPv6 else if(proxy.type == ProxyType::Socks4 && server.ipv6) server.ipv6 = false; @@ -380,7 +382,7 @@ void Settings::LoadIngame() } /////////////////////////////////////////////////////////////////////////////// -// Routine zum Speichern der Konfiguration +// Routine for saving the configuration void Settings::Save() { libsiedler2::Archiv settings; @@ -399,7 +401,7 @@ void Settings::Save() libsiedler2::ArchivItem_Ini* iniInterface = static_cast(settings.find("interface")); libsiedler2::ArchivItem_Ini* iniAddons = static_cast(settings.find("addons")); - // ist eine der Kategorien nicht vorhanden? + // Is one of the categories missing? RTTR_Assert(iniGlobal && iniVideo && iniLanguage && iniDriver && iniSound && iniLobby && iniServer && iniProxy && iniInterface && iniAddons); @@ -444,6 +446,7 @@ void Settings::Save() iniSound->setValue("musik_volume", sound.musicVolume); iniSound->setValue("effekte", sound.effectsEnabled); iniSound->setValue("effekte_volume", sound.effectsVolume); + iniSound->setValue("bird_sounds", sound.birdsEnabled); iniSound->setValue("playlist", sound.playlist); // } diff --git a/libs/s25main/Settings.h b/libs/s25main/Settings.h index b9a8645459..05985335ef 100644 --- a/libs/s25main/Settings.h +++ b/libs/s25main/Settings.h @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -83,6 +83,7 @@ class Settings : public Singleton uint8_t musicVolume; bool effectsEnabled; uint8_t effectsVolume; + bool birdsEnabled; std::string playlist; /// musicplayer playlist name } sound; diff --git a/libs/s25main/SoundManager.cpp b/libs/s25main/SoundManager.cpp index 011a79624f..81e1ea1e2c 100644 --- a/libs/s25main/SoundManager.cpp +++ b/libs/s25main/SoundManager.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -96,7 +96,7 @@ void SoundManager::playAnimalSound(unsigned soundLstId) void SoundManager::playBirdSounds(const unsigned treeCount) { - if(!SETTINGS.sound.effectsEnabled) + if(!SETTINGS.sound.effectsEnabled || !SETTINGS.sound.birdsEnabled) return; using namespace std::chrono; diff --git a/libs/s25main/desktops/dskOptions.cpp b/libs/s25main/desktops/dskOptions.cpp index aafc3417b4..92bc6f6955 100644 --- a/libs/s25main/desktops/dskOptions.cpp +++ b/libs/s25main/desktops/dskOptions.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -99,6 +99,8 @@ enum ID_txtCommonPortrait, ID_btCommonPortrait, ID_cbCommonPortrait, + ID_txtBirdSounds, + ID_grpBirdSounds, }; // Use these as IDs in dedicated groups constexpr auto ID_btOn = 1; @@ -231,11 +233,11 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) ipv6->AddTextButton(ID_btOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("IPv6"), NormalFont); ipv6->AddTextButton(ID_btOff, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("IPv4"), NormalFont); ipv6->SetSelection(SETTINGS.server.ipv6); - // ipv6-feld ggf (de-)aktivieren + // Enable/disable the IPv6 field if necessary ipv6->GetCtrl(1)->SetEnabled(SETTINGS.proxy.type != ProxyType::Socks5); //-V807 curPos.y += rowHeight + sectionSpacingCommon; - // Proxyserver + // Proxy server groupCommon->AddText(ID_txtProxy, curPos, _("Proxyserver:"), COLOR_YELLOW, FontStyle{}, NormalFont); ctrlEdit* proxy = groupCommon->AddEdit(ID_edtProxy, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont); proxy->SetText(SETTINGS.proxy.hostname); @@ -252,7 +254,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) upnp->SetSelection(SETTINGS.global.use_upnp); curPos.y += rowHeight; - // Proxytyp + // Proxy type groupCommon->AddText(ID_txtProxyType, curPos, _("Proxytyp:"), COLOR_YELLOW, FontStyle{}, NormalFont); combo = groupCommon->AddComboBox(ID_cbProxyType, curPos + ctrlOffset, ctrlSizeLarge, TextureColor::Grey, NormalFont, 100); @@ -359,16 +361,6 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) constexpr Offset volOffset(400, -5); constexpr Extent ctrlSizeSmall(90, ctrlSize.y); - groupSound->AddText(ID_txtMusic, curPos, _("Music"), COLOR_YELLOW, FontStyle{}, NormalFont); - mainGroup = groupSound->AddOptionGroup(ID_grpMusic, GroupSelectType::Check); - mainGroup->AddTextButton(ID_btOn, curPos + bt1Offset, ctrlSizeSmall, TextureColor::Grey, _("On"), NormalFont); - mainGroup->AddTextButton(ID_btOff, curPos + bt2Offset, ctrlSizeSmall, TextureColor::Grey, _("Off"), NormalFont); - - ctrlProgress* Mvolume = - groupSound->AddProgress(ID_pgMusicVol, curPos + volOffset, ctrlSize, TextureColor::Grey, 139, 138, 100); - Mvolume->SetPosition((SETTINGS.sound.musicVolume * 100) / 255); //-V807 - curPos.y += rowHeight + sectionSpacing; - groupSound->AddText(ID_txtEffects, curPos, _("Effects"), COLOR_YELLOW, FontStyle{}, NormalFont); mainGroup = groupSound->AddOptionGroup(ID_grpEffects, GroupSelectType::Check); mainGroup->AddTextButton(ID_btOn, curPos + bt1Offset, ctrlSizeSmall, TextureColor::Grey, _("On"), NormalFont); @@ -379,6 +371,22 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) FXvolume->SetPosition((SETTINGS.sound.effectsVolume * 100) / 255); curPos.y += rowHeight + sectionSpacing; + groupSound->AddText(ID_txtBirdSounds, curPos, _("Bird sounds"), COLOR_YELLOW, FontStyle{}, NormalFont); + mainGroup = groupSound->AddOptionGroup(ID_grpBirdSounds, GroupSelectType::Check); + mainGroup->AddTextButton(ID_btOn, curPos + bt1Offset, ctrlSizeSmall, TextureColor::Grey, _("On"), NormalFont); + mainGroup->AddTextButton(ID_btOff, curPos + bt2Offset, ctrlSizeSmall, TextureColor::Grey, _("Off"), NormalFont); + curPos.y += rowHeight + sectionSpacing; + + groupSound->AddText(ID_txtMusic, curPos, _("Music"), COLOR_YELLOW, FontStyle{}, NormalFont); + mainGroup = groupSound->AddOptionGroup(ID_grpMusic, GroupSelectType::Check); + mainGroup->AddTextButton(ID_btOn, curPos + bt1Offset, ctrlSizeSmall, TextureColor::Grey, _("On"), NormalFont); + mainGroup->AddTextButton(ID_btOff, curPos + bt2Offset, ctrlSizeSmall, TextureColor::Grey, _("Off"), NormalFont); + + ctrlProgress* Mvolume = + groupSound->AddProgress(ID_pgMusicVol, curPos + volOffset, ctrlSize, TextureColor::Grey, 139, 138, 100); + Mvolume->SetPosition((SETTINGS.sound.musicVolume * 100) / 255); //-V807 + curPos.y += rowHeight + sectionSpacing; + groupSound->AddTextButton(ID_btMusicPlayer, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Music player"), NormalFont); curPos.y += rowHeight + sectionSpacing; @@ -396,7 +404,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) combo->SetSelection(combo->GetNumItems() - 1); } - // "Allgemein" auswählen + // Select "General" mainGroup = GetCtrl(ID_grpOptions); mainGroup->SetSelection(ID_btCommon, true); @@ -405,7 +413,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) loadVideoModes(); - // Und zu der Combobox hinzufügen + // and add to the combo box ctrlComboBox& cbVideoModes = *groupGraphics->GetCtrl(ID_cbResolution); for(const auto& videoMode : video_modes) { @@ -420,15 +428,15 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) cbVideoModes.AddString(str.str()); - // Ist das die aktuelle Auflösung? Dann selektieren + // Select, if this is the current resolution if(videoMode == SETTINGS.video.fullscreenSize) //-V807 cbVideoModes.SetSelection(cbVideoModes.GetNumItems() - 1); } - // "Vollbild" setzen + // Set "Fullscreen" groupGraphics->GetCtrl(ID_grpFullscreen)->SetSelection(SETTINGS.video.fullscreen); //-V807 - // "Limit Framerate" füllen + // Fill "Limit Framerate" auto* cbFrameRate = groupGraphics->GetCtrl(ID_cbFramerate); if(VIDEODRIVER.HasVSync()) cbFrameRate->AddString(_("Dynamic (Limits to display refresh rate, works with most drivers)")); @@ -452,8 +460,9 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) // Sound // { - groupSound->GetCtrl(ID_grpMusic)->SetSelection(SETTINGS.sound.musicEnabled); groupSound->GetCtrl(ID_grpEffects)->SetSelection(SETTINGS.sound.effectsEnabled); + groupSound->GetCtrl(ID_grpBirdSounds)->SetSelection(SETTINGS.sound.birdsEnabled); + groupSound->GetCtrl(ID_grpMusic)->SetSelection(SETTINGS.sound.musicEnabled); // } @@ -511,7 +520,7 @@ void dskOptions::Msg_Group_ComboSelectItem(const unsigned group_id, const unsign case 2: SETTINGS.proxy.type = ProxyType::Socks5; break; } - // ipv6 gleich sichtbar deaktivieren + // Disable IPv6 visually if(SETTINGS.proxy.type == ProxyType::Socks4 && SETTINGS.server.ipv6) { GetCtrl(ID_grpCommon)->GetCtrl(ID_grpIpv6)->SetSelection(0); @@ -560,6 +569,8 @@ void dskOptions::Msg_Group_OptionGroupChange(const unsigned /*group_id*/, const case ID_grpFullscreen: SETTINGS.video.fullscreen = enabled; break; case ID_grpVBO: SETTINGS.video.vbo = enabled; break; case ID_grpOptTextures: SETTINGS.video.shared_textures = enabled; break; + case ID_grpEffects: SETTINGS.sound.effectsEnabled = enabled; break; + case ID_grpBirdSounds: SETTINGS.sound.birdsEnabled = enabled; break; case ID_grpMusic: SETTINGS.sound.musicEnabled = enabled; if(enabled) @@ -567,7 +578,6 @@ void dskOptions::Msg_Group_OptionGroupChange(const unsigned /*group_id*/, const else MUSICPLAYER.Stop(); break; - case ID_grpEffects: SETTINGS.sound.effectsEnabled = enabled; break; case ID_grpDebugData: // Special case: Uses e.g. ID_btSubmitDebugOn directly SETTINGS.global.submit_debug_data = selection; @@ -615,7 +625,7 @@ void dskOptions::Msg_ButtonClick(const unsigned ctrl_id) { auto* groupCommon = GetCtrl(ID_grpCommon); - // Name abspeichern + // Save the name SETTINGS.lobby.name = groupCommon->GetCtrl(ID_edtName)->GetText(); if(!validatePort(groupCommon->GetCtrl(ID_edtPort)->GetText(), SETTINGS.server.localPort)) return; diff --git a/libs/s25main/ingameWindows/iwOptionsWindow.cpp b/libs/s25main/ingameWindows/iwOptionsWindow.cpp index a5bf028dd4..0436ce310c 100644 --- a/libs/s25main/ingameWindows/iwOptionsWindow.cpp +++ b/libs/s25main/ingameWindows/iwOptionsWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -9,6 +9,7 @@ #include "Settings.h" #include "SoundManager.h" #include "WindowManager.h" +#include "controls/ctrlCheck.h" #include "controls/ctrlImageButton.h" #include "controls/ctrlProgress.h" #include "drivers/AudioDriverWrapper.h" @@ -41,16 +42,17 @@ enum ID_btMusicPlayer, ID_btAdvanced, ID_btSurrender, - ID_btEndGame + ID_btEndGame, + ID_cpBirdSounds }; } iwOptionsWindow::iwOptionsWindow(SoundManager& soundManager) - : IngameWindow(CGI_OPTIONSWINDOW, IngameWindow::posLastOrCenter, Extent(300, 515), _("Game menu"), + : IngameWindow(CGI_OPTIONSWINDOW, IngameWindow::posLastOrCenter, Extent(300, 545), _("Game menu"), LOADER.GetImageN("resource", 41)), soundManager(soundManager) { - // Der Soldat oben + // The soldier on top AddImage(ID_imgSoldier, DrawPoint(150, 36), LOADER.GetImageN("io", 30)); AddText(ID_txtRttr, DrawPoint(150, 60), "Return To The Roots", COLOR_YELLOW, FontStyle::CENTER, NormalFont); @@ -69,37 +71,38 @@ iwOptionsWindow::iwOptionsWindow(SoundManager& soundManager) AddImageButton(ID_btReadme, DrawPoint(35, 160), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 79)); AddText(ID_txtReadme, DrawPoint(85, 180), _("Load 'ReadMe' file"), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont); - // "Spiel laden!" // TODO: Implement // AddImageButton( 8, DrawPoint(35, 210), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 48)); // AddText(9, DrawPoint(85, 230), _("Load game!"), COLOR_YELLOW, 0 | FontStyle::BOTTOM, NormalFont); - // "Spiel speichern!" // TODO: Move back down to y=250 (Button) 270 (Text) after Load button is implemented AddImageButton(ID_btSave, DrawPoint(35, 230), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 47)); AddText(ID_txtSave, DrawPoint(85, 255), _("Save game!"), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont); - // Geräusche an/aus + // Sound on/off AddImageButton(ID_btSoundEffects, DrawPoint(35, 300), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 114 + !SETTINGS.sound.effectsEnabled)); //-V807 - // Musik an/aus - AddImageButton(ID_btMusic, DrawPoint(35, 340), Extent(35, 35), TextureColor::Green2, - LOADER.GetImageN("io", 116 + !SETTINGS.sound.musicEnabled)); - - // Geräuschlautstärke + // Sound volume AddProgress(ID_pgEffectVol, DrawPoint(100, 306), Extent(160, 22), TextureColor::Green2, 139, 138, 100) ->SetPosition((SETTINGS.sound.effectsVolume * 100) / 255); - // Musiklautstärke - AddProgress(ID_pgMusicVol, DrawPoint(100, 346), Extent(160, 22), TextureColor::Green2, 139, 138, 100) + // Bird sounds on/off + AddCheckBox(ID_cpBirdSounds, DrawPoint(100, 342), Extent(160, 22), TextureColor::Green2, _("Bird sounds"), NormalFont, false) + ->setChecked(SETTINGS.sound.birdsEnabled); + + // Music on/off + AddImageButton(ID_btMusic, DrawPoint(35, 371), Extent(35, 35), TextureColor::Green2, + LOADER.GetImageN("io", 116 + !SETTINGS.sound.musicEnabled)); + + // Music volume + AddProgress(ID_pgMusicVol, DrawPoint(100, 377), Extent(160, 22), TextureColor::Green2, 139, 138, 100) ->SetPosition((SETTINGS.sound.musicVolume * 100) / 255); - AddTextButton(ID_btMusicPlayer, DrawPoint(100, 380), Extent(160, 22), TextureColor::Green2, _("Music player"), - NormalFont); - AddTextButton(ID_btAdvanced, DrawPoint(67, 412), Extent(168, 24), TextureColor::Green2, _("Advanced"), NormalFont); - AddTextButton(ID_btSurrender, DrawPoint(67, 443), Extent(168, 24), TextureColor::Red1, _("Surrender"), NormalFont); - AddTextButton(ID_btEndGame, DrawPoint(67, 474), Extent(168, 24), TextureColor::Red1, _("End game"), NormalFont); + AddTextButton(ID_btMusicPlayer, DrawPoint(100, 413), Extent(160, 22), TextureColor::Green2, _("Music player"), NormalFont); + AddTextButton(ID_btAdvanced, DrawPoint(67, 442), Extent(168, 24), TextureColor::Green2, _("Advanced"), NormalFont); + AddTextButton(ID_btSurrender, DrawPoint(67, 473), Extent(168, 24), TextureColor::Red1, _("Surrender"), NormalFont); + AddTextButton(ID_btEndGame, DrawPoint(67, 504), Extent(168, 24), TextureColor::Red1, _("End game"), NormalFont); } void iwOptionsWindow::Msg_ButtonClick(const unsigned ctrl_id) @@ -160,3 +163,15 @@ void iwOptionsWindow::Msg_ProgressChange(const unsigned ctrl_id, const unsigned break; } } + +void iwOptionsWindow::Msg_CheckboxChange(const unsigned ctrl_id, const bool checked) +{ + switch(ctrl_id) + { + case ID_cpBirdSounds: + { + SETTINGS.sound.birdsEnabled = checked; + break; + } + } +} diff --git a/libs/s25main/ingameWindows/iwOptionsWindow.h b/libs/s25main/ingameWindows/iwOptionsWindow.h index 50f9a87369..6671da7e79 100644 --- a/libs/s25main/ingameWindows/iwOptionsWindow.h +++ b/libs/s25main/ingameWindows/iwOptionsWindow.h @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -18,4 +18,5 @@ class iwOptionsWindow : public IngameWindow private: void Msg_ButtonClick(unsigned ctrl_id) override; void Msg_ProgressChange(unsigned ctrl_id, unsigned short position) override; + void Msg_CheckboxChange(unsigned ctrl_id, bool checked) override; }; diff --git a/libs/s25main/notifications/NotificationManager.h b/libs/s25main/notifications/NotificationManager.h index 3097dd42b2..ef85ba2a1a 100644 --- a/libs/s25main/notifications/NotificationManager.h +++ b/libs/s25main/notifications/NotificationManager.h @@ -7,6 +7,7 @@ #include "notifications/Subscription.h" #include #include +#include #include class NotificationManager