1697 static bool HandleViewportScroll() |
1697 static bool HandleViewportScroll() |
1698 { |
1698 { |
1699 WindowEvent e; |
1699 WindowEvent e; |
1700 BaseWindow *w; |
1700 BaseWindow *w; |
1701 |
1701 |
|
1702 bool scrollwheel_scrolling = _patches.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0); |
|
1703 |
1702 if (!_scrolling_viewport) return true; |
1704 if (!_scrolling_viewport) return true; |
1703 |
1705 |
1704 w = BaseWindow::FindFromPt(_cursor.pos.x, _cursor.pos.y); |
1706 w = BaseWindow::FindFromPt(_cursor.pos.x, _cursor.pos.y); |
1705 |
1707 |
1706 if (!_right_button_down || w == NULL) { |
1708 if (!(_right_button_down || scrollwheel_scrolling) || w == NULL) { |
1707 _cursor.fix_at = false; |
1709 _cursor.fix_at = false; |
1708 _scrolling_viewport = false; |
1710 _scrolling_viewport = false; |
1709 return true; |
1711 return true; |
1710 } |
1712 } |
1711 |
1713 |
1713 e.we.scroll.delta.x = -_cursor.delta.x; |
1715 e.we.scroll.delta.x = -_cursor.delta.x; |
1714 e.we.scroll.delta.y = -_cursor.delta.y; |
1716 e.we.scroll.delta.y = -_cursor.delta.y; |
1715 } else { |
1717 } else { |
1716 e.we.scroll.delta.x = _cursor.delta.x; |
1718 e.we.scroll.delta.x = _cursor.delta.x; |
1717 e.we.scroll.delta.y = _cursor.delta.y; |
1719 e.we.scroll.delta.y = _cursor.delta.y; |
|
1720 } |
|
1721 |
|
1722 if (scrollwheel_scrolling) { |
|
1723 /* We are using scrollwheels for scrolling */ |
|
1724 e.we.scroll.delta.x = _cursor.h_wheel; |
|
1725 e.we.scroll.delta.y = _cursor.v_wheel; |
|
1726 _cursor.v_wheel = 0; |
|
1727 _cursor.h_wheel = 0; |
1718 } |
1728 } |
1719 |
1729 |
1720 /* Create a scroll-event and send it to the window */ |
1730 /* Create a scroll-event and send it to the window */ |
1721 e.event = WE_SCROLL; |
1731 e.event = WE_SCROLL; |
1722 w->wndproc(w, &e); |
1732 w->wndproc(w, &e); |
1931 void MouseLoop(int click, int mousewheel) |
1941 void MouseLoop(int click, int mousewheel) |
1932 { |
1942 { |
1933 int x,y; |
1943 int x,y; |
1934 BaseWindow *w; |
1944 BaseWindow *w; |
1935 ViewPort *vp; |
1945 ViewPort *vp; |
|
1946 bool scrollwheel_scrolling = _patches.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0); |
1936 |
1947 |
1937 DecreaseWindowCounters(); |
1948 DecreaseWindowCounters(); |
1938 HandlePlacePresize(); |
1949 HandlePlacePresize(); |
1939 UpdateTileSelection(); |
1950 UpdateTileSelection(); |
1940 if (!VpHandlePlaceSizingDrag()) return; |
1951 if (!VpHandlePlaceSizingDrag()) return; |
1946 if (!HandleMouseOver()) return; |
1957 if (!HandleMouseOver()) return; |
1947 |
1958 |
1948 x = _cursor.pos.x; |
1959 x = _cursor.pos.x; |
1949 y = _cursor.pos.y; |
1960 y = _cursor.pos.y; |
1950 |
1961 |
1951 if (click == 0 && mousewheel == 0) return; |
1962 if (click == 0 && mousewheel == 0 && !scrollwheel_scrolling) return; |
1952 |
1963 |
1953 w = BaseWindow::FindFromPt(x, y); |
1964 w = BaseWindow::FindFromPt(x, y); |
1954 if (w == NULL) return; |
1965 if (w == NULL) return; |
1955 if (!MaybeBringWindowToFront(w)) return; |
1966 if (!MaybeBringWindowToFront(w)) return; |
1956 vp = IsPtInWindowViewport(w, x, y); |
1967 vp = IsPtInWindowViewport(w, x, y); |
1957 |
1968 |
1958 /* Don't allow any action in a viewport if either in menu of in generating world */ |
1969 /* Don't allow any action in a viewport if either in menu of in generating world */ |
1959 if (vp != NULL && (_game_mode == GM_MENU || IsGeneratingWorld())) return; |
1970 if (vp != NULL && (_game_mode == GM_MENU || IsGeneratingWorld())) return; |
1960 |
1971 |
1961 if (mousewheel != 0) { |
1972 if (mousewheel != 0) { |
1962 WindowEvent e; |
1973 if (_patches.scrollwheel_scrolling == 0) { |
1963 |
1974 /* Scrollwheel is in zoom mode. Make the zoom event. */ |
1964 /* Send WE_MOUSEWHEEL event to window */ |
1975 WindowEvent e; |
1965 e.event = WE_MOUSEWHEEL; |
1976 |
1966 e.we.wheel.wheel = mousewheel; |
1977 /* Send WE_MOUSEWHEEL event to window */ |
1967 w->wndproc(w, &e); |
1978 e.event = WE_MOUSEWHEEL; |
|
1979 e.we.wheel.wheel = mousewheel; |
|
1980 w->wndproc(w, &e); |
|
1981 } |
1968 |
1982 |
1969 /* Dispatch a MouseWheelEvent for widgets if it is not a viewport */ |
1983 /* Dispatch a MouseWheelEvent for widgets if it is not a viewport */ |
1970 if (vp == NULL) w->DispatchMouseWheelEvent(w->GetWidgetFromPos(x - w->Left(), y - w->Top()), mousewheel); |
1984 if (vp == NULL) w->DispatchMouseWheelEvent(w->GetWidgetFromPos(x - w->Left(), y - w->Top()), mousewheel); |
1971 } |
1985 } |
1972 |
1986 |
1973 if (vp != NULL) { |
1987 if (vp != NULL) { |
|
1988 if (scrollwheel_scrolling) click = 2; // we are using the scrollwheel in a viewport, so we emulate right mouse button |
1974 switch (click) { |
1989 switch (click) { |
1975 case 1: |
1990 case 1: |
1976 DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite); |
1991 DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite); |
1977 if (_thd.place_mode != 0 && |
1992 if (_thd.place_mode != 0 && |
1978 // query button and place sign button work in pause mode |
1993 // query button and place sign button work in pause mode |