4848 ID_cpBirdSounds
4949};
5050
51+ using Offset = DrawPoint;
5152constexpr auto windowSize = Extent(300 , 545 );
53+ constexpr auto imageButtonSize = Extent(35 , 35 );
54+ constexpr auto optionSizeSmall = Extent(160 , 22 );
55+ constexpr auto optionSizeBig = Extent(168 , 24 );
56+ constexpr auto optionOffset = Offset(65 , 6 );
57+ constexpr auto textOffset = Offset(50 , 24 );
5258constexpr auto centerPosition = windowSize.x / 2 ;
53- constexpr auto rowHeight = 40 ;
54- constexpr auto rowHeightSmall = 31 ;
5559constexpr auto textSpacing = 17 ;
56- constexpr auto textPadding = 35 ;
57- constexpr auto headerStartPosition = DrawPoint(centerPosition, 10 ) ;
60+ constexpr auto generalSpacing = 5 ;
61+ constexpr auto leftMargin = 35 ;
5862} // namespace
5963
6064iwOptionsWindow::iwOptionsWindow (SoundManager& soundManager)
6165 : IngameWindow(CGI_OPTIONSWINDOW, IngameWindow::posLastOrCenter, windowSize, _(" Game menu" ),
6266 LOADER.GetImageN(" resource" , 41 )),
6367 soundManager(soundManager)
6468{
65- using Offset = DrawPoint;
66- constexpr Extent buttonImageSize (35 , 35 );
67- constexpr Extent optionSizeSmall (160 , 22 );
68- constexpr Extent optionSizeBig (168 , 24 );
69- constexpr Offset textOffset (50 , 24 );
70- constexpr Offset optionOffset (65 , 6 );
71-
72- DrawPoint curPos = headerStartPosition;
69+ DrawPoint curPos = DrawPoint (centerPosition, 10 );
7370
7471 // The soldier on top
7572 constexpr Offset soldierOffset (0 , 26 );
@@ -87,59 +84,59 @@ iwOptionsWindow::iwOptionsWindow(SoundManager& soundManager)
8784 " 2005 - %s Settlers Freaks" ,
8885 COLOR_YELLOW, FontStyle::CENTER, NormalFont)
8986 % rttr::version::GetYear ();
90- curPos.y += rowHeightSmall ;
91- curPos.x = textPadding ;
87+ curPos.y += textSpacing * 2 ;
88+ curPos.x = leftMargin ;
9289
93- AddImageButton (ID_btKeyboardLayout, curPos, buttonImageSize , TextureColor::Green2, LOADER.GetImageN (" io" , 79 ));
90+ AddImageButton (ID_btKeyboardLayout, curPos, imageButtonSize , TextureColor::Green2, LOADER.GetImageN (" io" , 79 ));
9491 AddText (ID_txtKeyboardLayout, curPos + textOffset, _ (" Keyboard layout" ), COLOR_YELLOW, FontStyle::BOTTOM,
9592 NormalFont);
96- curPos.y += rowHeight ;
93+ curPos.y += imageButtonSize. y + generalSpacing ;
9794
98- AddImageButton (ID_btReadme, curPos, buttonImageSize , TextureColor::Green2, LOADER.GetImageN (" io" , 79 ));
95+ AddImageButton (ID_btReadme, curPos, imageButtonSize , TextureColor::Green2, LOADER.GetImageN (" io" , 79 ));
9996 AddText (ID_txtReadme, curPos + textOffset, _ (" Load 'ReadMe' file" ), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);
100- curPos.y += rowHeight ;
97+ curPos.y += imageButtonSize. y + generalSpacing ;
10198
10299 // TODO: Implement
103- // AddImageButton(ID_btLoad, curPos, buttonImageSize , TextureColor::Green2, LOADER.GetImageN("io", 48));
100+ // AddImageButton(ID_btLoad, curPos, imageButtonSize , TextureColor::Green2, LOADER.GetImageN("io", 48));
104101 // AddText(ID_txtLoad, curPos + textOffset, _("Load game!"), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);
105- // curPos.y += rowHeight ;
102+ // curPos.y += imageButtonSize.y + generalSpacing ;
106103
107- curPos.y += rowHeight / 2 ; // TODO: Delete this row, if the Load button is implemented
108- AddImageButton (ID_btSave, curPos, buttonImageSize , TextureColor::Green2, LOADER.GetImageN (" io" , 47 ));
104+ curPos.y += 3 + imageButtonSize. y / 2 ; // TODO: Delete this row, if the Load button is implemented
105+ AddImageButton (ID_btSave, curPos, imageButtonSize , TextureColor::Green2, LOADER.GetImageN (" io" , 47 ));
109106 AddText (ID_txtSave, curPos + textOffset, _ (" Save game!" ), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);
110- curPos.y += rowHeight / 2 ; // TODO: Delete this row, if the Load button is implemented
111- curPos.y += rowHeight ;
107+ curPos.y += 3 + imageButtonSize. y / 2 ; // TODO: Delete this row, if the Load button is implemented
108+ curPos.y += imageButtonSize. y + generalSpacing ;
112109
113110 // Sound on/off + volume
114- AddImageButton (ID_btSoundEffects, curPos, buttonImageSize , TextureColor::Green2,
111+ AddImageButton (ID_btSoundEffects, curPos, imageButtonSize , TextureColor::Green2,
115112 LOADER.GetImageN (" io" , 114 + !SETTINGS.sound .effectsEnabled )); // -V807
116113 AddProgress (ID_pgEffectVol, curPos + optionOffset, optionSizeSmall, TextureColor::Green2, 139 , 138 , 100 )
117114 ->SetPosition ((SETTINGS.sound .effectsVolume * 100 ) / 255 );
118- curPos.y += rowHeight ;
115+ curPos.y += imageButtonSize. y ;
119116
120117 AddCheckBox (ID_cpBirdSounds, curPos + optionOffset, optionSizeSmall, TextureColor::Green2, _ (" Bird sounds" ),
121118 NormalFont, false )
122119 ->setChecked (SETTINGS.sound .birdsEnabled );
123- curPos.y += rowHeight ;
120+ curPos.y += optionSizeSmall. y * 2 ;
124121
125122 // Music on/off + volume
126- AddImageButton (ID_btMusic, curPos, buttonImageSize , TextureColor::Green2,
123+ AddImageButton (ID_btMusic, curPos, imageButtonSize , TextureColor::Green2,
127124 LOADER.GetImageN (" io" , 116 + !SETTINGS.sound .musicEnabled ));
128125 AddProgress (ID_pgMusicVol, curPos + optionOffset, optionSizeSmall, TextureColor::Green2, 139 , 138 , 100 )
129126 ->SetPosition ((SETTINGS.sound .musicVolume * 100 ) / 255 );
130- curPos.y += rowHeight ;
127+ curPos.y += imageButtonSize. y ;
131128
132129 AddTextButton (ID_btMusicPlayer, curPos + optionOffset, optionSizeSmall, TextureColor::Green2, _ (" Music player" ),
133130 NormalFont);
134- curPos.y += rowHeight ;
131+ curPos.y += optionSizeSmall. y * 2 ;
135132
136133 // Buttons at the bottom
137134 curPos.x = centerPosition;
138135 constexpr Offset btOffset (-(optionSizeBig.x / 2 ), 0 );
139136 AddTextButton (ID_btAdvanced, curPos + btOffset, optionSizeBig, TextureColor::Green2, _ (" Advanced" ), NormalFont);
140- curPos.y += rowHeightSmall ;
137+ curPos.y += optionSizeBig. y + generalSpacing ;
141138 AddTextButton (ID_btSurrender, curPos + btOffset, optionSizeBig, TextureColor::Red1, _ (" Surrender" ), NormalFont);
142- curPos.y += rowHeightSmall ;
139+ curPos.y += optionSizeBig. y + generalSpacing ;
143140 AddTextButton (ID_btEndGame, curPos + btOffset, optionSizeBig, TextureColor::Red1, _ (" End game" ), NormalFont);
144141}
145142
@@ -204,12 +201,6 @@ void iwOptionsWindow::Msg_ProgressChange(const unsigned ctrl_id, const unsigned
204201
205202void iwOptionsWindow::Msg_CheckboxChange (const unsigned ctrl_id, const bool checked)
206203{
207- switch (ctrl_id)
208- {
209- case ID_cpBirdSounds:
210- {
211- SETTINGS.sound .birdsEnabled = checked;
212- break ;
213- }
214- }
204+ RTTR_Assert (ctrl_id == ID_cpBirdSounds);
205+ SETTINGS.sound .birdsEnabled = checked;
215206}
0 commit comments