1515#include " gameData/const_gui_ids.h"
1616#include " s25util/colors.h"
1717
18+ namespace {
19+ enum
20+ {
21+ ID_txtResolution,
22+ ID_txtFullScreen,
23+ ID_grpFullscreen,
24+ ID_cbResolution,
25+ ID_cbInvertMouse,
26+ ID_cbStatisticScale,
27+ };
28+ constexpr auto ID_btOn = 1 ;
29+ constexpr auto ID_btOff = 0 ;
30+ } // namespace
31+
1832iwSettings::iwSettings ()
1933 : IngameWindow(CGI_SETTINGS, IngameWindow::posLastOrCenter, Extent(370 , 172 ), _(" Settings" ),
2034 LOADER.GetImageN(" resource" , 41 ))
2135{
22- AddText (46 , DrawPoint (15 , 40 ), _ (" Fullscreen resolution:" ), COLOR_YELLOW, FontStyle{}, NormalFont);
23- AddText (47 , DrawPoint (15 , 85 ), _ (" Mode:" ), COLOR_YELLOW, FontStyle{}, NormalFont);
24- AddCheckBox (4 , DrawPoint (200 , 124 ), Extent (150 , 26 ), TextureColor::Grey, _ (" Statistics Scale" ), NormalFont, false );
25- GetCtrl<ctrlCheck>(4 )->setChecked (SETTINGS.ingame .scale_statistics );
26-
27- // "Vollbild"
28- ctrlOptionGroup* optiongroup = AddOptionGroup (3 , GroupSelectType::Check);
29- optiongroup->AddTextButton (1 , DrawPoint (200 , 70 ), Extent (150 , 22 ), TextureColor::Grey, _ (" Fullscreen" ), NormalFont);
30- optiongroup->AddTextButton (2 , DrawPoint (200 , 95 ), Extent (150 , 22 ), TextureColor::Grey, _ (" Windowed" ), NormalFont);
36+ AddText (ID_txtResolution, DrawPoint (15 , 40 ), _ (" Fullscreen resolution:" ), COLOR_YELLOW, FontStyle{}, NormalFont);
37+ auto * cbResolution =
38+ AddComboBox (ID_cbResolution, DrawPoint (200 , 35 ), Extent (150 , 22 ), TextureColor::Grey, NormalFont, 110 );
3139
32- // "Vollbild" setzen
33- optiongroup = GetCtrl<ctrlOptionGroup>(3 );
34- optiongroup->SetSelection ((SETTINGS.video .fullscreen ? 1 : 2 )); // -V807
3540 VIDEODRIVER.ListVideoModes (video_modes);
36-
37- // "Auflösung"
38- AddComboBox (0 , DrawPoint (200 , 35 ), Extent (150 , 22 ), TextureColor::Grey, NormalFont, 110 );
39-
40- // Und zu der Combobox hinzufügen
4141 for (unsigned i = 0 ; i < video_modes.size (); ++i)
4242 {
4343 // >=800x600, alles andere macht keinen Sinn
4444 if (video_modes[i].width >= 800 && video_modes[i].height >= 600 )
4545 {
46- GetCtrl<ctrlComboBox>(0 )->AddString (helpers::format (" %ux%u" , video_modes[i].width , video_modes[i].height ));
47-
48- // Ist das die aktuelle Auflösung? Dann selektieren
46+ cbResolution->AddString (helpers::format (" %ux%u" , video_modes[i].width , video_modes[i].height ));
4947 if (video_modes[i] == SETTINGS.video .fullscreenSize )
50- GetCtrl<ctrlComboBox>( 0 ) ->SetSelection (i);
48+ cbResolution ->SetSelection (i);
5149 } else
5250 {
5351 video_modes.erase (video_modes.begin () + i);
5452 --i;
5553 }
5654 }
55+ AddText (ID_txtFullScreen, DrawPoint (15 , 85 ), _ (" Mode:" ), COLOR_YELLOW, FontStyle{}, NormalFont);
56+ ctrlOptionGroup* optiongroup = AddOptionGroup (ID_grpFullscreen, GroupSelectType::Check);
57+ optiongroup->AddTextButton (ID_btOn, DrawPoint (200 , 70 ), Extent (150 , 22 ), TextureColor::Grey, _ (" Fullscreen" ),
58+ NormalFont);
59+ optiongroup->AddTextButton (ID_btOff, DrawPoint (200 , 95 ), Extent (150 , 22 ), TextureColor::Grey, _ (" Windowed" ),
60+ NormalFont);
61+ optiongroup->SetSelection (SETTINGS.video .fullscreen ); // -V807
62+
63+ AddCheckBox (ID_cbInvertMouse, DrawPoint (15 , 124 ), Extent (150 , 26 ), TextureColor::Grey, _ (" Invert mouse" ),
64+ NormalFont, false )
65+ ->setChecked (SETTINGS.interface .revert_mouse );
66+ AddCheckBox (ID_cbStatisticScale, DrawPoint (200 , 124 ), Extent (150 , 26 ), TextureColor::Grey, _ (" Statistics Scale" ),
67+ NormalFont, false )
68+ ->setChecked (SETTINGS.ingame .scale_statistics );
5769}
5870
5971iwSettings::~iwSettings ()
6072{
6173 try
6274 {
63- auto * SizeCombo = GetCtrl<ctrlComboBox>(0 );
75+ auto * SizeCombo = GetCtrl<ctrlComboBox>(ID_cbResolution );
6476 SETTINGS.video .fullscreenSize = video_modes[SizeCombo->GetSelection ().get ()];
6577
6678 if ((SETTINGS.video .fullscreen && SETTINGS.video .fullscreenSize != VIDEODRIVER.GetWindowSize ())
@@ -85,18 +97,15 @@ void iwSettings::Msg_OptionGroupChange(const unsigned ctrl_id, const unsigned se
8597{
8698 switch (ctrl_id)
8799 {
88- case 3 : SETTINGS.video .fullscreen = ( selection == 1 ) ; break ;
100+ case ID_grpFullscreen : SETTINGS.video .fullscreen = selection == ID_btOn ; break ;
89101 }
90102}
91103
92104void iwSettings::Msg_CheckboxChange (const unsigned ctrl_id, const bool checked)
93105{
94106 switch (ctrl_id)
95107 {
96- case 4 :
97- {
98- SETTINGS.ingame .scale_statistics = checked;
99- break ;
100- }
108+ case ID_cbInvertMouse: SETTINGS.interface .revert_mouse = checked; break ;
109+ case ID_cbStatisticScale: SETTINGS.ingame .scale_statistics = checked; break ;
101110 }
102111}
0 commit comments