• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Return-To-The-Roots / s25client / 19082290288

04 Nov 2025 08:43PM UTC coverage: 50.469% (-0.005%) from 50.474%
19082290288

Pull #1817

github

web-flow
Merge d20bb1968 into 7333cc249
Pull Request #1817: Proposal to turn off/on bird sounds

2 of 36 new or added lines in 4 files covered. (5.56%)

7 existing lines in 3 files now uncovered.

22510 of 44602 relevant lines covered (50.47%)

34626.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/libs/s25main/ingameWindows/iwOptionsWindow.cpp
1
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "iwOptionsWindow.h"
6
#include "Loader.h"
7
#include "MusicPlayer.h"
8
#include "RTTR_Version.h"
9
#include "Settings.h"
10
#include "SoundManager.h"
11
#include "WindowManager.h"
12
#include "controls/ctrlImageButton.h"
13
#include "controls/ctrlProgress.h"
14
#include "drivers/AudioDriverWrapper.h"
15
#include "iwEndgame.h"
16
#include "iwMusicPlayer.h"
17
#include "iwSave.h"
18
#include "iwSettings.h"
19
#include "iwSurrender.h"
20
#include "iwTextfile.h"
21
#include "ogl/FontStyle.h"
22
#include "gameData/const_gui_ids.h"
23
#include "controls/ctrlCheck.h"
24

25
namespace {
26
enum
27
{
28
    ID_imgSoldier,
29
    ID_txtRttr,
30
    ID_txtVersion,
31
    ID_txtCopyright,
32
    ID_btKeyboardLayout,
33
    ID_txtKeyboardLayout,
34
    ID_btReadme,
35
    ID_txtReadme,
36
    ID_btSave,
37
    ID_txtSave,
38
    ID_btSoundEffects,
39
    ID_btMusic,
40
    ID_pgEffectVol,
41
    ID_pgMusicVol,
42
    ID_btMusicPlayer,
43
    ID_btAdvanced,
44
    ID_btSurrender,
45
    ID_btEndGame,
46
    ID_cpBirdSounds
47
};
48
}
49

50
iwOptionsWindow::iwOptionsWindow(SoundManager& soundManager)
×
NEW
51
    : IngameWindow(CGI_OPTIONSWINDOW, IngameWindow::posLastOrCenter, Extent(300, 545), _("Game menu"),
×
52
                   LOADER.GetImageN("resource", 41)),
×
53
      soundManager(soundManager)
×
54
{
55
    // The soldier on top
56
    AddImage(ID_imgSoldier, DrawPoint(150, 36), LOADER.GetImageN("io", 30));
×
57

58
    AddText(ID_txtRttr, DrawPoint(150, 60), "Return To The Roots", COLOR_YELLOW, FontStyle::CENTER, NormalFont);
×
59
    AddText(ID_txtVersion, DrawPoint(150, 77), rttr::version::GetReadableVersion(), COLOR_YELLOW, FontStyle::CENTER,
×
60
            NormalFont);
×
61
    AddFormattedText(ID_txtCopyright, DrawPoint(150, 94),
×
62
                     "\xC2\xA9"
63
                     "2005 - %s Settlers Freaks",
64
                     COLOR_YELLOW, FontStyle::CENTER, NormalFont)
×
65
      % rttr::version::GetYear();
×
66

67
    AddImageButton(ID_btKeyboardLayout, DrawPoint(35, 120), Extent(35, 35), TextureColor::Green2,
×
68
                   LOADER.GetImageN("io", 79));
×
69
    AddText(ID_txtKeyboardLayout, DrawPoint(85, 140), _("Keyboard layout"), COLOR_YELLOW, FontStyle::BOTTOM,
×
70
            NormalFont);
×
71
    AddImageButton(ID_btReadme, DrawPoint(35, 160), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 79));
×
72
    AddText(ID_txtReadme, DrawPoint(85, 180), _("Load 'ReadMe' file"), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);
×
73

74
    // "Load game!"
75
    // TODO: Implement
76
    // AddImageButton( 8, DrawPoint(35, 210), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 48));
77
    // AddText(9, DrawPoint(85, 230), _("Load game!"), COLOR_YELLOW, 0 | FontStyle::BOTTOM, NormalFont);
78

79
    // "Save game!"
80
    // TODO: Move back down to y=250 (Button) 270 (Text) after Load button is implemented
81
    AddImageButton(ID_btSave, DrawPoint(35, 230), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 47));
×
82
    AddText(ID_txtSave, DrawPoint(85, 255), _("Save game!"), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);
×
83

84
    // Sound on/off
85
    AddImageButton(ID_btSoundEffects, DrawPoint(35, 300), Extent(35, 35), TextureColor::Green2,
×
86
                   LOADER.GetImageN("io", 114 + !SETTINGS.sound.effectsEnabled)); //-V807
×
87

88
    // Sound volume
89
    AddProgress(ID_pgEffectVol, DrawPoint(100, 306), Extent(160, 22), TextureColor::Green2, 139, 138, 100)
×
90
      ->SetPosition((SETTINGS.sound.effectsVolume * 100) / 255);
×
91

92
    // Bird sounds on/off
NEW
93
    AddCheckBox(ID_cpBirdSounds, DrawPoint(100, 342), Extent(160, 22), TextureColor::Green2, _("Bird sounds"), NormalFont, false)
×
NEW
94
      ->setChecked(SETTINGS.sound.birdsEnabled);
×
95

96
    // Music on/off
NEW
97
    AddImageButton(ID_btMusic, DrawPoint(35, 371), Extent(35, 35), TextureColor::Green2,
×
NEW
98
                   LOADER.GetImageN("io", 116 + !SETTINGS.sound.musicEnabled));
×
99

100
    // Music volume
NEW
101
    AddProgress(ID_pgMusicVol, DrawPoint(100, 377), Extent(160, 22), TextureColor::Green2, 139, 138, 100)
×
UNCOV
102
      ->SetPosition((SETTINGS.sound.musicVolume * 100) / 255);
×
103

NEW
104
    AddTextButton(ID_btMusicPlayer, DrawPoint(100, 413), Extent(160, 22), TextureColor::Green2, _("Music player"), NormalFont);
×
NEW
105
    AddTextButton(ID_btAdvanced, DrawPoint(67, 442), Extent(168, 24), TextureColor::Green2, _("Advanced"), NormalFont);
×
NEW
106
    AddTextButton(ID_btSurrender, DrawPoint(67, 473), Extent(168, 24), TextureColor::Red1, _("Surrender"), NormalFont);
×
NEW
107
    AddTextButton(ID_btEndGame, DrawPoint(67, 504), Extent(168, 24), TextureColor::Red1, _("End game"), NormalFont);
×
UNCOV
108
}
×
109

110
void iwOptionsWindow::Msg_ButtonClick(const unsigned ctrl_id)
×
111
{
112
    switch(ctrl_id)
×
113
    {
114
        case ID_btEndGame:
×
115
            WINDOWMANAGER.ToggleWindow(std::make_unique<iwEndgame>());
×
116
            Close();
×
117
            break;
×
118
        case ID_btKeyboardLayout:
×
119
            WINDOWMANAGER.ToggleWindow(std::make_unique<iwTextfile>("keyboardlayout.txt", _("Keyboard layout")));
×
120
            break;
×
121
        case ID_btReadme: WINDOWMANAGER.ToggleWindow(std::make_unique<iwTextfile>("readme.txt", _("Readme!"))); break;
×
122
        case ID_btSave: WINDOWMANAGER.ToggleWindow(std::make_unique<iwSave>()); break;
×
123

124
        case ID_btSoundEffects:
×
125
            SETTINGS.sound.effectsEnabled = !SETTINGS.sound.effectsEnabled; //-V807
×
126
            GetCtrl<ctrlImageButton>(ID_btSoundEffects)
×
127
              ->SetImage(LOADER.GetTextureN("io", 114 + !SETTINGS.sound.effectsEnabled));
×
128

129
            if(!SETTINGS.sound.effectsEnabled)
×
130
                soundManager.stopAll();
×
131
            break;
×
132

133
        case ID_btMusic:
×
134
            SETTINGS.sound.musicEnabled = !SETTINGS.sound.musicEnabled;
×
135
            GetCtrl<ctrlImageButton>(ID_btMusic)
×
136
              ->SetImage(LOADER.GetTextureN("io", 116 + !SETTINGS.sound.musicEnabled));
×
137
            if(SETTINGS.sound.musicEnabled)
×
138
                MUSICPLAYER.Play();
×
139
            else
140
                MUSICPLAYER.Stop();
×
141
            break;
×
142
        case ID_btMusicPlayer: WINDOWMANAGER.ToggleWindow(std::make_unique<iwMusicPlayer>()); break;
×
143
        case ID_btSurrender:
×
144
            WINDOWMANAGER.ReplaceWindow(std::make_unique<iwSurrender>());
×
145
            Close();
×
146
            break;
×
147
        case ID_btAdvanced:
×
148
            WINDOWMANAGER.ReplaceWindow(std::make_unique<iwSettings>());
×
149
            Close();
×
150
            break;
×
151
    }
152
}
×
153

154
void iwOptionsWindow::Msg_ProgressChange(const unsigned ctrl_id, const unsigned short position)
×
155
{
156
    switch(ctrl_id)
×
157
    {
158
        case ID_pgEffectVol:
×
159
            SETTINGS.sound.effectsVolume = static_cast<uint8_t>((position * 255) / 100);
×
160
            AUDIODRIVER.SetMasterEffectVolume(SETTINGS.sound.effectsVolume);
×
161
            break;
×
162
        case ID_pgMusicVol:
×
163
            SETTINGS.sound.musicVolume = static_cast<uint8_t>((position * 255) / 100);
×
164
            AUDIODRIVER.SetMusicVolume(SETTINGS.sound.musicVolume);
×
165
            break;
×
166
    }
167
}
×
168

NEW
169
void iwOptionsWindow::Msg_CheckboxChange(const unsigned ctrl_id, const bool checked)
×
170
{
NEW
171
    switch(ctrl_id)
×
172
    {
NEW
173
        case ID_cpBirdSounds:
×
174
        {
NEW
175
            SETTINGS.sound.birdsEnabled = checked;
×
NEW
176
            break;
×
177
        }
178
    }
NEW
179
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc