diff options
-rw-r--r-- | bin/data/openttdd.grf | bin | 460778 -> 460845 bytes | |||
-rw-r--r-- | bin/data/openttdw.grf | bin | 460970 -> 461037 bytes | |||
-rw-r--r-- | bin/data/orig_dos.obg | 2 | ||||
-rw-r--r-- | bin/data/orig_dos_de.obg | 2 | ||||
-rw-r--r-- | bin/data/orig_win.obg | 2 | ||||
-rw-r--r-- | src/table/sprites.h | 5 | ||||
-rw-r--r-- | src/widget.cpp | 6 | ||||
-rw-r--r-- | src/window.cpp | 46 | ||||
-rw-r--r-- | src/window_gui.h | 16 |
9 files changed, 51 insertions, 28 deletions
diff --git a/bin/data/openttdd.grf b/bin/data/openttdd.grf Binary files differindex c60a07900..250024428 100644 --- a/bin/data/openttdd.grf +++ b/bin/data/openttdd.grf diff --git a/bin/data/openttdw.grf b/bin/data/openttdw.grf Binary files differindex fa0924c7e..e3b4904f2 100644 --- a/bin/data/openttdw.grf +++ b/bin/data/openttdw.grf diff --git a/bin/data/orig_dos.obg b/bin/data/orig_dos.obg index c46289cc7..a9b06a9ff 100644 --- a/bin/data/orig_dos.obg +++ b/bin/data/orig_dos.obg @@ -24,7 +24,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8 TRGC.GRF = ed446637e034104c5559b32c18afe78d TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9 TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6 -OPENTTDD.GRF = c886c7d5b38a93f2cb1cdc0d33472eb8 +OPENTTDD.GRF = 1575b6d5ba127ab93f9569d3a0839cbb [origin] default = You can find it on your Transport Tycoon Deluxe CD-ROM. diff --git a/bin/data/orig_dos_de.obg b/bin/data/orig_dos_de.obg index 897f767fa..7dc812db2 100644 --- a/bin/data/orig_dos_de.obg +++ b/bin/data/orig_dos_de.obg @@ -24,7 +24,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8 TRGC.GRF = ed446637e034104c5559b32c18afe78d TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9 TRGT.GRF = fcde1d7e8a74197d72a62695884b909e -OPENTTDD.GRF = c886c7d5b38a93f2cb1cdc0d33472eb8 +OPENTTDD.GRF = 1575b6d5ba127ab93f9569d3a0839cbb [origin] default = You can find it on your Transport Tycoon Deluxe CD-ROM. diff --git a/bin/data/orig_win.obg b/bin/data/orig_win.obg index a476d3036..fa3b405e7 100644 --- a/bin/data/orig_win.obg +++ b/bin/data/orig_win.obg @@ -24,7 +24,7 @@ TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32 TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1 TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8 -OPENTTDW.GRF = b6689105405fa3ea34cb8a5543633d29 +OPENTTDW.GRF = 09d1d843fcc0c2c278e5e6a6b557d658 [origin] default = You can find it on your Transport Tycoon Deluxe CD-ROM. diff --git a/src/table/sprites.h b/src/table/sprites.h index 5c14d88ba..c9ca6c98d 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -49,7 +49,7 @@ enum Sprites { /* Extra graphic spritenumbers */ SPR_OPENTTD_BASE = 4896, - OPENTTD_SPRITE_COUNT = 149, + OPENTTD_SPRITE_COUNT = 150, /* Halftile-selection sprites */ SPR_HALFTILE_SELECTION_FLAT = SPR_OPENTTD_BASE, @@ -62,7 +62,8 @@ enum Sprites { SPR_BOX_EMPTY = SPR_OPENTTD_BASE + 41, SPR_BOX_CHECKED = SPR_OPENTTD_BASE + 42, SPR_WARNING_SIGN = SPR_OPENTTD_BASE + 43, // warning sign (shown if there are any newgrf errors) - SPR_WINDOW_RESIZE = SPR_OPENTTD_BASE + 44, // resize icon + SPR_WINDOW_RESIZE_RIGHT= SPR_OPENTTD_BASE + 44, // resize icon to the right + SPR_WINDOW_RESIZE_LEFT = SPR_OPENTTD_BASE + 149, // resize icon to the left /* Arrow icons pointing in all 4 directions */ SPR_ARROW_DOWN = SPR_OPENTTD_BASE + 45, SPR_ARROW_UP = SPR_OPENTTD_BASE + 46, diff --git a/src/widget.cpp b/src/widget.cpp index ce4f4f160..2643eb9e3 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -451,7 +451,11 @@ void Window::DrawWidgets() const clicked = !!(this->flags4 & WF_SIZING); DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE); - DrawSprite(SPR_WINDOW_RESIZE, PAL_NONE, r.left + 3 + clicked, r.top + 3 + clicked); + if (wi->left < (this->width / 2)) { + DrawSprite(SPR_WINDOW_RESIZE_LEFT, PAL_NONE, r.left + 2, r.top + 3 + clicked); + } else { + DrawSprite(SPR_WINDOW_RESIZE_RIGHT, PAL_NONE, r.left + 3 + clicked, r.top + 3 + clicked); + } break; case WWT_CLOSEBOX: { diff --git a/src/window.cpp b/src/window.cpp index b73c4a6ba..ad8bbc889 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -228,7 +228,7 @@ bool Window::HasWidgetOfType(WidgetType widget_type) const } static void StartWindowDrag(Window *w); -static void StartWindowSizing(Window *w); +static void StartWindowSizing(Window *w, bool to_left); /** * Dispatch left mouse-button (possibly double) click in window. @@ -322,7 +322,9 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click) } if (w->desc_flags & WDF_RESIZABLE && wi->type == WWT_RESIZEBOX) { - StartWindowSizing(w); + /* When the resize widget is on the left size of the window + * we assume that that button is used to resize to the left. */ + StartWindowSizing(w, wi->left < (w->width / 2)); w->InvalidateWidget(widget); return; } @@ -1511,8 +1513,6 @@ static bool HandleWindowDragging() w->SetDirty(); return false; } else if (w->flags4 & WF_SIZING) { - int x, y; - /* Stop the sizing if the left mouse button was released */ if (!_left_button_down) { w->flags4 &= ~WF_SIZING; @@ -1520,8 +1520,15 @@ static bool HandleWindowDragging() break; } - x = _cursor.pos.x - _drag_delta.x; - y = _cursor.pos.y - _drag_delta.y; + /* Compute difference in pixels between cursor position and reference point in the window. + * If resizing the left edge of the window, moving to the left makes the window bigger not smaller. + */ + int x, y = _cursor.pos.y - _drag_delta.y; + if (w->flags4 & WF_SIZING_LEFT) { + x = _drag_delta.x - _cursor.pos.x; + } else { + x = _cursor.pos.x - _drag_delta.x; + } /* X and Y has to go by step.. calculate it. * The cast to int is necessary else x/y are implicitly casted to @@ -1531,18 +1538,26 @@ static bool HandleWindowDragging() if (w->resize.step_height > 1) y -= y % (int)w->resize.step_height; /* Check if we don't go below the minimum set size */ - if ((int)w->width + x < (int)w->resize.width) + if ((int)w->width + x < (int)w->resize.width) { x = w->resize.width - w->width; - if ((int)w->height + y < (int)w->resize.height) + } + if ((int)w->height + y < (int)w->resize.height) { y = w->resize.height - w->height; + } /* Window already on size */ if (x == 0 && y == 0) return false; - /* Now find the new cursor pos.. this is NOT _cursor, because - we move in steps. */ - _drag_delta.x += x; + /* Now find the new cursor pos.. this is NOT _cursor, because we move in steps. */ _drag_delta.y += y; + if (w->flags4 & WF_SIZING_LEFT && x != 0) { + _drag_delta.x -= x; // x > 0 -> window gets longer -> left-edge moves to left -> subtract x to get new position. + w->SetDirty(); + w->left -= x; // If dragging left edge, move left window edge in opposite direction by the same amount. + /* ResizeWindow() below ensures marking new position as dirty. */ + } else { + _drag_delta.x += x; + } /* ResizeWindow sets both pre- and after-size to dirty for redrawal */ ResizeWindow(w, x, y); @@ -1579,12 +1594,13 @@ static void StartWindowDrag(Window *w) } /** - * Start resizing a window - * @param w Window to start resizing + * Start resizing a window. + * @param w Window to start resizing. + * @param to_left Whether to drag towards the left or not */ -static void StartWindowSizing(Window *w) +static void StartWindowSizing(Window *w, bool to_left) { - w->flags4 |= WF_SIZING; + w->flags4 |= to_left ? WF_SIZING_LEFT : WF_SIZING_RIGHT; _dragging_window = true; _drag_delta.x = _cursor.pos.x; diff --git a/src/window_gui.h b/src/window_gui.h index bfcb33cba..f873eb94a 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -587,15 +587,17 @@ enum WindowFlags { WF_SCROLL_UP = 1 << 4, ///< Upper scroll button has been pressed, @see ScrollbarClickHandler() WF_SCROLL_DOWN = 1 << 5, ///< Lower scroll button has been pressed, @see ScrollbarClickHandler() WF_SCROLL_MIDDLE = 1 << 6, ///< Scrollbar scrolling, @see ScrollbarClickHandler() - WF_HSCROLL = 1 << 7, - WF_SIZING = 1 << 8, ///< Window is being resized. - WF_STICKY = 1 << 9, ///< Window is made sticky by user + WF_SCROLL2 = 1 << 7, + WF_HSCROLL = 1 << 8, + WF_SIZING_RIGHT = 1 << 9, ///< Window is being resized towards the right. + WF_SIZING_LEFT = 1 << 10, ///< Window is being resized towards the left. + WF_SIZING = WF_SIZING_RIGHT | WF_SIZING_LEFT, ///< Window is being resized. + WF_STICKY = 1 << 11, ///< Window is made sticky by user - WF_DISABLE_VP_SCROLL = 1 << 10, ///< Window does not do autoscroll, @see HandleAutoscroll() + WF_DISABLE_VP_SCROLL = 1 << 12, ///< Window does not do autoscroll, @see HandleAutoscroll() - WF_WHITE_BORDER_ONE = 1 << 11, - WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE, - WF_SCROLL2 = 1 << 13, + WF_WHITE_BORDER_ONE = 1 << 13, + WF_WHITE_BORDER_MASK = 1 << 14 | WF_WHITE_BORDER_ONE, }; Window *BringWindowToFrontById(WindowClass cls, WindowNumber number); |