diff options
author | rubidium <rubidium@openttd.org> | 2010-12-11 10:10:25 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-12-11 10:10:25 +0000 |
commit | b8c9931f75e65961dc599c6b9edf5861d7ec6474 (patch) | |
tree | 048372ff83f7881784e25b5939b534b15abfbce8 /src | |
parent | 9336dccee6b92e531e2777701e5790f6b01a19ce (diff) | |
download | openttd-b8c9931f75e65961dc599c6b9edf5861d7ec6474.tar.xz |
(svn r21460) -Change [FS#3975]: place the bridge building window under the mouse instead of somewhere randomly on the screen and change the default sort order
Diffstat (limited to 'src')
-rw-r--r-- | src/bridge_gui.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index efe1d1636..6c61f21f2 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -204,6 +204,16 @@ public: } } + virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + { + /* Position the window so hopefully the first bridge from the list is under the mouse pointer. */ + NWidgetBase *list = this->GetWidget<NWidgetBase>(BBSW_BRIDGE_LIST); + Point corner; // point of the top left corner of the window. + corner.y = Clamp(_cursor.pos.y - list->pos_y - 5, GetMainViewTop(), GetMainViewBottom() - sm_height); + corner.x = Clamp(_cursor.pos.x - list->pos_x - 5, 0, _screen.width - sm_width); + return corner; + } + virtual void DrawWidget(const Rect &r, int widget) const { switch (widget) { @@ -286,7 +296,7 @@ public: /** Set the default size of the Build Bridge Window. */ uint16 BuildBridgeWindow::last_size = 4; /** Set the default sorting for the bridges */ -Listing BuildBridgeWindow::last_sorting = {false, 0}; +Listing BuildBridgeWindow::last_sorting = {true, 2}; /** Available bridge sorting functions. */ GUIBridgeList::SortFunction * const BuildBridgeWindow::sorter_funcs[] = { |