194 * not happening until someone rewrites the whole widget-code */ |
194 * not happening until someone rewrites the whole widget-code */ |
195 if ((sb = &w->vscroll, wi1->type == WWT_SCROLLBAR) || (sb = &w->vscroll2, wi1->type == WWT_SCROLL2BAR) || |
195 if ((sb = &w->vscroll, wi1->type == WWT_SCROLLBAR) || (sb = &w->vscroll2, wi1->type == WWT_SCROLL2BAR) || |
196 (sb = &w->vscroll2, wi2->type == WWT_SCROLL2BAR) || (sb = &w->vscroll, wi2->type == WWT_SCROLLBAR) ) { |
196 (sb = &w->vscroll2, wi2->type == WWT_SCROLL2BAR) || (sb = &w->vscroll, wi2->type == WWT_SCROLLBAR) ) { |
197 |
197 |
198 if (sb->count > sb->cap) { |
198 if (sb->count > sb->cap) { |
199 int pos = clamp(sb->pos + wheel, 0, sb->count - sb->cap); |
199 int pos = Clamp(sb->pos + wheel, 0, sb->count - sb->cap); |
200 if (pos != sb->pos) { |
200 if (pos != sb->pos) { |
201 sb->pos = pos; |
201 sb->pos = pos; |
202 SetWindowDirty(w); |
202 SetWindowDirty(w); |
203 } |
203 } |
204 } |
204 } |
1293 } |
1293 } |
1294 } |
1294 } |
1295 |
1295 |
1296 /* Make sure the window doesn't leave the screen |
1296 /* Make sure the window doesn't leave the screen |
1297 * 13 is the height of the title bar */ |
1297 * 13 is the height of the title bar */ |
1298 nx = clamp(nx, 13 - t->right, _screen.width - 13 - t->left); |
1298 nx = Clamp(nx, 13 - t->right, _screen.width - 13 - t->left); |
1299 ny = clamp(ny, 0, _screen.height - 13); |
1299 ny = Clamp(ny, 0, _screen.height - 13); |
1300 |
1300 |
1301 /* Make sure the title bar isn't hidden by behind the main tool bar */ |
1301 /* Make sure the title bar isn't hidden by behind the main tool bar */ |
1302 v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
1302 v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
1303 if (v != NULL) { |
1303 if (v != NULL) { |
1304 int v_bottom = v->top + v->height; |
1304 int v_bottom = v->top + v->height; |
1464 |
1464 |
1465 if (!_scrolling_viewport) return true; |
1465 if (!_scrolling_viewport) return true; |
1466 |
1466 |
1467 w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y); |
1467 w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y); |
1468 |
1468 |
|
1469 if (!(_right_button_down || scrollwheel_scrolling) || w == NULL) { |
|
1470 _cursor.fix_at = false; |
|
1471 _scrolling_viewport = false; |
|
1472 return true; |
|
1473 } |
|
1474 |
1469 if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE && w == FindWindowById(WC_MAIN_WINDOW, 0)) { |
1475 if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE && w == FindWindowById(WC_MAIN_WINDOW, 0)) { |
1470 /* If the main window is following a vehicle, then first let go of it! */ |
1476 /* If the main window is following a vehicle, then first let go of it! */ |
1471 const Vehicle *veh = GetVehicle(WP(w, vp_d).follow_vehicle); |
1477 const Vehicle *veh = GetVehicle(WP(w, vp_d).follow_vehicle); |
1472 ScrollMainWindowTo(veh->x_pos, veh->y_pos, true); /* This also resets follow_vehicle */ |
1478 ScrollMainWindowTo(veh->x_pos, veh->y_pos, true); /* This also resets follow_vehicle */ |
1473 return true; |
|
1474 } |
|
1475 |
|
1476 if (!(_right_button_down || scrollwheel_scrolling) || w == NULL) { |
|
1477 _cursor.fix_at = false; |
|
1478 _scrolling_viewport = false; |
|
1479 return true; |
1479 return true; |
1480 } |
1480 } |
1481 |
1481 |
1482 if (_patches.reverse_scroll) { |
1482 if (_patches.reverse_scroll) { |
1483 e.we.scroll.delta.x = -_cursor.delta.x; |
1483 e.we.scroll.delta.x = -_cursor.delta.x; |
1770 if (scrollwheel_scrolling) click = MC_RIGHT; // we are using the scrollwheel in a viewport, so we emulate right mouse button |
1770 if (scrollwheel_scrolling) click = MC_RIGHT; // we are using the scrollwheel in a viewport, so we emulate right mouse button |
1771 switch (click) { |
1771 switch (click) { |
1772 case MC_DOUBLE_LEFT: |
1772 case MC_DOUBLE_LEFT: |
1773 case MC_LEFT: |
1773 case MC_LEFT: |
1774 DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite); |
1774 DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite); |
1775 if (_thd.place_mode != 0 && |
1775 if (_thd.place_mode != VHM_NONE && |
1776 /* query button and place sign button work in pause mode */ |
1776 /* query button and place sign button work in pause mode */ |
1777 _cursor.sprite != SPR_CURSOR_QUERY && |
1777 _cursor.sprite != SPR_CURSOR_QUERY && |
1778 _cursor.sprite != SPR_CURSOR_SIGN && |
1778 _cursor.sprite != SPR_CURSOR_SIGN && |
1779 _pause_game != 0 && |
1779 _pause_game != 0 && |
1780 !_cheats.build_in_pause.value) { |
1780 !_cheats.build_in_pause.value) { |
1781 return; |
1781 return; |
1782 } |
1782 } |
1783 |
1783 |
1784 if (_thd.place_mode == 0) { |
1784 if (_thd.place_mode == VHM_NONE) { |
1785 HandleViewportClicked(vp, x, y); |
1785 HandleViewportClicked(vp, x, y); |
1786 } else { |
1786 } else { |
1787 PlaceObject(); |
1787 PlaceObject(); |
1788 } |
1788 } |
1789 break; |
1789 break; |
2111 top = newh - w->height; |
2111 top = newh - w->height; |
2112 left = (neww - w->width) >> 1; |
2112 left = (neww - w->width) >> 1; |
2113 break; |
2113 break; |
2114 |
2114 |
2115 case WC_STATUS_BAR: |
2115 case WC_STATUS_BAR: |
2116 ResizeWindow(w, clamp(neww, 320, 640) - w->width, 0); |
2116 ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0); |
2117 top = newh - w->height; |
2117 top = newh - w->height; |
2118 left = (neww - w->width) >> 1; |
2118 left = (neww - w->width) >> 1; |
2119 break; |
2119 break; |
2120 |
2120 |
2121 case WC_SEND_NETWORK_MSG: |
2121 case WC_SEND_NETWORK_MSG: |
2122 ResizeWindow(w, clamp(neww, 320, 640) - w->width, 0); |
2122 ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0); |
2123 top = (newh - 26); // 26 = height of status bar + height of chat bar |
2123 top = (newh - 26); // 26 = height of status bar + height of chat bar |
2124 left = (neww - w->width) >> 1; |
2124 left = (neww - w->width) >> 1; |
2125 break; |
2125 break; |
2126 |
2126 |
2127 case WC_CONSOLE: |
2127 case WC_CONSOLE: |