From fb765962aac37625f7058891d382ec2397a954ad Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 14 Feb 2023 18:18:16 +0100 Subject: [PATCH 1/7] Add test for scrolling with inverted mouse --- .../integration/testDskGameInterface.cpp | 128 +++++++++++------- 1 file changed, 76 insertions(+), 52 deletions(-) diff --git a/tests/s25Main/integration/testDskGameInterface.cpp b/tests/s25Main/integration/testDskGameInterface.cpp index 95beff05c7..e05bbd23e3 100644 --- a/tests/s25Main/integration/testDskGameInterface.cpp +++ b/tests/s25Main/integration/testDskGameInterface.cpp @@ -4,6 +4,7 @@ #include "GamePlayer.h" #include "PointOutput.h" +#include "Settings.h" #include "WindowManager.h" #include "buildings/nobBaseWarehouse.h" #include "desktops/dskGameInterface.h" @@ -66,63 +67,86 @@ void checkNotScrolling(const GameWorldView& view, Cursor cursor = Cursor::Hand) BOOST_FIXTURE_TEST_CASE(Scrolling, GameInterfaceFixture) { const int acceleration = 2; + SETTINGS.interface.revert_mouse = false; + Position startPos(10, 15); MouseCoords mouse(startPos, false, true); // Regular scrolling: Right down, 2 moves, right up - WINDOWMANAGER.Msg_RightDown(mouse); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); - DrawPoint pos = view->GetOffset(); - mouse.pos = startPos + Position(4, 3); - WINDOWMANAGER.Msg_MouseMove(mouse); - pos += acceleration * Position(4, 3); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); - BOOST_TEST_REQUIRE(view->GetOffset() == pos); - mouse.pos = startPos + Position(-6, 7); - WINDOWMANAGER.Msg_MouseMove(mouse); - pos += acceleration * Position(-6, 7); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); - BOOST_TEST_REQUIRE(view->GetOffset() == pos); - mouse.rdown = false; - WINDOWMANAGER.Msg_RightUp(mouse); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Hand); - BOOST_TEST_REQUIRE(view->GetOffset() == pos); - checkNotScrolling(*view); + { + WINDOWMANAGER.Msg_RightDown(mouse); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); + DrawPoint pos = view->GetOffset(); + mouse.pos = startPos + Position(4, 3); + WINDOWMANAGER.Msg_MouseMove(mouse); + pos += acceleration * Position(4, 3); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); + BOOST_TEST_REQUIRE(view->GetOffset() == pos); + mouse.pos = startPos + Position(-6, 7); + WINDOWMANAGER.Msg_MouseMove(mouse); + pos += acceleration * Position(-6, 7); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); + BOOST_TEST_REQUIRE(view->GetOffset() == pos); + mouse.rdown = false; + WINDOWMANAGER.Msg_RightUp(mouse); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Hand); + BOOST_TEST_REQUIRE(view->GetOffset() == pos); + checkNotScrolling(*view); + } + + // Inverted scrolling + { + SETTINGS.interface.revert_mouse = true; + WINDOWMANAGER.Msg_RightDown(mouse); + startPos = mouse.pos; + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); + const DrawPoint pos = view->GetOffset(); + mouse.pos = startPos + Position(4, 3); + WINDOWMANAGER.Msg_MouseMove(mouse); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); + BOOST_TEST_REQUIRE(view->GetOffset() == pos - acceleration * Position(4, 3)); + mouse.rdown = false; + WINDOWMANAGER.Msg_RightUp(mouse); + SETTINGS.interface.revert_mouse = false; + } // Opening a window does not cancel scrolling - mouse.rdown = true; - WINDOWMANAGER.Msg_RightDown(mouse); - startPos = mouse.pos; - KeyEvent key; - key.kt = KeyType::Char; - key.c = 'm'; - key.ctrl = key.alt = key.shift = false; - WINDOWMANAGER.Msg_KeyDown(key); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetTopMostWindow()); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); - mouse.pos = startPos + Position(-6, 7); - WINDOWMANAGER.Msg_MouseMove(mouse); - pos += acceleration * Position(-6, 7); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); - BOOST_TEST_REQUIRE(view->GetOffset() == pos); - // Closing it doesn't either - WINDOWMANAGER.Msg_KeyDown(key); - WINDOWMANAGER.Draw(); - BOOST_TEST_REQUIRE(gameDesktop->IsActive()); - BOOST_TEST_REQUIRE(!WINDOWMANAGER.GetTopMostWindow()); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); - mouse.pos = startPos + Position(-6, 7); - WINDOWMANAGER.Msg_MouseMove(mouse); - pos += acceleration * Position(-6, 7); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); - BOOST_TEST_REQUIRE(view->GetOffset() == pos); - // Left click does cancel it - mouse.ldown = true; - WINDOWMANAGER.Msg_LeftDown(mouse); - mouse.ldown = false; - WINDOWMANAGER.Msg_LeftUp(mouse); - BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Hand); - BOOST_TEST_REQUIRE(view->GetOffset() == pos); - checkNotScrolling(*view); + { + mouse.rdown = true; + WINDOWMANAGER.Msg_RightDown(mouse); + startPos = mouse.pos; + DrawPoint pos = view->GetOffset(); + KeyEvent key; + key.kt = KeyType::Char; + key.c = 'm'; + key.ctrl = key.alt = key.shift = false; + WINDOWMANAGER.Msg_KeyDown(key); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetTopMostWindow()); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); + mouse.pos = startPos + Position(-6, 7); + WINDOWMANAGER.Msg_MouseMove(mouse); + pos += acceleration * Position(-6, 7); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); + BOOST_TEST_REQUIRE(view->GetOffset() == pos); + // Closing it doesn't either + WINDOWMANAGER.Msg_KeyDown(key); + WINDOWMANAGER.Draw(); + BOOST_TEST_REQUIRE(gameDesktop->IsActive()); + BOOST_TEST_REQUIRE(!WINDOWMANAGER.GetTopMostWindow()); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); + mouse.pos = startPos + Position(-6, 7); + WINDOWMANAGER.Msg_MouseMove(mouse); + pos += acceleration * Position(-6, 7); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); + BOOST_TEST_REQUIRE(view->GetOffset() == pos); + // Left click does cancel it + mouse.ldown = true; + WINDOWMANAGER.Msg_LeftDown(mouse); + mouse.ldown = false; + WINDOWMANAGER.Msg_LeftUp(mouse); + BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Hand); + BOOST_TEST_REQUIRE(view->GetOffset() == pos); + checkNotScrolling(*view); + } } BOOST_FIXTURE_TEST_CASE(ScrollingWhileRoadBuilding, GameInterfaceFixture) From f9a7a8cc230f731ce009de89a28eb33323ee4320 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 14 Feb 2023 18:56:42 +0100 Subject: [PATCH 2/7] Add option to invert the mouse movement when moving the map Closes #951 --- libs/s25main/desktops/dskOptions.cpp | 12 +++++ libs/s25main/ingameWindows/iwSettings.cpp | 65 +++++++++++++---------- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/libs/s25main/desktops/dskOptions.cpp b/libs/s25main/desktops/dskOptions.cpp index 5011438d0a..0261f64bb7 100644 --- a/libs/s25main/desktops/dskOptions.cpp +++ b/libs/s25main/desktops/dskOptions.cpp @@ -64,6 +64,8 @@ enum ID_grpDebugData, ID_txtUPNP, ID_grpUPNP, + ID_txtInvertScroll, + ID_grpInvertScroll, ID_txtSmartCursor, ID_grpSmartCursor, ID_txtGFInfo, @@ -238,6 +240,16 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) } curPos.y += 50; + groupAllgemein->AddText(ID_txtInvertScroll, curPos, _("Mouse scroll behavior:"), COLOR_YELLOW, FontStyle{}, + NormalFont); + ctrlOptionGroup* invertScroll = groupAllgemein->AddOptionGroup(ID_grpInvertScroll, GroupSelectType::Check); + invertScroll->AddTextButton(ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Original"), NormalFont, + _("When scrolling the map with the mouse move the camera.")); + invertScroll->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Inverted"), NormalFont, + _("When scrolling the map with the mouse move the map.")); + invertScroll->SetSelection(SETTINGS.interface.revert_mouse); + curPos.y += 30; + groupAllgemein->AddText(ID_txtSmartCursor, curPos, _("Smart Cursor"), COLOR_YELLOW, FontStyle{}, NormalFont); ctrlOptionGroup* smartCursor = groupAllgemein->AddOptionGroup(ID_grpSmartCursor, GroupSelectType::Check); smartCursor->AddTextButton( diff --git a/libs/s25main/ingameWindows/iwSettings.cpp b/libs/s25main/ingameWindows/iwSettings.cpp index edd878f701..c010913e02 100644 --- a/libs/s25main/ingameWindows/iwSettings.cpp +++ b/libs/s25main/ingameWindows/iwSettings.cpp @@ -15,52 +15,64 @@ #include "gameData/const_gui_ids.h" #include "s25util/colors.h" +namespace { +enum +{ + ID_txtResolution, + ID_txtFullScreen, + ID_grpFullscreen, + ID_cbResolution, + ID_cbInvertMouse, + ID_cbStatisticScale, +}; +constexpr auto ID_btOn = 1; +constexpr auto ID_btOff = 0; +} // namespace + iwSettings::iwSettings() : IngameWindow(CGI_SETTINGS, IngameWindow::posLastOrCenter, Extent(370, 172), _("Settings"), LOADER.GetImageN("resource", 41)) { - AddText(46, DrawPoint(15, 40), _("Fullscreen resolution:"), COLOR_YELLOW, FontStyle{}, NormalFont); - AddText(47, DrawPoint(15, 85), _("Mode:"), COLOR_YELLOW, FontStyle{}, NormalFont); - AddCheckBox(4, DrawPoint(200, 124), Extent(150, 26), TextureColor::Grey, _("Statistics Scale"), NormalFont, false); - GetCtrl(4)->setChecked(SETTINGS.ingame.scale_statistics); - - // "Vollbild" - ctrlOptionGroup* optiongroup = AddOptionGroup(3, GroupSelectType::Check); - optiongroup->AddTextButton(1, DrawPoint(200, 70), Extent(150, 22), TextureColor::Grey, _("Fullscreen"), NormalFont); - optiongroup->AddTextButton(2, DrawPoint(200, 95), Extent(150, 22), TextureColor::Grey, _("Windowed"), NormalFont); + AddText(ID_txtResolution, DrawPoint(15, 40), _("Fullscreen resolution:"), COLOR_YELLOW, FontStyle{}, NormalFont); + auto* cbResolution = + AddComboBox(ID_cbResolution, DrawPoint(200, 35), Extent(150, 22), TextureColor::Grey, NormalFont, 110); - // "Vollbild" setzen - optiongroup = GetCtrl(3); - optiongroup->SetSelection((SETTINGS.video.fullscreen ? 1 : 2)); //-V807 VIDEODRIVER.ListVideoModes(video_modes); - - // "Auflösung" - AddComboBox(0, DrawPoint(200, 35), Extent(150, 22), TextureColor::Grey, NormalFont, 110); - - // Und zu der Combobox hinzufügen for(unsigned i = 0; i < video_modes.size(); ++i) { // >=800x600, alles andere macht keinen Sinn if(video_modes[i].width >= 800 && video_modes[i].height >= 600) { - GetCtrl(0)->AddString(helpers::format("%ux%u", video_modes[i].width, video_modes[i].height)); - - // Ist das die aktuelle Auflösung? Dann selektieren + cbResolution->AddString(helpers::format("%ux%u", video_modes[i].width, video_modes[i].height)); if(video_modes[i] == SETTINGS.video.fullscreenSize) - GetCtrl(0)->SetSelection(i); + cbResolution->SetSelection(i); } else { video_modes.erase(video_modes.begin() + i); --i; } } + AddText(ID_txtFullScreen, DrawPoint(15, 85), _("Mode:"), COLOR_YELLOW, FontStyle{}, NormalFont); + ctrlOptionGroup* optiongroup = AddOptionGroup(ID_grpFullscreen, GroupSelectType::Check); + optiongroup->AddTextButton(ID_btOn, DrawPoint(200, 70), Extent(150, 22), TextureColor::Grey, _("Fullscreen"), + NormalFont); + optiongroup->AddTextButton(ID_btOff, DrawPoint(200, 95), Extent(150, 22), TextureColor::Grey, _("Windowed"), + NormalFont); + optiongroup->SetSelection(SETTINGS.video.fullscreen); //-V807 + + AddCheckBox(ID_cbInvertMouse, DrawPoint(15, 124), Extent(150, 26), TextureColor::Grey, _("Invert mouse"), + NormalFont, false) + ->setChecked(SETTINGS.interface.revert_mouse); + AddCheckBox(ID_cbStatisticScale, DrawPoint(200, 124), Extent(150, 26), TextureColor::Grey, _("Statistics Scale"), + NormalFont, false) + ->setChecked(SETTINGS.ingame.scale_statistics); } iwSettings::~iwSettings() { try { - auto* SizeCombo = GetCtrl(0); + auto* SizeCombo = GetCtrl(ID_cbResolution); SETTINGS.video.fullscreenSize = video_modes[SizeCombo->GetSelection().get()]; if((SETTINGS.video.fullscreen && SETTINGS.video.fullscreenSize != VIDEODRIVER.GetWindowSize()) @@ -85,7 +97,7 @@ void iwSettings::Msg_OptionGroupChange(const unsigned ctrl_id, const unsigned se { switch(ctrl_id) { - case 3: SETTINGS.video.fullscreen = (selection == 1); break; + case ID_grpFullscreen: SETTINGS.video.fullscreen = selection == ID_btOn; break; } } @@ -93,10 +105,7 @@ void iwSettings::Msg_CheckboxChange(const unsigned ctrl_id, const bool checked) { switch(ctrl_id) { - case 4: - { - SETTINGS.ingame.scale_statistics = checked; - break; - } + case ID_cbInvertMouse: SETTINGS.interface.revert_mouse = checked; break; + case ID_cbStatisticScale: SETTINGS.ingame.scale_statistics = checked; break; } } From 51e8c35790ae695204f4127777336974cb3967f1 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 14 Feb 2023 19:00:03 +0100 Subject: [PATCH 3/7] Rename `revert_mouse` to `invert_mouse` That is more conventional and correct as "revert" could mean "undo" --- libs/s25main/Settings.cpp | 6 +++--- libs/s25main/Settings.h | 2 +- libs/s25main/desktops/dskGameInterface.cpp | 2 +- libs/s25main/desktops/dskOptions.cpp | 2 +- libs/s25main/ingameWindows/iwObservate.cpp | 2 +- libs/s25main/ingameWindows/iwSettings.cpp | 4 ++-- tests/s25Main/integration/testDskGameInterface.cpp | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libs/s25main/Settings.cpp b/libs/s25main/Settings.cpp index 059f778b35..7cac78af63 100644 --- a/libs/s25main/Settings.cpp +++ b/libs/s25main/Settings.cpp @@ -138,7 +138,7 @@ void Settings::LoadDefaults() // interface // { interface.autosave_interval = 0; - interface.revert_mouse = false; + interface.invert_mouse = false; // } // addons @@ -295,7 +295,7 @@ void Settings::Load() // interface // { interface.autosave_interval = iniInterface->getIntValue("autosave_interval"); - interface.revert_mouse = iniInterface->getBoolValue("revert_mouse"); + interface.invert_mouse = iniInterface->getValue("invert_mouse", false); // } // addons @@ -455,7 +455,7 @@ void Settings::Save() // interface // { iniInterface->setValue("autosave_interval", interface.autosave_interval); - iniInterface->setValue("revert_mouse", interface.revert_mouse); + iniInterface->setValue("invert_mouse", interface.invert_mouse); // } // addons diff --git a/libs/s25main/Settings.h b/libs/s25main/Settings.h index e702c34ed7..79a41002b3 100644 --- a/libs/s25main/Settings.h +++ b/libs/s25main/Settings.h @@ -103,7 +103,7 @@ class Settings : public Singleton struct { unsigned autosave_interval; - bool revert_mouse; + bool invert_mouse; } interface; struct diff --git a/libs/s25main/desktops/dskGameInterface.cpp b/libs/s25main/desktops/dskGameInterface.cpp index 42bb9c12fc..e8e5bc7abb 100644 --- a/libs/s25main/desktops/dskGameInterface.cpp +++ b/libs/s25main/desktops/dskGameInterface.cpp @@ -691,7 +691,7 @@ bool dskGameInterface::Msg_MouseMove(const MouseCoords& mc) int acceleration = SETTINGS.global.smartCursor ? 2 : 3; - if(SETTINGS.interface.revert_mouse) + if(SETTINGS.interface.invert_mouse) acceleration = -acceleration; gwv.MoveBy((mc.GetPos() - startScrollPt) * acceleration); diff --git a/libs/s25main/desktops/dskOptions.cpp b/libs/s25main/desktops/dskOptions.cpp index 0261f64bb7..aa697ff279 100644 --- a/libs/s25main/desktops/dskOptions.cpp +++ b/libs/s25main/desktops/dskOptions.cpp @@ -247,7 +247,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) _("When scrolling the map with the mouse move the camera.")); invertScroll->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Inverted"), NormalFont, _("When scrolling the map with the mouse move the map.")); - invertScroll->SetSelection(SETTINGS.interface.revert_mouse); + invertScroll->SetSelection(SETTINGS.interface.invert_mouse); curPos.y += 30; groupAllgemein->AddText(ID_txtSmartCursor, curPos, _("Smart Cursor"), COLOR_YELLOW, FontStyle{}, NormalFont); diff --git a/libs/s25main/ingameWindows/iwObservate.cpp b/libs/s25main/ingameWindows/iwObservate.cpp index e93f029c39..e01f120749 100644 --- a/libs/s25main/ingameWindows/iwObservate.cpp +++ b/libs/s25main/ingameWindows/iwObservate.cpp @@ -231,7 +231,7 @@ bool iwObservate::Msg_MouseMove(const MouseCoords& mc) { int acceleration = SETTINGS.global.smartCursor ? 2 : 3; - if(SETTINGS.interface.revert_mouse) + if(SETTINGS.interface.invert_mouse) acceleration = -acceleration; view->MoveBy((mc.GetPos() - scrollOrigin) * acceleration); diff --git a/libs/s25main/ingameWindows/iwSettings.cpp b/libs/s25main/ingameWindows/iwSettings.cpp index c010913e02..5bbced6464 100644 --- a/libs/s25main/ingameWindows/iwSettings.cpp +++ b/libs/s25main/ingameWindows/iwSettings.cpp @@ -62,7 +62,7 @@ iwSettings::iwSettings() AddCheckBox(ID_cbInvertMouse, DrawPoint(15, 124), Extent(150, 26), TextureColor::Grey, _("Invert mouse"), NormalFont, false) - ->setChecked(SETTINGS.interface.revert_mouse); + ->setChecked(SETTINGS.interface.invert_mouse); AddCheckBox(ID_cbStatisticScale, DrawPoint(200, 124), Extent(150, 26), TextureColor::Grey, _("Statistics Scale"), NormalFont, false) ->setChecked(SETTINGS.ingame.scale_statistics); @@ -105,7 +105,7 @@ void iwSettings::Msg_CheckboxChange(const unsigned ctrl_id, const bool checked) { switch(ctrl_id) { - case ID_cbInvertMouse: SETTINGS.interface.revert_mouse = checked; break; + case ID_cbInvertMouse: SETTINGS.interface.invert_mouse = checked; break; case ID_cbStatisticScale: SETTINGS.ingame.scale_statistics = checked; break; } } diff --git a/tests/s25Main/integration/testDskGameInterface.cpp b/tests/s25Main/integration/testDskGameInterface.cpp index e05bbd23e3..cb12339e6b 100644 --- a/tests/s25Main/integration/testDskGameInterface.cpp +++ b/tests/s25Main/integration/testDskGameInterface.cpp @@ -67,7 +67,7 @@ void checkNotScrolling(const GameWorldView& view, Cursor cursor = Cursor::Hand) BOOST_FIXTURE_TEST_CASE(Scrolling, GameInterfaceFixture) { const int acceleration = 2; - SETTINGS.interface.revert_mouse = false; + SETTINGS.interface.invert_mouse = false; Position startPos(10, 15); MouseCoords mouse(startPos, false, true); @@ -95,7 +95,7 @@ BOOST_FIXTURE_TEST_CASE(Scrolling, GameInterfaceFixture) // Inverted scrolling { - SETTINGS.interface.revert_mouse = true; + SETTINGS.interface.invert_mouse = true; WINDOWMANAGER.Msg_RightDown(mouse); startPos = mouse.pos; BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); @@ -106,7 +106,7 @@ BOOST_FIXTURE_TEST_CASE(Scrolling, GameInterfaceFixture) BOOST_TEST_REQUIRE(view->GetOffset() == pos - acceleration * Position(4, 3)); mouse.rdown = false; WINDOWMANAGER.Msg_RightUp(mouse); - SETTINGS.interface.revert_mouse = false; + SETTINGS.interface.invert_mouse = false; } // Opening a window does not cancel scrolling From 9492317de41c1b64bf12ef08a03d9d53302c9632 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 13 Aug 2023 19:26:06 +0200 Subject: [PATCH 4/7] Rename to `invertMouse` --- libs/s25main/Settings.cpp | 6 +++--- libs/s25main/Settings.h | 2 +- libs/s25main/desktops/dskGameInterface.cpp | 2 +- libs/s25main/desktops/dskOptions.cpp | 2 +- libs/s25main/ingameWindows/iwObservate.cpp | 2 +- libs/s25main/ingameWindows/iwSettings.cpp | 4 ++-- tests/s25Main/integration/testDskGameInterface.cpp | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libs/s25main/Settings.cpp b/libs/s25main/Settings.cpp index 1301bdaceb..a88aeaaa8b 100644 --- a/libs/s25main/Settings.cpp +++ b/libs/s25main/Settings.cpp @@ -139,7 +139,7 @@ void Settings::LoadDefaults() // interface // { interface.autosave_interval = 0; - interface.invert_mouse = false; + interface.invertMouse = false; interface.enableWindowPinning = false; // } @@ -298,7 +298,7 @@ void Settings::Load() // interface // { interface.autosave_interval = iniInterface->getIntValue("autosave_interval"); - interface.invert_mouse = iniInterface->getValue("invert_mouse", false); + interface.invertMouse = iniInterface->getValue("invert_mouse", false); interface.enableWindowPinning = iniInterface->getValue("enable_window_pinning", false); // } @@ -461,7 +461,7 @@ void Settings::Save() // interface // { iniInterface->setValue("autosave_interval", interface.autosave_interval); - iniInterface->setValue("invert_mouse", interface.invert_mouse); + iniInterface->setValue("invert_mouse", interface.invertMouse); iniInterface->setValue("enable_window_pinning", interface.enableWindowPinning); // } diff --git a/libs/s25main/Settings.h b/libs/s25main/Settings.h index b25d19d45a..cd9169f6dd 100644 --- a/libs/s25main/Settings.h +++ b/libs/s25main/Settings.h @@ -105,7 +105,7 @@ class Settings : public Singleton struct { unsigned autosave_interval; - bool invert_mouse; + bool invertMouse; bool enableWindowPinning; } interface; diff --git a/libs/s25main/desktops/dskGameInterface.cpp b/libs/s25main/desktops/dskGameInterface.cpp index e8e5bc7abb..9731ff1460 100644 --- a/libs/s25main/desktops/dskGameInterface.cpp +++ b/libs/s25main/desktops/dskGameInterface.cpp @@ -691,7 +691,7 @@ bool dskGameInterface::Msg_MouseMove(const MouseCoords& mc) int acceleration = SETTINGS.global.smartCursor ? 2 : 3; - if(SETTINGS.interface.invert_mouse) + if(SETTINGS.interface.invertMouse) acceleration = -acceleration; gwv.MoveBy((mc.GetPos() - startScrollPt) * acceleration); diff --git a/libs/s25main/desktops/dskOptions.cpp b/libs/s25main/desktops/dskOptions.cpp index 077241ed0d..fccfde47ba 100644 --- a/libs/s25main/desktops/dskOptions.cpp +++ b/libs/s25main/desktops/dskOptions.cpp @@ -250,7 +250,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) _("When scrolling the map with the mouse move the camera.")); invertScroll->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Inverted"), NormalFont, _("When scrolling the map with the mouse move the map.")); - invertScroll->SetSelection(SETTINGS.interface.invert_mouse); + invertScroll->SetSelection(SETTINGS.interface.invertMouse); curPos.y += 30; groupAllgemein->AddText(ID_txtSmartCursor, curPos, _("Smart Cursor"), COLOR_YELLOW, FontStyle{}, NormalFont); diff --git a/libs/s25main/ingameWindows/iwObservate.cpp b/libs/s25main/ingameWindows/iwObservate.cpp index e01f120749..8666fcd8ff 100644 --- a/libs/s25main/ingameWindows/iwObservate.cpp +++ b/libs/s25main/ingameWindows/iwObservate.cpp @@ -231,7 +231,7 @@ bool iwObservate::Msg_MouseMove(const MouseCoords& mc) { int acceleration = SETTINGS.global.smartCursor ? 2 : 3; - if(SETTINGS.interface.invert_mouse) + if(SETTINGS.interface.invertMouse) acceleration = -acceleration; view->MoveBy((mc.GetPos() - scrollOrigin) * acceleration); diff --git a/libs/s25main/ingameWindows/iwSettings.cpp b/libs/s25main/ingameWindows/iwSettings.cpp index 5bbced6464..7432fb4fc7 100644 --- a/libs/s25main/ingameWindows/iwSettings.cpp +++ b/libs/s25main/ingameWindows/iwSettings.cpp @@ -62,7 +62,7 @@ iwSettings::iwSettings() AddCheckBox(ID_cbInvertMouse, DrawPoint(15, 124), Extent(150, 26), TextureColor::Grey, _("Invert mouse"), NormalFont, false) - ->setChecked(SETTINGS.interface.invert_mouse); + ->setChecked(SETTINGS.interface.invertMouse); AddCheckBox(ID_cbStatisticScale, DrawPoint(200, 124), Extent(150, 26), TextureColor::Grey, _("Statistics Scale"), NormalFont, false) ->setChecked(SETTINGS.ingame.scale_statistics); @@ -105,7 +105,7 @@ void iwSettings::Msg_CheckboxChange(const unsigned ctrl_id, const bool checked) { switch(ctrl_id) { - case ID_cbInvertMouse: SETTINGS.interface.invert_mouse = checked; break; + case ID_cbInvertMouse: SETTINGS.interface.invertMouse = checked; break; case ID_cbStatisticScale: SETTINGS.ingame.scale_statistics = checked; break; } } diff --git a/tests/s25Main/integration/testDskGameInterface.cpp b/tests/s25Main/integration/testDskGameInterface.cpp index cb12339e6b..69a43be134 100644 --- a/tests/s25Main/integration/testDskGameInterface.cpp +++ b/tests/s25Main/integration/testDskGameInterface.cpp @@ -67,7 +67,7 @@ void checkNotScrolling(const GameWorldView& view, Cursor cursor = Cursor::Hand) BOOST_FIXTURE_TEST_CASE(Scrolling, GameInterfaceFixture) { const int acceleration = 2; - SETTINGS.interface.invert_mouse = false; + SETTINGS.interface.invertMouse = false; Position startPos(10, 15); MouseCoords mouse(startPos, false, true); @@ -95,7 +95,7 @@ BOOST_FIXTURE_TEST_CASE(Scrolling, GameInterfaceFixture) // Inverted scrolling { - SETTINGS.interface.invert_mouse = true; + SETTINGS.interface.invertMouse = true; WINDOWMANAGER.Msg_RightDown(mouse); startPos = mouse.pos; BOOST_TEST_REQUIRE(WINDOWMANAGER.GetCursor() == Cursor::Scroll); @@ -106,7 +106,7 @@ BOOST_FIXTURE_TEST_CASE(Scrolling, GameInterfaceFixture) BOOST_TEST_REQUIRE(view->GetOffset() == pos - acceleration * Position(4, 3)); mouse.rdown = false; WINDOWMANAGER.Msg_RightUp(mouse); - SETTINGS.interface.invert_mouse = false; + SETTINGS.interface.invertMouse = false; } // Opening a window does not cancel scrolling From 3b7f3689423da810d8f94db0b5704c13b1afad5a Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 13 Aug 2023 20:02:47 +0200 Subject: [PATCH 5/7] Improve wording of the option and tooltips --- libs/s25main/desktops/dskOptions.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/s25main/desktops/dskOptions.cpp b/libs/s25main/desktops/dskOptions.cpp index fccfde47ba..38483b1caf 100644 --- a/libs/s25main/desktops/dskOptions.cpp +++ b/libs/s25main/desktops/dskOptions.cpp @@ -243,13 +243,13 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) } curPos.y += 50; - groupAllgemein->AddText(ID_txtInvertScroll, curPos, _("Mouse scroll behavior:"), COLOR_YELLOW, FontStyle{}, + groupAllgemein->AddText(ID_txtInvertScroll, curPos, _("Invert Mouse Pan:"), COLOR_YELLOW, FontStyle{}, NormalFont); ctrlOptionGroup* invertScroll = groupAllgemein->AddOptionGroup(ID_grpInvertScroll, GroupSelectType::Check); - invertScroll->AddTextButton(ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Original"), NormalFont, - _("When scrolling the map with the mouse move the camera.")); - invertScroll->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Inverted"), NormalFont, - _("When scrolling the map with the mouse move the map.")); + invertScroll->AddTextButton(ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Off"), NormalFont, + _("Map moves in the same direction the mouse is moved when scrolling/panning.")); + invertScroll->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("On"), NormalFont, + _("Map moves in the opposite direction the mouse is moved when scrolling/panning.")); invertScroll->SetSelection(SETTINGS.interface.invertMouse); curPos.y += 30; From e6feeefe5e74465ee3f1db9b3c39be4263bb7b34 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 13 Aug 2023 20:10:29 +0200 Subject: [PATCH 6/7] Make the button order consistently "On-Off" --- libs/s25main/desktops/dskOptions.cpp | 36 +++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/libs/s25main/desktops/dskOptions.cpp b/libs/s25main/desktops/dskOptions.cpp index 38483b1caf..6d9a64cd24 100644 --- a/libs/s25main/desktops/dskOptions.cpp +++ b/libs/s25main/desktops/dskOptions.cpp @@ -201,8 +201,8 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) groupAllgemein->AddText(ID_txtIpv6, curPos, _("Use IPv6:"), COLOR_YELLOW, FontStyle{}, NormalFont); ctrlOptionGroup* ipv6 = groupAllgemein->AddOptionGroup(ID_grpIpv6, GroupSelectType::Check); - ipv6->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("IPv6"), NormalFont); - ipv6->AddTextButton(ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("IPv4"), NormalFont); + ipv6->AddTextButton(ID_btOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("IPv6"), NormalFont); + ipv6->AddTextButton(ID_btOff, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("IPv4"), NormalFont); ipv6->SetSelection(SETTINGS.server.ipv6); // ipv6-feld ggf (de-)aktivieren ipv6->GetCtrl(1)->SetEnabled(SETTINGS.proxy.type != ProxyType::Socks5); //-V807 @@ -221,8 +221,8 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) groupAllgemein->AddText(ID_txtUPNP, curPos, _("Use UPnP"), COLOR_YELLOW, FontStyle{}, NormalFont); ctrlOptionGroup* upnp = groupAllgemein->AddOptionGroup(ID_grpUPNP, GroupSelectType::Check); - upnp->AddTextButton(ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Off"), NormalFont); - upnp->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("On"), NormalFont); + upnp->AddTextButton(ID_btOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("On"), NormalFont); + upnp->AddTextButton(ID_btOff, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Off"), NormalFont); upnp->SetSelection(SETTINGS.global.use_upnp); curPos.y += 30; @@ -243,31 +243,30 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) } curPos.y += 50; - groupAllgemein->AddText(ID_txtInvertScroll, curPos, _("Invert Mouse Pan:"), COLOR_YELLOW, FontStyle{}, - NormalFont); + groupAllgemein->AddText(ID_txtInvertScroll, curPos, _("Invert Mouse Pan:"), COLOR_YELLOW, FontStyle{}, NormalFont); ctrlOptionGroup* invertScroll = groupAllgemein->AddOptionGroup(ID_grpInvertScroll, GroupSelectType::Check); - invertScroll->AddTextButton(ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Off"), NormalFont, - _("Map moves in the same direction the mouse is moved when scrolling/panning.")); - invertScroll->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("On"), NormalFont, + invertScroll->AddTextButton(ID_btOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("On"), NormalFont, _("Map moves in the opposite direction the mouse is moved when scrolling/panning.")); + invertScroll->AddTextButton(ID_btOff, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Off"), NormalFont, + _("Map moves in the same direction the mouse is moved when scrolling/panning.")); invertScroll->SetSelection(SETTINGS.interface.invertMouse); curPos.y += 30; groupAllgemein->AddText(ID_txtSmartCursor, curPos, _("Smart Cursor"), COLOR_YELLOW, FontStyle{}, NormalFont); ctrlOptionGroup* smartCursor = groupAllgemein->AddOptionGroup(ID_grpSmartCursor, GroupSelectType::Check); + smartCursor->AddTextButton(ID_btOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("On"), NormalFont, + _("Place cursor on default button for new dialogs / action windows (default)")); smartCursor->AddTextButton( - ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Off"), NormalFont, + ID_btOff, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Off"), NormalFont, _("Don't move cursor automatically\nUseful e.g. for split-screen / dual-mice multiplayer (see wiki)")); - smartCursor->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("On"), NormalFont, - _("Place cursor on default button for new dialogs / action windows (default)")); smartCursor->SetSelection(SETTINGS.global.smartCursor); curPos.y += 50; groupAllgemein->AddText(ID_txtDebugData, curPos, _("Submit debug data:"), COLOR_YELLOW, FontStyle{}, NormalFont); optiongroup = groupAllgemein->AddOptionGroup(ID_grpDebugData, GroupSelectType::Check); - optiongroup->AddTextButton(ID_btSubmitDebugOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("On"), + optiongroup->AddTextButton(ID_btSubmitDebugOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("On"), NormalFont); - optiongroup->AddTextButton(ID_btSubmitDebugAsk, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Ask always"), + optiongroup->AddTextButton(ID_btSubmitDebugAsk, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Ask always"), NormalFont); optiongroup->SetSelection((SETTINGS.global.submit_debug_data == 1) ? ID_btSubmitDebugOn : @@ -276,8 +275,8 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) groupAllgemein->AddText(ID_txtGFInfo, curPos, _("Show GameFrame Info:"), COLOR_YELLOW, FontStyle{}, NormalFont); optiongroup = groupAllgemein->AddOptionGroup(ID_grpGFInfo, GroupSelectType::Check); - optiongroup->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("On"), NormalFont); - optiongroup->AddTextButton(ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Off"), NormalFont); + optiongroup->AddTextButton(ID_btOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("On"), NormalFont); + optiongroup->AddTextButton(ID_btOff, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Off"), NormalFont); optiongroup->SetSelection(SETTINGS.global.showGFInfo); @@ -290,9 +289,8 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) // "Vollbild" groupGrafik->AddText(ID_txtFullscreen, curPos, _("Mode:"), COLOR_YELLOW, FontStyle{}, NormalFont); optiongroup = groupGrafik->AddOptionGroup(ID_grpFullscreen, GroupSelectType::Check); - optiongroup->AddTextButton(ID_btOn, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Fullscreen"), - NormalFont); - optiongroup->AddTextButton(ID_btOff, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Windowed"), NormalFont); + optiongroup->AddTextButton(ID_btOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("Fullscreen"), NormalFont); + optiongroup->AddTextButton(ID_btOff, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("Windowed"), NormalFont); curPos.y += 50; // "VSync" From abb7e33d9e56a0e3fa4e329fc9b8685fbe9b9c2a Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 13 Aug 2023 20:24:21 +0200 Subject: [PATCH 7/7] Change label in iwSettings to "Invert Mouse Pan" Co-authored-by: Florian Albrechtskirchinger --- libs/s25main/ingameWindows/iwSettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/s25main/ingameWindows/iwSettings.cpp b/libs/s25main/ingameWindows/iwSettings.cpp index 7432fb4fc7..814d8f4cdf 100644 --- a/libs/s25main/ingameWindows/iwSettings.cpp +++ b/libs/s25main/ingameWindows/iwSettings.cpp @@ -60,7 +60,7 @@ iwSettings::iwSettings() NormalFont); optiongroup->SetSelection(SETTINGS.video.fullscreen); //-V807 - AddCheckBox(ID_cbInvertMouse, DrawPoint(15, 124), Extent(150, 26), TextureColor::Grey, _("Invert mouse"), + AddCheckBox(ID_cbInvertMouse, DrawPoint(15, 124), Extent(150, 26), TextureColor::Grey, _("Invert Mouse Pan"), NormalFont, false) ->setChecked(SETTINGS.interface.invertMouse); AddCheckBox(ID_cbStatisticScale, DrawPoint(200, 124), Extent(150, 26), TextureColor::Grey, _("Statistics Scale"),