Mercurial > hg > openttd
changeset 8423:c9e5db937b31 draft
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Sun, 27 Jan 2008 11:01:10 +0000 |
parents | b4a6ad2b644b |
children | 17e30bf8f359 |
files | src/airport_gui.cpp src/dock_gui.cpp src/misc_gui.cpp src/rail_gui.cpp src/road_gui.cpp src/station_gui.h |
diffstat | 6 files changed, 33 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -186,7 +186,12 @@ 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; }
--- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -254,7 +254,13 @@ 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; }
--- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -773,7 +773,7 @@ } -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 @@ /* 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)
--- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -864,7 +864,12 @@ 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;
--- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -825,9 +825,14 @@ 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;
--- a/src/station_gui.h +++ b/src/station_gui.h @@ -58,7 +58,7 @@ 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;