3333 ID_txtKeyboardLayout,
3434 ID_btReadme,
3535 ID_txtReadme,
36+ ID_btLoad,
37+ ID_txtLoad,
3638 ID_btSave,
3739 ID_txtSave,
3840 ID_btSoundEffects,
@@ -45,64 +47,100 @@ enum
4547 ID_btEndGame,
4648 ID_cpBirdSounds
4749};
48- }
50+
51+ constexpr auto windowSize = Extent(300 , 545 );
52+ constexpr auto centerPosition = windowSize.x / 2 ;
53+ constexpr auto rowHeight = 40 ;
54+ constexpr auto rowHeightSmall = 31 ;
55+ constexpr auto textSpacing = 17 ;
56+ constexpr auto textPadding = 35 ;
57+ constexpr auto headerStartPosition = DrawPoint(centerPosition, 10 );
58+ } // namespace
4959
5060iwOptionsWindow::iwOptionsWindow (SoundManager& soundManager)
51- : IngameWindow(CGI_OPTIONSWINDOW, IngameWindow::posLastOrCenter, Extent( 300 , 545 ) , _(" Game menu" ),
61+ : IngameWindow(CGI_OPTIONSWINDOW, IngameWindow::posLastOrCenter, windowSize , _(" Game menu" ),
5262 LOADER.GetImageN(" resource" , 41 )),
5363 soundManager(soundManager)
5464{
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;
73+
5574 // The soldier on top
56- AddImage (ID_imgSoldier, DrawPoint (150 , 36 ), LOADER.GetImageN (" io" , 30 ));
75+ constexpr Offset soldierOffset (0 , 26 );
76+ AddImage (ID_imgSoldier, curPos + soldierOffset, LOADER.GetImageN (" io" , 30 ));
77+ curPos.y += textSpacing + soldierOffset.y ;
5778
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 ),
79+ AddText (ID_txtRttr, curPos, " Return To The Roots" , COLOR_YELLOW, FontStyle::CENTER, NormalFont);
80+ curPos.y += textSpacing;
81+
82+ AddText (ID_txtVersion, curPos, rttr::version::GetReadableVersion (), COLOR_YELLOW, FontStyle::CENTER, NormalFont);
83+ curPos.y += textSpacing;
84+
85+ AddFormattedText (ID_txtCopyright, curPos,
6286 " \xC2\xA9 "
6387 " 2005 - %s Settlers Freaks" ,
6488 COLOR_YELLOW, FontStyle::CENTER, NormalFont)
6589 % rttr::version::GetYear ();
90+ curPos.y += rowHeightSmall;
91+ curPos.x = textPadding;
6692
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,
93+ AddImageButton (ID_btKeyboardLayout, curPos, buttonImageSize, TextureColor::Green2, LOADER.GetImageN (" io" , 79 ));
94+ AddText (ID_txtKeyboardLayout, curPos + textOffset, _ (" Keyboard layout" ), COLOR_YELLOW, FontStyle::BOTTOM,
7095 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);
96+ curPos.y += rowHeight;
7397
74- // TODO: Implement
75- // AddImageButton( 8, DrawPoint(35, 210), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 48));
76- // AddText(9, DrawPoint(85, 230), _("Load game!"), COLOR_YELLOW, 0 | FontStyle::BOTTOM, NormalFont);
77-
78- // TODO: Move back down to y=250 (Button) 270 (Text) after Load button is implemented
79- AddImageButton (ID_btSave, DrawPoint (35 , 230 ), Extent (35 , 35 ), TextureColor::Green2, LOADER.GetImageN (" io" , 47 ));
80- AddText (ID_txtSave, DrawPoint (85 , 255 ), _ (" Save game!" ), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);
98+ AddImageButton (ID_btReadme, curPos, buttonImageSize, TextureColor::Green2, LOADER.GetImageN (" io" , 79 ));
99+ AddText (ID_txtReadme, curPos + textOffset, _ (" Load 'ReadMe' file" ), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);
100+ curPos.y += rowHeight;
81101
82- // Sound on/off
83- AddImageButton (ID_btSoundEffects, DrawPoint (35 , 300 ), Extent (35 , 35 ), TextureColor::Green2,
102+ // TODO: Implement
103+ // AddImageButton(ID_btLoad, curPos, buttonImageSize, TextureColor::Green2, LOADER.GetImageN("io", 48));
104+ // AddText(ID_txtLoad, curPos + textOffset, _("Load game!"), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);
105+ // curPos.y += rowHeight;
106+
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 ));
109+ 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;
112+
113+ // Sound on/off + volume
114+ AddImageButton (ID_btSoundEffects, curPos, buttonImageSize, TextureColor::Green2,
84115 LOADER.GetImageN (" io" , 114 + !SETTINGS.sound .effectsEnabled )); // -V807
85-
86- // Sound volume
87- AddProgress (ID_pgEffectVol, DrawPoint (100 , 306 ), Extent (160 , 22 ), TextureColor::Green2, 139 , 138 , 100 )
116+ AddProgress (ID_pgEffectVol, curPos + optionOffset, optionSizeSmall, TextureColor::Green2, 139 , 138 , 100 )
88117 ->SetPosition ((SETTINGS.sound .effectsVolume * 100 ) / 255 );
118+ curPos.y += rowHeight;
89119
90- // Bird sounds on/off
91- AddCheckBox (ID_cpBirdSounds, DrawPoint ( 100 , 342 ), Extent ( 160 , 22 ), TextureColor::Green2, _ ( " Bird sounds " ), NormalFont, false )
120+ AddCheckBox (ID_cpBirdSounds, curPos + optionOffset, optionSizeSmall, TextureColor::Green2, _ ( " Bird sounds" ),
121+ NormalFont, false )
92122 ->setChecked (SETTINGS.sound .birdsEnabled );
123+ curPos.y += rowHeight;
93124
94- // Music on/off
95- AddImageButton (ID_btMusic, DrawPoint ( 35 , 371 ), Extent ( 35 , 35 ) , TextureColor::Green2,
125+ // Music on/off + volume
126+ AddImageButton (ID_btMusic, curPos, buttonImageSize , TextureColor::Green2,
96127 LOADER.GetImageN (" io" , 116 + !SETTINGS.sound .musicEnabled ));
97-
98- // Music volume
99- AddProgress (ID_pgMusicVol, DrawPoint (100 , 377 ), Extent (160 , 22 ), TextureColor::Green2, 139 , 138 , 100 )
128+ AddProgress (ID_pgMusicVol, curPos + optionOffset, optionSizeSmall, TextureColor::Green2, 139 , 138 , 100 )
100129 ->SetPosition ((SETTINGS.sound .musicVolume * 100 ) / 255 );
101-
102- AddTextButton (ID_btMusicPlayer, DrawPoint (100 , 413 ), Extent (160 , 22 ), TextureColor::Green2, _ (" Music player" ), NormalFont);
103- AddTextButton (ID_btAdvanced, DrawPoint (67 , 442 ), Extent (168 , 24 ), TextureColor::Green2, _ (" Advanced" ), NormalFont);
104- AddTextButton (ID_btSurrender, DrawPoint (67 , 473 ), Extent (168 , 24 ), TextureColor::Red1, _ (" Surrender" ), NormalFont);
105- AddTextButton (ID_btEndGame, DrawPoint (67 , 504 ), Extent (168 , 24 ), TextureColor::Red1, _ (" End game" ), NormalFont);
130+ curPos.y += rowHeight;
131+
132+ AddTextButton (ID_btMusicPlayer, curPos + optionOffset, optionSizeSmall, TextureColor::Green2, _ (" Music player" ),
133+ NormalFont);
134+ curPos.y += rowHeight;
135+
136+ // Buttons at the bottom
137+ curPos.x = centerPosition;
138+ constexpr Offset btOffset (-(optionSizeBig.x / 2 ), 0 );
139+ AddTextButton (ID_btAdvanced, curPos + btOffset, optionSizeBig, TextureColor::Green2, _ (" Advanced" ), NormalFont);
140+ curPos.y += rowHeightSmall;
141+ AddTextButton (ID_btSurrender, curPos + btOffset, optionSizeBig, TextureColor::Red1, _ (" Surrender" ), NormalFont);
142+ curPos.y += rowHeightSmall;
143+ AddTextButton (ID_btEndGame, curPos + btOffset, optionSizeBig, TextureColor::Red1, _ (" End game" ), NormalFont);
106144}
107145
108146void iwOptionsWindow::Msg_ButtonClick (const unsigned ctrl_id)
0 commit comments