From be7d27234fb9a5f07e40a3638c2552c6aae56a9e Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:17:05 +0200 Subject: [PATCH 1/5] map drag with right mouse --- client/eventsSDL/InputSourceMouse.cpp | 4 ++- client/gui/EventDispatcher.cpp | 8 ++++++ client/gui/EventDispatcher.h | 2 ++ client/gui/EventsReceiver.h | 4 ++- client/mapView/MapViewActions.cpp | 7 +++++- client/mapView/MapViewActions.h | 1 + client/windows/InfoWindows.cpp | 36 ++++++++++++++++++++++++++- client/windows/InfoWindows.h | 8 ++++++ config/schemas/settings.json | 2 +- 9 files changed, 67 insertions(+), 5 deletions(-) diff --git a/client/eventsSDL/InputSourceMouse.cpp b/client/eventsSDL/InputSourceMouse.cpp index d043fa30f..d23f6877d 100644 --- a/client/eventsSDL/InputSourceMouse.cpp +++ b/client/eventsSDL/InputSourceMouse.cpp @@ -33,7 +33,7 @@ InputSourceMouse::InputSourceMouse() void InputSourceMouse::handleEventMouseMotion(const SDL_MouseMotionEvent & motion) { Point newPosition = Point(motion.x, motion.y) / GH.screenHandler().getScalingFactor(); - Point distance= Point(-motion.xrel, -motion.yrel) / GH.screenHandler().getScalingFactor(); + Point distance = Point(-motion.xrel, -motion.yrel) / GH.screenHandler().getScalingFactor(); mouseButtonsMask = motion.state; @@ -41,6 +41,8 @@ void InputSourceMouse::handleEventMouseMotion(const SDL_MouseMotionEvent & motio GH.events().dispatchGesturePanning(middleClickPosition, newPosition, distance); else if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_LEFT)) GH.events().dispatchMouseDragged(newPosition, distance); + else if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_RIGHT)) + GH.events().dispatchMouseDraggedPopup(newPosition, distance); else GH.input().setCursorPosition(newPosition); } diff --git a/client/gui/EventDispatcher.cpp b/client/gui/EventDispatcher.cpp index 0518d305f..b43f8d209 100644 --- a/client/gui/EventDispatcher.cpp +++ b/client/gui/EventDispatcher.cpp @@ -35,6 +35,7 @@ void EventDispatcher::processLists(ui16 activityFlag, const Functor & cb) processList(AEventsReceiver::HOVER, hoverable); processList(AEventsReceiver::MOVE, motioninterested); processList(AEventsReceiver::DRAG, draginterested); + processList(AEventsReceiver::DRAG_POPUP, dragPopupInterested); processList(AEventsReceiver::KEYBOARD, keyinterested); processList(AEventsReceiver::TIME, timeinterested); processList(AEventsReceiver::WHEEL, wheelInterested); @@ -433,3 +434,10 @@ void EventDispatcher::dispatchMouseDragged(const Point & currentPosition, const elem->mouseDragged(currentPosition, lastUpdateDistance); } } + +void EventDispatcher::dispatchMouseDraggedPopup(const Point & currentPosition, const Point & lastUpdateDistance) +{ + EventReceiversList diCopy = dragPopupInterested; + for(auto & elem : diCopy) + elem->mouseDraggedPopup(currentPosition, lastUpdateDistance); +} diff --git a/client/gui/EventDispatcher.h b/client/gui/EventDispatcher.h index cd61a6b0c..4c212779e 100644 --- a/client/gui/EventDispatcher.h +++ b/client/gui/EventDispatcher.h @@ -30,6 +30,7 @@ class EventDispatcher EventReceiversList keyinterested; EventReceiversList motioninterested; EventReceiversList draginterested; + EventReceiversList dragPopupInterested; EventReceiversList timeinterested; EventReceiversList wheelInterested; EventReceiversList doubleClickInterested; @@ -66,6 +67,7 @@ public: void dispatchMouseMoved(const Point & distance, const Point & position); void dispatchMouseDragged(const Point & currentPosition, const Point & lastUpdateDistance); + void dispatchMouseDraggedPopup(const Point & currentPosition, const Point & lastUpdateDistance); void dispatchShowPopup(const Point & position, int tolerance); void dispatchClosePopup(const Point & position); diff --git a/client/gui/EventsReceiver.h b/client/gui/EventsReceiver.h index 6727dec87..da194890f 100644 --- a/client/gui/EventsReceiver.h +++ b/client/gui/EventsReceiver.h @@ -61,6 +61,7 @@ public: virtual void wheelScrolled(int distance) {} virtual void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) {} virtual void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) {} + virtual void mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) {} /// Called when UI element hover status changes virtual void hover(bool on) {} @@ -97,7 +98,8 @@ public: TEXTINPUT = 512, GESTURE = 1024, DRAG = 2048, - INPUT_MODE_CHANGE = 4096 + INPUT_MODE_CHANGE = 4096, + DRAG_POPUP = 8192 }; /// Returns true if element is currently hovered by mouse diff --git a/client/mapView/MapViewActions.cpp b/client/mapView/MapViewActions.cpp index 6c87edba4..6b2041a57 100644 --- a/client/mapView/MapViewActions.cpp +++ b/client/mapView/MapViewActions.cpp @@ -34,7 +34,7 @@ MapViewActions::MapViewActions(MapView & owner, const std::shared_ptrgetPixelsVisibleDimensions().x; pos.h = model->getPixelsVisibleDimensions().y; - addUsedEvents(LCLICK | SHOW_POPUP | DRAG | GESTURE | HOVER | MOVE | WHEEL); + addUsedEvents(LCLICK | SHOW_POPUP | DRAG | DRAG_POPUP | GESTURE | HOVER | MOVE | WHEEL); } void MapViewActions::setContext(const std::shared_ptr & context) @@ -101,6 +101,11 @@ void MapViewActions::mouseDragged(const Point & cursorPosition, const Point & la owner.onMapSwiped(lastUpdateDistance); } +void MapViewActions::mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) +{ + owner.onMapSwiped(lastUpdateDistance); +} + void MapViewActions::gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) { owner.onMapSwiped(lastUpdateDistance); diff --git a/client/mapView/MapViewActions.h b/client/mapView/MapViewActions.h index 02dd877aa..463f70780 100644 --- a/client/mapView/MapViewActions.h +++ b/client/mapView/MapViewActions.h @@ -42,6 +42,7 @@ public: void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override; void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) override; void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override; + void mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) override; void wheelScrolled(int distance) override; bool dragActive; diff --git a/client/windows/InfoWindows.cpp b/client/windows/InfoWindows.cpp index 4eaa690be..ba15715b8 100644 --- a/client/windows/InfoWindows.cpp +++ b/client/windows/InfoWindows.cpp @@ -245,8 +245,11 @@ void CRClickPopup::createAndPush(const CGObjectInstance * obj, const Point & p, } } -CRClickPopupInt::CRClickPopupInt(const std::shared_ptr & our) +CRClickPopupInt::CRClickPopupInt(const std::shared_ptr & our) : + dragDistance(Point(0, 0)) { + addUsedEvents(DRAG_POPUP); + CCS->curh->hide(); inner = our; addChild(our.get(), false); @@ -257,6 +260,17 @@ CRClickPopupInt::~CRClickPopupInt() CCS->curh->show(); } +void CRClickPopupInt::mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) +{ + if(!settings["adventure"]["rightButtonDrag"].Bool()) + return; + + dragDistance += lastUpdateDistance; + + if(dragDistance.length() > 16) + close(); +} + Point CInfoBoxPopup::toScreen(Point p) { auto bounds = adventureInt->terrainAreaPixels(); @@ -267,6 +281,18 @@ Point CInfoBoxPopup::toScreen(Point p) return p; } +void CInfoBoxPopup::mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) +{ + if(!settings["adventure"]["rightButtonDrag"].Bool()) + return; + + dragDistance += lastUpdateDistance; + + if(dragDistance.length() > 16) + close(); +} + + CInfoBoxPopup::CInfoBoxPopup(Point position, const CGTownInstance * town) : CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("TOWNQVBK"), toScreen(position)) { @@ -275,6 +301,8 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGTownInstance * town) OBJECT_CONSTRUCTION; tooltip = std::make_shared(Point(9, 10), iah); + + addUsedEvents(DRAG_POPUP); } CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero) @@ -285,6 +313,8 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero) OBJECT_CONSTRUCTION; tooltip = std::make_shared(Point(9, 10), iah); + + addUsedEvents(DRAG_POPUP); } CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr) @@ -295,6 +325,8 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr) OBJECT_CONSTRUCTION; tooltip = std::make_shared(Point(9, 10), iah); + + addUsedEvents(DRAG_POPUP); } CInfoBoxPopup::CInfoBoxPopup(Point position, const CGCreature * creature) @@ -302,6 +334,8 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGCreature * creature) { OBJECT_CONSTRUCTION; tooltip = std::make_shared(Point(9, 10), creature); + + addUsedEvents(DRAG_POPUP); } std::shared_ptr diff --git a/client/windows/InfoWindows.h b/client/windows/InfoWindows.h index 5da10014b..a06416934 100644 --- a/client/windows/InfoWindows.h +++ b/client/windows/InfoWindows.h @@ -78,9 +78,13 @@ class CRClickPopupInt : public CRClickPopup { std::shared_ptr inner; + Point dragDistance; + public: CRClickPopupInt(const std::shared_ptr & our); ~CRClickPopupInt(); + + void mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) override; }; /// popup on adventure map for town\hero and other objects with customized popup content @@ -89,11 +93,15 @@ class CInfoBoxPopup : public CWindowObject std::shared_ptr tooltip; Point toScreen(Point pos); + Point dragDistance; + public: CInfoBoxPopup(Point position, const CGTownInstance * town); CInfoBoxPopup(Point position, const CGHeroInstance * hero); CInfoBoxPopup(Point position, const CGGarrison * garr); CInfoBoxPopup(Point position, const CGCreature * creature); + + void mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) override; }; /// component selection window diff --git a/config/schemas/settings.json b/config/schemas/settings.json index d1e70bc4f..5dc55b828 100644 --- a/config/schemas/settings.json +++ b/config/schemas/settings.json @@ -316,7 +316,7 @@ "type" : "object", "additionalProperties" : false, "default" : {}, - "required" : [ "heroMoveTime", "enemyMoveTime", "scrollSpeedPixels", "heroReminder", "quickCombat", "objectAnimation", "terrainAnimation", "forceQuickCombat", "borderScroll", "leftButtonDrag", "smoothDragging", "backgroundDimLevel", "hideBackground", "backgroundDimSmallWindows" ], + "required" : [ "heroMoveTime", "enemyMoveTime", "scrollSpeedPixels", "heroReminder", "quickCombat", "objectAnimation", "terrainAnimation", "forceQuickCombat", "borderScroll", "leftButtonDrag", "rightButtonDrag", "smoothDragging", "backgroundDimLevel", "hideBackground", "backgroundDimSmallWindows" ], "properties" : { "heroMoveTime" : { "type" : "number", From 8f24778e9db714c88fb94eeebca914b2245c613b Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:36:41 +0200 Subject: [PATCH 2/5] config for right drag --- Mods/vcmi/config/vcmi/english.json | 6 +++-- Mods/vcmi/config/vcmi/german.json | 6 +++-- .../windows/settings/AdventureOptionsTab.cpp | 8 ++++++ .../widgets/settings/adventureOptionsTab.json | 26 +++++++++++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Mods/vcmi/config/vcmi/english.json b/Mods/vcmi/config/vcmi/english.json index 1cf794845..85e283e34 100644 --- a/Mods/vcmi/config/vcmi/english.json +++ b/Mods/vcmi/config/vcmi/english.json @@ -234,8 +234,10 @@ "vcmi.adventureOptions.borderScroll.help" : "{Border Scrolling}\n\nScroll adventure map when cursor is adjacent to window edge. Can be disabled by holding down CTRL key.", "vcmi.adventureOptions.infoBarCreatureManagement.hover" : "Info Panel Creature Management", "vcmi.adventureOptions.infoBarCreatureManagement.help" : "{Info Panel Creature Management}\n\nAllows rearranging creatures in info panel instead of cycling between default components.", - "vcmi.adventureOptions.leftButtonDrag.hover" : "Left Click Drag Map", - "vcmi.adventureOptions.leftButtonDrag.help" : "{Left Click Drag Map}\n\nWhen enabled, moving mouse with left button pressed will drag adventure map view.", + "vcmi.adventureOptions.leftButtonDrag.hover" : "Left Click Drag", + "vcmi.adventureOptions.leftButtonDrag.help" : "{Left Click Drag}\n\nWhen enabled, moving mouse with left button pressed will drag adventure map view.", + "vcmi.adventureOptions.rightButtonDrag.hover" : "Right Click Drag", + "vcmi.adventureOptions.rightButtonDrag.help" : "{Right Click Drag}\n\nWhen enabled, moving mouse with right button pressed will drag adventure map view.", "vcmi.adventureOptions.smoothDragging.hover" : "Smooth Map Dragging", "vcmi.adventureOptions.smoothDragging.help" : "{Smooth Map Dragging}\n\nWhen enabled, map dragging has a modern run out effect.", "vcmi.adventureOptions.skipAdventureMapAnimations.hover" : "Skip fading effects", diff --git a/Mods/vcmi/config/vcmi/german.json b/Mods/vcmi/config/vcmi/german.json index 3a8b9cea7..46ee28c79 100644 --- a/Mods/vcmi/config/vcmi/german.json +++ b/Mods/vcmi/config/vcmi/german.json @@ -234,8 +234,10 @@ "vcmi.adventureOptions.borderScroll.help" : "{Scrollen am Rand}\n\nScrollt die Abenteuerkarte, wenn sich der Cursor neben dem Fensterrand befindet. Kann mit gedrückter STRG-Taste deaktiviert werden.", "vcmi.adventureOptions.infoBarCreatureManagement.hover" : "Info-Panel Kreaturenmanagement", "vcmi.adventureOptions.infoBarCreatureManagement.help" : "{Info-Panel Kreaturenmanagement}\n\nErmöglicht die Neuanordnung von Kreaturen im Info-Panel, anstatt zwischen den Standardkomponenten zu wechseln", - "vcmi.adventureOptions.leftButtonDrag.hover" : "Ziehen der Karte mit Links", - "vcmi.adventureOptions.leftButtonDrag.help" : "{Ziehen der Karte mit Links}\n\nWenn aktiviert, wird die Maus bei gedrückter linker Taste in die Kartenansicht gezogen", + "vcmi.adventureOptions.leftButtonDrag.hover" : "Ziehen mit Links", + "vcmi.adventureOptions.leftButtonDrag.help" : "{Ziehen mit Links}\n\nWenn aktiviert, wird die Maus bei gedrückter linker Taste in der Kartenansicht gezogen", + "vcmi.adventureOptions.rightButtonDrag.hover" : "Ziehen mit Rechts", + "vcmi.adventureOptions.rightButtonDrag.help" : "{Ziehen mit Rechts}\n\nWenn aktiviert, wird die Maus bei gedrückter rechter Taste in der Kartenansicht gezogen", "vcmi.adventureOptions.smoothDragging.hover" : "Nahtloses Ziehen der Karte", "vcmi.adventureOptions.smoothDragging.help" : "{Nahtloses Ziehen der Karte}\n\nWenn aktiviert hat das Ziehen der Karte einen sanften Auslaufeffekt.", "vcmi.adventureOptions.skipAdventureMapAnimations.hover" : "Fading-Effekte überspringen", diff --git a/client/windows/settings/AdventureOptionsTab.cpp b/client/windows/settings/AdventureOptionsTab.cpp index 21e289b60..30f98f76c 100644 --- a/client/windows/settings/AdventureOptionsTab.cpp +++ b/client/windows/settings/AdventureOptionsTab.cpp @@ -126,6 +126,10 @@ AdventureOptionsTab::AdventureOptionsTab() { return setBoolSetting("adventure", "leftButtonDrag", value); }); + addCallback("rightButtonDragChanged", [](bool value) + { + return setBoolSetting("adventure", "rightButtonDrag", value); + }); addCallback("smoothDraggingChanged", [](bool value) { return setBoolSetting("adventure", "smoothDragging", value); @@ -177,6 +181,10 @@ AdventureOptionsTab::AdventureOptionsTab() if (leftButtonDragCheckbox) leftButtonDragCheckbox->setSelected(settings["adventure"]["leftButtonDrag"].Bool()); + std::shared_ptr rightButtonDragCheckbox = widget("rightButtonDragCheckbox"); + if (rightButtonDragCheckbox) + rightButtonDragCheckbox->setSelected(settings["adventure"]["rightButtonDrag"].Bool()); + std::shared_ptr smoothDraggingCheckbox = widget("smoothDraggingCheckbox"); if (smoothDraggingCheckbox) smoothDraggingCheckbox->setSelected(settings["adventure"]["smoothDragging"].Bool()); diff --git a/config/widgets/settings/adventureOptionsTab.json b/config/widgets/settings/adventureOptionsTab.json index 57886e5e2..33b48a884 100644 --- a/config/widgets/settings/adventureOptionsTab.json +++ b/config/widgets/settings/adventureOptionsTab.json @@ -371,6 +371,18 @@ } ] }, + { + "type": "verticalLayout", + "customType": "labelDescription", + "position": {"x": 225, "y": 415}, + "items": + [ + { + "text": "vcmi.adventureOptions.rightButtonDrag.hover", + "created" : "desktop" + } + ] + }, { "type": "verticalLayout", "customType": "checkbox", @@ -419,6 +431,20 @@ "callback": "smoothDraggingChanged" } ] + }, + { + "type": "verticalLayout", + "customType": "checkbox", + "position": {"x": 190, "y": 413}, + "items": + [ + { + "name": "rightButtonDragCheckbox", + "help": "vcmi.adventureOptions.rightButtonDrag", + "callback": "rightButtonDragChanged", + "created" : "desktop" + } + ] } ] } From 8ae4a4ab8ab7e7e88fc5e430f0bacbba10addd49 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:49:14 +0200 Subject: [PATCH 3/5] better german --- Mods/vcmi/config/vcmi/german.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mods/vcmi/config/vcmi/german.json b/Mods/vcmi/config/vcmi/german.json index 46ee28c79..dde909330 100644 --- a/Mods/vcmi/config/vcmi/german.json +++ b/Mods/vcmi/config/vcmi/german.json @@ -235,9 +235,9 @@ "vcmi.adventureOptions.infoBarCreatureManagement.hover" : "Info-Panel Kreaturenmanagement", "vcmi.adventureOptions.infoBarCreatureManagement.help" : "{Info-Panel Kreaturenmanagement}\n\nErmöglicht die Neuanordnung von Kreaturen im Info-Panel, anstatt zwischen den Standardkomponenten zu wechseln", "vcmi.adventureOptions.leftButtonDrag.hover" : "Ziehen mit Links", - "vcmi.adventureOptions.leftButtonDrag.help" : "{Ziehen mit Links}\n\nWenn aktiviert, wird die Maus bei gedrückter linker Taste in der Kartenansicht gezogen", + "vcmi.adventureOptions.leftButtonDrag.help" : "{Ziehen mit Links}\n\nWenn aktiviert, kann mit gedrückter linker Taste die Kartenansicht gezogen werden", "vcmi.adventureOptions.rightButtonDrag.hover" : "Ziehen mit Rechts", - "vcmi.adventureOptions.rightButtonDrag.help" : "{Ziehen mit Rechts}\n\nWenn aktiviert, wird die Maus bei gedrückter rechter Taste in der Kartenansicht gezogen", + "vcmi.adventureOptions.rightButtonDrag.help" : "{Ziehen mit Rechts}\n\nWenn aktiviert, kann mit gedrückter rechter Taste die Kartenansicht gezogen werden", "vcmi.adventureOptions.smoothDragging.hover" : "Nahtloses Ziehen der Karte", "vcmi.adventureOptions.smoothDragging.help" : "{Nahtloses Ziehen der Karte}\n\nWenn aktiviert hat das Ziehen der Karte einen sanften Auslaufeffekt.", "vcmi.adventureOptions.skipAdventureMapAnimations.hover" : "Fading-Effekte überspringen", From aa6cbdf13b959e07496442a2fff401cb32e8b7c9 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Wed, 28 Aug 2024 23:07:00 +0200 Subject: [PATCH 4/5] make it also usable on android --- client/windows/settings/AdventureOptionsTab.cpp | 4 ++++ client/windows/settings/GeneralOptionsTab.cpp | 4 +++- client/windows/settings/SettingsMainWindow.cpp | 5 +++++ client/windows/settings/SettingsMainWindow.h | 1 + config/widgets/settings/adventureOptionsTab.json | 8 ++++---- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/client/windows/settings/AdventureOptionsTab.cpp b/client/windows/settings/AdventureOptionsTab.cpp index 30f98f76c..0fa168a7b 100644 --- a/client/windows/settings/AdventureOptionsTab.cpp +++ b/client/windows/settings/AdventureOptionsTab.cpp @@ -11,6 +11,7 @@ #include "AdventureOptionsTab.h" +#include "../../eventsSDL/InputHandler.h" #include "../../../lib/filesystem/ResourcePath.h" #include "../../gui/CGuiHandler.h" #include "../../widgets/Buttons.h" @@ -36,6 +37,9 @@ AdventureOptionsTab::AdventureOptionsTab() OBJECT_CONSTRUCTION; setRedrawParent(true); + addConditional("touchscreen", GH.input().getCurrentInputMode() == InputMode::TOUCH); + addConditional("keyboardMouse", GH.input().getCurrentInputMode() == InputMode::KEYBOARD_AND_MOUSE); + addConditional("controller", GH.input().getCurrentInputMode() == InputMode::CONTROLLER); #ifdef VCMI_MOBILE addConditional("mobile", true); addConditional("desktop", false); diff --git a/client/windows/settings/GeneralOptionsTab.cpp b/client/windows/settings/GeneralOptionsTab.cpp index b0a965414..d8ead20f8 100644 --- a/client/windows/settings/GeneralOptionsTab.cpp +++ b/client/windows/settings/GeneralOptionsTab.cpp @@ -97,7 +97,9 @@ GeneralOptionsTab::GeneralOptionsTab() OBJECT_CONSTRUCTION; setRedrawParent(true); - addConditional("touchscreen", GH.input().hasTouchInputDevice()); + addConditional("touchscreen", GH.input().getCurrentInputMode() == InputMode::TOUCH); + addConditional("keyboardMouse", GH.input().getCurrentInputMode() == InputMode::KEYBOARD_AND_MOUSE); + addConditional("controller", GH.input().getCurrentInputMode() == InputMode::CONTROLLER); #ifdef VCMI_MOBILE addConditional("mobile", true); addConditional("desktop", false); diff --git a/client/windows/settings/SettingsMainWindow.cpp b/client/windows/settings/SettingsMainWindow.cpp index 6b7b53a1b..af6b4769d 100644 --- a/client/windows/settings/SettingsMainWindow.cpp +++ b/client/windows/settings/SettingsMainWindow.cpp @@ -196,3 +196,8 @@ void SettingsMainWindow::onScreenResize() if (tab) tab->updateResolutionSelector(); } + +void SettingsMainWindow::inputModeChanged(InputMode mode) +{ + tabContentArea->reset(); +} diff --git a/client/windows/settings/SettingsMainWindow.h b/client/windows/settings/SettingsMainWindow.h index 7b26921df..5813ac46b 100644 --- a/client/windows/settings/SettingsMainWindow.h +++ b/client/windows/settings/SettingsMainWindow.h @@ -42,5 +42,6 @@ public: void showAll(Canvas & to) override; void onScreenResize() override; + void inputModeChanged(InputMode mode) override; }; diff --git a/config/widgets/settings/adventureOptionsTab.json b/config/widgets/settings/adventureOptionsTab.json index 33b48a884..3cddfb4ac 100644 --- a/config/widgets/settings/adventureOptionsTab.json +++ b/config/widgets/settings/adventureOptionsTab.json @@ -364,7 +364,7 @@ }, { "text": "vcmi.adventureOptions.leftButtonDrag.hover", - "created" : "desktop" + "created" : "keyboardMouse" }, { "text": "vcmi.adventureOptions.smoothDragging.hover" @@ -379,7 +379,7 @@ [ { "text": "vcmi.adventureOptions.rightButtonDrag.hover", - "created" : "desktop" + "created" : "keyboardMouse" } ] }, @@ -423,7 +423,7 @@ "name": "leftButtonDragCheckbox", "help": "vcmi.adventureOptions.leftButtonDrag", "callback": "leftButtonDragChanged", - "created" : "desktop" + "created" : "keyboardMouse" }, { "name": "smoothDraggingCheckbox", @@ -442,7 +442,7 @@ "name": "rightButtonDragCheckbox", "help": "vcmi.adventureOptions.rightButtonDrag", "callback": "rightButtonDragChanged", - "created" : "desktop" + "created" : "keyboardMouse" } ] } From 091523d67b49fbde38046251c6fd4a37eaca93c1 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Wed, 28 Aug 2024 23:37:38 +0200 Subject: [PATCH 5/5] add missing event --- client/windows/settings/SettingsMainWindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/windows/settings/SettingsMainWindow.cpp b/client/windows/settings/SettingsMainWindow.cpp index af6b4769d..05562bae5 100644 --- a/client/windows/settings/SettingsMainWindow.cpp +++ b/client/windows/settings/SettingsMainWindow.cpp @@ -45,6 +45,8 @@ SettingsMainWindow::SettingsMainWindow(BattleInterface * parentBattleUi) : Inter addCallback("closeWindow", [this](int) { backButtonCallback(); }); build(config); + addUsedEvents(INPUT_MODE_CHANGE); + std::shared_ptr background = widget("background"); pos.w = background->pos.w; pos.h = background->pos.h;