Skip to content

Commit 933201a

Browse files
committed
Add option to invert the mouse movement when moving the map
Closes #951
1 parent c564588 commit 933201a

File tree

2 files changed

+49
-28
lines changed

2 files changed

+49
-28
lines changed

libs/s25main/desktops/dskOptions.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ enum
6464
ID_grpDebugData,
6565
ID_txtUPNP,
6666
ID_grpUPNP,
67+
ID_txtInvertScroll,
68+
ID_grpInvertScroll,
6769
ID_txtSmartCursor,
6870
ID_grpSmartCursor,
6971
ID_txtGFInfo,
@@ -238,6 +240,16 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0))
238240
}
239241
curPos.y += 50;
240242

243+
groupAllgemein->AddText(ID_txtInvertScroll, curPos, _("Mouse scroll behavior:"), COLOR_YELLOW, FontStyle{},
244+
NormalFont);
245+
ctrlOptionGroup* invertScroll = groupAllgemein->AddOptionGroup(ID_grpInvertScroll, GroupSelectType::Check);
246+
invertScroll->AddTextButton(ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Original"), NormalFont,
247+
_("When scrolling the map with the mouse move the camera."));
248+
invertScroll->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Inverted"), NormalFont,
249+
_("When scrolling the map with the mouse move the map."));
250+
invertScroll->SetSelection(SETTINGS.interface.revert_mouse);
251+
curPos.y += 30;
252+
241253
groupAllgemein->AddText(ID_txtSmartCursor, curPos, _("Smart Cursor"), COLOR_YELLOW, FontStyle{}, NormalFont);
242254
ctrlOptionGroup* smartCursor = groupAllgemein->AddOptionGroup(ID_grpSmartCursor, GroupSelectType::Check);
243255
smartCursor->AddTextButton(

libs/s25main/ingameWindows/iwSettings.cpp

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,64 @@
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+
1832
iwSettings::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

5971
iwSettings::~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

92104
void 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

Comments
 (0)