(svn r16789) -Codechange: unify the drawing of the Accepts/Supplies cargo lists in the station build windows.

This commit is contained in:
yexo 2009-07-10 22:03:09 +00:00
parent 58ee544cff
commit 4843b3c45d
6 changed files with 31 additions and 27 deletions

View File

@ -233,13 +233,13 @@ public:
if (_settings_game.economy.station_noise_level) { if (_settings_game.economy.station_noise_level) {
/* show the noise of the selected airport */ /* show the noise of the selected airport */
SetDParam(0, airport->noise_level); SetDParam(0, airport->noise_level);
DrawString(WD_FRAMERECT_LEFT, this->width - WD_FRAMERECT_RIGHT, top, STR_STATION_NOISE); DrawString(this->widget[BAW_BOTTOMPANEL].left + WD_FRAMERECT_LEFT, this->widget[BAW_BOTTOMPANEL].right - WD_FRAMERECT_RIGHT, top, STR_STATION_NOISE);
top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
} }
/* strings such as 'Size' and 'Coverage Area' */ /* strings such as 'Size' and 'Coverage Area' */
top = DrawStationCoverageAreaText(WD_FRAMERECT_LEFT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL; top = DrawStationCoverageAreaText(this->widget[BAW_BOTTOMPANEL].left + WD_FRAMERECT_LEFT, this->widget[BAW_BOTTOMPANEL].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
top = DrawStationCoverageAreaText(WD_FRAMERECT_LEFT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL; top = DrawStationCoverageAreaText(this->widget[BAW_BOTTOMPANEL].left + WD_FRAMERECT_LEFT, this->widget[BAW_BOTTOMPANEL].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
if (top != this->widget[BAW_BOTTOMPANEL].bottom) { if (top != this->widget[BAW_BOTTOMPANEL].bottom) {
this->SetDirty(); this->SetDirty();
ResizeWindowForWidget(this, BAW_BOTTOMPANEL, 0, top - this->widget[BAW_BOTTOMPANEL].bottom); ResizeWindowForWidget(this, BAW_BOTTOMPANEL, 0, top - this->widget[BAW_BOTTOMPANEL].bottom);

View File

@ -402,11 +402,13 @@ public:
SetTileSelectSize(1, 1); SetTileSelectSize(1, 1);
} }
int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad, false); /* strings such as 'Size' and 'Coverage Area' */
text_end = DrawStationCoverageAreaText(4, text_end + 4, SCT_ALL, rad, true) + 4; int top = this->widget[BDSW_LT_OFF].bottom + WD_PAR_VSEP_NORMAL;
if (text_end != this->widget[BDSW_BACKGROUND].bottom) { top = DrawStationCoverageAreaText(this->widget[BDSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BDSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
top = DrawStationCoverageAreaText(this->widget[BDSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BDSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
if (top != this->widget[BDSW_BACKGROUND].bottom) {
this->SetDirty(); this->SetDirty();
ResizeWindowForWidget(this, 2, 0, text_end - this->widget[BDSW_BACKGROUND].bottom); ResizeWindowForWidget(this, BDSW_BACKGROUND, 0, top - this->widget[BDSW_BACKGROUND].bottom);
this->SetDirty(); this->SetDirty();
} }
} }

View File

@ -811,7 +811,7 @@ void GuiShowTooltips(StringID str, uint paramcount, const uint64 params[], bool
static int DrawStationCoverageText(const CargoArray &cargos, static int DrawStationCoverageText(const CargoArray &cargos,
int str_x, int str_y, StationCoverageType sct, bool supplies) int left, int right, int top, StationCoverageType sct, bool supplies)
{ {
bool first = true; bool first = true;
@ -847,19 +847,20 @@ static int DrawStationCoverageText(const CargoArray &cargos,
assert(b < endof(string)); assert(b < endof(string));
SetDParamStr(0, string); SetDParamStr(0, string);
return DrawStringMultiLine(str_x, str_x + 144, str_y, INT32_MAX, STR_JUST_RAW_STRING); return DrawStringMultiLine(left, right, top, INT32_MAX, STR_JUST_RAW_STRING);
} }
/** /**
* Calculates and draws the accepted or supplied cargo around the selected tile(s) * Calculates and draws the accepted or supplied cargo around the selected tile(s)
* @param sx x position where the string is to be drawn * @param left x position where the string is to be drawn
* @param sy y position where the string is to be drawn * @param right the right most position to draw on
* @param top y position where the string is to be drawn
* @param sct which type of cargo is to be displayed (passengers/non-passengers) * @param sct which type of cargo is to be displayed (passengers/non-passengers)
* @param rad radius around selected tile(s) to be searched * @param rad radius around selected tile(s) to be searched
* @param supplies if supplied cargos should be drawn, else accepted cargos * @param supplies if supplied cargos should be drawn, else accepted cargos
* @return Returns the y value below the string that was drawn * @return Returns the y value below the string that was drawn
*/ */
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies) int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
{ {
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
if (tile < MapSize()) { if (tile < MapSize()) {
@ -869,10 +870,10 @@ int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad
} else { } else {
cargos = GetAcceptanceAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad); cargos = GetAcceptanceAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad);
} }
return DrawStationCoverageText(cargos, sx, sy, sct, supplies); return DrawStationCoverageText(cargos, left, right, top, sct, supplies);
} }
return sy; return top;
} }
void CheckRedrawStationCoverage(const Window *w) void CheckRedrawStationCoverage(const Window *w)

View File

@ -1063,11 +1063,13 @@ public:
DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 101 + y_offset, STR_STATION_BUILD_PLATFORM_LENGTH, TC_FROMSTRING, SA_CENTER); DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 101 + y_offset, STR_STATION_BUILD_PLATFORM_LENGTH, TC_FROMSTRING, SA_CENTER);
DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 141 + y_offset, STR_STATION_BUILD_COVERAGE_AREA_TITLE, TC_FROMSTRING, SA_CENTER); DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 141 + y_offset, STR_STATION_BUILD_COVERAGE_AREA_TITLE, TC_FROMSTRING, SA_CENTER);
int text_end = DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad, false); /* strings such as 'Size' and 'Coverage Area' */
text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4; int top = 166 + y_offset;
if (text_end != this->widget[BRSW_BACKGROUND].bottom) { top = DrawStationCoverageAreaText(this->widget[BRSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BRSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
top = DrawStationCoverageAreaText(this->widget[BRSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BRSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
if (top != this->widget[BRSW_BACKGROUND].bottom) {
this->SetDirty(); this->SetDirty();
ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, text_end - this->widget[BRSW_BACKGROUND].bottom); ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, top - this->widget[BRSW_BACKGROUND].bottom);
this->SetDirty(); this->SetDirty();
} }

View File

@ -955,15 +955,14 @@ struct BuildRoadStationWindow : public PickerWindowBase {
StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4); StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4);
StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5); StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5);
int text_end = DrawStationCoverageAreaText(2, 147, /* strings such as 'Size' and 'Coverage Area' */
(this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY, StationCoverageType sct = (this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY;
rad, false); int top = 147;
text_end = DrawStationCoverageAreaText(2, text_end + 4, top = DrawStationCoverageAreaText(this->widget[BRSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BRSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, sct, rad, false) + WD_PAR_VSEP_NORMAL;
(this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY, top = DrawStationCoverageAreaText(this->widget[BRSW_BACKGROUND].left + WD_FRAMERECT_LEFT, this->widget[BRSW_BACKGROUND].right - WD_FRAMERECT_RIGHT, top, sct, rad, true) + WD_PAR_VSEP_NORMAL;
rad, true) + 4; if (top != this->widget[BRSW_BACKGROUND].bottom) {
if (text_end > this->widget[BRSW_BACKGROUND].bottom) {
this->SetDirty(); this->SetDirty();
ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, text_end - this->widget[BRSW_BACKGROUND].bottom); ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, top - this->widget[BRSW_BACKGROUND].bottom);
this->SetDirty(); this->SetDirty();
} }
} }

View File

@ -33,7 +33,7 @@ enum StationCoverageType {
SCT_ALL SCT_ALL
}; };
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies); int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies);
void CheckRedrawStationCoverage(const Window *w); void CheckRedrawStationCoverage(const Window *w);
void ShowSelectStationIfNeeded(CommandContainer cmd, int w, int h); void ShowSelectStationIfNeeded(CommandContainer cmd, int w, int h);