diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 5e1109e49e..40f6471f2e 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -170,7 +170,8 @@ namespace OpenRA public bool ViewportEdgeScroll = true; public bool LockMouseWindow = false; - public MouseScrollType MouseScroll = MouseScrollType.Standard; + public MouseScrollType MiddleMouseScroll = MouseScrollType.Standard; + public MouseScrollType RightMouseScroll = MouseScrollType.Disabled; public MouseButtonPreference MouseButtonPreference = new MouseButtonPreference(); public float ViewportEdgeScrollStep = 10f; public float UIScrollSpeed = 50f; diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index b12b650657..14ea1c9a92 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -402,9 +402,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic MakeMouseFocusSettingsLive(); }; - var mouseScrollDropdown = panel.Get("MOUSE_SCROLL"); - mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown, gs); - mouseScrollDropdown.GetText = () => gs.MouseScroll.ToString(); + var middleMouseScrollDropdown = panel.Get("MIDDLE_MOUSE_SCROLL"); + middleMouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(middleMouseScrollDropdown, gs, false); + middleMouseScrollDropdown.GetText = () => gs.MiddleMouseScroll.ToString(); + + var rightMouseScrollDropdown = panel.Get("RIGHT_MOUSE_SCROLL"); + rightMouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(rightMouseScrollDropdown, gs, true); + rightMouseScrollDropdown.GetText = () => gs.RightMouseScroll.ToString(); var zoomModifierDropdown = panel.Get("ZOOM_MODIFIER"); zoomModifierDropdown.OnMouseDown = _ => ShowZoomModifierDropdown(zoomModifierDropdown, gs); @@ -573,7 +577,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic return () => { gs.UseClassicMouseStyle = dgs.UseClassicMouseStyle; - gs.MouseScroll = dgs.MouseScroll; + gs.MiddleMouseScroll = dgs.MiddleMouseScroll; + gs.RightMouseScroll = dgs.RightMouseScroll; gs.LockMouseWindow = dgs.LockMouseWindow; gs.ViewportEdgeScroll = dgs.ViewportEdgeScroll; gs.ViewportEdgeScrollStep = dgs.ViewportEdgeScrollStep; @@ -633,7 +638,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; } - static bool ShowMouseScrollDropdown(DropDownButtonWidget dropdown, GameSettings s) + static bool ShowMouseScrollDropdown(DropDownButtonWidget dropdown, GameSettings s, bool rightMouse) { var options = new Dictionary() { @@ -646,8 +651,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic Func setupItem = (o, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, - () => s.MouseScroll == options[o], - () => s.MouseScroll = options[o]); + () => (rightMouse ? s.RightMouseScroll : s.MiddleMouseScroll) == options[o], + () => { if (rightMouse) s.RightMouseScroll = options[o]; else s.MiddleMouseScroll = options[o]; }); item.Get("LABEL").GetText = () => o; return item; }; diff --git a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs index 4778ee24d3..f6f9d7472b 100644 --- a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs @@ -225,32 +225,37 @@ namespace OpenRA.Mods.Common.Widgets return true; } - var scrolltype = Game.Settings.Game.MouseScroll; - if (scrolltype == MouseScrollType.Disabled) + var scrollType = MouseScrollType.Disabled; + + if (mi.Button == MouseButton.Middle || mi.Button == (MouseButton.Left | MouseButton.Right)) + scrollType = Game.Settings.Game.MiddleMouseScroll; + else if (mi.Button == MouseButton.Right) + scrollType = Game.Settings.Game.RightMouseScroll; + + if (scrollType == MouseScrollType.Disabled) return false; - if (scrolltype == MouseScrollType.Standard || scrolltype == MouseScrollType.Inverted) + if (scrollType == MouseScrollType.Standard || scrollType == MouseScrollType.Inverted) { - if (mi.Event == MouseInputEvent.Move && - (mi.Button == MouseButton.Middle || mi.Button == (MouseButton.Left | MouseButton.Right))) + if (mi.Event == MouseInputEvent.Move) { - var d = scrolltype == MouseScrollType.Inverted ? -1 : 1; + var d = scrollType == MouseScrollType.Inverted ? -1 : 1; worldRenderer.Viewport.Scroll((Viewport.LastMousePos - mi.Location) * d, false); return true; } } - // Tiberian Sun style right-click-and-drag scrolling - if (scrolltype == MouseScrollType.Joystick) + // Tiberian Sun style click-and-drag scrolling + if (scrollType == MouseScrollType.Joystick) { - if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down) + if (mi.Event == MouseInputEvent.Down) { if (!TakeMouseFocus(mi)) return false; joystickScrollStart = mi.Location; } - if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Up) + if (mi.Event == MouseInputEvent.Up) { var wasJoystickScrolling = IsJoystickScrolling; @@ -261,10 +266,8 @@ namespace OpenRA.Mods.Common.Widgets return true; } - if (mi.Event == MouseInputEvent.Move && mi.Button == MouseButton.Right && joystickScrollStart.HasValue) - { + if (mi.Event == MouseInputEvent.Move && joystickScrollStart.HasValue) joystickScrollEnd = mi.Location; - } } return false; diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 354a40d54b..217feeaa64 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -337,84 +337,97 @@ Container@SETTINGS_PANEL: Width: 250 Height: 20 Font: Regular - Text: Left-Click Orders - Label@MOUSE_SCROLL_LABEL: + Text: Left-click Orders + Label@MIDDLE_MOUSE_SCROLL_LABEL: X: PARENT_RIGHT - WIDTH - 120 Y: 39 Width: 160 Height: 20 Font: Regular - Text: Mouse Scrolling Method: + Text: Middle-mouse Scrolling: Align: Right - DropDownButton@MOUSE_SCROLL: + DropDownButton@MIDDLE_MOUSE_SCROLL: X: PARENT_RIGHT - WIDTH - 15 Y: 38 Width: 100 Height: 25 Font: Regular - Text: Enabled - Checkbox@ALLOW_ZOOM_CHECKBOX: - X: 15 - Y: 70 - Width: 130 - Height: 20 - Font: Regular - Text: Allow zoom - Label@ZOOM_MODIFIER_LABEL: + Label@MIDDLE_MOUSE_SCROLL_LABEL: X: PARENT_RIGHT - WIDTH - 120 - Y: 68 + Y: 69 Width: 160 Height: 20 Font: Regular - Text: Modifier used to zoom: + Text: Right-mouse Scrolling: + Align: Right + DropDownButton@RIGHT_MOUSE_SCROLL: + X: PARENT_RIGHT - WIDTH - 15 + Y: 68 + Width: 100 + Height: 25 + Font: Regular + Label@ZOOM_MODIFIER_LABEL: + X: PARENT_RIGHT - WIDTH - 120 + Y: 98 + Width: 160 + Height: 20 + Font: Regular + Text: Scroll-zoom Modifier: Align: Right DropDownButton@ZOOM_MODIFIER: X: PARENT_RIGHT - WIDTH - 15 - Y: 68 + Y: 98 Width: 100 Height: 25 Font: Regular Text: Alt Checkbox@EDGESCROLL_CHECKBOX: X: 15 - Y: 100 + Y: 70 Width: 130 Height: 20 Font: Regular Text: Edge Scrolling + Checkbox@ALLOW_ZOOM_CHECKBOX: + X: 15 + Y: 100 + Width: 130 + Height: 20 + Font: Regular + Text: Scroll Zooming Checkbox@LOCKMOUSE_CHECKBOX: X: 15 Y: 130 Width: 130 Height: 20 Font: Regular - Text: Lock mouse to window + Text: Lock Mouse to Window Label@SCROLL_SPEED_LABEL: X: PARENT_RIGHT - WIDTH - 270 - Y: 97 + Y: 127 Width: 95 Height: 25 Text: Scroll Speed: Align: Right Slider@SCROLLSPEED_SLIDER: - X: PARENT_RIGHT - WIDTH - 15 - Y: 103 - Width: 250 + X: PARENT_RIGHT - WIDTH - 170 + Y: 133 + Width: 100 Height: 20 Ticks: 5 MinimumValue: 10 MaximumValue: 50 Label@UI_SCROLL_SPEED_LABEL: - X: PARENT_RIGHT - WIDTH - 270 + X: PARENT_RIGHT - WIDTH - 106 Y: 127 Width: 95 Height: 25 - Text: UI Scroll Speed: + Text: UI Scroll: Align: Right Slider@UI_SCROLLSPEED_SLIDER: - X: PARENT_RIGHT - WIDTH - 15 + X: PARENT_RIGHT - WIDTH - 6 Y: 133 - Width: 250 + Width: 100 Height: 20 Ticks: 5 MinimumValue: 1 diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index ffdf5c7494..dc45d46316 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -341,51 +341,64 @@ Background@SETTINGS_PANEL: Width: 250 Height: 20 Font: Regular - Text: Left-Click Orders - Label@MOUSE_SCROLL_LABEL: + Text: Left-click Orders + Label@MIDDLE_MOUSE_SCROLL_LABEL: X: PARENT_RIGHT - WIDTH - 120 Y: 39 Width: 160 Height: 20 Font: Regular - Text: Mouse Scrolling Method: + Text: Middle-mouse Scrolling: Align: Right - DropDownButton@MOUSE_SCROLL: + DropDownButton@MIDDLE_MOUSE_SCROLL: X: PARENT_RIGHT - WIDTH - 15 Y: 38 Width: 100 Height: 25 Font: Regular - Text: Enabled - Checkbox@ALLOW_ZOOM_CHECKBOX: - X: 15 - Y: 70 - Width: 130 - Height: 20 - Font: Regular - Text: Allow zoom - Label@ZOOM_MODIFIER_LABEL: + Label@MIDDLE_MOUSE_SCROLL_LABEL: X: PARENT_RIGHT - WIDTH - 120 - Y: 68 + Y: 69 Width: 160 Height: 20 Font: Regular - Text: Modifier used to zoom: + Text: Right-mouse Scrolling: + Align: Right + DropDownButton@RIGHT_MOUSE_SCROLL: + X: PARENT_RIGHT - WIDTH - 15 + Y: 68 + Width: 100 + Height: 25 + Font: Regular + Label@ZOOM_MODIFIER_LABEL: + X: PARENT_RIGHT - WIDTH - 120 + Y: 98 + Width: 160 + Height: 20 + Font: Regular + Text: Scroll-zoom Modifier: Align: Right DropDownButton@ZOOM_MODIFIER: X: PARENT_RIGHT - WIDTH - 15 - Y: 68 + Y: 98 Width: 100 Height: 25 Font: Regular Text: Alt Checkbox@EDGESCROLL_CHECKBOX: X: 15 - Y: 100 + Y: 70 Width: 130 Height: 20 Font: Regular Text: Edge Scrolling + Checkbox@ALLOW_ZOOM_CHECKBOX: + X: 15 + Y: 100 + Width: 130 + Height: 20 + Font: Regular + Text: Scroll Zooming Checkbox@LOCKMOUSE_CHECKBOX: X: 15 Y: 130 @@ -395,30 +408,30 @@ Background@SETTINGS_PANEL: Text: Lock mouse to window Label@SCROLL_SPEED_LABEL: X: PARENT_RIGHT - WIDTH - 270 - Y: 97 + Y: 127 Width: 95 Height: 25 Text: Scroll Speed: Align: Right Slider@SCROLLSPEED_SLIDER: - X: PARENT_RIGHT - WIDTH - 15 - Y: 103 - Width: 250 + X: PARENT_RIGHT - WIDTH - 170 + Y: 133 + Width: 100 Height: 20 Ticks: 5 MinimumValue: 10 MaximumValue: 50 Label@UI_SCROLL_SPEED_LABEL: - X: PARENT_RIGHT - WIDTH - 270 + X: PARENT_RIGHT - WIDTH - 106 Y: 127 Width: 95 Height: 25 - Text: UI Scroll Speed: + Text: UI Scroll: Align: Right Slider@UI_SCROLLSPEED_SLIDER: - X: PARENT_RIGHT - WIDTH - 15 + X: PARENT_RIGHT - WIDTH - 6 Y: 133 - Width: 250 + Width: 100 Height: 20 Ticks: 5 MinimumValue: 1