From 0847def759cd8c07d880387779d2d54cdc5382f8 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sun, 27 Jan 2008 11:01:10 +0000 Subject: [PATCH] (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long. --- src/airport_gui.cpp | 7 ++++++- src/dock_gui.cpp | 8 +++++++- src/misc_gui.cpp | 10 ++++++---- src/rail_gui.cpp | 7 ++++++- src/road_gui.cpp | 9 +++++++-- src/station_gui.h | 2 +- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index c65951bc96..86f288610d 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -186,7 +186,12 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) DrawWindowWidgets(w); // strings such as 'Size' and 'Coverage Area' // 'Coverage Area' - DrawStationCoverageAreaText(2, 206, SCT_ALL, rad); + int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad) + 4; + if (text_end > w->widget[6].bottom) { + SetWindowDirty(w); + ResizeWindowForWidget(w, 6, 0, text_end - w->widget[6].bottom); + SetWindowDirty(w); + } break; } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 2c36a1616d..39f40a3a2c 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -254,7 +254,13 @@ static void BuildDockStationWndProc(Window *w, WindowEvent *e) SetTileSelectSize(1, 1); } - DrawStationCoverageAreaText(4, 50, SCT_ALL, rad); + int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad) + 4; + if (text_end > w->widget[2].bottom) { + SetWindowDirty(w); + ResizeWindowForWidget(w, 2, 0, text_end - w->widget[2].bottom); + SetWindowDirty(w); + } + break; } diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 8ef6d5f3f9..aa4a969022 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -773,7 +773,7 @@ void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[ } -static void DrawStationCoverageText(const AcceptedCargo accepts, +static int DrawStationCoverageText(const AcceptedCargo accepts, int str_x, int str_y, StationCoverageType sct) { char *b = _userstring; @@ -809,17 +809,19 @@ static void DrawStationCoverageText(const AcceptedCargo accepts, /* Make sure we detect any buffer overflow */ assert(b < endof(_userstring)); - DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); + return DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); } -void DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad) +int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad) { TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); AcceptedCargo accepts; if (tile < MapSize()) { GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); - DrawStationCoverageText(accepts, sx, sy, sct); + return sy + DrawStationCoverageText(accepts, sx, sy, sct); } + + return sy; } void CheckRedrawStationCoverage(const Window *w) diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index b29267af3a..698ceaa0cb 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -864,7 +864,12 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) DrawStringCentered(74, 101 + y_offset, STR_3004_PLATFORM_LENGTH, TC_FROMSTRING); DrawStringCentered(74, 141 + y_offset, STR_3066_COVERAGE_AREA_HIGHLIGHT, TC_FROMSTRING); - DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad); + int text_end = DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad) + 4; + if (text_end > w->widget[BRSW_BACKGROUND].bottom) { + SetWindowDirty(w); + ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom); + SetWindowDirty(w); + } if (newstations) { uint y = 35; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 11ccd44efd..811a20d82d 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -825,9 +825,14 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e) StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4); StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5); - DrawStationCoverageAreaText(2, 146, + int text_end = DrawStationCoverageAreaText(2, 146, (w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY, - 3); + 3) + 4; + if (text_end > w->widget[BRSW_BACKGROUND].bottom) { + SetWindowDirty(w); + ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom); + SetWindowDirty(w); + } } break; diff --git a/src/station_gui.h b/src/station_gui.h index ef4a3efebf..ad1db88db5 100644 --- a/src/station_gui.h +++ b/src/station_gui.h @@ -58,7 +58,7 @@ enum StationCoverageType { SCT_ALL }; -void DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad); +int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad); void CheckRedrawStationCoverage(const Window *w); extern bool _station_show_coverage;